CreateImage problem =(

BlitzMax Forums/BlitzMax Programming/CreateImage problem =(

coffeedotbean(Posted 2005) [#1]
Erm my image does not show????


Graphics 640,480,0,32

image=CreateImage(256,256)
LockImage(image)
	SetColor 255,0,0 ; DrawRect 0,0,128,128
UnlockImage(image)

Repeat ; Cls

	DrawImage image,0,0

Flip ; Until KeyDown(KEY_ESCAPE) ; End



Odds On(Posted 2005) [#2]
I'm pretty sure you can't use the drawing commands such as DrawRect when the image is locked. In Blitz3D at least, the only commands you can use on a locked image are WritePixelFast and ReadPixelFast.


Sarge(Posted 2005) [#3]
well it looks like you can but only when you take off the CLS.


Perturbatio(Posted 2005) [#4]
The DrawRect command is in fact drawing to the current buffer not the locked image and when you remove cls it no longer wipes the current buffer and so displays.

(And because you are using windowed mode, there is only one buffer so it does not flicker).


coffeedotbean(Posted 2005) [#5]
So do I use pixmaps for making simple images in code?


tonyg(Posted 2005) [#6]
Yes, you do and then convert to an image when you've finished.


ImaginaryHuman(Posted 2005) [#7]
If you get into OpenGL you can use glCopyTexSubImage2D to grab from the backbuffer straight into an existing texture.


marksibly(Posted 2005) [#8]
...or use 'GrabImage'.

The thing is, OpenGL doesn't really have a (dependable) mechanism for rendering directly into textures, so 'SetBuffer ImageBuffer' style behaviour sort of goes out the window.

There is a new OpenGL extension out that addresses this, so in future...maybe...


coffeedotbean(Posted 2005) [#9]
wow a reply from God him self ;).... i fell all special now.