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
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
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.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
You don't need to compare.hen you want to save, compare each pixel to the backup.
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.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
yeah, I already said that in my other paragraph.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Not quite:
This is not necessary.When you want to save, compare each pixel to the backup.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
like I said, I already said that in my other paragraph.
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. 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!
Last edited by amleto; 9th July 2012 at 17:52.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
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.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
I think it is rather a case of not reading what I have written. anyway...
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Bookmarks