On 4/5/11 10:52 AM, Sebastian Haase wrote: > How about fixing PIL... I know that there is not a good track record > of getting patches into PIL , > but did you get to the bottom of it and find how draw.line is implemented?
no. I haven't. And yes adapting PIL to use the buffer interface for this kind of thing would be great. I also have wanted to do that for wxPython, where it would be welcome, but still haven't gotten around to it. > BTW, is it drawing anti-aliased lines ? Not with the ImageDraw module, but there is a new AggDraw module that should be more pretty. On 4/5/11 11:49 AM, Mark S Niemczyk wrote: > Just a suggestion (I am very new to Numpy), but wouldn't > > draw.line(tuple(points.tolist())) > > accomplish what you want. nope, tolist() creates a list of lists -- tuple() only converts the outer list to a tuple, which I why I did the list comprehension. On 4/5/11 10:53 AM, [email protected] wrote: > does a structured dtype work? Good idea -- I'll give it a try -- indeed it does: dt = np.dtype([('x', np.int32),('y',np.int32)]) draw.line(points.view(dtype=dt).reshape((-1,)).tolist(), fill="rgb(0,255,0)", width=4) but it's not any faster, alas. The fastest I've come up with is putting the elements in a single 1-d list. PIL can take either a sequence of tuples: [(x,y),(x,y),...] or the flattened version: [x,y,x,y,x,y,x,y,...] So this is the fastest: draw.line(points.flatten().tolist(), fill="rgb(0,255,0)", width=4) Thanks all, -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [email protected] _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
