[Qt-interest] XOR two QImages

Michael S msherman77 at yahoo.com
Wed Aug 11 15:28:28 CEST 2010


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.

Michael



More information about the Qt-interest-old mailing list