New image flattening functionality breaks saving functionality

Bug #999571 reported by grofaty
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
Critical
Cameron White

Bug Description

Tested in Pinta latest development on Ubuntu 12.04:
1. Open new image.
2. Select Paintbrush and draw something on canvas.
3. Click Layer | New Layer.
4. Select Text object from tools and type in text: test
5. File | Save as and save the file into PNG file type.

Close the file and open it again, you will notice that only blank (without "test" text) transparent layer is displayed.

P.S. I have tested this in Pinta v1.3 on Windows XP and it works fine. It looks like a regression to me.
This bug was already in Pinta few years ago and was fixed. Now bug reappeared.

Revision history for this message
grofaty (grofaty) wrote :

I have tested several revisions from github and I see a regression appeared in commit: "Add a 'Copy Merged' command, which copies the flattened image/selecti..." which is revision: aefe1ccd1a4d25562d67247f7ecfe8222322454c from May 14, 2012.

Revision history for this message
Cameron White (cameronwhite91) wrote :

I can't seem to reproduce this with the latest development build on 12.04 - saving appears to work fine for me.

Revision history for this message
grofaty (grofaty) wrote :

Cameron saving is working fine. Opening saved file is a problem. When such a file is opened only "transparent layer" is displayed (without text on it). See attachment.

I have tried this one more time and actually I have found out that the first revision this problem appears in is "Make "Flatten Image" and "Merge Layer Down" respect blend modes" witch is revision number: f0fddbd10d133ec8ad97e0129511f4e656337474 from May 14, 2012.

Revision history for this message
Cameron White (cameronwhite91) wrote :

I can reproduce this now on Ubuntu 12.04 with latest development build.

Changed in pinta:
importance: Undecided → High
milestone: none → 1.4
status: New → Confirmed
Revision history for this message
Robert Nordan (rpvn) wrote :

Closed my dupe of this bug and bumped the priority on this one since being able to save is failry mission-critical.

From my comments:" Every PNG image I saved was completely blank, and every JPG was completely black. ORA images saved fine. " Verified that the problem appeared in that commit.

The funny thing is, I can't see anything obviously wrong with the code. I suspect that GetFlattenedImage() does something that is incompatible with the saving procedure, but not sure what.

summary: - When multiple layers are used and saved into png file transparent image
- is saved
+ New image flattening functionality breaks saving functionality
Changed in pinta:
importance: High → Critical
Revision history for this message
Robert Nordan (rpvn) wrote :

Update: I found out that putting a breakpoint on [1] triggered plenty of times after reverting to a working state, but none at all in the current state. So the condition there is not being triggered anymore, seemingly meaning the alpha value is always set to 0. I tried commenting out the if clause, and saved files are still broken, so there probably is something wrong with the alpha value on the imagesurface being handed to it from GetFlattenedImage().

[1] https://github.com/PintaProject/Pinta/blob/master/Pinta.Core/Extensions/CairoExtensions.cs#L671

Revision history for this message
Robert Nordan (rpvn) wrote :

More exciting debugger action! The place where it seems to go wrong is in ImageSurface.Clone ()[1]. After stepping through there with a small image, I noticed that the cloned surface being returned is completely empty. Why this is doing that I don't know, since this method hasn't been changed.

[1] https://github.com/PintaProject/Pinta/blob/master/Pinta.Core/Extensions/CairoExtensions.cs#L800

Revision history for this message
Robert Nordan (rpvn) wrote :

OK, I changed the way the imagesurface is cloned. Instead of using the original as a source and repainting, the data array is just directly over. This fixes the problem, but to be honest don't don't understand why it was broken to begin with. ( So I employed MIDD: Magical Incantation-Driven Development)

In case there is a specific reason it was done this way before or anyone sees a reason why the new way is worse (performance?) I uploaded it as a pull request rather than commiting directly. [1] Anyone have any thoughts on this?

[1] https://github.com/PintaProject/Pinta/pull/29

Revision history for this message
Robert Nordan (rpvn) wrote :

Should have been "the data array is just directly copied over" in the previous comment.

Revision history for this message
grofaty (grofaty) wrote :

Looking into Git I have noticed that this bug was fixed with commit: https://github.com/PintaProject/Pinta/commit/66e34c5a2edc578cecfd1e691a1addd95590dc78

Tested on latest development and problem is solved. Thanks.

Revision history for this message
Robert Nordan (rpvn) wrote :

I've held off on closing this one because we weren't sure about how solid the fix was, I just pushed a revised fix. If that's good then we'll close.

Revision history for this message
Cameron White (cameronwhite91) wrote :

I figured out the cause of the original regression, and submitted a fix for that: https://github.com/PintaProject/Pinta/commit/c29a2d5b10847fc7f2076fca77f9a85365cb198c

I verified the change on Ubuntu 12.04 and Window 8, so I'll mark this as committed.

Changed in pinta:
assignee: nobody → Cameron White (cameronwhite91)
status: Confirmed → Fix Committed
Revision history for this message
grofaty (grofaty) wrote :

I tested this bug in pinta-1.4-preview-20120812 on Windows XP and I can report this is fixed. Thanks a lot!

Revision history for this message
grofaty (grofaty) wrote :

Pinta v1.4 on Windows XP. Problem solved.

Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.