Recent

Author Topic: Drawing a bitmap to an TImage  (Read 46353 times)

Ray Greene

  • Guest
Drawing a bitmap to an TImage
« on: February 15, 2004, 10:06:59 am »
When I try to draw a bitmap onto a TImage object, the bitmap is drawn at the top left of the form instead of on the TImage. This happens in Windows and Linux.

Anyone know why it happens and what can be done about it?

Anonymous

  • Guest
Drawing a bitmap to an TImage
« Reply #1 on: February 15, 2004, 07:12:30 pm »
The form has a canvas too so make sure you use the Timage's canvas (and not the form's)

MyImage : Timage
......
........
Myimage.canvas.draw.....

Ray Greene

  • Guest
Drawing a bitmap to an TImage
« Reply #2 on: February 16, 2004, 03:07:28 am »
I'm definitely drawing to the TImage's canvas. Here's the code:
Code: [Select]

procedure TForm1.Button1Click(Sender: TObject);
var
   Bmp: TBitmap;
begin
     Bmp := TBitmap.Create;
     Bmp.Height := Image1.Height;
     Bmp.Width := Image1.Width;
     Bmp.Canvas.Brush.Color := clBlack;
     Bmp.Canvas.FillRect(Rect(0,0,Image1.Width,Image1.Height));
     Image1.Canvas.Draw(0,0,Bmp);
end;


It works OK in Delphi, so it looks like a bug. I'll post a message on the Bug Tracking page.

 

TinyPortal © 2005-2018