[mapserver-commits] r11547 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Apr 12 11:20:46 EDT 2011


Author: tbonfort
Date: 2011-04-12 08:20:45 -0700 (Tue, 12 Apr 2011)
New Revision: 11547

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapgd.c
Log:
use a circle brush for wide GD lines (#3835)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-04-12 14:33:08 UTC (rev 11546)
+++ trunk/mapserver/HISTORY.TXT	2011-04-12 15:20:45 UTC (rev 11547)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk): 
 ---------------------------- 
 
+- use a circle brush for wide GD lines (#3835)
+
 - fix segmentation fault with transparent layers containing symbols (#3834)
 
 - fix memory leak on tiled vector polygons

Modified: trunk/mapserver/mapgd.c
===================================================================
--- trunk/mapserver/mapgd.c	2011-04-12 14:33:08 UTC (rev 11546)
+++ trunk/mapserver/mapgd.c	2011-04-12 15:20:45 UTC (rev 11547)
@@ -309,16 +309,14 @@
 {
   gdImagePtr ip;
   int c;
-
+  gdImagePtr brush;
+  
   if(!img || !p || !stroke) return MS_FAILURE;
   if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
 
   SETPEN(ip, stroke->color);
   c = stroke->color->pen;
 
-  /* GD only has to worry about stroke width and pattern, no end cap or join */
-  if(stroke->width > 1) gdImageSetThickness(ip, stroke->width);
-
   if(stroke->patternlength > 0) {
     int *style;
     int i, j, k=0;
@@ -344,12 +342,30 @@
 
     c = gdStyled;
   }
+
+  if(stroke->width > 1) {
+     int brush_fc; 
+     brush = gdImageCreate(stroke->width, stroke->width);
+     gdImageColorAllocate(brush, gdImageRed(ip,0), gdImageGreen(ip, 0), gdImageBlue(ip, 0));
+     gdImageColorTransparent(brush,0);
+     brush_fc = gdImageColorAllocate(brush, gdImageRed(ip,c), gdImageGreen(ip,c), gdImageBlue(ip,c));
+     gdImageFilledEllipse(brush,MS_NINT(stroke->width/2),MS_NINT(stroke->width/2),
+           stroke->width,stroke->width, brush_fc);
+     gdImageSetBrush(ip, brush);
+     if(stroke->patternlength > 0) {
+       c = gdStyledBrushed;
+     } else {
+       c = gdBrushed;
+     }
+  }
     
   /* finally draw something */
   imagePolyline(ip, p, c);
 
   /* clean up */
-  gdImageSetThickness(ip, 1);
+  if(stroke->width>1) {
+     gdImageDestroy(brush);
+  }
   return MS_SUCCESS;
 }
 



More information about the mapserver-commits mailing list