I'm storing a 3 value RGB representation into an 16bit integer by bit shifting it based off an answer from here (Convert RGB values to Integer). It seems to work for the g
and b
values, but r
is always returned as 0.
My code is:
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);