[mapserver-commits] r10231 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Thu Jun 17 10:04:53 EDT 2010


Author: tbonfort
Date: 2010-06-17 14:04:53 +0000 (Thu, 17 Jun 2010)
New Revision: 10231

Modified:
   sandbox/mapserver6/mapagg2.cpp
   sandbox/mapserver6/mapcairo.c
   sandbox/mapserver6/mapgd2.c
   sandbox/mapserver6/mapoutput.c
   sandbox/mapserver6/mapresample.c
Log:
raster fixes, gd text


Modified: sandbox/mapserver6/mapagg2.cpp
===================================================================
--- sandbox/mapserver6/mapagg2.cpp	2010-06-16 16:04:44 UTC (rev 10230)
+++ sandbox/mapserver6/mapagg2.cpp	2010-06-17 14:04:53 UTC (rev 10231)
@@ -655,7 +655,7 @@
    r->m_pixel_format.attach(r->m_rendering_buffer);
    r->m_renderer_base.attach(r->m_pixel_format);
    r->m_renderer_scanline.attach(r->m_renderer_base);
-   if (!bg || !MS_VALID_COLOR(*bg)) {
+   if (format->transparent || !bg || !MS_VALID_COLOR(*bg)) {
       r->m_renderer_base.clear(AGG_NO_COLOR);
    } else {
       r->m_renderer_base.clear(aggColor(bg));

Modified: sandbox/mapserver6/mapcairo.c
===================================================================
--- sandbox/mapserver6/mapcairo.c	2010-06-16 16:04:44 UTC (rev 10230)
+++ sandbox/mapserver6/mapcairo.c	2010-06-17 14:04:53 UTC (rev 10231)
@@ -621,10 +621,9 @@
 		r->cr = cairo_create(r->surface);
 		
 		
-        if(!bg || !MS_VALID_COLOR(*bg)) {
+        if(format->transparent || !bg || !MS_VALID_COLOR(*bg)) {
 			cairo_set_source_rgba (r->cr, 0,0,0,0);
 		} else {
-			bg->alpha=255;
 			msCairoSetSourceColor(r->cr,bg);
 		}
         cairo_save (r->cr);

Modified: sandbox/mapserver6/mapgd2.c
===================================================================
--- sandbox/mapserver6/mapgd2.c	2010-06-16 16:04:44 UTC (rev 10230)
+++ sandbox/mapserver6/mapgd2.c	2010-06-17 14:04:53 UTC (rev 10231)
@@ -357,7 +357,42 @@
 }
 
 int renderGlyphsGD(imageObj *img, double x, double y, labelStyleObj *style, char *text) {
-  return MS_SUCCESS;
+   gdImagePtr ip;
+   char *error=NULL;
+   int bbox[8];
+   if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
+   if(!text || !strlen(text)) return(MS_SUCCESS); /* not errors, just don't want to do anything */
+
+   if(style->color.pen == MS_PEN_UNSET) setPen(ip, &(style->color));
+   if(style->outlinecolor.pen == MS_PEN_UNSET) setPen(ip, &(style->outlinecolor));
+   if(style->shadowcolor.pen == MS_PEN_UNSET) setPen(ip, &(style->shadowcolor));
+
+   if(style->outlinecolor.pen >= 0) { /* handle the outline color */
+      error = gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x, y-1, text);
+      if(error) {
+         msSetError(MS_TTFERR, error, "msDrawTextGD()");
+         return(MS_FAILURE);
+      }
+
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x, y+1, text);
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x+1, y, text);
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x-1, y, text);
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x-1, y-1, text);      
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x-1, y+1, text);
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x+1, y-1, text);
+      gdImageStringFT(ip, bbox, style->outlinecolor.pen, style->font, style->size, style->rotation, x+1, y+1, text);
+   }
+
+   if(style->shadowcolor.pen >= 0) { /* handle the shadow color */
+      error = gdImageStringFT(ip, bbox, style->shadowcolor.pen, style->font, style->size, style->rotation, x+style->shadowsizex, y+style->shadowsizey, text);
+      if(error) {
+         msSetError(MS_TTFERR, error, "msDrawTextGD()");
+         return(MS_FAILURE);
+      }
+   }
+
+   gdImageStringFT(ip, bbox, style->color.pen, style->font, style->size, style->rotation, x, y, text);
+   return MS_SUCCESS;
 }
 
 int renderEllipseSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style) {
@@ -439,7 +474,60 @@
 }
 
 int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char *font, double size, char *string, rectObj *rect, double **advances) {
-  return MS_SUCCESS;
+#ifdef USE_GD_FT
+   int bbox[8];
+   char *error;
+   if(advances) {
+#if defined (GD_HAS_FTEX_XSHOW)
+      char *s;
+      int k;
+      gdFTStringExtra strex;
+      strex.flags = gdFTEX_XSHOW;
+      error = gdImageStringFTEx(NULL, bbox, 0, font, size, 0, 0, 0, string, &strex);
+      if(error) {
+         msSetError(MS_TTFERR, error, "gdImageStringFTEx()");
+         return(MS_FAILURE);
+      }
+
+      *advances = (double*)malloc( strlen(string) * sizeof(double) );
+      s = strex.xshow;
+      k = 0;
+      while ( *s && k < strlen(string) ) {
+         (*advances)[k++] = atof(s);      
+         while ( *s && *s != ' ')
+            s++;
+         if ( *s == ' ' )
+            s++;
+      }
+
+      gdFree(strex.xshow); /* done with character advances */
+
+      rect->minx = bbox[0];
+      rect->miny = bbox[5];
+      rect->maxx = bbox[2];
+      rect->maxy = bbox[1];
+      return MS_SUCCESS;
+#else
+      msSetError(MS_TTFERR, "gdImageStringFTEx support is not available or is not current enough (requires 2.0.29 or higher).", "msGetTruetypeTextBBox()");
+      return(MS_FAILURE);
+#endif
+   } else {
+      error = gdImageStringFT(NULL, bbox, 0, font, size, 0, 0, 0, string);
+      if(error) {
+         msSetError(MS_TTFERR, error, "msGetTruetypeTextBBox()");
+         return(MS_FAILURE);
+      }
+
+      rect->minx = bbox[0];
+      rect->miny = bbox[5];
+      rect->maxx = bbox[2];
+      rect->maxy = bbox[1];
+      return MS_SUCCESS;
+   }
+#else
+    msSetError(MS_TTFERR,"Truetype support not available", "getTruetypeTextBBoxGD()");
+    return(MS_FAILURE);
+#endif
 }
 
 /*

Modified: sandbox/mapserver6/mapoutput.c
===================================================================
--- sandbox/mapserver6/mapoutput.c	2010-06-16 16:04:44 UTC (rev 10230)
+++ sandbox/mapserver6/mapoutput.c	2010-06-17 14:04:53 UTC (rev 10231)
@@ -702,7 +702,8 @@
         dst->formatoptions[i] = strdup(src->formatoptions[i]);
 
     dst->inmapfile = src->inmapfile;
-
+    
+    
     if( MS_RENDERER_PLUGIN(dst) ) 
     {
         msInitializeRendererVTable(dst);

Modified: sandbox/mapserver6/mapresample.c
===================================================================
--- sandbox/mapserver6/mapresample.c	2010-06-16 16:04:44 UTC (rev 10230)
+++ sandbox/mapserver6/mapresample.c	2010-06-17 14:04:53 UTC (rev 10231)
@@ -1538,6 +1538,7 @@
 			sDummyMap.imagecolor.red = map->imagecolor.red;
 			sDummyMap.imagecolor.green = map->imagecolor.green;
 			sDummyMap.imagecolor.blue = map->imagecolor.blue;
+			sDummyMap.imagecolor.alpha = map->imagecolor.alpha;
 		}
     }
 



More information about the mapserver-commits mailing list