jonathan: thuban/Thuban/UI renderer.py,1.61,1.62

cvs@intevation.de cvs at intevation.de
Fri May 6 16:18:33 CEST 2005


Author: jonathan

Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv30217/Thuban/UI

Modified Files:
	renderer.py 
Log Message:
(MapRenderer.draw_raster_data): Fixed signature to match that in BaseRenderer. 
Use the new opacity argument in place of calling layer.Opacity(). In the case 
where the format is not 'RAW', alpha_data is None and the loaded image has 
alpha information, use the file's alpha information. This is still subject to 
the layer's opacity setting.


Index: renderer.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/renderer.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- renderer.py	25 Apr 2005 15:01:48 -0000	1.61
+++ renderer.py	6 May 2005 14:18:31 -0000	1.62
@@ -144,7 +144,7 @@
 
         return ret
 
-    def draw_raster_data(self, layer, x,y, data, format = 'BMP'):
+    def draw_raster_data(self, x,y, data, format = 'BMP', opacity=1.0):
 
         mask = None
         alpha = None
@@ -168,6 +168,7 @@
         else:
             stream = cStringIO.StringIO(image_data)
             image = wxImageFromStream(stream, raster_format_map[format])
+
             if mask_data is not None:
                 stream = cStringIO.StringIO(mask_data)
                 mask = wxImageFromStream(stream, raster_format_map[format])
@@ -175,20 +176,21 @@
             elif alpha_data is not None:
                 stream = cStringIO.StringIO(alpha_data)
                 alpha = wxImageFromStream(stream, raster_format_map[format])
-                alpha = alpha.GetData()[:] # XXX: do we need to copy this?
+                alpha = alpha.GetData() #[:] # XXX: do we need to copy this?
+            elif image.HasAlpha():
+                alpha = image.GetAlphaData()
 
         #
-        # if we are using the alpha_data then scale down the alpha values
-        # by the layer's opacity using a string translation table
+        # scale down the alpha values the opacity level using a string 
+        # translation table for efficiency.
         #
         if alpha is not None:
-            lo = layer.Opacity()
-            if lo == 0:
+            if opacity == 0:
                 return
-            elif lo == 1:
+            elif opacity == 1:
                 a = alpha
             else:
-                tr = [int(i*lo) for i in range(256)]
+                tr = [int(i*opacity) for i in range(256)]
                 table = array.array('B', tr).tostring()
                 a = alpha.translate(table)
 





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)