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

Function saveGdImage

mapimageio.c:802–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802int saveGdImage(gdImagePtr ip, FILE *fp, outputFormatObj *format) {
803 gdIOCtx *ctx = NULL;
804
805 if (fp && (fp == stdout))
806 ctx = msIO_getGDIOCtx( fp );
807
808 if(strcasecmp("ON", msGetOutputFormatOption(format, "INTERLACE", "ON")) == 0)
809 gdImageInterlace(ip, 1);
810
811 if(format->transparent)
812 gdImageColorTransparent(ip, 0);
813
814 if(strcasestr(format->driver, "/gif")) {
815#ifdef USE_GD_GIF
816 if (ctx)
817 gdImageGifCtx(ip, ctx);
818 else
819 gdImageGif(ip, fp);
820#else
821 msSetError(MS_MISCERR, "GIF output is not available.", "saveImageGD()");
822 return(MS_FAILURE);
823#endif
824 } else if(strcasestr(format->driver, "/png")) {
825#ifdef USE_GD_PNG
826 if (ctx)
827 gdImagePngCtx(ip, ctx);
828 else
829 gdImagePng(ip, fp);
830#else
831 msSetError(MS_MISCERR, "PNG output is not available.", "saveImageGD()");
832 return(MS_FAILURE);
833#endif
834 } else if(strcasestr(format->driver, "/jpeg")) {
835#ifdef USE_GD_JPEG
836 if (ctx)
837 gdImageJpegCtx(ip, ctx, atoi(msGetOutputFormatOption( format, "QUALITY", "75")));
838 else
839 gdImageJpeg(ip, fp, atoi(msGetOutputFormatOption( format, "QUALITY", "75")));
840#else
841 msSetError(MS_MISCERR, "JPEG output is not available.", "saveImageGD()");
842 return(MS_FAILURE);
843#endif
844 } else {
845 msSetError(MS_MISCERR, "Unknown or unsupported format.", "saveImageGD()");
846 return(MS_FAILURE);
847 }
848 msFree(ctx);
849
850 return MS_SUCCESS;
851}
852
853int saveGdImageBuffer(gdImagePtr ip, bufferObj *buffer, outputFormatObj *format) {
854 gdIOCtx *ctx;

Callers 2

saveImageGDFunction · 0.85
msSaveRasterBufferFunction · 0.85

Calls 6

msIO_getGDIOCtxFunction · 0.85
strcasecmpFunction · 0.85
msGetOutputFormatOptionFunction · 0.85
strcasestrFunction · 0.85
msSetErrorFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected