[Qt-interest] Painting to a QImage of format Format_Indexed8?
Dave Thorup
lists at kuwan.net
Thu Jun 4 04:45:38 CEST 2009
I'm trying to paint into an 8-bit indexed QImage with a QPainter but
this doesn't appear to work at all. I set up the color table as
follows:
QVector<QRgb> colorTable;
QImage * pImg = new QImage( 500, 500, QImage::Format_Indexed8 );
for ( int i = 0; i < 256; i++ )
{
colorTable.append( qRgb( i, i, i ) );
}
pImg->setColorTable( colorTable );
Then I fill the image with grey and create a QPainter for the image:
pImg->fill( 127 ); // fill with grey
QPainter painter( pImg );
Next if I try to paint into the image then nothing happens:
painter.fillRect( 50, 50, 300, 300, QBrush( qRgb( 255, 255,
255 ) ) ); // paint a white square
I then save the QImage to a PNG to view it and all I get is a grey
image. If I change the format to Format_RGB32 (and don't set the
color table) then everything works as I would expect it to.
Is painting into QImages of Format_Indexed8 just not supported? Any
suggestions?
Thanks
Qt. 4.4.3, Mac OS X 10.5.7
--
Dave Thorup
Software Engineer
http://bibblelabs.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090603/6f70ff9a/attachment.html
More information about the Qt-interest-old
mailing list