puzzled by ImageDraw line

  • Thread starter alexandre_irrthum
  • Start date
A

alexandre_irrthum

Hi there,

I am puzzled by the comportment of the line function from the ImageDraw
module with regard to the way it draws or does not draw the last pixel
of a line.

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.save("test.tif")

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top