[mapserver-commits] r10298 - sandbox/mapserver6
svn at osgeo.org
svn at osgeo.org
Thu Jul 8 07:38:04 EDT 2010
Author: tbonfort
Date: 2010-07-08 11:38:04 +0000 (Thu, 08 Jul 2010)
New Revision: 10298
Removed:
sandbox/mapserver6/mapkml.h
Modified:
sandbox/mapserver6/mapagg.cpp
sandbox/mapserver6/mapcairo.c
sandbox/mapserver6/mapdraw.c
sandbox/mapserver6/mapgd.c
sandbox/mapserver6/mapimageio.c
sandbox/mapserver6/maplabel.c
sandbox/mapserver6/maprendering.c
sandbox/mapserver6/mapscale.c
sandbox/mapserver6/maputil.c
Log:
gif image loading
Modified: sandbox/mapserver6/mapagg.cpp
===================================================================
--- sandbox/mapserver6/mapagg.cpp 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapagg.cpp 2010-07-08 11:38:04 UTC (rev 10298)
@@ -434,12 +434,30 @@
int agg2RenderPixmapSymbol(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj * style) {
AGG2Renderer *r = agg2GetRenderer(img);
pixel_format pf;
- rendering_buffer b;
+ rendering_buffer b;
rasterBufferObj *pixmap = symbol->pixmap_buffer;
assert(pixmap->type == MS_BUFFER_BYTE_RGBA);
if(!symbol->renderer_cache) {
band_type *data = (band_type*)malloc(pixmap->width*pixmap->height*4*sizeof(band_type));
- memcpy(data,pixmap->data.rgba.pixels,pixmap->width*pixmap->height*4);
+ for(unsigned int row=0; row<pixmap->height;row++) {
+ unsigned char *a = pixmap->data.rgba.a + row * pixmap->data.rgba.row_step;
+ unsigned char *r = pixmap->data.rgba.r + row * pixmap->data.rgba.row_step;
+ unsigned char *g = pixmap->data.rgba.g + row * pixmap->data.rgba.row_step;
+ unsigned char *b = pixmap->data.rgba.b + row * pixmap->data.rgba.row_step;
+ band_type* pixptr = data + row * pixmap->width * 4;
+ for(unsigned int col=0;col<pixmap->width;col++) {
+ pixptr[band_order::A] = *a;
+ pixptr[band_order::G] = *g;
+ pixptr[band_order::B] = *b;
+ pixptr[band_order::R] = *r;
+ pixptr+=4;
+ a += pixmap->data.rgba.pixel_step;
+ r += pixmap->data.rgba.pixel_step;
+ g += pixmap->data.rgba.pixel_step;
+ b += pixmap->data.rgba.pixel_step;
+ }
+ }
+ //memcpy(data,pixmap->data.rgba.pixels,pixmap->width*pixmap->height*4);
rendering_buffer *b = new rendering_buffer(data, pixmap->width, pixmap->height, (int)pixmap->width*4);
symbol->renderer_cache = (void*)b;
pf.attach(*b);
Modified: sandbox/mapserver6/mapcairo.c
===================================================================
--- sandbox/mapserver6/mapcairo.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapcairo.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -475,7 +475,8 @@
cairo_save(r->cr);
cairo_translate(r->cr,x,y);
- cairo_rotate(r->cr, -style->rotation);
+ if(style->rotation != 0.0)
+ cairo_rotate(r->cr, -style->rotation);
has_kerning = FT_HAS_KERNING((face->ftface));
for(i=0;i<numglyphs;i++) {
Modified: sandbox/mapserver6/mapdraw.c
===================================================================
--- sandbox/mapserver6/mapdraw.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapdraw.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -2387,14 +2387,14 @@
size = labelPtr->size;
}
if(msGetLabelSize(map,labelPtr,cachePtr->text,size,&r,NULL) != MS_SUCCESS)
- return(-1);
+ return(MS_FAILURE);
//adjust the baseline (see #1449)
if(labelPtr->type == MS_TRUETYPE) {
int nNewlines = msCountChars(cachePtr->text,'\n');
if(!nNewlines) {
- labelPtr->offsety += (MS_NINT(((r.miny + r.maxy) + size) / 2))/scalefactor;
- labelPtr->offsetx += (MS_NINT(r.minx / 2))/scalefactor;
+ labelPtr->offsety += MS_NINT((((r.miny + r.maxy) + size) / 2.0)/scalefactor);
+ labelPtr->offsetx += MS_NINT((r.minx / 2)/scalefactor);
}
else {
rectObj rect2; /*bbox of first line only*/
Modified: sandbox/mapserver6/mapgd.c
===================================================================
--- sandbox/mapserver6/mapgd.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapgd.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -77,7 +77,7 @@
if(!format->transparent && bg && MS_VALID_COLOR(*bg))
gdImageColorAllocate(ip, bg->red, bg->green, bg->blue); /* set the background color */
else {
- gdImageColorAllocate(ip,255,255,255);
+ gdImageColorAllocate(ip,117,17,91); /*random bg color (same one as picked in msResampleGDALToMap) */
gdImageColorTransparent(ip, 0);
}
@@ -710,8 +710,8 @@
if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
assert(symbol->pixmap_buffer && symbol->pixmap_buffer->type == MS_BUFFER_GD);
pp = symbol->pixmap_buffer->data.gd_img;
- gdImageAlphaBlending(ip,1);
- gdImageAlphaBlending(pp,1);
+ //gdImageAlphaBlending(ip,1);
+ //gdImageAlphaBlending(pp,1);
if(symbol->transparent)
gdImageColorTransparent(pp,symbol->transparentcolor);
@@ -735,7 +735,7 @@
gdImageDestroy(pp);
}
}
- gdImageAlphaBlending(ip,0);
+ //gdImageAlphaBlending(ip,0);
return MS_SUCCESS;
}
@@ -782,20 +782,20 @@
int getRasterBufferCopyGD(imageObj *img, rasterBufferObj *rb) {
gdImagePtr gdImg = MS_IMAGE_GET_GDIMAGEPTR(img);
+ int row;
rb->type = MS_BUFFER_GD;
rb->width = gdImg->sx;
rb->height = gdImg->sy;
- if(gdImageTrueColor(gdImg)) {
- rb->data.gd_img = gdImageCreateTrueColor(gdImg->sx,gdImg->sy);
- } else {
- rb->data.gd_img = gdImageCreate(gdImg->sx,gdImg->sy);
- }
- gdImageCopy(gdImg,rb->data.gd_img,0,0,0,0,gdImg->sx,gdImg->sy);
+ rb->data.gd_img = gdImageCreate(gdImg->sx,gdImg->sy);
+ rb->data.gd_img->transparent = gdImg->transparent;
+ gdImagePaletteCopy(rb->data.gd_img,gdImg);
+ for(row=0;row<gdImg->sy;row++)
+ memcpy(rb->data.gd_img->pixels[row],gdImg->pixels[row],gdImg->sx);
return MS_SUCCESS;
}
int mergeRasterBufferGD(imageObj *dest, rasterBufferObj *overlay, double opacity, int srcX, int srcY, int dstX, int dstY, int width, int height) {
- if(!dest || !overlay) return MS_FAILURE;
+ assert(dest && overlay);
assert(overlay->type == MS_BUFFER_GD);
gdImageCopyMerge(MS_IMAGE_GET_GDIMAGEPTR(dest),overlay->data.gd_img,dstX,dstY,srcX,srcY,width,height,opacity*100);
return MS_SUCCESS;
Modified: sandbox/mapserver6/mapimageio.c
===================================================================
--- sandbox/mapserver6/mapimageio.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapimageio.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -32,9 +32,8 @@
#include "mapserver.h"
#include <assert.h>
#include "jpeglib.h"
-#if 0
+
#include "gif_lib.h"
-#endif
MS_CVSID("$Id$")
@@ -690,7 +689,11 @@
row_pointers = (unsigned char**)malloc(height*sizeof(unsigned char*));
rb->data.rgba.pixel_step=4;
rb->data.rgba.row_step = width*4;
-
+ rb->data.rgba.b = &rb->data.rgba.pixels[0];
+ rb->data.rgba.g = &rb->data.rgba.pixels[1];
+ rb->data.rgba.r = &rb->data.rgba.pixels[2];
+ rb->data.rgba.a = &rb->data.rgba.pixels[3];
+
for(i=0;i<height;i++) {
row_pointers[i] = &(rb->data.rgba.pixels[i*rb->data.rgba.row_step]);
}
@@ -734,30 +737,6 @@
}
-int msLoadMSRasterBufferFromFile(char *path, rasterBufferObj *rb) {
- FILE *stream;
- unsigned char signature[8];
- int ret = MS_FAILURE;
- stream = fopen(path,"rb");
- if(!stream) {
- msSetError(MS_MISCERR, "unable to open file %s for reading", "msLoadRasterBuffer()", path);
- return MS_FAILURE;
- }
- fread(signature,1,8,stream);
- rewind(stream);
- if(png_check_sig(signature,8)) {
- ret = readPNG(stream,rb);
-#if 0
- } else if () {//GIF loading
-#endif
- } else {
- msSetError(MS_MISCERR,"unsupported pixmap format","readImage()");
- return MS_FAILURE;
- }
- fclose(stream);
- return ret;
-}
-
int saveGdImage(gdImagePtr ip, FILE *fp, outputFormatObj *format) {
if(strcasecmp("ON", msGetOutputFormatOption(format, "INTERLACE", "ON")) == 0)
gdImageInterlace(ip, 1);
@@ -834,104 +813,214 @@
}
}
-#if 0
/* not fully implemented and tested */
/* missing: set the first pointer to a,r,g,b */
-rasterBufferObj* readGIF(FILE *stream)
+int readGIF(FILE *stream, rasterBufferObj *rb)
{
- rasterBufferObj *rb = NULL;
- int i, p, codeSize, extCode, firstImageRead = MS_FALSE;
- GifFileType *image;
- GifPixelType *line;;
- GifRecordType recordType;
- GifByteType *codeBlock, *extension;
-
+ int i, j, codeSize, extCode, firstImageRead = MS_FALSE;
+ unsigned char *r,*g,*b,*a;
+ int transIdx = -1;
+ GifFileType *image;
+ GifPixelType *line;;
+ GifRecordType recordType;
+ GifByteType *codeBlock, *extension;
+ ColorMapObject *cmap;
+ int interlacedOffsets[] = {0,4,2,1};
+ int interlacedJumps[] = {8,8,4,2};
- rb = (rasterBufferObj*)malloc(sizeof(rasterBufferObj));
- image = DGifOpenFileHandle(fileno(stream));
- if (image == NULL) {
- /* MS_SETERROR ... */
- return NULL;
- }
- rb->row_step = rb->width*sizeof(int);
- rb->pixel_step = sizeof(int);
-
- do
- {
- if (DGifGetRecordType(image, &recordType) == GIF_ERROR) {
- /* MS_SETERROR ... */
- return NULL;
- }
+ rb->type = MS_BUFFER_BYTE_RGBA;
+ image = DGifOpenFileHandle(fileno(stream));
+ if (image == NULL) {
+ msSetError(MS_MISCERR,"failed to load gif image","readGIF()");
+ return MS_FAILURE;
+ }
+ rb->width = image->SWidth;
+ rb->height = image->SHeight;
+ rb->data.rgba.row_step = rb->width * 4;
+ rb->data.rgba.pixel_step = 4;
+ rb->data.rgba.pixels = (unsigned char*)malloc(rb->width*rb->height*4*sizeof(unsigned char*));
+ b = rb->data.rgba.b = &rb->data.rgba.pixels[0];
+ g = rb->data.rgba.g = &rb->data.rgba.pixels[1];
+ r = rb->data.rgba.r = &rb->data.rgba.pixels[2];
+ a = rb->data.rgba.a = &rb->data.rgba.pixels[3];
+
+ cmap = (image->Image.ColorMap)?image->Image.ColorMap:image->SColorMap;
+ for(i=0; i<rb->width*rb->height; i++) {
+ *a = 255;
+ *r = cmap->Colors[image->SBackGroundColor].Red;
+ *g = cmap->Colors[image->SBackGroundColor].Green;
+ *b = cmap->Colors[image->SBackGroundColor].Blue;
+ a+=rb->data.rgba.pixel_step;
+ r+=rb->data.rgba.pixel_step;
+ g+=rb->data.rgba.pixel_step;
+ b+=rb->data.rgba.pixel_step;
+ }
+
+ do
+ {
+ if (DGifGetRecordType(image, &recordType) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
- switch (recordType)
- {
- case SCREEN_DESC_RECORD_TYPE:
- DGifGetScreenDesc(image);
- break;
- case IMAGE_DESC_RECORD_TYPE:
- if (DGifGetImageDesc(image) == GIF_ERROR) {
- return NULL;
+ switch (recordType)
+ {
+ case SCREEN_DESC_RECORD_TYPE:
+ DGifGetScreenDesc(image);
+ break;
+ case IMAGE_DESC_RECORD_TYPE:
+ if (DGifGetImageDesc(image) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
+ if (!firstImageRead)
+ {
+
+ int row = image->Image.Top;
+ int col = image->Image.Left;
+ int width = image->Image.Width;
+ int height = image->Image.Height;
+
+ //sanity check:
+ if(col+width>rb->width || row+height>rb->height) {
+ msSetError(MS_MISCERR,"corrupted gif image, img size exceeds screen size","readGIF()");
+ return MS_FAILURE;
}
- if (!firstImageRead)
- {
- p = 0;
- rb->width = image->Image.Width;
- rb->height = image->Image.Height;
- rb->pixelbuffer = (unsigned char*)malloc(rb->width*rb->height*sizeof(int));
-
- line = (GifPixelType *) malloc(image->Image.Width *
- sizeof(GifPixelType));
- for (i = 0; i < image->Image.Height; i++) {
- if (DGifGetLine(image, line, image->Image.Width) == GIF_ERROR) {
- return NULL;
- }
- memcpy(rb->pixelbuffer+p, line, image->Image.Width);
- p += image->Image.Width;
- }
- free((char *) line);
- firstImageRead = MS_TRUE;
- }
- else
- { /* Skip all next images */
- if (DGifGetCode(image, &codeSize, &codeBlock) == GIF_ERROR) {
- return NULL;
- }
- while (codeBlock != NULL) {
- if (DGifGetCodeNext(image, &codeBlock) == GIF_ERROR) {
- return NULL;
- }
- }
+
+ line = (GifPixelType *) malloc(width * sizeof(GifPixelType));
+ if(image->Image.Interlace) {
+ int count;
+ for(count=0; count<4; count++) {
+ for(i=row+interlacedOffsets[count];i<row+height;i+=interlacedJumps[count]) {
+ int offset = i * rb->data.rgba.row_step + col * rb->data.rgba.pixel_step;
+ a = rb->data.rgba.a + offset;
+ r = rb->data.rgba.r + offset;
+ g = rb->data.rgba.g + offset;
+ b = rb->data.rgba.b + offset;
+ if (DGifGetLine(image, line, width) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
+
+ for(j=0; j<width; j++) {
+ GifPixelType pix = line[j];
+ if(transIdx == -1 || pix != transIdx) {
+ *a = 255;
+ *r = cmap->Colors[pix].Red;
+ *g = cmap->Colors[pix].Green;
+ *b = cmap->Colors[pix].Blue;
+ } else {
+ *a = *r = *g = *b = 0;
+ }
+ a+=rb->data.rgba.pixel_step;
+ r+=rb->data.rgba.pixel_step;
+ g+=rb->data.rgba.pixel_step;
+ b+=rb->data.rgba.pixel_step;
+ }
+ }
+ }
+ } else {
+ for (i = 0; i < height; i++) {
+ int offset = i * rb->data.rgba.row_step + col * rb->data.rgba.pixel_step;
+ a = rb->data.rgba.a + offset;
+ r = rb->data.rgba.r + offset;
+ g = rb->data.rgba.g + offset;
+ b = rb->data.rgba.b + offset;
+ if (DGifGetLine(image, line, width) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
+ for(j=0; j<width; j++) {
+ GifPixelType pix = line[j];
+ if(transIdx == -1 || pix != transIdx) {
+ *a = 255;
+ *r = cmap->Colors[pix].Red;
+ *g = cmap->Colors[pix].Green;
+ *b = cmap->Colors[pix].Blue;
+ } else {
+ *a = *r = *g = *b = 0;
+ }
+ a+=rb->data.rgba.pixel_step;
+ r+=rb->data.rgba.pixel_step;
+ g+=rb->data.rgba.pixel_step;
+ b+=rb->data.rgba.pixel_step;
+ }
+ }
}
- break;
- case EXTENSION_RECORD_TYPE:
- /* skip all extension blocks */
- if (DGifGetExtension(image, &extCode, &extension) == GIF_ERROR) {
- return NULL;
+ free((char *) line);
+ firstImageRead = MS_TRUE;
+ }
+ else
+ { /* Skip all next images */
+ if (DGifGetCode(image, &codeSize, &codeBlock) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
}
- for (;;) {
- if (DGifGetExtensionNext(image, &extension) == GIF_ERROR) {
- return NULL;
- }
- if (extension == NULL)
- break;
+ while (codeBlock != NULL) {
+ if (DGifGetCodeNext(image, &codeBlock) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
}
- break;
- case UNDEFINED_RECORD_TYPE:
- break;
- case TERMINATE_RECORD_TYPE:
- break;
- default:
- break;
- }
-
- } while (recordType != TERMINATE_RECORD_TYPE);
+ }
+ break;
+ case EXTENSION_RECORD_TYPE:
+ /* skip all extension blocks */
+ if (DGifGetExtension(image, &extCode, &extension) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
+ if(extCode == 249 && (extension[1] & 1))
+ transIdx = extension[4];
+ for (;;) {
+ if (DGifGetExtensionNext(image, &extension) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"corrupted gif image?","readGIF()");
+ return MS_FAILURE;
+ }
+ if (extension == NULL)
+ break;
+ if(extension[1] & 1)
+ transIdx = extension[4];
+ }
+ break;
+ case UNDEFINED_RECORD_TYPE:
+ break;
+ case TERMINATE_RECORD_TYPE:
+ break;
+ default:
+ break;
+ }
- if (DGifCloseFile(image) == GIF_ERROR) {
- /* MS_SETERROR ... */
- }
+ } while (recordType != TERMINATE_RECORD_TYPE);
- return rb;
+ if (DGifCloseFile(image) == GIF_ERROR) {
+ msSetError(MS_MISCERR,"failed to close gif after loading","readGIF()");
+ return MS_FAILURE;
+ }
+
+ return MS_SUCCESS;
}
-#endif
+int msLoadMSRasterBufferFromFile(char *path, rasterBufferObj *rb) {
+ FILE *stream;
+ unsigned char signature[8];
+ int ret = MS_FAILURE;
+ stream = fopen(path,"rb");
+ if(!stream) {
+ msSetError(MS_MISCERR, "unable to open file %s for reading", "msLoadRasterBuffer()", path);
+ return MS_FAILURE;
+ }
+ fread(signature,1,8,stream);
+ rewind(stream);
+ if(png_check_sig(signature,8)) {
+ ret = readPNG(stream,rb);
+ } else if (!strncmp((char*)signature,"GIF",3)) {
+ ret = readGIF(stream,rb);
+ } else {
+ msSetError(MS_MISCERR,"unsupported pixmap format","readImage()");
+ return MS_FAILURE;
+ }
+ fclose(stream);
+ return ret;
+}
Deleted: sandbox/mapserver6/mapkml.h
===================================================================
Modified: sandbox/mapserver6/maplabel.c
===================================================================
--- sandbox/mapserver6/maplabel.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/maplabel.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -906,8 +906,8 @@
x = x1 - rect.minx;
y = rect.maxy - y1;
- q.x = p->x + MS_NINT(x * cos_a - (y) * sin_a);
- q.y = p->y - MS_NINT(x * sin_a + (y) * cos_a);
+ q.x = p->x + (x * cos_a - (y) * sin_a);
+ q.y = p->y - (x * sin_a + (y) * cos_a);
if(poly) {
/*
Modified: sandbox/mapserver6/maprendering.c
===================================================================
--- sandbox/mapserver6/maprendering.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/maprendering.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -242,6 +242,7 @@
pointObj point;
double original_rotation = style->rotation;
double symbol_width;
+ int ret = MS_FAILURE;
if(symbol->type != MS_SYMBOL_TRUETYPE)
symbol_width = MS_MAX(1,symbol->sizex*style->scale);
else {
@@ -276,7 +277,7 @@
}
in = 0;
while (current_length <= length) {
- int ret;
+
point.x = p->line[i].point[j - 1].x + current_length * rx;
point.y = p->line[i].point[j - 1].y + current_length * ry;
switch (symbol->type) {
@@ -344,13 +345,13 @@
point.y = p->line[i].point[j - 1].y + offset * ry;
switch (symbol->type) {
case MS_SYMBOL_PIXMAP:
- return renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
+ ret = renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
case MS_SYMBOL_ELLIPSE:
- return renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
+ ret = renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style);
case MS_SYMBOL_VECTOR:
- return renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
+ ret = renderer->renderVectorSymbol(image, point.x, point.y, symbol, style);
case MS_SYMBOL_TRUETYPE:
- return renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
+ ret = renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style);
}
}
before_length += length;
@@ -358,6 +359,7 @@
}
}
+ return ret;
}
int msDrawLineSymbol(symbolSetObj *symbolset, imageObj *image, shapeObj *p,
@@ -440,8 +442,7 @@
if(!symbol->full_font_path)
symbol->full_font_path = strdup(msLookupHashTable(&(symbolset->fontset->fonts),
symbol->font));
- if(!symbol->full_font_path)
- return;
+ assert(symbol->full_font_path);
}
//compute a markerStyle and use it on the line
@@ -479,6 +480,7 @@
int msDrawShadeSymbol(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor)
{
+ int ret = MS_SUCCESS;
if (!p)
return MS_SUCCESS;
if (p->numlines <= 0)
@@ -510,7 +512,6 @@
rendererVTableObj *renderer = image->format->vtable;
shapeObj *offsetPolygon = NULL;
symbolObj *symbol = symbolset->symbol[style->symbol];
- int ret = MS_SUCCESS;
/* store a reference to the renderer to be used for freeing */
if(style->symbol)
symbol->renderer = renderer;
@@ -531,22 +532,23 @@
if(ret != MS_SUCCESS) goto cleanup;
if(MS_VALID_COLOR(style->outlinecolor)) {
strokeStyleObj s;
+ initStrokeStyle(&s);
MS_COPYCOLOR(&s.color,&style->outlinecolor);
s.patternlength = 0;
s.width = (style->width == 0)?scalefactor:style->width*scalefactor;
-
- s.color.alpha = style->color.alpha;
ret = renderer->renderLine(image,offsetPolygon,&s);
}
goto cleanup; /*finished plain polygon*/
} else if(symbol->type == MS_SYMBOL_HATCH){
if(MS_VALID_COLOR(style->backgroundcolor)) {
- renderer->renderPolygon(image,offsetPolygon, &style->backgroundcolor);
+ ret = renderer->renderPolygon(image,offsetPolygon, &style->backgroundcolor);
+ if(ret != MS_SUCCESS) goto cleanup;
}
double width = (style->width <= 0)?scalefactor:style->width*scalefactor;
style->color.alpha = MS_NINT(style->opacity*2.55);
double spacing = (style->size <= 0)?scalefactor:style->size*scalefactor;
ret = msHatchPolygon(image,offsetPolygon,spacing,width,style->angle, &style->color);
+ goto cleanup;
}
else {
switch(symbol->type) {
@@ -577,11 +579,14 @@
computeSymbolStyle(&s,style,symbol,scalefactor);
int pw,ph;
- if (!MS_VALID_COLOR(s.color) && !MS_VALID_COLOR(s.outlinecolor) && symbol->type != MS_SYMBOL_PIXMAP)
- return MS_SUCCESS; // nothing to do (colors are required except for PIXMAP symbols
+ if (!MS_VALID_COLOR(s.color) && !MS_VALID_COLOR(s.outlinecolor) && symbol->type != MS_SYMBOL_PIXMAP) {
+ ret = MS_SUCCESS; // nothing to do (colors are required except for PIXMAP symbols
+ goto cleanup;
+ }
if(MS_VALID_COLOR(s.backgroundcolor)) {
- renderer->renderPolygon(image,offsetPolygon, &s.backgroundcolor);
+ ret = renderer->renderPolygon(image,offsetPolygon, &s.backgroundcolor);
+ if(ret != MS_SUCCESS) goto cleanup;
}
imageObj *tile;
@@ -608,113 +613,117 @@
msDrawShadeSymbolSWF(symbolset, image, p, style, scalefactor);
#endif
}
+ return ret;
}
int msDrawMarkerSymbol(symbolSetObj *symbolset,imageObj *image, pointObj *p, styleObj *style,
double scalefactor)
{
- if (!p)
- return MS_SUCCESS;
- if (style->symbol >= symbolset->numsymbols || style->symbol < 0)
- return MS_SUCCESS; /* no such symbol, 0 is OK */
+ int ret = MS_SUCCESS;
+ if (!p)
+ return MS_SUCCESS;
+ if (style->symbol >= symbolset->numsymbols || style->symbol < 0)
+ return MS_SUCCESS; /* no such symbol, 0 is OK */
if (image)
{
- if(MS_RENDERER_PLUGIN(image->format)) {
- rendererVTableObj *renderer = image->format->vtable;
- symbolStyleObj s;
- double p_x,p_y;
- symbolObj *symbol = symbolset->symbol[style->symbol];
- /* store a reference to the renderer to be used for freeing */
- symbol->renderer = renderer;
- switch (symbol->type) {
- case (MS_SYMBOL_TRUETYPE): {
- if(!symbol->full_font_path)
- symbol->full_font_path = strdup(msLookupHashTable(&(symbolset->fontset->fonts),
- symbol->font));
- if(!symbol->full_font_path) {
- msSetError(MS_MEMERR,"allocation error", "msDrawMArkerSymbol()");
- return MS_FAILURE;
- }
- }
- break;
- case (MS_SYMBOL_PIXMAP): {
- if(!symbol->pixmap_buffer) {
- if(MS_SUCCESS != msPreloadImageSymbol(renderer,symbol))
- return MS_FAILURE;
- }
- }
- break;
+ if(MS_RENDERER_PLUGIN(image->format)) {
+ rendererVTableObj *renderer = image->format->vtable;
+ symbolStyleObj s;
+ double p_x,p_y;
+ symbolObj *symbol = symbolset->symbol[style->symbol];
+ /* store a reference to the renderer to be used for freeing */
+ symbol->renderer = renderer;
+ switch (symbol->type) {
+ case (MS_SYMBOL_TRUETYPE): {
+ if(!symbol->full_font_path)
+ symbol->full_font_path = strdup(msLookupHashTable(&(symbolset->fontset->fonts),
+ symbol->font));
+ if(!symbol->full_font_path) {
+ msSetError(MS_MEMERR,"allocation error", "msDrawMArkerSymbol()");
+ return MS_FAILURE;
}
- initSymbolStyle(&s);
- computeSymbolStyle(&s,style,symbol,scalefactor);
- s.style = style;
+ }
+ break;
+ case (MS_SYMBOL_PIXMAP): {
+ if(!symbol->pixmap_buffer) {
+ if(MS_SUCCESS != msPreloadImageSymbol(renderer,symbol))
+ return MS_FAILURE;
+ }
+ }
+ break;
+ }
+ initSymbolStyle(&s);
+ computeSymbolStyle(&s,style,symbol,scalefactor);
+ s.style = style;
- if (!MS_VALID_COLOR(s.color) && !MS_VALID_COLOR(s.outlinecolor) && symbol->type != MS_SYMBOL_PIXMAP)
- return MS_SUCCESS; // nothing to do if no color, except for pixmap symbols
-
-
-
- //TODO: skip the drawing of the symbol if it's smaller than a pixel ?
- /*
+ if (!MS_VALID_COLOR(s.color) && !MS_VALID_COLOR(s.outlinecolor) && symbol->type != MS_SYMBOL_PIXMAP)
+ return MS_SUCCESS; // nothing to do if no color, except for pixmap symbols
+
+
+
+ //TODO: skip the drawing of the symbol if it's smaller than a pixel ?
+ /*
if (s.size < 1)
return; // size too small
- */
+ */
- p_x = p->x + style->offsetx * scalefactor;
- p_y = p->y + style->offsety * scalefactor;
+ p_x = p->x + style->offsetx * scalefactor;
+ p_y = p->y + style->offsety * scalefactor;
- if(renderer->supports_imagecache) {
- imageObj *tile = getTile(image, symbol, &s, -1, -1);
- if(tile!=NULL)
- return renderer->renderTile(image, tile, p_x, p_y);
- else {
- msSetError(MS_RENDERERERR, "problem creating cached tile", "msDrawMarkerSymbol()");
- return MS_FAILURE;
- }
- }
- switch (symbol->type) {
- case (MS_SYMBOL_TRUETYPE): {
- if(!symbol->full_font_path)
- symbol->full_font_path = strdup(msLookupHashTable(&(symbolset->fontset->fonts),
- symbol->font));
- if(!symbol->full_font_path) {
- msSetError(MS_MEMERR,"allocation error", "msDrawMArkerSymbol()");
- return MS_FAILURE;
- }
- renderer->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
+ if(renderer->supports_imagecache) {
+ imageObj *tile = getTile(image, symbol, &s, -1, -1);
+ if(tile!=NULL)
+ return renderer->renderTile(image, tile, p_x, p_y);
+ else {
+ msSetError(MS_RENDERERERR, "problem creating cached tile", "msDrawMarkerSymbol()");
+ return MS_FAILURE;
+ }
+ }
+ switch (symbol->type) {
+ case (MS_SYMBOL_TRUETYPE): {
+ if(!symbol->full_font_path)
+ symbol->full_font_path = strdup(msLookupHashTable(&(symbolset->fontset->fonts),
+ symbol->font));
+ if(!symbol->full_font_path) {
+ msSetError(MS_MEMERR,"allocation error", "msDrawMArkerSymbol()");
+ return MS_FAILURE;
+ }
+ ret = renderer->renderTruetypeSymbol(image, p_x, p_y, symbol, &s);
- }
- break;
- case (MS_SYMBOL_PIXMAP): {
- if(!symbol->pixmap_buffer) {
- if(MS_SUCCESS != msPreloadImageSymbol(renderer,symbol))
- return MS_FAILURE;
- }
- renderer->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
- }
- break;
- case (MS_SYMBOL_ELLIPSE): {
- renderer->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
- }
- break;
- case (MS_SYMBOL_VECTOR): {
- renderer->renderVectorSymbol(image, p_x, p_y, symbol, &s);
- }
- break;
- default:
- break;
- }
- }
- else if( MS_RENDERER_IMAGEMAP(image->format) )
- msDrawMarkerSymbolIM(symbolset, image, p, style, scalefactor);
+ }
+ break;
+ case (MS_SYMBOL_PIXMAP): {
+ if(!symbol->pixmap_buffer) {
+ if(MS_SUCCESS != msPreloadImageSymbol(renderer,symbol))
+ return MS_FAILURE;
+ }
+ ret = renderer->renderPixmapSymbol(image,p_x,p_y,symbol,&s);
+ }
+ break;
+ case (MS_SYMBOL_ELLIPSE): {
+ ret = renderer->renderEllipseSymbol(image, p_x, p_y,symbol, &s);
+ }
+ break;
+ case (MS_SYMBOL_VECTOR): {
+ ret = renderer->renderVectorSymbol(image, p_x, p_y, symbol, &s);
+ }
+ break;
+ default:
+ break;
+ }
+ return ret;
+ }
+ else if( MS_RENDERER_IMAGEMAP(image->format) )
+ msDrawMarkerSymbolIM(symbolset, image, p, style, scalefactor);
#ifdef USE_MING_FLASH
- else if( MS_RENDERER_SWF(image->format) )
- msDrawMarkerSymbolSWF(symbolset, image, p, style, scalefactor);
+ else if( MS_RENDERER_SWF(image->format) )
+ msDrawMarkerSymbolSWF(symbolset, image, p, style, scalefactor);
#endif
- }
+ }
+ return ret;
}
Modified: sandbox/mapserver6/mapscale.c
===================================================================
--- sandbox/mapserver6/mapscale.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/mapscale.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -339,7 +339,7 @@
symbolObj *embededSymbol;
if( ! renderer ) {
- msSetError(MS_MISCERR,"unsupported outputformat","msEmbeScalebar()");
+ msSetError(MS_MISCERR,"unsupported outputformat","msEmbedScalebar()");
return MS_FAILURE;
}
index = msGetSymbolIndex(&(map->symbolset), "scalebar", MS_FALSE);
Modified: sandbox/mapserver6/maputil.c
===================================================================
--- sandbox/mapserver6/maputil.c 2010-07-08 11:35:27 UTC (rev 10297)
+++ sandbox/mapserver6/maputil.c 2010-07-08 11:38:04 UTC (rev 10298)
@@ -679,9 +679,12 @@
rendererVTableObj *renderer = img->format->vtable;
FILE *stream;
int ret;
- if(filename)
- stream = fopen(msBuildPath(szPath, map->mappath, filename),"wb");
- else {
+ if(filename) {
+ if(map)
+ stream = fopen(msBuildPath(szPath, map->mappath, filename),"wb");
+ else
+ stream = fopen(filename,"wb");
+ } else {
if ( msIO_needBinaryStdout() == MS_FAILURE )
return MS_FAILURE;
stream = stdout;
More information about the mapserver-commits
mailing list