[Qt-interest] how to paint monochrome QImage colorised(black=>arbitrary color, white=>transparent)?
Ross Bencina
rossb-lists at audiomulch.com
Sat May 8 15:55:01 CEST 2010
Sorry to answer my own question. Google got me this:
QColor c = // color of image we want
QImage image0 = QImage(
":/ImageName.png" ).convertToFormat(QImage::Format_Indexed8);
image0.setColor(0, c.rgb());
image0.setColor(1, Qt::transparent);
(cache image 0)
painter.drawImage( x, y, image0 );
That works.
I'm not sure if this is the most efficient though. Is it worth caching the
image converted to the native screen color depth?
Ross.
> Can anyone recommend the best (most efficient) way to paint a monochrome
> QImage such that the white pixels are transparent and the black pixels
> take
> on a specified color?
>
> Thanks!
>
> Ross
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list