With Qt, I am trying to convert a Format_Indexed8
image to Format_RGB30
by using a custom conversion rule defined by a color table. I thought this would be simple, since QImage::convertToFormat
can take a color table as an argument, but I can't make it work.
Here is my code:
QImage image = QImage(data, width, height, QImage::Format_Indexed8);
QVector<QRgb> colorTable(256);
for (int i = 0; i < 255; i++)
colorTable[i] = qRgb(255 - i, i, i);
image = image.convertToFormat(QImage::Format_RGB30, colorTable);
This code just gives me an image that is in RGB format, but that looks identical to the eye to the grayscale image.