tuupola / hagl

Hardware Agnostic Graphics Library for embedded
https://www.appelsiini.net/tags/hagl/
MIT License
302 stars 49 forks source link

Hex to rgb565 #118

Open 32teeth opened 9 months ago

32teeth commented 9 months ago

uint16_t util_color_to_rgb565(const char *color)
{
  int red, green, blue;
  sscanf(color, "%02x%02x%02x", &red, &green, &blue);
  return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
}

adding this to make use of taking string hex to convert to rgb565