Pergunta

This is a order of bit number of color channel from wiki ARGB and RGBA

but there is a different order from another site Link

Which one is correct??

How about the order of RBG???

Foi útil?

Solução

Wikipedia's picture :

ARGB representation on little-endian architecture

depicts layout of bytes of 32-bit ARGB integer on little-endian architecture.

Whereas picture from your question corresponds to big-endian layout of same ARGB integer.

So, the answer is : both pictures are correct, they just account for different architectures in terms of bit addressing in memory.

What you should care about is, regardless of endianess, for ARGB, A is the most-significant byte of 32-bit value, R at the second-most significant, ... and B can be found as the least significant Byte.

So you can extract them correctly with corresponding bit-shifting operations regardless on what type of "endian" platform you are.

Edit In fact, the picture from your question seems odd to me, since it displays A, R, G, B bytes in reverse order (even addressing them correctly). I recommend you stick to diagram from wikipedia to avid confusion.

Answering your comment : Java's TYPE_INT_BGR has reversed encoding of rgb colors as compared to TYPE_INT_RGB , see java.awt.image.BufferedImage.java :

case TYPE_INT_BGR:
         {
             colorModel = new DirectColorModel(24,
                                                   0x000000ff,   // Red
                                                   0x0000ff00,   // Green
                                                   0x00ff0000    // Blue
                                                   );

Which one to use depend on your needs, but I would guess you'd be ok with RGB and ARGB.

Hope that helps

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top