Bug 697423 - pngalpha device breaks transparent edge antialiasing
Summary: pngalpha device breaks transparent edge antialiasing
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Other Driver (show other bugs)
Version: 9.20
Hardware: PC Windows 10
: P4 normal
Assignee: Robin Watts
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-06 06:35 UTC by Masamichi Hosoda
Modified: 2016-12-29 06:43 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
transparent.eps (347.59 KB, application/postscript)
2016-12-06 06:35 UTC, Masamichi Hosoda
Details
transparent-gs918.png (2.42 KB, image/png)
2016-12-06 06:36 UTC, Masamichi Hosoda
Details
transparent-gs919.png (3.59 KB, image/png)
2016-12-06 06:36 UTC, Masamichi Hosoda
Details
transparent-gs920.png (3.59 KB, image/png)
2016-12-06 06:37 UTC, Masamichi Hosoda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masamichi Hosoda 2016-12-06 06:35:35 UTC
Created attachment 13216 [details]
transparent.eps

If I understand correctly, Ghostscript 9.19 broke transparent edge antialiasing.

The attached transparent.eps contains some white drawing materials.
I obtained transparent PNG (RGBA PNG) with the following command.

gswin32c -dSAFER -dEPSCrop -dGraphicsAlphaBits#4 -dTextAlphaBits#4 -dNOPAUSE -dBATCH -sDEVICE#pngalpha -sOutputFile#transparent.png transparent.eps

When using Ghostscript 9.18, there is no problem with png output.
(transparent-gs918.png)

When using Ghostscript 9.20 and 9.19, the transparent edge in png output becomes gray.
(transparent-gs920.png, transparent-gs919.png)
Comment 1 Masamichi Hosoda 2016-12-06 06:36:24 UTC
Created attachment 13217 [details]
transparent-gs918.png
Comment 2 Masamichi Hosoda 2016-12-06 06:36:48 UTC
Created attachment 13218 [details]
transparent-gs919.png
Comment 3 Masamichi Hosoda 2016-12-06 06:37:10 UTC
Created attachment 13219 [details]
transparent-gs920.png
Comment 4 Ken Sharp 2016-12-06 06:53:54 UTC
(In reply to Masamichi Hosoda from comment #0)
> Created attachment 13216 [details]
> transparent.eps
> 
> If I understand correctly, Ghostscript 9.19 broke transparent edge
> antialiasing.
> 
> The attached transparent.eps contains some white drawing materials.
> I obtained transparent PNG (RGBA PNG) with the following command.

PostScript doesn't have a transparent imaging model, so your EPS cannot be transparent (and isn't).

What it does, apparently, contain is a number of objects drawn in white. Nothing is drawn on the media beforehand, so the resulting objects are simply white on a normally white background (since, as I said, PostScript doesn't have a transparency model).

9.18 produces a pure white output with the pngalpha device for me (presumably the reporter is viewing with something which has a non-white background), while the current code renders the white objects in shades of grey. 9.19 behaves the same, so this is at least 6 months old. The GraphicsAlphaBits and TextAlphaBits switches are not required to reproduce this, nor the -dSAFER, -dNOPAUSE or -dBATCH switches.

Apparently Michael owns that device....
Comment 5 Ken Sharp 2016-12-06 08:08:08 UTC
According to git bisect the commit which caused this is 	d9f041d6fe7eda89364df1424f85ace974ed0fec

This was a commit from Robin, so I'm changing the assignment.
Comment 6 Robin Watts 2016-12-29 06:43:28 UTC
Fixed in:

commit 0aeb0bbd41cc16e70ab6e4b1d56e0c510bf2a758
Author: Robin Watts <robin.watts@artifex.com>
Date:   Thu Dec 29 13:39:50 2016 +0000

    Bug 697423: Fix overflow in pngalpha.

    The composite creation maths in the copy_alpha method overflowed
    due to the alpha range being changed from 0..15 to 0..255 in
    commit d9f041d6fe7eda89364df1424f85ace974ed0fec. Changing to
    unsigned solves this.