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


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);
}
posted @ 2023-03-24 08:30  zhaocundang  阅读(141)  评论(0编辑  收藏  举报