You need to set the dimension of your bitmap to the dimension of the
Timage control.

Allan.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of gajo
Sent: Sunday, 17 October 2004 2:19 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] How to make a Canvas a Bitmap?

Hi,
I have an Image, and have drawn some shapes and text using the image's
Canvas. Now I want to convert it to bitmap, that is, to make the
Image.Picture.Bitmap property contain my drawing (so I can make the
image transparent).

I tried like this:
var
  img: TImage;
begin
  img := TImage.Create(form1);
  img.Parent := form1;
  // and set width, height, etc....
  img.Picture.Bitmap := TBitmap.Create;
  with img.Picture.Bitmap do begin
    Canvas.Ellipse(0,0,SOME_VALUE,SOME_VALUE);
    Canvas.TextOut(10,10,'Some text')
  end;
  img.Show
end;

And this doesn't work, cause the bitmap won't draw; instead I get a
white square. I've read the help and there it says I need to set the
image whether it's a bitmap, icon or metafile, and that I should do this
by setting the Graphic property of the image. So I trtied creating a
separate bmp object, and set

img.Picture.Bitmap := bmp;
img.Pciture.Graphic := bmp;

Still no results. What should I do?

Gajo

p.s. Sorry for the spelling mistakes, my keyboard is broken or
something...
p.s.s. Of course, when I draw with img.Canvas (and not
img.Picture.Bitmap.Canvas) then everything works ok, except that it's
not a bitmap and I can't make it transparent :(

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to