[mapserver-commits] r10300 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Thu Jul 8 09:38:25 EDT 2010


Author: tbonfort
Date: 2010-07-08 13:38:25 +0000 (Thu, 08 Jul 2010)
New Revision: 10300

Modified:
   sandbox/mapserver6/mapagg.cpp
   sandbox/mapserver6/mapimageio.c
Log:
convert gd pixmap to pc256 if the file was truecolor


Modified: sandbox/mapserver6/mapagg.cpp
===================================================================
--- sandbox/mapserver6/mapagg.cpp	2010-07-08 13:16:09 UTC (rev 10299)
+++ sandbox/mapserver6/mapagg.cpp	2010-07-08 13:38:25 UTC (rev 10300)
@@ -59,10 +59,8 @@
 
 #ifdef CPL_MSB
 typedef mapserver::order_argb band_order;
-typedef mapserver::blender_argb32_pre blender;
 #else
 typedef mapserver::order_bgra band_order;
-typedef mapserver::blender_bgra32_pre blender;
 #endif
 
 #define AGG_LINESPACE 1.33

Modified: sandbox/mapserver6/mapimageio.c
===================================================================
--- sandbox/mapserver6/mapimageio.c	2010-07-08 13:16:09 UTC (rev 10299)
+++ sandbox/mapserver6/mapimageio.c	2010-07-08 13:38:25 UTC (rev 10300)
@@ -646,6 +646,26 @@
         rb->type = MS_BUFFER_NONE;
         return MS_FAILURE;
     }
+    if(gdImageTrueColor(img)) {
+       int x,y;
+       gdImagePtr pimg = gdImageCreate(gdImageSX(img),gdImageSY(img));
+       gdImageColorAllocateAlpha(pimg,0,0,0,127);
+       for(y = 0 ; y < gdImageSY(img); y++) {
+          for(x = 0; x < gdImageSX(img); x++) {
+             int pix = gdImageGetTrueColorPixel(img,x,y);
+             if(gdTrueColorGetAlpha(pix) == 127) {
+                gdImageSetPixel(pimg,x,y,0);
+                pimg->transparent = 0;
+             } else {
+                gdImageSetPixel(pimg,x,y,gdImageColorResolveAlpha(pimg,gdTrueColorGetRed(pix),gdTrueColorGetGreen(pix),
+                      gdTrueColorGetBlue(pix),gdTrueColorGetAlpha(pix)));
+             }
+             
+          }
+       }
+       gdImageDestroy(img);
+       img = pimg;
+    }
     rb->type = MS_BUFFER_GD;
     rb->width = gdImageSX(img);
     rb->height = gdImageSY(img);



More information about the mapserver-commits mailing list