PDA

View Full Version : [Easy] Pics on Forms!



n3ss3s
04-11-2008, 02:30 PM
Why I posted this in the intermediates section is that I believe the "Beginners" should not confuse their heads with stuff like images on forms, but the "core" of scripting.


Okay, pics on forms coming right up.


You have the TImage variable, defined in the variables. I use an example MyPic now, - so, MyPic: TImage.

Now, you have a bitmap variable too, lets say MyBitmap: Integer, yes, it is an integer.


You define your bitmap using normally the SCAR -> Tools -> Picture To String, get the code it writes to debug box, "MyBitmap := BitmapFromString(....);" and copy it to your LoadBitmaps procedure if you have one, or wherever you feel like is the best.

Also, if your bitmap is big, use

MyBitmap := LoadBitmap('pathandname.bmp');


Now, here comes the part the form comes to the picture again, THIS IS HOW YOU PUT THE PIC TO THE FORM!

CopyCanvas(GetBitmapCanvas(MyBitmap), MyPic.Canvas, x1, y1, x2, y2, x1, y1, x2, y2);

The first thing, GetBitmapCanvas(MyBitmap) is the source canvas, the canvas that gets painted on your TImage's canvas.
Second one is the canvas of your TImage.

the first four x and y s are the area of the bitmap to copy to the canvas, and last four are the area of the TImage's canvas to copy to.


Post a question if you feel like you didn't get something.

ShowerThoughts
04-11-2008, 03:02 PM
Haha Good one ;)

mixster
04-11-2008, 03:17 PM
SafeDrawBitmap is much easier to explain and use as long as the sizes are right, which you can do with GetBitmapSize and then assigning the values to the TImage :)