[mapserver-commits] r10194 - sandbox/mapserver6

svn at osgeo.org svn at osgeo.org
Sun May 30 06:08:17 EDT 2010


Author: tbonfort
Date: 2010-05-30 06:08:15 -0400 (Sun, 30 May 2010)
New Revision: 10194

Modified:
   sandbox/mapserver6/mapagg2.cpp
   sandbox/mapserver6/mapcairo.c
Log:
agg pixmap symbols


Modified: sandbox/mapserver6/mapagg2.cpp
===================================================================
--- sandbox/mapserver6/mapagg2.cpp	2010-05-28 20:18:58 UTC (rev 10193)
+++ sandbox/mapserver6/mapagg2.cpp	2010-05-30 10:08:15 UTC (rev 10194)
@@ -353,12 +353,48 @@
     return MS_SUCCESS;
 }
 
-int agg2RenderPixmapSymbol(imageObj *img, double x, double y,
-        symbolObj *symbol, symbolStyleObj * style) {
+int agg2RenderPixmapSymbol(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj * style) {
+	AGG2Renderer *r = agg2GetRenderer(img);
     rasterBufferObj *pixmap = symbol->pixmap_buffer;
     rendering_buffer b(pixmap->pixelbuffer, pixmap->width, pixmap->height, pixmap->width*4);
     pixel_format pf(b);
-    
+    r->m_rasterizer_aa.reset();
+    r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+	if( style->rotation != 0 || style->scale != 1) {
+		mapserver::trans_affine image_mtx;
+		image_mtx *= mapserver::trans_affine_translation(-(pf.width()/2.),-(pf.height()/2.));
+		/*agg angles are antitrigonometric*/
+		image_mtx *= mapserver::trans_affine_rotation(-style->rotation);
+		image_mtx *= mapserver::trans_affine_scaling(style->scale);
+
+
+
+		image_mtx *= mapserver::trans_affine_translation(x,y);
+		image_mtx.invert();
+		typedef mapserver::span_interpolator_linear<> interpolator_type;
+		interpolator_type interpolator(image_mtx);
+		mapserver::span_allocator<color_type> sa;
+
+		// "hardcoded" bilinear filter
+		//------------------------------------------
+		typedef mapserver::span_image_filter_rgba_bilinear_clip<pixel_format, interpolator_type> span_gen_type;
+		span_gen_type sg(pf, mapserver::rgba(0,0,0,0), interpolator);
+		mapserver::path_storage pixmap_bbox;
+		int ims_2 = MS_NINT(MS_MAX(pixmap->width,pixmap->height)*style->scale*1.415)/2+1;
+		
+		pixmap_bbox.move_to(x-ims_2,y-ims_2);
+		pixmap_bbox.line_to(x+ims_2,y-ims_2);
+		pixmap_bbox.line_to(x+ims_2,y+ims_2);
+		pixmap_bbox.line_to(x-ims_2,y+ims_2);
+		
+		r->m_rasterizer_aa.add_path(pixmap_bbox);
+		mapserver::render_scanlines_aa(r->m_rasterizer_aa, r->sl_line, r->m_renderer_base, sa, sg);
+	}
+	else {
+		//just copy the image at the correct location (we place the pixmap on 
+		//the nearest integer pixel to avoid blurring)
+		r->m_renderer_base.blend_from(pf,0,MS_NINT(x-pixmap->width/2.),MS_NINT(y-pixmap->height/2.));
+	}
     return MS_FAILURE;
 }
 

Modified: sandbox/mapserver6/mapcairo.c
===================================================================
--- sandbox/mapserver6/mapcairo.c	2010-05-28 20:18:58 UTC (rev 10193)
+++ sandbox/mapserver6/mapcairo.c	2010-05-30 10:08:15 UTC (rev 10194)
@@ -158,7 +158,7 @@
     cairo_font_face_set_user_data (newface->face, &newface->facekey,
             &(newface->ftface), (cairo_destroy_func_t) FT_Done_Face);
 
-    newface->path = font;
+    newface->path = strdup(font);
     return newface;
 }
 



More information about the mapserver-commits mailing list