Writing to pixmap other than using writepixel?

BlitzMax Forums/BlitzMax Programming/Writing to pixmap other than using writepixel?

chimaera(Posted 2012) [#1]
Hi everyone,

I have been looking around in the forums but I haven't stumbled up an answer to my question.

Is there a way or command which would allow me to draw anything else other than using writePixel to a pixmap? Or is it the only way?

The problem I have is that I would like to write a bigger form/object, lets say a filled circle (oval) that is 10 pixels in diameter, to a large pixmap (1680x1050). And I really don't want to do it "manually" with drawpixel.

Any suggestions are welcome!

Thanks!


col(Posted 2012) [#2]
You can but not at runtime speeds. GrabPixmap and GrabImage and notoriously slow. GPUs are generally a one way street. They are fast when sending data to it so it can process it for the display, but not so fast at returning data back to the CPU. Modern cards have modern features for this exact purpose, but its out of scope for Max2D. And Max2D uses the CPU for the Pixmap hence the speed issue.
You will also have problems if you're grabbing larger than your current screen resolution.

But anyway for an 'offline' ( out of mainloop ) method you could use something like drawing an oval, grab it as an image (slow), set the scaling appropriately then draw the bigger scaled image, grab the backbuffer as a pixmap ( even slower ) at the desired resolution. TBH this will more than likely be so slow its unusable, although its untested.

Maybe someone will have a faster native OpenGL solution? Or have you tried the CPU method of updating the pixmap manually ?



Last edited 2012


ImaginaryHuman(Posted 2012) [#3]
Drawpixel has some overhead if you're calling it a lot. Best you can do with the CPU is to get the base pointer of the pixmap memory and then use pointers to access the pixel data.

ie

local p:tpixmap=loadpixmap("myimage.png")
p=convertpixmap(p,PF_RGBA8888)
local pb:byte ptr=pixmappixelptr(p)
pb[0]=#FF000000 'draw a red pixel



Floyd(Posted 2012) [#4]
You could try pixmapgraphics module.

It may be as much as you need, or at least point you in the right direction.