- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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;