[Qt-interest] how to paint monochrome QImagecolorised(black=>arbitrary color, white=>transparent)?
Stephen Chu
stephen at ju-ju.com
Mon May 10 15:35:51 CEST 2010
In article <hs5aem$el$1 at eple.troll.no>,
"Ross Bencina" <rossb-lists at audiomulch.com> wrote:
> > 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.
Glad to help. How if I can only figure out how to use an 8-bit image as
a mask to arbitrary drawing...
--
Stephen Chu
More information about the Qt-interest-old
mailing list