Skip to content
Marco Calautti edited this page Nov 3, 2017 · 3 revisions

General Information

  • Codec Name: RGB565
  • Found in: Possibly anywhere, but mostly on games/consoles supporting DXTn compressed textures.
  • Type: Color encoding
  • Endianness: Any
  • Rainbow's implementation: ColorCodecRGB565, ImageUtils.Conv5To8/Conv6To8/Conv8To5/Conv8To6
  • Additional info: N/A

Codec Specification

Each RGB565 color is encoded as a uint16 (two bytes), where red, green and blue channels are distributed as follows:

uint16 color = RRRRRGGGGGGBBBBB

One may be tempted to decode the 3 channels above to a full 8-bit RGB color as follows:

uint8 red = RRRRR << 3

uint8 green = GGGGGG << 2

uint8 blue = BBBBB << 3

However this is not correct, as for example decoding the maximum value for the red channel RRRRR=11111 will not give the maximum value for the red channel in full 8-bits. Indeed:

uint8 red = 11111<<3 = 11111000 = 248

and not 255.

The decoder and the encoder have to uniformly map each 5/6 bit value to the corresponding 8-bit one and viceversa.

Please refer to ImageUtils's methods specified in the General Information section.