8bit images use a colour look-up table thus the value you put as pixel data is the index in the colour table which is probably empty thus you get all black. QPixmap will always be 32b. Reading documentation really doesn't hurt - try it.
8bit images use a colour look-up table thus the value you put as pixel data is the index in the colour table which is probably empty thus you get all black. QPixmap will always be 32b. Reading documentation really doesn't hurt - try it.
Thanks wysota, yes RTFM, i've said that in the past
I assume that the conversion from 8bpp to 32bpp doesnt scale the pixel values and that is why my label is black?
Do I have to create a colour table, how do I associate the colour table with my pixmap? I am confused.
Best Regards
Still having problems with this, I have realised I need to create a colortable which I have populated with 'yellow' for all entries, so expecting a yellow image. The image is still black.
My code is below
QImage BPlaneI(ch_ptr,rows,cols,QImage::Format_Indexed8);//8 bit image
BPlaneI.setNumColors(256);
loadImageData(ch_ptr,rows,cols,&BPlaneI);//load image buffer from ch_ptr
for (int i=0; i<255; i++)
{
BPlaneI.setColor(i,Qt::darkYellow);
}
QPixmap qp(rows,cols);
qp.fromImage(BPlaneI,Qt::AutoColor);
QLabel l;
l.setPixmap(qp);
l.show();
Really stuck with this one, any ideas would be greatly appreciated
Thanks
I'm not sure what you mean by that but I think the answer is "no".
Try something obvious:Do I have to create a colour table, how do I associate the colour table with my pixmap? I am confused.
Qt Code:
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->show();To copy to clipboard, switch view to plain text mode
Bookmarks