Friday, April 20, 2007

PixelFormat16bppRGB565

Specifies that the format is 16 bits per pixel; 5 bits are used for the red component, 6 bits are used for the green component, and 5 bits are used for the blue component.

RGB8888(32 bit) to RGB565(16 bit) pixel format conversion

565 format represents each pixel in the following bit order:
565 format: RRRR RGGG GGGB BBBB

drop the least significant bits of each color channel, ex:

R8 = 255
Convert R8 => R5 by dropping the last bits (255 >> 3)
R5 = 31

Going the other way (R5G6B5 => R8G8B8) is trickier.
A naive implementation reverses the R8 => R3 operation by shifting up:

R5 = 31
Convert R5 => R8 by shifting up (31 << 3)
R8 = 248 (Not what we wanted, the channel is darker now).


0 comments: