On 18 Mar, 17:48, Miki <[EMAIL PROTECTED]> wrote:

> Apart from PIL, some other options are:
> 1. Most GUI frameworks (wxPython, PyQT, ...) give you a canvas object
> you can draw on

Yes, but at least on Windows you will get a GDI canvas. GDI is slow.


> 2. A bit of an overkill, but you can use PyOpenGL

OpenGL gives you a fast 'bitblit' for drawing bitmaps to the fram
buffer (much faster than GDI). Here is some C code that does that (8-
bit color depth). Translating to Python is trivial. I prefer not to
use PyOpenGL as it has some unwanted overhead. It is better to use
ctypes.


void bitblt(void *frame, int w, int h)
{
        glViewport(0,0,w,h);
        glClearColor(0.0, 0.0, 0.0, 0.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(0.0, (GLfloat)w, 0.0, (GLfloat)h);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glRasterPos2i(0,0);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glDrawPixels(w, h, GL_RGB, GL_UNSIGNED_BYTE_3_3_2, (GLvoid *)frame);
        glFlush();
}




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to