1

I want to change resampling kernel of Graphics32's TImgView32 on the fly. However there is no visible difference. Here's the code:

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImgView321.Bitmap.LoadFromFile('1.bmp');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ImgView321.Scale := ImgView321.Scale*2;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ImgView321.Scale := ImgView321.Scale/2;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  ImgView321.Bitmap.ResamplerClassName := 'TKernelResampler'; 
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ImgView321.Bitmap.ResamplerClassName := 'TNearestResampler'
end;
Tom
  • 2,962
  • 3
  • 39
  • 69
  • So where is the problem? (Btw.: It should be possible to use the same event handler for both up and down). – CWBudde Mar 19 '19 at 13:43
  • I changed the code to be even simpler. I don't see any change how the image is displayed – Tom Mar 19 '19 at 18:02

1 Answers1

1

When you choose 'TKernelResampler' it is important to specify the kernel that is used. The default is TBoxKernel with a result that is nearly identical with the 'TNearestResampler'

In fact it is identical from a visual perspective, just a different computation.

Try to use the 'TCubicKernel' or 'TLanczosKernel'. For more control you can also pick the 'THermiteKernel' or 'TAlbrechtKernel', which has two control parameters (instead of just one).

CWBudde
  • 1,783
  • 1
  • 24
  • 28
  • I tried your solution but it's still exactly as TNearestResampler. Also I don't have TLanczosKernel in the options in Design Time: https://i.imgur.com/lJ45WYz.png – Tom Mar 19 '19 at 22:24
  • You have to use TKernelResampler. With this you can change the kernel (not the resampler) to TLanczosKernel. [assuming you are using the latest GR32 v2.0) – CWBudde Mar 20 '19 at 23:03