ImageDraw line inconsistent ? (repost)

  • Thread starter alexandre_irrthum
  • Start date
A

alexandre_irrthum

Hi there,

Sorry to repost this, but I didn't get any answer one month ago. In
essence, it seems that the ImageDraw line function draws lines one
pixel shorter in some circumstances. This could be very annoying for
some applications where precise geometry does matter.

Below I test this function on a 3x3 image and show schematic
representations of obtained images (where o means a drawn pixel)

import Image, ImageDraw
im = Image.new("L", (3,3))
draw = ImageDraw.Draw(im)
draw.line((0,0,2,2), fill=255)
im.tostring()

Gives:

o--
-o-
---

So the last pixel of the line is not drawn.

Similarly, draw.line((0,2,2,0), fill=255) gives:

---
-o-
o--

And draw.line((1,0,1,2), fill=255) gives:

-o-
-o-
---

But, surprisingly, draw.line((0,1,2,1), fill=255) gives:

---
ooo
---

Where the last pixel of the line -is- drawn, as I expected it would be
for all lines.

This seems to be true for various image sizes and line angles: the last
pixel is never drawn unless the line is horizontal.

Any clues ?

Thanks

alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top