[mapserver-commits] r10250 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Fri Jun 25 13:32:27 EDT 2010


Author: tbonfort
Date: 2010-06-25 17:32:27 +0000 (Fri, 25 Jun 2010)
New Revision: 10250

Modified:
   sandbox/mapserver6/mapimageio.c
   sandbox/mapserver6/mapsymbol.h
Log:
premultiply/unpremultiply given palette



Modified: sandbox/mapserver6/mapimageio.c
===================================================================
--- sandbox/mapserver6/mapimageio.c	2010-06-25 17:31:57 UTC (rev 10249)
+++ sandbox/mapserver6/mapimageio.c	2010-06-25 17:32:27 UTC (rev 10250)
@@ -309,7 +309,7 @@
    
    stream = fopen(palette, "r");
    if(!stream) {
-    msSetError(MS_IOERR, "Error opening palette file %s.", "msImageCreateWithPaletteGD()", palette);
+    msSetError(MS_IOERR, "Error opening palette file %s.", "readPalette()", palette);
     return MS_FAILURE;
    }
    
@@ -318,21 +318,29 @@
       if(buffer[0] == '#' || buffer[0] == '\n' || buffer[0] == '\r')
         continue; /* skip comments and blank lines */
       if(!useAlpha) {
-         if(3 != sscanf(buffer,"%d,%d,%d\n",&r,&b,&g)) {
+         if(3 != sscanf(buffer,"%d,%d,%d\n",&r,&g,&b)) {
             msSetError(MS_MISCERR,"failed to parse color %d r,g,b triplet in line \"%s\" from file %s","readPalette()",*nEntries+1,buffer,palette);
             return MS_FAILURE;
          }
       }
       else {
-         if(4 != sscanf(buffer,"%d,%d,%d,%d\n",&r,&b,&g,&a)) {
+         if(4 != sscanf(buffer,"%d,%d,%d,%d\n",&r,&g,&b,&a)) {
             msSetError(MS_MISCERR,"failed to parse color %d r,g,b,a quadruplet in line \"%s\" from file %s","readPalette()",*nEntries+1,buffer,palette);
             return MS_FAILURE;
          }
       }
-      entries[*nEntries].r = r;
-      entries[*nEntries].g = g;
-      entries[*nEntries].b = b;
-      entries[*nEntries].a = (useAlpha) ? a : 255;
+      if(useAlpha && a != 255) {
+         double da = a/255.0;
+         entries[*nEntries].r = r * da;
+         entries[*nEntries].g = g * da;
+         entries[*nEntries].b = b * da;
+         entries[*nEntries].a = a;
+      } else {
+         entries[*nEntries].r = r;
+         entries[*nEntries].g = g;
+         entries[*nEntries].b = b;
+         entries[*nEntries].a = 255;
+      }
       (*nEntries)++;
    }
    fclose(stream);

Modified: sandbox/mapserver6/mapsymbol.h
===================================================================
--- sandbox/mapserver6/mapsymbol.h	2010-06-25 17:31:57 UTC (rev 10249)
+++ sandbox/mapserver6/mapsymbol.h	2010-06-25 17:32:27 UTC (rev 10250)
@@ -60,11 +60,11 @@
 } rgbaArrayObj;
 
 typedef struct {
-    unsigned char r,g,b,a;
+    unsigned char b,g,r,a;
 } rgbaPixel;
 
 typedef struct {
-    unsigned char b,g,r;
+    unsigned char r,g,b;
 } rgbPixel;
 
 



More information about the mapserver-commits mailing list