backbuffer and pixmapformat
BlitzMax Forums/BlitzMax Beginners Area/backbuffer and pixmapformat
| ||
If I want to make a pixmap to grab a portion of the backbuffer, how can I find out what pixmapformat the backbuffer is so that I can make the right type of pixmap with the format parameter in CreatePixmap? Or is a simply a case of if graphics was called with 32 bit I should use PF_RGBA8888, and if graphics was called with 16 bit I should use PF_RGB888? Or can I still made a 32 bit pixmap and grab a 16 bit screen and it won't look funny at all if saved to disk? Lot's of questions huh, any answered are good thanks :-) |
| ||
Function GrabPixmap:TPixmap( x,y,width,height ) |
| ||
I was being dense, making one, then calling grabpixmap as well. That would ahve been a memory hole before auto GC. Thanks. However, I guess the question about finding out the backbuffer format is still valid in the event you wanted to create a pixmap and copy portions of the backbuffer to it with readpixel and writepixel... |
| ||
In OpenGL it's usually RGBA8888 |
| ||
How do you copy portions of the backbuffer to a pixmap using readpixel/writepixel? |
| ||
good point, I'll shutup now... I'm just used to BlitzPlus and buffers etc. |
| ||
However, I guess the question about finding out the backbuffer format is still valid in the event you wanted to create a pixmap and copy portions of the backbuffer to it with readpixel and writepixel... There's a couple of commands related to this: Pixmapformat(pixmap) Will return one of the following formats: PF_A8 8 bit alpha PF_I8 8 bit intensity PF_RGB888 24 bit big endian RGB PF_BGR888 24 bit little endian RGB PF_RGBA8888 32 bit big endian RGB with alpha PF_BGRA8888 32 bit big endian RGB with alpha If you have routines that do specific operations on some of the channels, you can use this to determine on how to work, OR you can use an intermediate ConvertPixmap to convert it to your preferred format, do your work, and then convert it back to the format expected by the system. Not sure how necesary that is, but I use it in my Desaturation Fader (code archives, http://blitzbasic.com/codearcs/codearcs.php?code=1282 ) and appears to work without any problems. |
| ||
yeah so to find the backbuffer format, I just grab a bit and then checkout the pixmap format of the grab. Thanks. |
| ||
You use ReadPixel and WritePixel on an existing pixmap. You can't use that on the backbuffer itself. You have to first transfer the backbuffer data into a pixmap and then work on the pixmap and then draw/upload the pixmap/image. You can use GL_ReadPixels() for OpenGL reading the backbuffer into a memory space - such as that of a pixmap. |
| ||
thanks:) |