SRL Archive - Research & Development Lounge

procedure DrawImage


Da 0wner

2009-02-12 22:05:51

Draws an image on a form.
A simple yet effective procedure.


procedure DrawImage(var Image : TImage; bmp : integer);
var
bmp, width, heighth, FileNum : integer;
begin
GetBitmapSize(bmp, width, heighth);
CopyCanvas(getbitmapcanvas(bmp), Image.Canvas, 0, 0, width, heighth, 0, 0, width, heighth);
FreeBitmap(bmp);
end;

Naum

2009-02-13 11:52:28

You need to change Bitmap to Bmp and get rid of the var, for it to be able to work :)

Quickmarch

2009-02-13 12:20:04

Shouldn't you add x1, x2 etc so you can actually tell the procedure where to put it?

Da 0wner

2009-02-13 21:22:31

Oh, my bad I knew that naum :D. And no you don't quickmarch, you have the TImage's placement already setup. So all this does is draw the bitmap you specify on it. It's size should be the same as the TImage/Bitmap.

marpis

2009-03-08 17:35:45

I'll try this on my Videopoker game :)
edit: Where do u need the FileNum var?
and shouldnt u also remove var bmp, since you have presented it 2 times there?
(once var is presented in the [ like a in function(var a:integer) ] you don't need to present it again

BazzBarrett

2009-03-08 18:55:19

dont free the bitmap for us aswell because you may whant to use the bitmap for somthing else.

Da 0wner

2009-03-08 23:01:13


procedure DrawImage(var Image : TImage; var bmp : integer);
var
bmp, width, heighth : integer;
begin
GetBitmapSize(bmp, width, heighth);
CopyCanvas(getbitmapcanvas(bmp), Image.Canvas, 0, 0, width, heighth, 0, 0, width, heighth);
end;

New one. And lol I had no idea I had FileNum in there. I was planning on doing it a different way but I changed my mind and forgot to remove that. Thanks Marpis ;).