int msRemoveOutputFormat(mapObj *map, const char *name) { int i, j; /* -------------------------------------------------------------------- */ /* Detach from map. */ /* -------------------------------------------------------------------- */ if (map != NULL) { if (map->outputformatlist == NULL) { msSetError(MS_CHILDERR, "Can't remove format from empty outputformatlist", "msRemoveOutputFormat()"); return MS_FAILURE; } else { i = msGetOutputFormatIndex(map, name); if (i >= 0) { map->numoutputformats--; if(MS_REFCNT_DECR_IS_ZERO(map->outputformatlist[i])) msFreeOutputFormat( map->outputformatlist[i] ); for (j=i; j<map->numoutputformats-1; j++) { map->outputformatlist[j] = map->outputformatlist[j+1]; } } map->outputformatlist = (outputFormatObj **) realloc(map->outputformatlist, sizeof(void*) * (map->numoutputformats) ); return MS_SUCCESS; } } return MS_FAILURE; }
int msGetRasterTextBBox(rendererVTableObj *renderer, int size, char *string, rectObj *rect) { if(renderer && renderer->supports_bitmap_fonts) { int num_lines=1, cur_line_length=0, max_line_length=0; char *stringPtr = string; fontMetrics *fontPtr; if((fontPtr=renderer->bitmapFontMetrics[size]) == NULL) { msSetError(MS_MISCERR, "selected renderer does not support bitmap font size %d", "msGetRasterTextBBox()",size); return MS_FAILURE; } while(*stringPtr) { if(*stringPtr=='\n') { max_line_length = MS_MAX(cur_line_length,max_line_length); num_lines++; cur_line_length=0; } else { if(*stringPtr!='\r') cur_line_length++; } stringPtr++; } max_line_length = MS_MAX(cur_line_length,max_line_length); rect->minx = 0; rect->miny = -fontPtr->charHeight; rect->maxx = fontPtr->charWidth * max_line_length; rect->maxy = fontPtr->charHeight * (num_lines-1); return MS_SUCCESS; } else if(!renderer) { int ret = MS_FAILURE; outputFormatObj *format = msCreateDefaultOutputFormat(NULL,"AGG/PNG","tmp"); if(!format) { msSetError(MS_MISCERR, "failed to create default format", "msGetRasterTextBBox()"); return MS_FAILURE; } msInitializeRendererVTable(format); renderer = format->vtable; ret = msGetRasterTextBBox(renderer,size,string,rect); msFreeOutputFormat(format); return ret; } else { msSetError(MS_MISCERR, "selected renderer does not support raster fonts", "msGetRasterTextBBox()"); return MS_FAILURE; } }
int msGetTruetypeTextBBox(rendererVTableObj *renderer, char* fontstring, fontSetObj *fontset, double size, char *string, rectObj *rect, double **advances, int bAdjustbaseline) { outputFormatObj *format = NULL; int ret = MS_FAILURE; char *lookedUpFonts[MS_MAX_LABEL_FONTS]; int numfonts; if(!renderer) { format = msCreateDefaultOutputFormat(NULL,"AGG/PNG","tmp"); if(!format) { goto tt_cleanup; } msInitializeRendererVTable(format); renderer = format->vtable; } if(MS_FAILURE == msFontsetLookupFonts(fontstring, &numfonts, fontset, lookedUpFonts)) goto tt_cleanup; ret = renderer->getTruetypeTextBBox(renderer,lookedUpFonts,numfonts,size,string,rect,advances,bAdjustbaseline); tt_cleanup: if(format) { msFreeOutputFormat(format); } return ret; }
void msApplyOutputFormat( outputFormatObj **target, outputFormatObj *format, int transparent, int interlaced, int imagequality ) { int change_needed = MS_FALSE; int old_imagequality, old_interlaced; outputFormatObj *formatToFree = NULL; assert( target != NULL ); if( *target != NULL && MS_REFCNT_DECR_IS_ZERO( (*target) ) ) { formatToFree = *target; *target = NULL; } if( format == NULL ) { if( formatToFree ) msFreeOutputFormat( formatToFree ); *target = NULL; return; } msOutputFormatValidate( format, MS_FALSE ); /* -------------------------------------------------------------------- */ /* Do we need to change any values? If not, then just apply */ /* and return. */ /* -------------------------------------------------------------------- */ if( transparent != MS_NOOVERRIDE && !format->transparent != !transparent ) change_needed = MS_TRUE; old_imagequality = atoi(msGetOutputFormatOption( format, "QUALITY", "75")); if( imagequality != MS_NOOVERRIDE && old_imagequality != imagequality ) change_needed = MS_TRUE; old_interlaced = strcasecmp(msGetOutputFormatOption( format, "INTERLACE", "ON"), "OFF") != 0; if( interlaced != MS_NOOVERRIDE && !interlaced != !old_interlaced ) change_needed = MS_TRUE; if( change_needed ) { char new_value[128]; if( format->refcount > 0 ) format = msCloneOutputFormat( format ); if( transparent != MS_NOOVERRIDE ) { format->transparent = transparent; if( format->imagemode == MS_IMAGEMODE_RGB ) format->imagemode = MS_IMAGEMODE_RGBA; } if( imagequality != MS_NOOVERRIDE && imagequality != old_imagequality ) { snprintf( new_value, sizeof(new_value), "%d", imagequality ); msSetOutputFormatOption( format, "QUALITY", new_value ); } if( interlaced != MS_NOOVERRIDE && !interlaced != !old_interlaced ) { if( interlaced ) msSetOutputFormatOption( format, "INTERLACE", "ON" ); else msSetOutputFormatOption( format, "INTERLACE", "OFF" ); } } *target = format; format->refcount++; if( MS_RENDERER_PLUGIN(format) ) { msInitializeRendererVTable(format); } if( formatToFree ) msFreeOutputFormat( formatToFree ); }
outputFormatObj *msCreateDefaultOutputFormat( mapObj *map, const char *driver, const char *name ) { outputFormatObj *format = NULL; if( strncasecmp(driver,"GD/",3) == 0 ) { return msCreateDefaultOutputFormat( map, "AGG/PNG8", name ); } if( strcasecmp(driver,"UTFGRID") == 0 ) { if(!name) name="utfgrid"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/json"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("json"); format->renderer = MS_RENDER_WITH_UTFGRID; } else if( strcasecmp(driver,"AGG/PNG") == 0 ) { if(!name) name="png24"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_AGG; } else if( strcasecmp(driver,"AGG/PNG8") == 0 ) { if(!name) name="png8"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=8bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_AGG; msSetOutputFormatOption( format, "QUANTIZE_FORCE", "on"); msSetOutputFormatOption( format, "QUANTIZE_COLORS", "256"); } else if( strcasecmp(driver,"AGG/JPEG") == 0 ) { if(!name) name="jpeg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/jpeg"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("jpg"); format->renderer = MS_RENDER_WITH_AGG; } else if( strcasecmp(driver,"AGG/MIXED") == 0 && name != NULL && strcasecmp(name,"jpegpng") == 0 ) { format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/vnd.jpeg-png"); format->imagemode = MS_IMAGEMODE_RGBA; format->extension = msStrdup("XXX"); format->renderer = MS_RENDER_WITH_AGG; msSetOutputFormatOption( format, "OPAQUE_FORMAT", "jpeg"); msSetOutputFormatOption( format, "TRANSPARENT_FORMAT", "png24"); } else if( strcasecmp(driver,"AGG/MIXED") == 0 && name != NULL && strcasecmp(name,"jpegpng8") == 0 ) { format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/vnd.jpeg-png8"); format->imagemode = MS_IMAGEMODE_RGBA; format->extension = msStrdup("XXX"); format->renderer = MS_RENDER_WITH_AGG; msSetOutputFormatOption( format, "OPAQUE_FORMAT", "jpeg"); msSetOutputFormatOption( format, "TRANSPARENT_FORMAT", "png8"); } else if( strcasecmp(driver,"AGG/MIXED") == 0 ) { if(!name) name="mixed"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/mixed"); format->imagemode = MS_IMAGEMODE_RGBA; format->extension = msStrdup("XXX"); format->renderer = MS_RENDER_WITH_AGG; } #if defined(USE_CAIRO) else if( strcasecmp(driver,"CAIRO/PNG") == 0 ) { if(!name) name="cairopng"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=24bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } else if( strcasecmp(driver,"CAIRO/JPEG") == 0 ) { if(!name) name="cairojpeg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/jpeg"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("jpg"); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } else if( strcasecmp(driver,"CAIRO/PDF") == 0 ) { if(!name) name="pdf"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/x-pdf"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("pdf"); format->renderer = MS_RENDER_WITH_CAIRO_PDF; } else if( strcasecmp(driver,"CAIRO/SVG") == 0 ) { if(!name) name="svg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/svg+xml"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("svg"); format->renderer = MS_RENDER_WITH_CAIRO_SVG; } #ifdef _WIN32 else if( strcasecmp(driver,"CAIRO/WINGDI") == 0 ) { if(!name) name="cairowinGDI"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup(""); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup(""); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } else if( strcasecmp(driver,"CAIRO/WINGDIPRINT") == 0 ) { if(!name) name="cairowinGDIPrint"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup(""); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup(""); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } #endif #endif #if defined(USE_OGL) else if( strcasecmp(driver,"OGL/PNG") == 0 ) { if(!name) name="oglpng24"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=24bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_OGL; } #endif #if defined(USE_KML) else if( strcasecmp(driver,"KML") == 0 ) { if(!name) name="kml"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/vnd.google-earth.kml+xml"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("kml"); format->renderer = MS_RENDER_WITH_KML; msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kml"); } else if( strcasecmp(driver,"KMZ") == 0 ) { if(!name) name="kmz"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/vnd.google-earth.kmz"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("kmz"); format->renderer = MS_RENDER_WITH_KML; msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kmz"); } #endif #ifdef USE_GDAL else if( strncasecmp(driver,"gdal/",5) == 0 ) { if(!name) name=driver+5; format = msAllocOutputFormat( map, name, driver ); if( msInitDefaultGDALOutputFormat( format ) == MS_FAILURE ) { if( map != NULL ) { map->numoutputformats--; map->outputformatlist[map->numoutputformats] = NULL; } msFreeOutputFormat( format ); format = NULL; } } #endif #ifdef USE_OGR else if( strncasecmp(driver,"ogr/",4) == 0 ) { if(!name) name=driver+4; format = msAllocOutputFormat( map, name, driver ); if( msInitDefaultOGROutputFormat( format ) == MS_FAILURE ) { if( map != NULL ) { map->numoutputformats--; map->outputformatlist[map->numoutputformats] = NULL; } msFreeOutputFormat( format ); format = NULL; } } #endif else if( strcasecmp(driver,"imagemap") == 0 ) { if(!name) name="imagemap"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("text/html; driver=imagemap"); format->extension = msStrdup("html"); format->imagemode = MS_IMAGEMODE_NULL; format->renderer = MS_RENDER_WITH_IMAGEMAP; } else if( strcasecmp(driver,"template") == 0 ) { if(!name) name="template"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("text/html"); format->extension = msStrdup("html"); format->imagemode = MS_IMAGEMODE_FEATURE; format->renderer = MS_RENDER_WITH_TEMPLATE; } if( format != NULL ) format->inmapfile = MS_FALSE; return format; }
void msOutputFormatResolveFromImage( mapObj *map, imageObj* img ) { outputFormatObj* format = map->outputformat; assert( img->format == format ); assert( img->format->refcount >= 2 ); if( format->renderer == MS_RENDER_WITH_AGG && strcmp(format->driver, "AGG/MIXED") == 0 && (format->imagemode == MS_IMAGEMODE_RGB || format->imagemode == MS_IMAGEMODE_RGBA) ) { outputFormatObj * new_format; int has_non_opaque_pixels = MS_FALSE; const char* underlying_driver_type = NULL; const char* underlying_driver_name = NULL; // Check if the image has non opaque pixels if( format->imagemode == MS_IMAGEMODE_RGBA ) { rasterBufferObj rb; int ret; ret = format->vtable->getRasterBufferHandle(img,&rb); assert( ret == MS_SUCCESS ); if( rb.data.rgba.a ) { int row; for(row=0; row<rb.height && !has_non_opaque_pixels; row++) { int col; unsigned char *a; a=rb.data.rgba.a+row*rb.data.rgba.row_step; for(col=0; col<rb.width && !has_non_opaque_pixels; col++) { if(*a < 255) { has_non_opaque_pixels = MS_TRUE; } a+=rb.data.rgba.pixel_step; } } } } underlying_driver_type = ( has_non_opaque_pixels ) ? "TRANSPARENT_FORMAT" : "OPAQUE_FORMAT"; underlying_driver_name = msGetOutputFormatOption(format, underlying_driver_type, NULL); if( underlying_driver_name == NULL ) { msSetError(MS_MISCERR, "Missing %s format option on %s.", "msOutputFormatResolveFromImage()", underlying_driver_type, format->name ); return; } new_format = msSelectOutputFormat( map, underlying_driver_name ); if( new_format == NULL ) { msSetError(MS_MISCERR, "Cannot find %s output format.", "msOutputFormatResolveFromImage()", underlying_driver_name ); return; } if( new_format->renderer != MS_RENDER_WITH_AGG ) { msSetError(MS_MISCERR, "%s cannot be used as the %s format of %s since it is not AGG based.", "msOutputFormatResolveFromImage()", underlying_driver_name, underlying_driver_type, format->name ); return; } msApplyOutputFormat( &(map->outputformat), new_format, has_non_opaque_pixels, MS_NOOVERRIDE, MS_NOOVERRIDE ); msFreeOutputFormat( format ); img->format = map->outputformat; img->format->refcount ++; } }
void msWriteErrorImage(mapObj *map, char *filename, int blank) { imageObj *img; rendererVTableObj *renderer; int font_index = 0; int width=400, height=300; int nMargin =5; int nTextLength = 0; int nUsableWidth = 0; int nMaxCharsPerLine = 0; int nLines = 0; int i = 0; int nStart = 0; int nEnd = 0; int nLength = 0; char **papszLines = NULL; int nXPos = 0; int nYPos = 0; int nWidthTxt = 0; outputFormatObj *format = NULL; char *errormsg = msGetErrorString("; "); fontMetrics *font = NULL; char *imagepath = NULL, *imageurl = NULL; labelStyleObj ls; colorObj labelcolor, labeloutlinecolor, imagecolor, *imagecolorptr=NULL; ls.color = &labelcolor; ls.outlinecolor = &labeloutlinecolor; if (map) { if( map->width > 0 && map->height > 0 ) { width = map->width; height = map->height; } format = map->outputformat; imagepath = map->web.imagepath; imageurl = map->web.imageurl; } /* Default to GIF if no suitable GD output format set */ if (format == NULL || !MS_RENDERER_PLUGIN(format) || !format->vtable->supports_bitmap_fonts) format = msCreateDefaultOutputFormat( NULL, "GD/PC256", "gif" ); if(!format->transparent) { if(map && MS_VALID_COLOR(map->imagecolor)) { imagecolorptr = &map->imagecolor; } else { MS_INIT_COLOR(imagecolor,255,255,255,255); imagecolorptr = &imagecolor; } } img = msImageCreate(width,height,format,imagepath,imageurl,MS_DEFAULT_RESOLUTION,MS_DEFAULT_RESOLUTION,imagecolorptr); renderer = MS_IMAGE_RENDERER(img); for(i=0; i<5; i++) { /* use the first font we find */ if((font = renderer->bitmapFontMetrics[font_index]) != NULL) { ls.size = i; MS_INIT_COLOR(*ls.color,0,0,0,255); MS_INIT_COLOR(*ls.outlinecolor,255,255,255,255); break; } } /* if no font found we can't do much. this shouldn't happen */ if(font) { nTextLength = strlen(errormsg); nWidthTxt = nTextLength * font->charWidth; nUsableWidth = width - (nMargin*2); /* Check to see if it all fits on one line. If not, split the text on several lines. */ if(!blank) { if (nWidthTxt > nUsableWidth) { nMaxCharsPerLine = nUsableWidth/font->charWidth; nLines = (int) ceil ((double)nTextLength / (double)nMaxCharsPerLine); if (nLines > 0) { papszLines = (char **)malloc(nLines*sizeof(char *)); for (i=0; i<nLines; i++) { papszLines[i] = (char *)malloc((nMaxCharsPerLine+1)*sizeof(char)); papszLines[i][0] = '\0'; } } for (i=0; i<nLines; i++) { nStart = i*nMaxCharsPerLine; nEnd = nStart + nMaxCharsPerLine; if (nStart < nTextLength) { if (nEnd > nTextLength) nEnd = nTextLength; nLength = nEnd-nStart; strncpy(papszLines[i], errormsg+nStart, nLength); papszLines[i][nLength] = '\0'; } } } else { nLines = 1; papszLines = (char **)malloc(nLines*sizeof(char *)); papszLines[0] = msStrdup(errormsg); } for (i=0; i<nLines; i++) { nYPos = (font->charHeight) * ((i*2) +1); nXPos = font->charWidth;; renderer->renderBitmapGlyphs(img, nXPos, nYPos, &ls, papszLines[i]); } if (papszLines) { for (i=0; i<nLines; i++) { free(papszLines[i]); } free(papszLines); } } } /* actually write the image */ if(!filename) { msIO_setHeader("Content-type","%s", MS_IMAGE_MIME_TYPE(format)); msIO_sendHeaders(); } msSaveImage(NULL,img,filename); msFreeImage(img); if (format->refcount == 0) msFreeOutputFormat(format); msFree(errormsg); }
void msFreeMap(mapObj *map) { int i; if(!map) return; /* printf("msFreeMap(): maybe freeing map at %p count=%d.\n",map, map->refcount); */ if(MS_REFCNT_DECR_IS_NOT_ZERO(map)) { return; } if(map->debug >= MS_DEBUGLEVEL_VV) msDebug("msFreeMap(): freeing map at %p.\n",map); msCloseConnections(map); msFree(map->name); msFree(map->shapepath); msFree(map->mappath); msFreeProjection(&(map->projection)); msFreeProjection(&(map->latlon)); msFreeLabelCache(&(map->labelcache)); msFree(map->imagetype); msFreeFontSet(&(map->fontset)); msFreeSymbolSet(&map->symbolset); /* free symbols */ msFree(map->symbolset.filename); freeWeb(&(map->web)); freeScalebar(&(map->scalebar)); freeReferenceMap(&(map->reference)); freeLegend(&(map->legend)); for(i=0; i<map->maxlayers; i++) { if(GET_LAYER(map, i) != NULL) { GET_LAYER(map, i)->map = NULL; if(freeLayer((GET_LAYER(map, i))) == MS_SUCCESS) free(GET_LAYER(map, i)); } } msFree(map->layers); if(map->layerorder) free(map->layerorder); msFree(map->templatepattern); msFree(map->datapattern); msFreeHashItems(&(map->configoptions)); if(map->outputformat && map->outputformat->refcount > 0 && --map->outputformat->refcount < 1) msFreeOutputFormat(map->outputformat); for(i=0; i<map->numoutputformats; i++ ) { if(map->outputformatlist[i]->refcount > 0 && --map->outputformatlist[i]->refcount < 1) msFreeOutputFormat(map->outputformatlist[i]); } if(map->outputformatlist != NULL) msFree(map->outputformatlist); msFreeQuery(&(map->query)); #ifdef USE_V8_MAPSCRIPT if (map->v8context) msV8FreeContext(map); #endif msFree(map); }
outputFormatObj *msCreateDefaultOutputFormat( mapObj *map, const char *driver, const char *name ) { outputFormatObj *format = NULL; if( strcasecmp(driver,"GD/PC256") == 0 ) { #ifdef USE_GD_GIF return msCreateDefaultOutputFormat( map, "GD/GIF", "gif" ); #elif defined(USE_GD_PNG) return msCreateDefaultOutputFormat( map, "GD/PNG", "gdpng" ); #else return NULL; #endif } #ifdef USE_GD_GIF if( strcasecmp(driver,"GD/GIF") == 0 ) { if(!name) name="gif"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/gif"); format->imagemode = MS_IMAGEMODE_PC256; format->extension = msStrdup("gif"); format->renderer = MS_RENDER_WITH_GD; } #endif #ifdef USE_GD_PNG if( strcasecmp(driver,"GD/PNG") == 0 ) { if(!name) name="gdpng"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png"); format->imagemode = MS_IMAGEMODE_PC256; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_GD; } #endif /* USE_GD_PNG */ if( strcasecmp(driver,"AGG/PNG") == 0 ) { if(!name) name="png24"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_AGG; } if( strcasecmp(driver,"AGG/PNG8") == 0 ) { if(!name) name="png8"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=8bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_AGG; msSetOutputFormatOption( format, "QUANTIZE_FORCE", "on"); msSetOutputFormatOption( format, "QUANTIZE_COLORS", "256"); } if( strcasecmp(driver,"AGG/JPEG") == 0 ) { if(!name) name="jpeg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/jpeg"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("jpg"); format->renderer = MS_RENDER_WITH_AGG; } #if defined(USE_CAIRO) if( strcasecmp(driver,"CAIRO/PNG") == 0 ) { if(!name) name="cairopng"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=24bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } if( strcasecmp(driver,"CAIRO/JPEG") == 0 ) { if(!name) name="cairojpeg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/jpeg"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("jpg"); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } if( strcasecmp(driver,"CAIRO/PDF") == 0 ) { if(!name) name="pdf"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/x-pdf"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("pdf"); format->renderer = MS_RENDER_WITH_CAIRO_PDF; } if( strcasecmp(driver,"CAIRO/SVG") == 0 ) { if(!name) name="svg"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/svg+xml"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("svg"); format->renderer = MS_RENDER_WITH_CAIRO_SVG; } #ifdef _WIN32 if( strcasecmp(driver,"CAIRO/WINGDI") == 0 ) { if(!name) name="cairowinGDI"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup(""); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup(""); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } if( strcasecmp(driver,"CAIRO/WINGDIPRINT") == 0 ) { if(!name) name="cairowinGDIPrint"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup(""); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup(""); format->renderer = MS_RENDER_WITH_CAIRO_RASTER; } #endif #endif #if defined(USE_OGL) if( strcasecmp(driver,"OGL/PNG") == 0 ) { if(!name) name="oglpng24"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("image/png; mode=24bit"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("png"); format->renderer = MS_RENDER_WITH_OGL; } #endif #if defined(USE_KML) if( strcasecmp(driver,"KML") == 0 ) { if(!name) name="kml"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("application/vnd.google-earth.kml+xml"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = msStrdup("kml"); format->renderer = MS_RENDER_WITH_KML; msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kml"); } if( strcasecmp(driver,"KMZ") == 0 ) { if(!name) name="kmz"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = strdup("application/vnd.google-earth.kmz"); format->imagemode = MS_IMAGEMODE_RGB; format->extension = strdup("kmz"); format->renderer = MS_RENDER_WITH_KML; msSetOutputFormatOption( format, "ATTACHMENT", "mapserver.kmz"); } #endif #ifdef USE_GDAL if( strncasecmp(driver,"gdal/",5) == 0 ) { if(!name) name=driver+5; format = msAllocOutputFormat( map, name, driver ); if( msInitDefaultGDALOutputFormat( format ) == MS_FAILURE ) { if( map != NULL ) { map->numoutputformats--; map->outputformatlist[map->numoutputformats] = NULL; } msFreeOutputFormat( format ); format = NULL; } } #endif #ifdef USE_OGR if( strncasecmp(driver,"ogr/",4) == 0 ) { if(!name) name=driver+4; format = msAllocOutputFormat( map, name, driver ); if( msInitDefaultOGROutputFormat( format ) == MS_FAILURE ) { if( map != NULL ) { map->numoutputformats--; map->outputformatlist[map->numoutputformats] = NULL; } msFreeOutputFormat( format ); format = NULL; } } #endif if( strcasecmp(driver,"imagemap") == 0 ) { if(!name) name="imagemap"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("text/html; driver=imagemap"); format->extension = msStrdup("html"); format->imagemode = MS_IMAGEMODE_NULL; format->renderer = MS_RENDER_WITH_IMAGEMAP; } if( strcasecmp(driver,"template") == 0 ) { if(!name) name="template"; format = msAllocOutputFormat( map, name, driver ); format->mimetype = msStrdup("text/html"); format->extension = msStrdup("html"); format->imagemode = MS_IMAGEMODE_FEATURE; format->renderer = MS_RENDER_WITH_TEMPLATE; } if( format != NULL ) format->inmapfile = MS_FALSE; return format; }