Skip to content

Line anti-aliasing issues due to missing sRGB mishandling #65

@baryluk

Description

@baryluk

Hi,

I just started using aggdraw, and it definitively draws nicer lines than PIL for my application (opacity and antialiassing does help), but I noticed still imperfection and possibly a bug:

dump

Be sure to open it and view at 100% scale.

The issue is visible as uneven luminosity of the lines. I.e. if you look at the top center, and then count 3 or 4 lines to the right, it looks to be oscillating in brightness.

I am not talking about a Moiré pattern that appears in the center, that is somehow expected, but possibly is related partially. I am talking about straight slightly diagonal lines far from the center.

It feels like maybe the sRGB is not used correctly? Which is a bit strange, as I see there is support for gamma, linear and sRGB in the aggdraw.

# Python 3.8.1
from PIL import Image, ImageDraw  # Pillow 6.2.1
import aggdraw  # Version 1.3.11
w, h = 1024, 1024
img = Image.new("RGB", (w, h))
img1 = aggdraw.Draw(img)
img1.setantialias(True)
pen = aggdraw.Pen("white", 1.0, opacity=127)

img1.line(xyxyxy, pen)
# ...

img1.flush()
img.save("dump.png")
img.show()

With opacity=255 effect is visible even more:

dump

dump

When drawing a similar type of lines (width and angle) for example in Inkscape, I see much more uniform luminance and the oscillations are there, but essentially invisible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions