[Qt-interest] how to paint monochrome QImagecolorised(black=>arbitrary color, white=>transparent)?
Ross Bencina
rossb-lists at audiomulch.com
Sun May 9 05:33:29 CEST 2010
> If your image is a 1-bit bitmap, you can convert it to a QBitmap then
> set the background mode to transparent, set pen to the color you want.
> Then draw the pixmap:
>
> QBitmap theBitmap = QBitmap::fromImage(theImage);
> painter->setBackgroundMode(Qt::TransparentMode);
> painter->setPen(theColor);
> painter->drawPixmap(where, theBitmap);
Thanks, actually my source image was in a resource so it was possible to
load the bitmap directly from the resource:
QBitmap theBitmap( ":/DynamicsMeterNumber0.png" );
...
painter->setBackgroundMode(Qt::TransparentMode);
painter->setPen(theColor);
painter->drawPixmap(where, theBitmap);
Many thanks
Ross.
More information about the Qt-interest-old
mailing list