[mapserver-commits] r10786 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Dec 7 23:30:14 EST 2010


Author: warmerdam
Date: 2010-12-07 20:30:14 -0800 (Tue, 07 Dec 2010)
New Revision: 10786

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapdrawgdal.c
Log:
fixed support for MS_BUFFER_BYTE_RGBA in 16 bit classification case (#3624)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2010-12-08 04:28:36 UTC (rev 10785)
+++ trunk/mapserver/HISTORY.TXT	2010-12-08 04:30:14 UTC (rev 10786)
@@ -14,6 +14,9 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Fixed 16bit classification support - problem introduced with new 
+  renderer architecture (#3624) 
+
 - Cleanup open gdal datasets in msGDALCleanup() (if we have a very new
   GDAL).  This makes it easier to identify memory leaks. 
 

Modified: trunk/mapserver/mapdrawgdal.c
===================================================================
--- trunk/mapserver/mapdrawgdal.c	2010-12-08 04:28:36 UTC (rev 10785)
+++ trunk/mapserver/mapdrawgdal.c	2010-12-08 04:30:14 UTC (rev 10786)
@@ -2191,9 +2191,10 @@
     const char *pszBuckets;
     int  bUseIntegers = FALSE;
     int  *cmap, c, j, k, bGotNoData = FALSE, bGotFirstValue;
+    unsigned char *rb_cmap[4];
     CPLErr eErr;
 
-    assert( rb->type == MS_BUFFER_GD );
+    assert( rb->type == MS_BUFFER_GD || rb->type == MS_BUFFER_BYTE_RGBA );
 
 /* ==================================================================== */
 /*      Read the requested data in one gulp into a floating point       */
@@ -2355,6 +2356,10 @@
 /* ==================================================================== */
 
     cmap = (int *) msSmallCalloc(sizeof(int),nBucketCount);
+    rb_cmap[0] = (unsigned char *) msSmallCalloc(1,nBucketCount);
+    rb_cmap[1] = (unsigned char *) msSmallCalloc(1,nBucketCount);
+    rb_cmap[2] = (unsigned char *) msSmallCalloc(1,nBucketCount);
+    rb_cmap[3] = (unsigned char *) msSmallCalloc(1,nBucketCount);
 
     for(i=0; i < nBucketCount; i++) 
     {
@@ -2378,13 +2383,28 @@
             }
             if(rb->type == MS_BUFFER_GD) {
             	RESOLVE_PEN_GD(rb->data.gd_img, layer->class[c]->styles[0]->color);
+                if( MS_TRANSPARENT_COLOR(layer->class[c]->styles[0]->color) )
+                    cmap[i] = -1;
+                else if( MS_VALID_COLOR(layer->class[c]->styles[0]->color))
+                {
+                    /* use class color */
+                    cmap[i] = layer->class[c]->styles[0]->color.pen;
+                }
             }
-            if( MS_TRANSPARENT_COLOR(layer->class[c]->styles[0]->color) )
-                cmap[i] = -1;
-            else if( MS_VALID_COLOR(layer->class[c]->styles[0]->color))
+            else if( rb->type == MS_BUFFER_BYTE_RGBA )
             {
-                /* use class color */
-                cmap[i] = layer->class[c]->styles[0]->color.pen;
+                if( MS_TRANSPARENT_COLOR(layer->class[c]->styles[0]->color) )
+                {
+                    /* leave it transparent */
+                }
+                else if( MS_VALID_COLOR(layer->class[c]->styles[0]->color))
+                {
+                    /* use class color */
+                    rb_cmap[0][i] = layer->class[c]->styles[0]->color.red;
+                    rb_cmap[1][i] = layer->class[c]->styles[0]->color.green;
+                    rb_cmap[2][i] = layer->class[c]->styles[0]->color.blue;
+                    rb_cmap[3][i] = 255;
+                }
             }
         }
     }
@@ -2422,16 +2442,36 @@
                 continue;
             }
 
-            result = cmap[iMapIndex];
-            if( result == -1 )
-                continue;
+            if( rb->type == MS_BUFFER_GD )
+            {
+                result = cmap[iMapIndex];
+                if( result == -1 )
+                    continue;
 
-            rb->data.gd_img->pixels[i][j] = result;
+                rb->data.gd_img->pixels[i][j] = result;
+            }
+            else if( rb->type == MS_BUFFER_BYTE_RGBA )
+            {
+                /* currently we never have partial alpha so keep simple */
+                if( rb_cmap[3][iMapIndex] > 0 )
+                    RB_SET_PIXEL( rb, j, i, 
+                                  rb_cmap[0][iMapIndex], 
+                                  rb_cmap[1][iMapIndex], 
+                                  rb_cmap[2][iMapIndex], 
+                                  rb_cmap[3][iMapIndex] );
+            }
         }
     }
 
+/* -------------------------------------------------------------------- */
+/*      Cleanup                                                         */
+/* -------------------------------------------------------------------- */
     free( pafRawData );
     free( cmap );
+    free( rb_cmap[0] );
+    free( rb_cmap[1] );
+    free( rb_cmap[2] );
+    free( rb_cmap[3] );
 
     assert( k == dst_xsize * dst_ysize );
 



More information about the mapserver-commits mailing list