Skip to content

Instantly share code, notes, and snippets.

@XProger
Last active June 5, 2016 19:48
Show Gist options
  • Select an option

  • Save XProger/f840849a1070fdc9d930 to your computer and use it in GitHub Desktop.

Select an option

Save XProger/f840849a1070fdc9d930 to your computer and use it in GitHub Desktop.
Fast convert 24-bit color to 16-bit.
// 24 to 16
unsigned short color = (r & 0xF8) << 8 | (g & 0xFC) << 3 | b >> 3;
// 16 to 24
unsigned int color = (c & 0xF800) << 8 | (c & 0x07E0) << 5 | (c & 0x001F) << 3;
@GrayFace

GrayFace commented Jun 5, 2016

Copy link
Copy Markdown

16 to 24 is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment