dabo Commit
Revision 5152
Date: 2009-03-27 14:53:10 -0700 (Fri, 27 Mar 2009)
Author: Paul
Trac: http://trac.dabodev.com/changeset/5152

Changed:
U   trunk/ide/ReportDesigner.py

Log:
Performance with images in the report designer was horrible, getting worse as 
the image file size increased. This fix caches the wx.Bitmap instances so they
don't need to be recreated during every Paint cycle.



Diff:
Modified: trunk/ide/ReportDesigner.py
===================================================================
--- trunk/ide/ReportDesigner.py 2009-03-26 19:14:01 UTC (rev 5151)
+++ trunk/ide/ReportDesigner.py 2009-03-27 21:53:10 UTC (rev 5152)
@@ -962,6 +962,7 @@
 
 
        def afterInit(self):
+               self._cachedBitmaps = {}
                self._rd = self.Form.editor
                self._rw = self._rd._rw
                self.Bands = self._rw.Bands
@@ -1419,13 +1420,16 @@
 
                                        if imageFile is not None:
                                                if os.path.exists(imageFile) 
and not os.path.isdir(imageFile):
-                                                       import wx
-                                                       expr = None
-                                                       img = 
wx.Image(imageFile)
-                                                       ## Whether rescaling, 
resizing, or nothing happens depends on the 
-                                                       ## scalemode prop. For 
now, we just unconditionally rescale:
-                                                       img.Rescale(rect[2], 
rect[3])
-                                                       bmp = 
img.ConvertToBitmap()
+                                                       bmp = 
self._cachedBitmaps.get(imageFile, None)
+                                                       if bmp is None:
+                                                               import wx
+                                                               expr = None
+                                                               img = 
wx.Image(imageFile)
+                                                               ## Whether 
rescaling, resizing, or nothing happens depends on the 
+                                                               ## scalemode 
prop. For now, we just unconditionally rescale:
+                                                               
img.Rescale(rect[2], rect[3])
+                                                               bmp = 
img.ConvertToBitmap()
+                                                               
self._cachedBitmaps[imageFile] = bmp
                                                else:
                                                        expr = "<< file not 
found >>"
                                        else:
@@ -2002,6 +2006,7 @@
 
        def drawReportForm(self):
                """Resize and position the bands accordingly, and draw the 
objects."""
+
                viewStart = self.GetViewStart()
                self.SetScrollbars(0,0,0,0)
                rw = self._rw



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to