You may try to do the following:
First, construct QImage
from your buffer using this constructor: QImage(const uchar* data, int width, int height, Format format)
, using QImage::Format_Indexed8
as format
i.e.
QImage img(dataBuffer, 1000, 1000, QImage::Format_Indexed8)
Second, Initialize color translation map: it should be QVector<QRgb>
, so you need to do something like this:
QVector<QRgb> colorMap(256);
colorMap[255] = QRgb(255, 255, 255); // Any color of your choice
// probably some other mappings
Then use QImage::convertToFormat
like this:
QImage converted = img.convertToFormat(QImage::Format_RGB32, colorMap)
This will convert it to RGB. Basically, that's it, now you can draw this image on your widget or save it to file.