How does TileImage work?

BlitzMax Forums/BlitzMax Beginners Area/How does TileImage work?

Hi,

In your example you are drawing directly to the back buffer using Plot. This is why you see the untiled dots. Unlike Blitz2D there's no SetBuffer() command, so things have to be done a little bit differently. Basically, how I understand it is the image itself is stored in video ram, so to access it you need to get it into CPU addressable ram using the LockImage function. LockImage returns a pixmap onto which you can then draw whatever you want using WritePixel. Example:

Graphics 640, 480, 0

ImageTile:TImage = CreateImage(32, 32)

Pixmap = LockImage(ImageTile)
For Px = 0 To 100
	Alpha = 255; Red = 255; Green = 255; Blue = 255
	WritePixel(Pixmap, Rand(0, 31), Rand(0, 31), ..
		(Alpha Shl 24) + (Red Shl 16) + (Green Shl 8) + (Blue))
Next
UnlockImage ImageTile

While Not KeyDown(KEY_ESCAPE)
Cls

	Count = Count + 1
	If Count > 31 Count = 0
	
	TileImage ImageTile, Count, Count

Flip
Wend