PDA

View Full Version : Painting an overlay on a QLabel->QImage



papillon
7th July 2012, 16:23
I've a QLabel which I use to display a reference QImage. Now, I'd like to paint over the reference image, and save only the overlay strokes as a separate QImage (thus no pixels from the reference image have to be accounted).
Any suggestion? Thanks

amleto
8th July 2012, 11:05
one brute-force & not very good way is to save a copy of the original pixmap, then let user draw whatever they want on the other copy. When you want to save, compare each pixel to the backup. If the pixel value is different, save it, otherwise save a transparent/empty pixel.

A better way would be to have enough control of the strokes and user operations that you can just copy the painter path and write them to an empty pixmap at the same time as painting them on the image.

high_flyer
9th July 2012, 10:15
hen you want to save, compare each pixel to the backup.
You don't need to compare.
Just have two pixmaps.
Draw the original in to the first pixmap and show it.
When the user draws, draw it in to the other pixmap *and* on to the original (and don't show the second pixmap), this way you can show the composite result, while having both versions separate.

amleto
9th July 2012, 12:43
yeah, I already said that in my other paragraph.

high_flyer
9th July 2012, 12:53
Not quite:

When you want to save, compare each pixel to the backup.
This is not necessary.

amleto
9th July 2012, 17:44
yeah, I already said that in my other paragraph.

Not quite:
When you want to save, compare each pixel to the backup.
This is not necessary.

like I said, I already said that in my other paragraph.

one brute-force & not very good way is to save a copy of the original pixmap, then let user draw whatever they want on the other copy. When you want to save, compare each pixel to the backup. If the pixel value is different, save it, otherwise save a transparent/empty pixel.

A better way would be to have enough control of the strokes and user operations that you can just copy the painter path and write them to an empty pixmap at the same time as painting them on the image.

The second paragraph is clearly separate from the first paragraph that you keep quoting because it is a separate paragraph. I hope it is clear now. :p I haven't even mentioned that I started that paragraph with 'A better way' to indicate that I am talking about an alternative method. A method where I make no reference to comparisons at all.

... dangit!

high_flyer
10th July 2012, 09:13
From your second paragraph one can understand (as I did) that you imply that operations should be taken to save a painter path (as in, explicitly deal with the painter path), specially when one reads your fist paragraph where you suggest comparing pixels.
My point was that this all is not needed.
If you didn't mean it, well, that's the way (at least) I understood it.

And cool down man.

amleto
10th July 2012, 09:28
I think it is rather a case of not reading what I have written. anyway...