canvas
BlitzMax Forums/BlitzMax Programming/canvas
| ||
how read pixel from canvas , speed code ??? Function GetPixel(x:Int, y:Int, r:Int Var, g:Int Var, b:Int Var) Local TempPixmap:TPixmap = GrabPixmap(x,y,1,1) Local TempPtr:Byte Ptr = TempPixmap.PixelPtr(0,0) r = TempPtr[2] g = TempPtr[1] b = TempPtr[0] End Function |
| ||
Sorry, what? |
| ||
how read pixel fast from canvas ?? |
| ||
Last I checked, there was no way to read pixel data quickly from a canvas or graphics buffer. |
| ||
For OpenGL at least I'd recommend you simply define an Integer and then pass the pointer to that integer as a parameter to glReadPixels() and read just 1 pixel, it will put the value into the integer. You have to set up the glreadpixels properly with a few other commands first. This should be faster than creating a new pixmap each time, converting the coordinates into an offset, reading into the memory (which uses glreadpixels internally for gl), and then extracting the components. You could also use a byte pointer pointing to the integer to extract. |