Romi Agar wrote:
A sample application can be found at http://rmg.planet.ee/python/
About my platform:
Python 2.6.1, wxPython 2.8.9.2 (msw-ansi) on Vista 32bit
The flicker is best reproduced when quickly panning the image.
Testing on OS-X, there is no flicker, but neither can you quickly do anything -- the whole thing is very pokey. dragging the scrollbars it can't keep up or resizing the window, or...
I think part of the problem is that when scrolling or re-sizing there are a lot of events, and the drawing can't keep up. One solution to this os to put in a time -- when there is an event that requires a re-draw, wait a bit, and only re-draw if another event doesn't come though right away. That way it doesn't try to re-draw 100 times a second.
A few other comments:
self.dc = wx.MemoryDC()
It's generally considered not a good idea to keep dcs around -- you only need to keep the buffer bitmap -- you can re-create the dc when you need to.
I'm not sure what the point of the backbuffer is -- isn't that what self.bmp already is?
I've enclosed a slightly simplified version.
Just for fun, I've enclosed a version using FloatCanvas -- it uses the somwhat experimental "ScaledBitmap2", though it works fine for this. It can be sped up some if you use lower quality scaling for highly zoomed in views (that required going into the FloatCanvas code).
ScaledBitmap2 is better for large bitmaps, as it only scales the part of the image that you can see -- the old ScaledBitmap scales the whole thing -- fine for little icons and the like, but not a good idea for large images.
SampleApp.py (5.73 KB)
ScaledBitmapDemo.py (1.83 KB)
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov