bugGNUstep - Bugs: bug #57335, PNG writing support appears to be...

 
 

bug #57335: PNG writing support appears to be broken

Submitted by:  Yavor Doganov <yavor>
Submitted on:  Sun 01 Dec 2019 04:54:28 PM UTC  
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  Fred Kiefer <FredKiefer>
Open/Closed:  Closed

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 03 Dec 2019 06:27:07 AM UTC, comment #4: 

I confirm it works for me, thanks very much.

Yavor Doganov <yavor>
Mon 02 Dec 2019 09:50:51 PM UTC, comment #3: 

Thank you for this bug report. It help me fix a division by zero error when alpha was 0 and a bitmap image was un-pre-multiplied.
The fix is already submitted to git. Please give it a try.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Mon 02 Dec 2019 07:02:10 AM UTC, comment #2: 

comment #1:

> the white bits where shown as black. Is this the bug you are reporting?


Yes.

> What you did is switch off this conversion.


Yes, but not as a "fix", I was hoping that it might give you a clue what's going wrong.

> And for simple data where alpha is either 1 or 0 this results in correct images.


I just tried with a half-transparent image (alpha 0.5) and to my surprise the conversion is correct with current code.  But I'm afraid that "simple data" is quite a common case, especially for icons.

Yavor Doganov <yavor>
Sun 01 Dec 2019 10:00:10 PM UTC, comment #1: 

The test code you provides tries to convert a tiff file into a PNG image. This should be possible with GNUstep. I tried to convert the GNUstep logo from tiff to PNG and ended up with an image where the white bits where shown as black. Is this the bug you are reporting?

What the code here does is to follow the PNG specification. PNG stores values with non pre-multiplied alpha. GNUstep internally uses pre-multiplied alpha as this allows for faster drawing. When exporting to PNG we need to make sure we output the data non pre-multiplied and this code here tries to do the conversion.

What you did is switch off this conversion. And for simple data where alpha is either 1 or 0 this results in correct images. But this of course does not solve the issue why the conversion is wrong. Sorry, I will need some more time to look into this.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Sun 01 Dec 2019 04:54:28 PM UTC, original submission:  

Conversion between the different (supported) image formats is supposed to work flawlessly, as should be demonstrated with the attached simple program.  I tried it on several GNUstep app icons in TIFF format and it produces unusable PNG images.

After some investigation it turned out that this is due to the implicit conversion in NSBitmapImageRep -_PNGRepresentationWithProperties:, due to this condition (NSBitmapImageRep+PNG.m:325):

if ([self isPlanar] || !(_format & NSAlphaNonpremultipliedBitmapFormat))

If I change it to ([self isPlanar]) only then the resulting PNG images are fine.

Yavor Doganov <yavor>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #47959:  foo.m added by yavor (853B - text/x-objcsrc - Example program for converting an image to PNG)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Posted a comment)
  • -email is unavailable- added by yavor (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-06 FredKiefer StatusReady For Test => Fixed
        Open/ClosedIn Test => Closed
    2019-12-02 FredKiefer StatusConfirmed => Ready For Test
        Open/ClosedOpen => In Test
    2019-12-01 FredKiefer StatusNone => Confirmed
        Assigned toNone => FredKiefer
    2019-12-01 yavor Attached File- => Added foo.m, #47959

    Back to the top


    Powered by Savane 3.5