MCPcopy Create free account
hub / github.com/MapServer/MapServer / msSaveImageIM

Function msSaveImageIM

mapimagemap.c:1976–2069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1974 */
1975
1976int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format )
1977
1978{
1979 FILE *stream;
1980 char workbuffer[5000];
1981 int nSize=0, size=0, iIndice=0;
1982
1983DEBUG_IF printf("msSaveImageIM\n<BR>");
1984
1985if(filename != NULL && strlen(filename) > 0) {
1986 stream = fopen(filename, "wb");
1987 if(!stream) {
1988 msSetError(MS_IOERR, "(%s)", "msSaveImage()", filename);
1989 return(MS_FAILURE);
1990 }
1991 } else { /* use stdout */
1992
1993#ifdef _WIN32
1994 /*
1995 * Change stdout mode to binary on win32 platforms
1996 */
1997 if(_setmode( _fileno(stdout), _O_BINARY) == -1) {
1998 msSetError(MS_IOERR, "Unable to change stdout to binary mode.", "msSaveImage()");
1999 return(MS_FAILURE);
2000 }
2001#endif
2002 stream = stdout;
2003 }
2004
2005/* if( strcasecmp("ON",msGetOutputFormatOption( format, "INTERLACE", "ON" ))
2006 == 0 )
2007 gdImageInterlace(img, 1);
2008
2009 if(format->transparent)
2010 gdImageColorTransparent(img, 0);
2011*/
2012 if( strcasecmp(format->driver,"imagemap") == 0 )
2013 {
2014DEBUG_IF printf("ALLOCD %d<BR>\n", img->size);
2015/* DEBUG_IF printf("F %s<BR>\n", img->img.imagemap); */
2016DEBUG_IF printf("FLEN %d<BR>\n", (int)strlen(img->img.imagemap));
2017 if (dxf == 2){
2018 msIO_fprintf(stream, "%s", layerlist);
2019 } else if (dxf){
2020 msIO_fprintf(stream, " 0\nSECTION\n 2\nHEADER\n 9\n$ACADVER\n 1\nAC1009\n0\nENDSEC\n 0\nSECTION\n 2\nTABLES\n 0\nTABLE\n%s0\nENDTAB\n0\nENDSEC\n 0\nSECTION\n 2\nBLOCKS\n0\nENDSEC\n 0\nSECTION\n 2\nENTITIES\n", layerlist);
2021 } else {
2022 msIO_fprintf(stream, "<map name=\"%s\" width=\"%d\" height=\"%d\">\n", mapName, img->width, img->height);
2023 }
2024 nSize = sizeof(workbuffer);
2025
2026 size = strlen(img->img.imagemap);
2027 if (size > nSize)
2028 {
2029 iIndice = 0;
2030 while ((iIndice + nSize) <= size)
2031 {
2032 snprintf(workbuffer, sizeof(workbuffer), "%s", img->img.imagemap+iIndice );
2033 workbuffer[nSize-1] = '\0';

Callers 1

msSaveImageFunction · 0.85

Calls 5

msSetErrorFunction · 0.85
strcasecmpFunction · 0.85
msIO_fprintfFunction · 0.85
msIO_fwriteFunction · 0.85
msGetOutputFormatOptionFunction · 0.85

Tested by

no test coverage detected