[Qt-interest] XOR two QImages
Samuel Rødal
samuel.rodal at nokia.com
Wed Aug 11 15:53:11 CEST 2010
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
More information about the Qt-interest-old
mailing list