Hi all, I seem to be talking to myself here, but if someone (including myself) wants to pick this up in the future, it'll be good to have it in the archives.
Christopher Barker wrote: >> There is also the >> wx.Image.SetDataBuffer method, which will have the wxImage use the >> buffer passed in without making a copy, but if the buffer doesn't >> live as long as the image does it will likely cause a crash. > > This would probably be the easiest way to get top performance at the > moment. If we can make the Agg data a buffer, and somehow do the > reference counting right so it doesn't get deleted while the wxImage is > still around (that may not be hard -- the wxImage has to be converted to > a wxBitmap to be drawn anyway) I've been suing this for another use, and Robin just added an improved version of new wx.Image factory function I wrote for just this purpose: def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer parameter must be a Python object that implements the buffer interface, such as a string, array, etc. The dataBuffer object is expected to contain a series of RGB bytes and be width*height*3 bytes long. A buffer object can optionally be supplied for the image's alpha channel data, and it is expected to be width*height bytes long. A reference to the data and alpha buffer objects are kept with the wx.Image, so that they won't get deleted until after the wx.Image is deleted. However please be aware that it is not guaranteed that an object won't move its memory buffer to a new location when it needs to resize its contents. If that happens then the wx.Image will end up referring to an invalid memory location and could cause the application to crash. Therefore care should be taken to not manipulate the objects used for the data and alpha buffers in a way that would cause them to change size. """ image = wx.EmptyImage(width, height) image.SetDataBuffer(dataBuffer) if alphaBuffer is not None: image.SetAlphaBuffer(alphaBuffer) image._buffer = dataBuffer image._alpha = alphaBuffer return image Does the aggDrawer already implement a Python buffer object? If so, using this would be easy. If not, then it probably should, unless we go straight to the numpy array protocol. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel