Extract bits from an int
Monkey Forums/Monkey Programming/Extract bits from an int
| ||
I'm sure it's shameful that I need to ask but... Using ReadPixels how do I extract the R,G,B and A values from the supplied INT The pixel data is stored in int-per-pixel ARGB format, with the alpha component stored in bits 24-31, the red component in bits 16-23, the green component in bits 8-15 and the blue component in bits 0-7. Ta! -Chris |
| ||
Bit shifting: Local argb:Int = pixels[i] Local a:Int = (argb Shr 24) & $ff Local r:Int = (argb Shr 16) & $ff Local g:Int = (argb Shr 8) & $ff Local b:Int = argb & $ff |
| ||
As always, you rock! Thank you :) -Chris |