Delphi image 等比例縮小


//等比例縮小
uses Math;
var
Zoom:Extended;
W,H:integer;
bmp:Tbitmap;
begin
  bmp:=Tbitmap.Create;
  bmp.LoadFromFile('c:\aa.bmp');
  Zoom:=Image1.Width/Max(bmp.Width,bmp.Height); //獲得比例值
  W:=Trunc(bmp.Width*Zoom);
  H:=Trunc(bmp.Height*Zoom);
  //居中顯示縮小后的圖片
  Image1.Canvas.StretchDraw(Rect(Trunc((Image1.width-W)/2),Trunc((Image1.Height-H)/2),Trunc((Image1.width-W)/2)+W,Trunc((Image1.Height-H)/2)+H),Bmp);
  bmp.free;
end;

 


免責聲明!

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



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