ImageDraw line inconsistent ? (repost)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alexandre_irrthum@yahoo.com

    #1

    ImageDraw line inconsistent ? (repost)

    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

  • Fredrik Lundh

    #2
    Re: ImageDraw line inconsistent ? (repost)

    alexandre_irrth um@yahoo.com wrote:
    [color=blue]
    > 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.[/color]

    Find information, resources and relevant links for python-hosting.com. This domain may be for sale.


    </F>



    Comment

    Working...