本文整理自网络,侵删。
//等比例缩小uses Math;varZoom: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;
相关阅读 >>
Delphi+mysql:tadoquery使用插入中文乱码解决方法
winapi 字符及字符串函数(8): ischarupper - 是否是个大写字母
更多相关阅读请进入《Delphi》频道 >>