Pixmaps?

BlitzMax Forums/BlitzMax Programming/Pixmaps?

Pete Carter(Posted 2009) [#1]
Does anyone know of any tutorials or good examples of how to use pixmaps. i need to create and edit pixmaps, but i see there are quite a few functions with pixmaps that ive not used, id like to know some more detail if anyone can throw any light on the subject that would be great. as the docs are next to no use in this area.


Arowx(Posted 2009) [#2]
Hi Pete,

I think the key thing is GrabPixmap for getting a pixmap from images which will allow you to combine images together then take a snapshot.

TPixmap.Paste(... is great for adding blocks of images together handy for making animation strips.

TPixmap.Window(.. lets you get a chunk of an exiting pixmap.

For more direct editing you really need to start getting hold of the pixel pointer and using it to draw/alter the original pixmap there are a few example of this in the codearchive somewhere...

That's the limit of my know how on Pixmaps in a nutshell!

NB: If your creating a pixmap the format can sometimes trip you up, well it has done me anyway, just test step by step!


Pete Carter(Posted 2009) [#3]
thanks Arowx.

Yeah the format settings has confused me a bit. I was hoping there was some example or tutorial on the subject that id missed :O(

Pete


Arowx(Posted 2009) [#4]
I think it depends on your platform and maybe even your graphics card ...

But if you use PixmapFormat (pixmap) then you should know what type your pixmap is!


_JIM(Posted 2009) [#5]
I usually convert my pixmaps before doing anything to them. That way I know what I'm dealing with.

ConvertPixmap:TPixmap(pixmap:TPixmap,format)

Pixmap editing is quite simple in concept, but it gets slightly more complicated when you want to make it fast.

There's 2 hacks you need to know:

1) How to access a pixmap fast:

Kind of pseudo-code:

Local pptr:Int ptr = PixmapPixelPtr(p)
For Local i:Int = 0 To Width - 1
	For Local j:Int = 0 To Height - 1
		pptr[0] = something
		pptr:+1
	Next
Next


2) A personal favourite. Getting RGBA out of Int in a very easy way.

Local color:Int
Local cptr:Byte ptr = VarPtr(color)
cptr[0] = RED
cptr[1] = GREEN
cptr[2] = BLUE
cptr[3] = ALPHA


That is if the format is RBGA8888.

Hope this helps ;)


Jesse(Posted 2009) [#6]
PETER, I suggest for you to look directly at the pixmap module source for better help. I am shure that's how most of us here have figured out how to use the functions. it's not that complicated. it's rather simple actually.


Pete Carter(Posted 2009) [#7]
Thanks for your help _JIM and Jesse

I will have a look at the pixmap module. Ive heard that intel graphics chipsets have problems with drawpixmap? im going to have a play with pixmaps today but ive only got my laptop with me and it has a gma3100 in it. oh well I won't know till i try it :O)

Pete


Pete Carter(Posted 2009) [#8]
everything seams to work fine on my laptop. is there a known problem with pixmaps that makes them different on different hardware.

Ive been making a very odd tile editor that uses pixmaps to store the tile data.


Brucey(Posted 2009) [#9]
In OpenGL, DrawPixmap is very driver dependent.

For example, using DrawPixmap on this work PC, a large-ish video struggles to update at 25fps.
However, the same pixmap drawn as a TImage, can update at 60fps.

There's plenty of information around the internet with people having issues with the relevant GL commands.


ImaginaryHuman(Posted 2009) [#10]
I found pixmaps to be as much as 10 times slower than images. Depends on the GPU and the interface/bus.


_Skully(Posted 2009) [#11]
Well that really does make sense since the Pixelmap has to transfer across the video bus whereas an image doesn't (preloaded)


Pete Carter(Posted 2009) [#12]
im not using them in realtime so it doesnt matter for my editor.