Hi all, the ImageDraw.Draw.polygon function does not draw as I expect it. Deep down in the C-code some Floor, Ceil and +0.5 seem to combine for a strange effect.
1. Any suggestions to actually draw within the outline only?
2. Why can't I draw with alpha-blending (it seems like I
have to im.paste to achieve this -- so inefficient...)
3. Do I have to destruct the Draw instance with del explicitly
(like it's done in the example code)
or is the implicit destruction enough to get it freed?
4. Is ImagePath.Path more efficient or just syntactic sugar?
Code to show the effect:
#piltest.py
import Image, ImageDraw
def save(image, fname='save.png'):
W = file(fname, 'wb')
image.save(W)
W.close()
def testpic():
"""Test polygon, line etc. drawing."""
im = Image.new('RGBA', (100,100))
D = ImageDraw.Draw(im)
fi=(0xbf, 0xbf, 0xbf, 0x7f)
D.line([(39,0),(39,100)],fill=fi) #vertical lines
D.line([(50,0),(50,100)],fill=fi)
D.line([(61,0),(61,100)],fill=fi)
D.line([(0,39),(100,39)],fill=fi) #horizontal lines
D.line([(0,50),(100,50)],fill=fi)
D.line([(0,61),(100,61)],fill=fi)
fi=(0xbf, 0x00, 0x00, 0x7f) #red
ou=(0x7f, 0x00, 0x00, 0x7f)
D.polygon([(40, 40), (40, 60), (60, 60), (60, 40)], fill=fi,
outline=ou)
D.polygon([(10, 10), (10, 30), (30, 30), (30, 10)], fill=fi,
outline=ou)
D.polygon([(70, 10), (71, 30), (91, 30), (90, 10)], fill=fi,
outline=ou)
fi=(0x00, 0xbf, 0x00, 0x7f) #green
ou=(0x00, 0x7f, 0x00, 0x7f)
D.polygon([(20, 70), (10, 80), (20, 90), (30, 80)], fill=fi,
outline=ou)
D.polygon([(81, 70), (70, 80), (80, 90), (91, 80)], fill=fi,
outline=ou)
D.polygon([(50, 40), (40, 50), (50, 60), (60, 50)], fill=fi,
outline=ou)
D.point([(0, 0)],fill='red') #mark origin
save(im)
the resulting save.png is attached -- hopefully small enough ;-)
I intend to use the polygon function to draw land/coastlines
combined with satellite (point) data -- that's where the alpha
blending is supposed to enter the picture...
Thanks for your help.
\bye Lothar (Meyer-Lerbs, Bremen, Germany)
<<inline: save.png>>
_______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
