PDA

View Full Version : Painting one Image from another Image with paint brush



avanindra
21st July 2012, 12:49
Hi Folks,

I want to create a paint brush , which instead of using a single color or color pattern , uses pixels from another image. Is there a way to do it efficiently?...

In my current setting , I am doing painting on a QImage with paint brush. But I also want a brush which can recover the original image if the region under brush is painted with some color. In short I want an unpaint brush.

thanks and regards

Avanindra Singh

wysota
21st July 2012, 13:08
You need two images. One is the original image which you do not touch, just use for compositing. The other image starts with being fully transparent. There you use QPainter::drawImage() to paint parts of some other (third? first?) image over it. Erasing your actions is quite easy because you just draw with a Clear compositing mode on it again. Finally you compose the output image by using the "Painter's Algorithm" -- first draw the original image and then draw the other image over it.