Images are the basic 'unit' of graphics in Blitz. Images are either loaded files using 'LoadImage', or created by your program using 'CreateImage'. All images loaded into Blitz must be in .bmp, .jpg, or .png format for Blitz to display it. We recommend using .png format whenever possible. This offers high quality images with no loss of quality with comparable compression to .jpg.
All Images have what is known as a 'handle' or 'hotspot'.
A hotspot is an x,y coordinate that specifies where the centre of the image is. When you draw an image, the image's hotspot is positioned at the x,y coordinate given in the drawing command. By default, when you create a new image its hotspot is set 0,0 - the upper left corner of the image. You can change the hotspot of an image using the 'HandleImage', 'MidHandle' or 'AutoMidHandle' commands.Its rather confusing - but 'handle' is often referred to as a variable that holds the location in memory of a file, image, or sound. When you load an image, sound, font, etc., you have to give it a variable to 'hold' its position in memory. In the Command Reference, you will often find handle referred to as this variable.
Color MaskingImages also have what is known as a mask color.
This colour is used when drawing an image to provide transparency. The colors in an image that are the same as the mask color are NOT drawn. The mask color of an image can be changed using the 'MaskImage' command. By default, an image's mask colour is black. Sometimes, you will not want an image to be drawn with transparency. For example, if you are drawing a backdrop you will probably want it to overwrite everything on the screen. In these situations, you should use the 'block' drawing commands to draw images. For example, the 'TileImage' command draws an image with transparency, but 'TileBlock' does not.
Every image drawing command ('DrawImage','TileImage','DrawImageRect') has an equivalent block drawing command ('DrawBlock','TileBlock','DrawBlockRect').You can also draw to images using the ImageBuffer function. Just as you can draw to the screen's front and back buffers, you can also draw to an image's buffer!
Here's a quick example:Graphics 640,480
image=CreateImage( 32,32 ) ;creates a 32 by 32 image
SetBuffer ImageBuffer( image ) ;now we're drawing to the image!
Line 0,0,31,31 ;draw a 'cross'
Line 31,0,0,31 ;...
SetBuffer FrontBuffer() ;now we're drawing to the front buffer again
For k=1 to 10 ;draw a bunch of images...
DrawImage image,Rnd(640),Rnd(480)
NextEach image can also contain multiple frames. Each frame is the same width and height as the image, and has the same image handle and mask color.
You can use multiple frame images for animation, map blocks and so on. Most of the image commands allow you specify an optional frame number.