[mapserver-commits] r7188 - in trunk/mapserver: . mapscript/doc mapscript/java/examples mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Wed Dec 19 05:44:21 EST 2007


Author: unicoletti
Date: 2007-12-19 05:44:20 -0500 (Wed, 19 Dec 2007)
New Revision: 7188

Modified:
   trunk/mapserver/mapscript/doc/mapscript.txt
   trunk/mapserver/mapscript/java/examples/DrawMap.java
   trunk/mapserver/mapscript/swiginc/image.i
   trunk/mapserver/mapserver.h
Log:
#2448: implement getSize on imageObj

Modified: trunk/mapserver/mapscript/doc/mapscript.txt
===================================================================
--- trunk/mapserver/mapscript/doc/mapscript.txt	2007-12-18 23:26:29 UTC (rev 7187)
+++ trunk/mapserver/mapscript/doc/mapscript.txt	2007-12-19 10:44:20 UTC (rev 7188)
@@ -859,8 +859,12 @@
     MS_RENDER_WITH_GD, MS_RENDER_WITH_SWF, MS_RENDER_WITH_RAWDATA,
     MS_RENDER_WITH_PDF, or MS_RENDER_WITH_IMAGEMAP.  Don't mess with this!
 
-size : int
-    I don't see where this is used.  Anyone?  --SG
+size : int immutable
+    To access this attribute use the getSize method.
+   
+.. note:: the getSize method is inefficient as it does a call to getBytes and then computes
+   the size of the byte array. The bytearray is then immediately discarded. In most
+   cases it is more efficient to call getBytes directly.
 
 width : int immutable
     Image width in pixels.
@@ -882,6 +886,13 @@
     form of this buffer will vary by mapscript language (eg. string in Python,
     byte[] array in Java and C#, unhandled in perl)
 
+getSize() : int
+    Resturns the size of the binary buffer representing the image buffer.
+   
+.. note:: the getSize method is inefficient as it does a call to getBytes and then computes
+   the size of the byte array. The byte array is then immediately discarded. In most
+   cases it is more efficient to call getBytes directly.
+
 save( string filename [, mapObj_ parent_map=NULL ] ) : int
     Save image to *filename*.  The optional *parent_map* parameter must be
     specified if saving GeoTIFF images.

Modified: trunk/mapserver/mapscript/java/examples/DrawMap.java
===================================================================
--- trunk/mapserver/mapscript/java/examples/DrawMap.java	2007-12-18 23:26:29 UTC (rev 7187)
+++ trunk/mapserver/mapscript/java/examples/DrawMap.java	2007-12-19 10:44:20 UTC (rev 7188)
@@ -36,6 +36,8 @@
     int i=0;
     //for (i=0; i<100; i++) {
     	imageObj img = map.draw();
+    	System.out.println("Image size is: "+img.getSize());
+    	System.out.println("Image size from getBytes is: "+img.getBytes().length);
     	System.out.println(i+") the map will be drawn to:"+args[1]);
     	img.save(args[1], map);
     //}

Modified: trunk/mapserver/mapscript/swiginc/image.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/image.i	2007-12-18 23:26:29 UTC (rev 7187)
+++ trunk/mapserver/mapscript/swiginc/image.i	2007-12-19 10:44:20 UTC (rev 7188)
@@ -224,6 +224,20 @@
 
         return buffer;
     }
-    
+
+    int getSize() {
+        gdBuffer buffer;
+	int size=0;
+        
+        buffer.data = msSaveImageBuffer(self, &buffer.size, self->format);
+	size = buffer.size;
+            
+        if( buffer.data == NULL || buffer.size == 0 ) {
+            buffer.data = NULL;
+            msSetError(MS_MISCERR, "Failed to get image buffer size", "getSize");
+        }
+	free(buffer.data);
+        return size;
+    }
 }
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2007-12-18 23:26:29 UTC (rev 7187)
+++ trunk/mapserver/mapserver.h	2007-12-19 10:44:20 UTC (rev 7188)
@@ -1333,7 +1333,9 @@
 %mutable;
 #endif
   int renderer;
+#ifndef SWIG
   int size;
+#endif
 
 #ifndef SWIG
   union {



More information about the mapserver-commits mailing list