Issue #1 resolved

widelines draw with different widths depending on direction

gormish
created an issue

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)

vertical line going down

dr.line((5,5,5,45),width=2,fill=255)

vertical line going up

dr.line((10,45,10,5),width=2,fill=255)

horizontal right

dr.line((20,5,50,5),width=2,fill=128)

horizontal left

dr.line((50,15,20,15),width=2,fill = 128)

diagonal - slash

dr.line((10,70,30,50),width=2,fill=192) dr.line((40,50,20,70),width=2,fill=192)

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: