qt RGB 转RGB565 生成提供单片机LCD显示

发布时间 2023-03-24 08:33:51作者: zhaocundang

void convertRgbToRgb565(int red, int green, int blue)
{
  uint16_t rgb565;
  QColor color(red, green, blue);
  uint16_t r = color.red() >> 3;
  uint16_t g = color.green() >> 2;
  uint16_t b = color.blue() >> 3;
  rgb565 = (r << 11) | (g << 5) | b;
  printf("%s%s%s","0x",qPrintable(QString("%1").arg(rgb565,4,16,QLatin1Char('0')).toUpper()),",");//不足8位补0;
fflush (stdout);
}