Help with TImage and TPixmap

BlitzMax Forums/BlitzMax Beginners Area/Help with TImage and TPixmap

Storm8191(Posted 2005) [#1]
Hello, I'm trying to test out a method to generate an image in realtime, but I can't get this to work at all. My plan is to create an image, and then use LockImage and WritePixel to draw to the pixmap. This is how things are supposed to be done, according to all the examples I've seen. But it's not working, and I don't know why.

Graphics 640, 480, 0
out:TImage = CreateImage:TImage(32, 32, 1, DYNAMICIMAGE)
in:TPixmap = LockImage:TPixmap(out)
	Print "Your pixmap has size "+ PixmapWidth(in) +", "+ PixmapHeight(in)
	For i:Int = 0 To 31
		WritePixel in,  i,  0, (255 Shl 24) Or 255
		WritePixel in,  i, 31, (255 Shl 24) Or 255
		WritePixel in,  0,  i, (255 Shl 24) Or 255
		WritePixel in, 31,  i, (255 Shl 24) Or 255
	Next
	Print "Color at [0,0] = "+ ReadPixel(in, 0, 0)
	Print "Color at [1,1] = "+ ReadPixel(in, 1, 1)
UnlockImage out
in = Null
FlushMem

DrawImage out, 0,0
Flip
Cls
Flush


For the image drawing, I've also tried DrawImageRect but it didn't help any. Does anyone see why this doesn't work? I'd really like to be able to build images when needed.

Thanks in advance.


skidracer(Posted 2005) [#2]
Change Or to |, as the Or operator in Blitzmax is logical and results in either True or False.


Storm8191(Posted 2005) [#3]
Weee, it works. Thanks, I was really starting to wonder if these pixmaps with images would work at all.

Now I just have to figure out what I'm going to do with them. :p


mudcat(Posted 2005) [#4]
"Now I just have to figure out what I'm going to do with them. :p"

You crack me up q:)


Dreamora(Posted 2005) [#5]
In best case, you don't do anything in realtime or it will most likely became a very bad "waking up"