How to create an ARGB_8888 pixel value?

Posted by vidstige on Stack Overflow See other posts from Stack Overflow or by vidstige
Published on 2011-11-23T17:32:45Z Indexed on 2011/11/23 17:50 UTC
Read the original article Hit count: 166

Filed under:
|
|
|

Say I want to create an array of pixel values to pass into the createBitmap method described here. I have three int values r, g, b in the range 0 - 0xff. How do I transform those into a opaque pixel p?

Does the alpha channel go in the high byte or the low byte?

I googled up the documentation but it only states that:

Each pixel is stored on 4 bytes. Each channel (RGB and alpha for translucency) is stored with 8 bits of precision (256 possible values.) This configuration is very flexible and offers the best quality. It should be used whenever possible.

So, how to write this method?

int createPixel(int r, int g, int b)
{
  retrurn ?
}

© Stack Overflow or respective owner

Related posts about java

Related posts about android