Bug 692862 - Rounded boxes with zero height have a white triangle inside in gs 9.x
Summary: Rounded boxes with zero height have a white triangle inside in gs 9.x
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Graphics Library (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Robin Watts
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 22:12 UTC by Pavel Roskin
Modified: 2013-03-07 11:15 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
Lilypond output (64.45 KB, application/postscript)
2012-02-16 22:12 UTC, Pavel Roskin
Details
Rendering to pngalpha - with white triangle (48.38 KB, image/png)
2012-02-16 22:14 UTC, Pavel Roskin
Details
Rendering to pnggray - without white triangle (16.61 KB, image/png)
2012-02-16 22:15 UTC, Pavel Roskin
Details
Patch to fix the white triangle (704 bytes, patch)
2012-02-16 22:16 UTC, Pavel Roskin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Roskin 2012-02-16 22:12:36 UTC
Created attachment 8360 [details]
Lilypond output

The bug was originally filed against Lilypond:
http://code.google.com/p/lilypond/issues/detail?id=2328

Lilypond wants to draw a line with rounded ends.  If rendering to PNG format, a write triangular area appears inside the line.

I found by bisecting ghostscript repository that the issue was introduced in commit 43b14b24fcc13d816dd41ca335d52cd3074bd0d8, between 8.71 and 9.01.

Reverting the patch fixes rendering.

Rendering to the pnggray device doesn't make the white triange, so ghostscript is inconsistent between devices.
Comment 1 Pavel Roskin 2012-02-16 22:14:22 UTC
Created attachment 8361 [details]
Rendering to pngalpha - with white triangle

Rendered by
gs -r300 -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=box-alpha.png box.ps
Comment 2 Pavel Roskin 2012-02-16 22:15:11 UTC
Created attachment 8362 [details]
Rendering to pnggray - without white triangle

Rendered by
gs -r300 -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=box-gray.png box.ps
Comment 3 Pavel Roskin 2012-02-16 22:16:55 UTC
Created attachment 8363 [details]
Patch to fix the white triangle

This is essentially a revert of commit

commit cbcc4ac3c4d74ef2ca915c13c6d35a8a930ae4ff
Author: Robin Watts <robin.watts@artifex.com>
Date:   Wed Apr 7 13:13:57 2010 +0000

    Fix for bug 691228, problems with wide strokes with round caps/joins with
    antialiasing enabled.
    
    2 small problems in the same code. In the antialiased case, we stroke by
    forming 2 paths (one up either side of the line) and then reverse one and
    concatenate it. This should happen whenever we meet a closepath, but due to
    a misplaced return, was being missed out in some round join cases.
    
    Also, when using a round join in the case where 2 lines meet 'in-line' we
    would inadvertently leave the point on the wrong side of the line.
    
    No changes in localcluster testing as this only affects antialiased results
    and that's not tested currently.
    
    git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11031 a1074d23-0009-0410-80fe-cf8c14f379e6
Comment 4 Robin Watts 2013-03-07 11:15:30 UTC
(In reply to comment #3)
> Created attachment 8363 [details]
> Patch to fix the white triangle
> 
> This is essentially a revert of commit

Simple reversion is clearly not the right fix, as that reintroduces all the problems that caused bug 691228 in the first place.

I have implemented a fix that makes the fix dependent on the relative direction of the vectors, and this seems to fix both cases.

commit 6961e71d7b6b9162f6b75fae60469175a4c8d43e
Author: Robin Watts <robin.watts@artifex.com>
Date:   Thu Mar 7 00:45:41 2013 +0000

    Bug 692862: Fix stroking problem with antialiasing

    The fix for bug 691228 causes problems in some cases; when joining
    two segment that are directly in line with the next, we add a
    circular line cap to ensure correct rendering. Which side of this
    end cap we end up on depends on which direction the line then
    continues in.

Thanks for the report!