PIL ImageDraw line not long enough

Bob Greschke bob at passcal.nmt.edu
Thu Mar 30 12:59:17 EST 2006


I've resorted to actually drawing all of the characters of the alphabet on a 
graph to avoid having to drag around font files.  It's mostly just uppercase 
characters, so it's not too bad.

But I noticed that some of the line segments have to be extended one pixel 
longer than they should be in order for the last pixel to show up.

The character cells are 6 pixels wide by 8 pixels high.  An "L" is drawn 
with

   Graph.line((x,y, x,y+7, x+5,y+7), Color)

where the starting x and y are supplied to the function.  An L works OK, but 
to get a "T" to look right I have to do

   Graph.line((x+1,y, x+5,y), Color)
   Graph.line((x+3,y, x+3,y+8), Color)

I have to extend the vertical line to y+8, instead of y+7 to get the line 
segment to be drawn long enough.  This is on Linux, Solaris, 2.x versions of 
Python, 1.1.5 version of PIL, and on Windows with the latest of everything. 
Am I missing a setting somewhere?

Thanks!

Bob







More information about the Python-list mailing list