Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[bug #57335] PNG writing support appears to be broken

1 view
Skip to first unread message

Yavor Doganov

unread,
Dec 1, 2019, 11:54:35 AM12/1/19
to Yavor Doganov, bug-g...@gnu.org
URL:
<https://savannah.gnu.org/bugs/?57335>

Summary: PNG writing support appears to be broken
Project: GNUstep
Submitted by: yavor
Submitted on: Sun 01 Dec 2019 06:54:28 PM EET
Category: Gui/AppKit
Severity: 3 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any

_______________________________________________________

Details:

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.



_______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 01 Dec 2019 06:54:28 PM EET Name: foo.m Size: 853B By: yavor
Example program for converting an image to PNG
<http://savannah.gnu.org/bugs/download.php?file_id=47959>

_______________________________________________________

Reply to this item at:

<https://savannah.gnu.org/bugs/?57335>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/


Fred Kiefer

unread,
Dec 1, 2019, 5:00:16 PM12/1/19
to Fred Kiefer, Yavor Doganov, bug-g...@gnu.org
Update of bug #57335 (project gnustep):

Status: None => Confirmed
Assigned to: None => FredKiefer

_______________________________________________________

Follow-up 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.

Yavor Doganov

unread,
Dec 2, 2019, 2:02:15 AM12/2/19
to Fred Kiefer, Yavor Doganov, bug-g...@gnu.org
Follow-up Comment #2, bug #57335 (project gnustep):

[comment #1 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.

Fred Kiefer

unread,
Dec 2, 2019, 4:51:04 PM12/2/19
to Fred Kiefer, Yavor Doganov, bug-g...@gnu.org
Update of bug #57335 (project gnustep):

Status: Confirmed => Ready For Test
Open/Closed: Open => In Test

_______________________________________________________

Follow-up 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.

Yavor Doganov

unread,
Dec 3, 2019, 1:27:16 AM12/3/19
to Fred Kiefer, Yavor Doganov, bug-g...@gnu.org
Follow-up Comment #4, bug #57335 (project gnustep):

I confirm it works for me, thanks very much.

Fred Kiefer

unread,
Dec 6, 2019, 2:46:02 PM12/6/19
to Fred Kiefer, Yavor Doganov, bug-g...@gnu.org
Update of bug #57335 (project gnustep):

Status: Ready For Test => Fixed
Open/Closed: In Test => Closed
0 new messages