Getting a pixels colour?
BlitzMax Forums/BlitzMax Beginners Area/Getting a pixels colour?
| ||
Hi there, I've been playing around with the BlitzMax demo, and I was wondering if there is any way to read pixel data from the back buffer, or any where else for that matter. The equivalent Blitz3D command would be GetColor or ReadPixel. |
| ||
You can use ReadPixel (it must be used with a pixmap). |
| ||
To read the backbuffer you have to use glReadPixels(). Standard OpenGL is unfortunately very poor with regards to reading the buffer, although quite competent at drawing it. |
| ||
Here's an example of writepixel... click |
| ||
It's a bit long winded but next BlitzMax update will allow a more efficient method:Function ReadBackBuffer(x,y) Global grab Local rgba,pixmap If Not grab grab=CreateImage(1,1,1,DYNAMICIMAGE) GrabImage grab,x,y pixmap=LockImage(grab,0,True,False) rgba=ReadPixel(pixmap,0,0) UnlockImage pixmap Return rgba End Function |
| ||
Thanks guys. I've got it sorted now. |