It looks like the Pygame will soon be wanting quicker methods for sharing image data than the traditional tostring/fromstring. Both PIL and Pygame now have a "frombuffer" command, which speeds up this transaction by avoiding one of the two copies of pixel data.
We're explorating the idea of "tobuffer" communication, that would allow copy-free transfer of images between libraries. We're pushing much more of our library to ctypes. This is a Google Summer of Code project, and we have already succeeded at getting a PIL Image tostring mapped into the SDL_Surface structure without any C code on our side. Moving more of the Pygame library to Python/ctypes has us looking to lean on outside libraries for the heavy drawing and filtering work. If we could get a data pointer to the pixel data into Python we could perform the zero copy image transfer with no C extension. Obviously there are potential issues when two image libraries are mapping to the same pixel data. On the SDL side we have the advantage that the SDL_Surface structures understand the concept of not "owning" the pixel data. It's been awhile since I looked at the python Buffer object API. Would there be any direct problems providing a Image.tobuffer() call to match tostring()? The other option could be to rely on ctypes to return a ctypes.c_ubytes_Array back to pythonspace. I believe we could have just as good results with the array data type already including in the python standard lib. Obviously we will benefit from the same sort of techniques going back and forth with the PyopenGL libraries, but I thought it would be smart to start the process with PIL. _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
