Re: [matplotlib-devel] [Matplotlib-users] Problems upgrading to mpl 0.87.4
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
Re: [matplotlib-devel] [Matplotlib-users] Problems upgrading to mpl 0.87.4
On Thursday 17 August 2006 7:19 pm, Christopher Barker wrote: > I seem to be talking to myself here I think all the high rollers are at SciPy 2006. - 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
Re: [matplotlib-devel] [Matplotlib-users] Problems upgrading to mpl 0.87.4
On 8/17/06, Christopher Barker <[EMAIL PROTECTED]> wrote: > 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. I haven't had time to thoroughly absorb all your post. From skimming it looks like we could do a similar approach as the qtagg blitting. If you look at the else clause in the FigureCanvasQTAgg.paintEvent method, you'll see we added a to_string method to the BufferRegion object. Using this string buffer we create a QImage and blit it. It includes the alpha channel. I'll paste the block of interest to save you a little digging. bbox = self.replot w, h = int(bbox.width()), int(bbox.height()) l, t = bbox.ll().x().get(), bbox.ur().y().get() reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian) self.pixmap.convertFromImage(qImage, qt.QPixmap.Color) p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap) - Charlie - 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
Re: [matplotlib-devel] [Matplotlib-users] Problems upgrading to mpl 0.87.4
Darren Dale wrote: > I think all the high rollers are at SciPy 2006. Oh right. This is the third year in a row that I have ALMOST gone myself. Maybe next year. But what's the deal? Aren't they all hooked up to wifi and checking email constantly? -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
Re: [matplotlib-devel] [Matplotlib-users] Problems upgrading to mpl 0.87.4
Charlie Moad wrote: > I'll paste the block of interest to save > you a little digging. > >bbox = self.replot >w, h = int(bbox.width()), int(bbox.height()) >l, t = bbox.ll().x().get(), bbox.ur().y().get() >reg = self.copy_from_bbox(bbox) So this is one copy. >stringBuffer = reg.to_string() Is this another? or does to_string not copy? >qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, > qt.QImage.IgnoreEndian) Here we have difference from wx -- AFAICT, a wx.Image doesn't do rgba32, it does RGB24, with a separate 8bit alpha channel. if to_string copies anyway, then that wouldn't make much difference. But do we really need alpha here anyway? >self.pixmap.convertFromImage(qImage, qt.QPixmap.Color) >p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap) And this looks like wx. I wish I had more time to work on this, but I'm in a crunch that I'll be in for while -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