procedure BitmapZoomIn(filepath:string;img:TImage);
const Zoom = 300;
var Bmp,ZBmp:TBitmap;
ZW,ZH:integer;
begin
Bmp:=TBitmap.Create;
Bmp.loadfromfile(filepath);
if Bmp.Width>Bmp.Height then
begin
ZW:=Zoom;
ZH:=Round(Bmp.Height*Zoom/Bmp.Width);
end
else
begin
ZW:=Round(Bmp.Width*Zoom/Bmp.Height);
ZH:=Zoom;
end;
ZBmp:=TBitmap.Create;
ZBmp.Height:=ZH;
Zbmp.Width:=ZW;
//用CopyRect 顏色會怪怪的
//ZBmp.Canvas.CopyRect(Rect(0,0,ZW,ZH),Bmp.Canvas,Rect(0,0,Bmp.Width,Bmp.Height));
ZBmp.Canvas.StretchDraw(Rect(0, 0, ZW, ZH), Bmp);
img.picture.bitmap.Assign(ZBmp);
ZBmp.Free;
Bmp.Free;
end;
文章標籤
全站熱搜