[mapserver-commits] r10232 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Thu Jun 17 11:12:05 EDT 2010


Author: tbonfort
Date: 2010-06-17 15:12:05 +0000 (Thu, 17 Jun 2010)
New Revision: 10232

Modified:
   sandbox/mapserver6/mapgd2.c
Log:
gd ellipse and truetype markers


Modified: sandbox/mapserver6/mapgd2.c
===================================================================
--- sandbox/mapserver6/mapgd2.c	2010-06-17 14:04:53 UTC (rev 10231)
+++ sandbox/mapserver6/mapgd2.c	2010-06-17 15:12:05 UTC (rev 10232)
@@ -396,7 +396,53 @@
 }
 
 int renderEllipseSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style) {
-  return MS_SUCCESS;
+   /* check for trivial cases - 1x1 and 2x2, GD does not do these well */
+   gdImagePtr ip;
+   int w,h,fc,oc;
+   if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
+   if(style->color.pen == MS_PEN_UNSET) setPen(ip, &(style->color));
+   if(style->outlinecolor.pen == MS_PEN_UNSET) setPen(ip, &(style->outlinecolor));
+   fc =style->color.pen;
+   oc = style->outlinecolor.pen;
+   
+   if(oc==-1 && fc ==-1) {
+      return MS_SUCCESS;
+   }
+   
+   w = symbol->sizex * style->scale;
+   h = symbol->sizey * style->scale;
+   
+   if(w==1 && h==1) {
+      if(fc >= 0)
+         gdImageSetPixel(ip, x, y, fc);
+      else 
+         gdImageSetPixel(ip, x, y, oc);
+      return MS_SUCCESS;
+   }
+
+   if(w==2 && h==2) {
+      if(oc >= 0) {
+         gdImageSetPixel(ip, x, y, oc);
+         gdImageSetPixel(ip, x, y+1, oc);
+         gdImageSetPixel(ip, x+1, y, oc);
+         gdImageSetPixel(ip, x+1, y+1, oc);
+      } else {
+         gdImageSetPixel(ip, x, y, fc);
+         gdImageSetPixel(ip, x, y+1, fc);
+         gdImageSetPixel(ip, x+1, y, fc);
+         gdImageSetPixel(ip, x+1, y+1, fc);
+      }
+      return MS_SUCCESS;
+   }
+
+   if(symbol->filled) {
+      if(fc >= 0) gdImageFilledEllipse(ip, x, y, w, h, fc);        
+      if(oc >= 0) gdImageArc(ip, x, y, w, h, 0, 360, oc);
+   } else {
+      if(fc < 0) fc = oc; /* try the outline color */
+      gdImageArc(ip, x, y, w, h, 0, 360, fc);
+   }
+   return MS_SUCCESS;
 }
 
 int renderVectorSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style) {
@@ -404,6 +450,34 @@
 }
 
 int renderTruetypeSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *s) {
+   int bbox[8];
+   char *error;
+   gdImagePtr ip;
+   if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
+   if(s->color.pen == MS_PEN_UNSET) setPen(ip, &(s->color));
+   if(s->outlinecolor.pen == MS_PEN_UNSET) setPen(ip, &(s->outlinecolor));
+   gdImageStringFT(NULL, bbox, s->color.pen, symbol->full_font_path, s->scale, s->rotation, 0,0, symbol->character);
+   
+   x -=  (bbox[2] - bbox[0])/2;
+   y +=  (bbox[1] - bbox[5])/2;
+
+   if( s->outlinecolor.pen >= 0 ) {
+      error = gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x, y-1, symbol->character);
+      if(error) {
+         msSetError(MS_TTFERR, error, "msDrawMarkerSymbolGD()");
+         return MS_FAILURE;
+      }
+
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x+1, y, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x-1, y, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x+1, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x+1, y-1, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x-1, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, s->outlinecolor.pen, symbol->full_font_path, s->scale, s->rotation, x-1, y-1, symbol->character);
+   }
+
+   gdImageStringFT(ip, bbox, s->color.pen, symbol->full_font_path, s->scale, s->rotation, x, y, symbol->character);
   return MS_SUCCESS;
 }
 



More information about the mapserver-commits mailing list