
Originally Posted by
dbrmik
I assume that the conversion from 8bpp to 32bpp doesnt scale the pixel values and that is why my label is black?
I'm not sure what you mean by that but I think the answer is "no".
Do I have to create a colour table, how do I associate the colour table with my pixmap? I am confused.
Try something obvious:
image.setNumColors(2);
image.setColor(0, qRgb(0,0,0));
image.setColor(1, qRgb(255,255,0));
image.fill(0);
for(int i=0;i<100;i++)
image.setPixel(i, i, 1);
label
->setPixmap
(QPixmap::fromImage(image
));
label->show();
QImage image(100,100, QImage::Format_Indexed8);
image.setNumColors(2);
image.setColor(0, qRgb(0,0,0));
image.setColor(1, qRgb(255,255,0));
image.fill(0);
for(int i=0;i<100;i++)
image.setPixel(i, i, 1);
QLabel *label = new QLabel;
label->setPixmap(QPixmap::fromImage(image));
label->show();
To copy to clipboard, switch view to plain text mode
Bookmarks