Now to do an automatic batch thumbnail software for private use, hope to have a master glad, it is better for code!
CodePudding user response:
GDI functions can?CodePudding user response:
Narrow generally is near several points on average, amplification of interpolation, the higher the accuracy, the slower speedCodePudding user response:
Respond to similar problems before, image scaling is one of the best algorithm bicubic resample, GDI StretchBlt, StretchDIBits didn't use this algorithm, the need to achieve, but can use GDI + :USES WinAPI GDIPAPI, WinAPI. GDIPOBJ;
Var
Bitmap1: TGPBitmap;
Bitmap2: TBitmap;
Graphic: TGPGraphics;
The begin
Bitmap1:=TGPBitmap. Create (' test. BMP);//BMP, GIF, jpeg, PNG...
Bitmap2:=TBitmap. Create;
With Bitmap2 do
The begin
Width:=Bitmap1 GetWidth * 2 div 3;//the shrink to 2/3 width
Height:=Bitmap1 GetHeight * 2 div 3;//the shrink to 2/3 height
PixelFormat:=pf32bit;
end;
Graphic:=TGPGraphics. Create (Bitmap2. Canvas. Handle).
Graphic. SetInterpolationMode (InterpolationModeHighQualityBicubic);//bicubic resample
Graphic. DrawImage (Bitmap1, 0, 0, Bitmap2 Width, Bitmap2, Height);
Bitmap2. SaveToFile (' test_resized. BMP);
Graphic. Free;
Bitmap2. Free;
Bitmap1. Free;
end;