From: Kevin A. <al...@se...> - 2001-09-16 19:53:19
|
I was playing with PyGame earlier today to see how drawing times compared to my code. PyGame is definitely faster, but I don't know what portions of my wxPython code can be optimized. It will be a while before I know what we can and can't do with PyGame, but right now it looks like we'll be able to leverage PyGame for drawing and sound. Anyway, while trying things out in PyGame, the issue of using a surface array and numPy came up. Basically, the window bitmap gets stored as a numPy array which is where all the calculations and plotting take place and then you convert the numPy array back to a bitmap for the screen. Chris Barker sent me some code a few weeks ago that also uses NumPy to speed up some scaling transformations. I don't know whether numPy or PIL is faster for rotation and other effects. Anyway, numPy is new to me, just like PIL, so I'm not sure what conversions I need to support to make it convenient to use. Is it enough to simply support getArray and setArray type methods for Bitmap and a drawArray for BitmapCanvas? I would appreciate some feedback from anyone using numPy on what would be the most helpful. There is an example conversion of a numPy array to wxImage/wxBitmap at: http://wxpython.org/cgi-bin/wiki/WorkingWithImages and there is some array to PIL and PPM code as part of the numPy demos. So, conversions are easy to add to PythonCard, I just need to know what kinds, so hopefully someone already doing visualizations with numPy can provide some guidance. I will probably move the Bitmap class out of widget.py and into its own module, which I'm thinking about simply calling image.py. That module will also contain any generic image conversion and utility functions outside the Bitmap class. If you are interested in working on that module let me know. I would like to provide convenient ways to display data from PIL and numPy and thus make PythonCard a useful tool for users of those packages without requiring them to learn much new stuff in order to get work done. ka |