Is there a cross platform, all target GetPixel?
Monkey Forums/Monkey Programming/Is there a cross platform, all target GetPixel?
| ||
Im looking for a completely cross target solution to GetPixel im just wondering if its possible to just drop in a import blah and call GetPixel like we used to in BlitzMax. Anyone have any code that does this without using diddy? |
| ||
Isn't it called ReadPixel? |
| ||
I made this little method/function for me that checks for one pixel and returns the rgb values. The GetPixel method was removed in the Diddy Framework. Method CustomGetPixel:Int[](x:Int, y:Int) Local Pixels:Int[1] 'store 1 pixel ReadPixels(Pixels, x, y, 1, 1) Local a : Int = ( Pixels[0] Shr 24 ) & $ff Local r : Int = ( Pixels[0] Shr 16 ) & $ff Local g : Int = ( Pixels[0] Shr 8 ) & $ff Local b : Int = Pixels[0] & $ff Local PixelValues:Int[] = [r,g,b] Return PixelValues End Method |
| ||
Ah thanks for that didn't know there was readpixel. Thanks guys :) |
| ||
But, you should know that this method will actually read the pixel which is rendered on the screen in that moment. This means that, IN REAL TIME, if you have a PNG with transparent bg and you are drawing it over a nice colorfull background and you call ReadPixel to see what color you have... you will receive that background color. |
| ||
you will receive that background color But you can mask that colour by bit-shifting (as long as it is a single colour which you dont care about). |
| ||
yes. you can do that when loading the level for example.. |
| ||
Well its gonna help a lot, i don't see why a simple getpixel wasn't added to monkey for compatibility, also a loadpixmap etc |
| ||
, i don't see why a simple getpixel wasn't added to monkey for compatibility, also a loadpixmap etc i can answer why no LoadPixmap (which miniB3D implements BTW): because mobile devices limit the amount of memory each app can use, so in order to maximize memory constraints, ESPECIALLY in android, Mojo2D dumps the loaded image after it's bound to the graphics card. Android's Java heap is NOT effected by bound textures, so this can save a bit of room, but at the expense of having to reload images when the context is lost. |
| ||
Ah ok :) |