我将 3 值 RGB 表示形式存储为 16 位整数,方法是根据此处的答案(将 RGB 值转换为整数)进行位移。它似乎适用于g
andb
值,但r
总是返回为 0。
我的代码是:
uint16_t rgb = ((r&0x0ff) << 16) | ((g&0x0ff) << 8) | (b&0x0ff);
qDebug() << "wrote rgb: " << rgb;
qDebug() << "wrote r: " << r << " g: " << g << " b: " << b;
qDebug() << "unshifted r: " << ((rgb >> 16) & 0x0ff) << " g: " << ((rgb >> 8) & 0x0ff) << " b: " << (rgb & 0x0ff);