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