Problems with polygon drawing

Andrew Mark <[email protected]> Fri, 23 Aug 2013 10:05:04 +0200
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
I'd like to use PIL to rasterise a polygon, but I'm having trouble getting even a simple test to work. I expect the following to produce a 11x11 array with a white diamond on a black background, but I only get the background. 

diamond = array([[5,0], [10,5], [5,10], [0,5]])
img = Image.new('L', (11,11), 0)
draw = ImageDraw.Draw(img)
draw.polygon(diamond, fill=1, outline=1)
array(img)

array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

The method draw.line() works as it should. What am I doing wrong?

Thanks,

-AM
_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig