Fredrik Lundh is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

effbot / pil-2009-raclette http://effbot.org/zone/pil-index.htm

Work repository for PIL 1.1.7 and beyond. The "default" branch should be fairly solid, the other branches less so. For production use, see the pil-117 repository.

Clone this repository (size: 1.6 MB): HTTPS / SSH
hg clone https://bitbucket.org/effbot/pil-2009-raclette
hg clone ssh://hg@bitbucket.org/effbot/pil-2009-raclette

Issues

#1 widelines draw with different widths depending on direction

Reported by gormish (last edited )

ImagingDrawWideLine() in Draw.c has a bug in every version I've seen, which leads to different width lines depending on the order of the points in the line. This is especially bad at some angles where a 'width=2' line can completely disappear.

This is due to use of a cast vs. a floor in draw.c. Here is the fix:

<pre> bash-3.2$ diff Imaging-1.1.6.orig/libImaging/Draw.c Imaging-1.1.6/libImaging/Draw.c 689,690c689,690 < dx = (int) (d * (y1-y0) + 0.5); < dy = (int) (d * (x1-x0) + 0.5); ---

dx = (int) floor(d * (y1-y0) + 0.5); dy = (int) floor(d * (x1-x0) + 0.5);

</pre>

Here is test program:

<pre>

import Image, ImageDraw im = Image.new("L",(120,120)) dr = ImageDraw.Draw(im)

  1. vertical line going down dr.line((5,5,5,45),width=2,fill=255)
  2. vertical line going up dr.line((10,45,10,5),width=2,fill=255)
  3. horizontal right dr.line((20,5,50,5),width=2,fill=128)
  4. horizontal left dr.line((50,15,20,15),width=2,fill = 128)
  5. diagonal - slash dr.line((10,70,30,50),width=2,fill=192) dr.line((40,50,20,70),width=2,fill=192)
  6. diagonal - backslash dr.line((70,10,90,30),width=4,fill=96) dr.line((100,30,80,10),width=4,fill=96)

dr.line((50,30,65,35,80,45,90,60,100,75,100,85,95,90,90,90, 80,85,60,80,55,70,50,50),width=2,fill=255) im.save('lines.png') </pre>

Here is the image without the fix:

Status: resolved Responsible: Fredrik Lundh Type: bug Priority: major
Milestone: raclette-alpha Component: pil-core Version: pil-1.1.6

Attachments

Comments and changes

  1. #1 gormish

    written

  2. #2 gormish

    written

  3. #3 gormish

    written

  4. #4 gormish

    written

  5. #5 Fredrik Lundh

    written

    • Changed status from new to open.
    • Changed component from nothing to pil-core.
  6. #6 Fredrik Lundh

    written

    • Changed status from open to resolved.

    Thanks! Fixed in 8d2ed93e043c .

Add comment / attachment

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?