Fast 2D Raster Rendering with GUI

Peter Wang misterwang at gmail.com
Tue Mar 18 21:35:54 EDT 2008


On Mar 18, 6:51 pm, Ivan Illarionov <ivan.illario... at gmail.com> wrote:
> > That's another new step for me. Any ideas where to start?
>
> http://docs.python.org/ext/simpleExample.html
>
> And look into the source of existing extensions. PIL and PyCairo are
> the best in your situation.

You shouldn't be afraid of doing raster graphics in Python; you'll
just need to be familiar with Numpy.  You can easily compose layers,
mask out operations to only happen on one channel, etc., and code it
all up in Python while getting C-level speed.  The gotcha, if you use
PIL, is that you're going to have to use tostring() and fromstring()
to get the array data back and forth between numpy and PIL.  An
alternative is to use openGL, as others have suggested, and blit into
a texture.  If you use pyglet, for instance, you can use Andrew
Straw's pygarrayimage module to convert a numpy array directly into a
texture.

I wouldn't recommend Cairo for doing pixel-level ops, since it is a
vector graphics library.


-Peter



More information about the Python-list mailing list