Scale an image nicely in Delphi?

后端 未结 4 397
独厮守ぢ
独厮守ぢ 2020-12-05 03:42

I\'m using Delphi 2009 and I\'d like to scale an image to fit the available space. the image is always displayed smaller than the original. the problem is TImage Stretch p

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 03:57

    You really, really want to use Graphics32.

    procedure DrawSrcToDst(Src, Dst: TBitmap32);
    var
      R: TKernelResampler;  
    begin
      R := TKernelResampler.Create(Src);
      R.Kernel := TLanczosKernel.Create;
      Dst.Draw(Dst.BoundsRect, Src.BoundsRect, Src);
    end;
    

    You have several methods and filters to choose when resampling an image. The example above uses a kernel resampler (kinda slow, but with great results) and a Lanczos filter as reconstruction kernel. The above example should work for you.

提交回复
热议问题