Pixmaps and banks

BlitzMax Forums/BlitzMax Beginners Area/Pixmaps and banks

Simon S(Posted 2005) [#1]
I'm writing a pixmap to bank function to get super quick access to the pixels without lockimage.

But I'm a bit worried by all that pixmap format business, does it relate to the mac platorm? readpixel returns the usual AARRGGBB format, but is blitz doing handy translations? or will the copybank stuff still have the bits in the AARRGGBB format regardless of platform?

I don't have access to Mac or Linux, does anyone know the situation here?

Thanks in advance.


ImaginaryHuman(Posted 2005) [#2]
It should be cross platform.

Why not use a static bank, that way you don't have to copy the data? Or does it have to be copied? If you are trying to access the pixels in a pixmap, using a static bank would be a lot faster - no copying needed. You can always use ConvertPixmap() to turn it into the format you want, as a catch-all.

You can also grab the backbuffer directly into a bank by using glReadPixels()


Simon S(Posted 2005) [#3]
Static bank? Not heard of that. Is that the CreateStaticPixmap thing? It does sound like a bank from it's description. Well if it's as fast a bank and the readpixel is as fast as a peek, I'd be happy enough.

I'll give it a go tommorrow.

Also that glReadpixels() thing is a great tip which I've no doubt I can use for something else.


BlitzSupport(Posted 2005) [#4]
Be warned that glReadPixels is very slow! You're probably on a better path with the Pixmaps stuff...


ImaginaryHuman(Posted 2005) [#5]
I guess I just mentioned the glReadPixels for use if they wanted to just grab the image once-off to put it into a bank or pixmap, I agree it is not very practical for doing it every frame.


Simon S(Posted 2005) [#6]
Heh, got about 3 small projects on the go and I've ground to a halt on each one. That's what I get for taking a huge break from coding. Still I appreciate the advice so far.

AngelDaniel, I need a bit of clarification from when you mentioned "No copy needed". I assumed when Createstaticpixmap refers to "object that references an existing block of memory" it meant a pre-defined createbank(), which I'd need to copy the pixels into manually (I want to put the pixel data from an image and/or backbuffer into a bank for the fastest possible reading at a later point)

Is there something more immediate you were referring to? I couldn't find any examples of createstaticpixmap on the forum search.


ImaginaryHuman(Posted 2005) [#7]
I didn't say create static pixmap. I said create a static bank. A static bank is an empty bank which just `wraps around` an existing block of memory. So you can wrap it onto the PixmapPixelBuf() address in memory. It then doesn't have content of its own, it is sharing the content with the pixmap object. So you don't have to copy the data from the pixmap to the bank, they are basically one and the same - two object types looking at the same block of memory.

Use CreateStaticBank() and give it the address of your pixmap's buffer.

No, I did not mean to create a bank first and then do a static bank on top of it, that is pointless.


Simon S(Posted 2005) [#8]
Ah that makes a lot more sense. I had no idea about the CreateStaticBank() command, hence my total misunderstanding.

That's great, Thanks for your help.