J
JackyKen
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在下面的按钮件中实现图像的缩小,思路是这样的:先将图像画在内存中,然后用StrechDraw将其考到Image上
但缩小后图像完全变了样,不知道StrechDraw是不是这样用的,请各位指点一下:
procedure TMDIChildForm.ToolButton2Click(Sender: TObject);
var
mbitmap:TBitmap;
begin
if Image1.Width>500 then
begin
Image1.Width:=Image1.Width-160;
Image1.Height:=Image1.Height-100;
Image1.Picture.Bitmap.Width:=Image1.Width;
Image1.Picture.Bitmap.Height:=Image1.Height; //这一段将image1缩小
mbitmap:=TBitmap.Create;
try
mbitmap.Width:=1600;
mbitmap.Height:=1000;
DrawPicture(mbitmap); //画图程序,在mbitmap上画一幅图
Image1.Picture.Bitmap.Canvas.StretchDraw(rect(0,0,Image1.Picture.Bitmap.Width,Image1.Picture.Bitmap.Height),mbitmap);//考到image上
finally
mbitmap.Free;
mbitmap:=nil;
end;
end;
end;
但缩小后图像完全变了样,不知道StrechDraw是不是这样用的,请各位指点一下:
procedure TMDIChildForm.ToolButton2Click(Sender: TObject);
var
mbitmap:TBitmap;
begin
if Image1.Width>500 then
begin
Image1.Width:=Image1.Width-160;
Image1.Height:=Image1.Height-100;
Image1.Picture.Bitmap.Width:=Image1.Width;
Image1.Picture.Bitmap.Height:=Image1.Height; //这一段将image1缩小
mbitmap:=TBitmap.Create;
try
mbitmap.Width:=1600;
mbitmap.Height:=1000;
DrawPicture(mbitmap); //画图程序,在mbitmap上画一幅图
Image1.Picture.Bitmap.Canvas.StretchDraw(rect(0,0,Image1.Picture.Bitmap.Width,Image1.Picture.Bitmap.Height),mbitmap);//考到image上
finally
mbitmap.Free;
mbitmap:=nil;
end;
end;
end;