[Qt-interest] XOR two QImages
Michael S
msherman77 at yahoo.com
Wed Aug 11 21:04:49 CEST 2010
Thanks Samuel,
It worked as expected. Now I am trying to do the same with text, i.e. draw text on top of QImage
QImage bgImg ("bg.png");
QImage fgImg ("fg.JPG");
QPainter painter (&bgImg);
painter.setCompositionMode(QPainter::CompositionMode_Xor);
painter.drawImage(0, 0, fgImg);
bgImg.save("result.bmp");
QFont font ("Verdana", 24);
painter.setFont(font);
QString sText ("HELLO WORLD");
painter.drawText (200,200, sText);
bgImg.save("result.bmp");
But it doesn't seem to have the same affect on text. Are there any QPainter or QFont settings I'd need to adjust?
Thanks again,
Michal
--- On Wed, 8/11/10, Samuel Rødal <samuel.rodal at nokia.com> wrote:
> From: Samuel Rødal <samuel.rodal at nokia.com>
> Subject: Re: [Qt-interest] XOR two QImages
> To: qt-interest at trolltech.com
> Date: Wednesday, August 11, 2010, 9:53 AM
> On 08/11/2010 03:28 PM, ext Michael S
> wrote:
> > Good day all,
> >
> > I am trying to load to images from disk and impose on
> top of each other using the XOR raster operation. What I am
> getting is a black rectangle where the foreground (smaller)
> image is.
> >
> > Here the code snippet:
> >
> > QImage bgImg ("bg.png");
> > QImage fgImg ("fg.JPG");
> > QPainter painter (&bgImg);
> >
> painter.setCompositionMode(QPainter::CompositionMode_Xor);
> > painter.drawImage(0, 0, fgImg);
> > bgImg.save("result.bmp");
> >
> > I guess I should be doing something extra to get the
> desired result.
> > Please let me know if there are any ideas.
>
> CompositionMode_Xor is a composition operation based on the
> alpha
> channels of the images, have a look at the documentation:
>
> http://doc.qt.nokia.com/4.6/qpainter.html#CompositionMode-enum
>
> Maybe you want to use RasterOp_SourceXorDestination
> instead.
>
> --
> Samuel
> _______________________________________________
> 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