N
nonflammable
Unregistered / Unconfirmed
GUEST, unregistred user!
我要在TImage上画缩小的图,代码如下:
procedure PaintGraphic(SrcGraphic: TGraphic)
var
Bitmap1, Bitmap2: TBitmap;
begin
Image1.Picture.Graphic := TBitmap.Create;
Image1.Picture.Graphic.Height := 200;
Image1.Picture.Graphic.Width := 200;
TBitmap(Image1.Picture.Graphic).PixelFormat := pf24bit;
TBitmap(Image1.Picture.Graphic).Draw(0, 0, SrcGraphic);
Bitmap1.Assign(Image1.Picture.Graphic);
...部分代码,可能会改变Image1.Picture.Graphic...
Bitmap2.Assign(Bitmap1);
Image1.Picture.Graphic.Assign(Bitmap1);
Image1.Picture.Graphic.Height := 100;
Image1.Picture.Graphic.Width := 100;
Image1.Picture.Graphic.StretchDraw(Rect(0, 0, 100, 100), Bitmap2);
Bitmap2.Assign(Image1.Picture.Grapic);
end;
为什么执行了StretchDraw后Image1显示的图像不发生变化(只有背景变成白色)。
procedure PaintGraphic(SrcGraphic: TGraphic)
var
Bitmap1, Bitmap2: TBitmap;
begin
Image1.Picture.Graphic := TBitmap.Create;
Image1.Picture.Graphic.Height := 200;
Image1.Picture.Graphic.Width := 200;
TBitmap(Image1.Picture.Graphic).PixelFormat := pf24bit;
TBitmap(Image1.Picture.Graphic).Draw(0, 0, SrcGraphic);
Bitmap1.Assign(Image1.Picture.Graphic);
...部分代码,可能会改变Image1.Picture.Graphic...
Bitmap2.Assign(Bitmap1);
Image1.Picture.Graphic.Assign(Bitmap1);
Image1.Picture.Graphic.Height := 100;
Image1.Picture.Graphic.Width := 100;
Image1.Picture.Graphic.StretchDraw(Rect(0, 0, 100, 100), Bitmap2);
Bitmap2.Assign(Image1.Picture.Grapic);
end;
为什么执行了StretchDraw后Image1显示的图像不发生变化(只有背景变成白色)。