Drawing to Image

BlitzMax Forums/BlitzMax Beginners Area/Drawing to Image

BLaBZ(Posted 2010) [#1]
I'm trying to draw on an image and then display it but I'm not having much luck...

Graphics 800,600,0,2

image = CreateImage(800,600)
map = LockImage(image)
SetColor(255,0,0)
DrawRect(0,0,GraphicsWidth(),GraphicsHeight())
UnlockImage(image)

While Not KeyHit(KEY_ESCAPE)

DrawImage(image,0,0)

Flip
Cls 

Wend 



BLaBZ(Posted 2010) [#2]
nvm... seems like every time I spend 30 min looking for the answer and as soon as I post I find out how....


Graphics 800,600,0,2

Cls
image = CreateImage(800,600)
SetColor(255,0,0)
DrawRect(0,0,GraphicsWidth(),GraphicsHeight())
GrabImage(image,0,0)
Cls 


While Not KeyHit(KEY_ESCAPE)

DrawImage(image,0,0)

Flip
Cls 

Wend 


If anyone knows of any better ways feel free to post


GfK(Posted 2010) [#3]
You can't draw onto images/pixmaps like that.

There are several ways, depending on what you want to do.

First, you can use TPixmap.Paste(), to draw one pixmap onto another.

Second, you can use ReadPixel()/WritePixel().

You can also use regular drawing functions to draw onto the backbuffer, and then use GrabPixmap to store what you've drawn in a pixmap/image. [edit] as you've now figured out.