[mapserver-commits] r8735 - sandbox/graphics
svn at osgeo.org
svn at osgeo.org
Mon Mar 9 16:46:01 EDT 2009
Author: tbonfort
Date: 2009-03-09 16:46:00 -0400 (Mon, 09 Mar 2009)
New Revision: 8735
Modified:
sandbox/graphics/mapcairo.c
sandbox/graphics/mapserver.h
Log:
raster export/import for cairo
Modified: sandbox/graphics/mapcairo.c
===================================================================
--- sandbox/graphics/mapcairo.c 2009-03-09 20:44:25 UTC (rev 8734)
+++ sandbox/graphics/mapcairo.c 2009-03-09 20:46:00 UTC (rev 8735)
@@ -691,7 +691,40 @@
}
+void getRasterBufferCairo(imageObj *img, rasterBufferObj *rb) {
+ cairo_renderer *r = getCairoRenderer(img);
+ unsigned char *pb = cairo_image_surface_get_data(r->surface);
+ rb->pixelbuffer = pb;
+ rb->row_step = cairo_image_surface_get_stride(r->surface);
+ rb->pixel_step=4;
+ rb->width = cairo_image_surface_get_width(r->surface);
+ rb->height = cairo_image_surface_get_height(r->surface);
+ rb->r = &(pb[1]);
+ rb->g = &(pb[2]);
+ rb->b = &(pb[3]);
+ if(cairo_image_surface_get_format(r->surface) == CAIRO_FORMAT_ARGB32) {
+ rb->a = &(pb[0]);
+ } else {
+ rb->a = NULL;
+ }
+}
+void mergeRasterBufferCairo(imageObj *img, rasterBufferObj *rb) {
+ cairo_surface_t *src;
+ cairo_format_t format;
+ cairo_renderer *r = getCairoRenderer(img);
+ if(rb->a)
+ format = CAIRO_FORMAT_ARGB32;
+ else
+ format = CAIRO_FORMAT_RGB24;
+ src = cairo_image_surface_create_for_data(rb->pixelbuffer,format,
+ rb->width,rb->height,
+ rb->row_step);
+ cairo_set_source_surface (r->cr,src,0,0);
+ cairo_paint_with_alpha(r->cr,1.0);
+
+}
+
void msFreeSymbolCairo(symbolObj *s) {
if(!s->renderer_cache)
return;
Modified: sandbox/graphics/mapserver.h
===================================================================
--- sandbox/graphics/mapserver.h 2009-03-09 20:44:25 UTC (rev 8734)
+++ sandbox/graphics/mapserver.h 2009-03-09 20:46:00 UTC (rev 8735)
@@ -2466,6 +2466,14 @@
/* end of prototypes for functions in mapcairo.c */
/* ==================================================================== */
+
+typedef struct {
+ unsigned char *pixelbuffer;
+ unsigned int width,height;
+ unsigned int pixel_step, row_step;
+ unsigned char *a,*r,*g,*b;
+} rasterBufferObj;
+
void *searchImageCache(struct imageCacheObj *ic, styleObj *style);
struct imageCacheObj *addImageCache(struct imageCacheObj *ic, int *icsize, styleObj *style,
More information about the mapserver-commits
mailing list