delphi GDI 圖片壓縮代碼 據說是位圖縮放保持原圖視覺效果最好的算法


delphi 圖片壓縮代碼 據說是位圖縮放保持原圖視覺效果最好的算法

若有更好的,請大神留言我也學習下,感謝!

 

uses WinAPI.GDIPAPI, WinAPI.GDIPOBJ;

var
  Bitmap1: TGPBitmap;
  Bitmap2: TBitmap;
  Graphic: TGPGraphics;
begin
  Bitmap1 := TGPBitmap.Create('test.bmp');  // bmp, gif, jpeg, png...
  Bitmap2 := TBitmap.Create;
  with Bitmap2 do
    begin
      Width := Bitmap1.GetWidth * 2 div 3;  // shrink to 2/3 width
      Height := Bitmap1.GetHeight * 2 div 3;  // 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;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM