MCPcopy Index your code
hub / github.com/MapServer/MapServer / msOutputFormatValidate

Function msOutputFormatValidate

mapoutput.c:1000–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

998/************************************************************************/
999
1000int msOutputFormatValidate( outputFormatObj *format, int issue_error )
1001
1002{
1003 int result = MS_TRUE;
1004 char *driver_ext;
1005
1006 format->bands = atoi(msGetOutputFormatOption( format, "BAND_COUNT", "1" ));
1007
1008 /* Enforce the requirement that JPEG be RGB and TRANSPARENT=OFF */
1009 driver_ext = strstr(format->driver,"/");
1010 if( driver_ext && ++driver_ext && !strcasecmp(driver_ext,"JPEG")) {
1011 if( format->transparent ){
1012 if( issue_error )
1013 msSetError( MS_MISCERR,
1014 "JPEG OUTPUTFORMAT %s has TRANSPARENT set ON, but this is not supported.\n"
1015 "It has been disabled.\n",
1016 "msOutputFormatValidate()", format->name );
1017 else
1018 msDebug( "JPEG OUTPUTFORMAT %s has TRANSPARENT set ON, but this is not supported.\n"
1019 "It has been disabled.\n",
1020 format->name );
1021
1022 format->transparent = MS_FALSE;
1023 result = MS_FALSE;
1024 }
1025 if( format->imagemode == MS_IMAGEMODE_RGBA )
1026 {
1027 if( issue_error )
1028 msSetError( MS_MISCERR,
1029 "JPEG OUTPUTFORMAT %s has IMAGEMODE RGBA, but this is not supported.\n"
1030 "IMAGEMODE forced to RGB.\n",
1031 "msOutputFormatValidate()", format->name );
1032 else
1033 msDebug( "JPEG OUTPUTFORMAT %s has IMAGEMODE RGBA, but this is not supported.\n"
1034 "IMAGEMODE forced to RGB.\n",
1035 format->name );
1036
1037 format->imagemode = MS_IMAGEMODE_RGB;
1038 result = MS_FALSE;
1039 }
1040 }
1041
1042 if( format->transparent && format->imagemode == MS_IMAGEMODE_RGB )
1043 {
1044 if( issue_error )
1045 msSetError( MS_MISCERR,
1046 "OUTPUTFORMAT %s has TRANSPARENT set ON, but an IMAGEMODE\n"
1047 "of RGB instead of RGBA. Changing imagemode to RGBA.\n",
1048 "msOutputFormatValidate()", format->name );
1049 else
1050 msDebug("OUTPUTFORMAT %s has TRANSPARENT set ON, but an IMAGEMODE\n"
1051 "of RGB instead of RGBA. Changing imagemode to RGBA.\n",
1052 format->name );
1053
1054 format->imagemode = MS_IMAGEMODE_RGBA;
1055 result = MS_FALSE;
1056 }
1057

Callers 4

msSelectOutputFormatFunction · 0.85
msApplyOutputFormatFunction · 0.85
loadOutputFormatFunction · 0.85
outputformat.cFile · 0.85

Calls 4

msGetOutputFormatOptionFunction · 0.85
strcasecmpFunction · 0.85
msSetErrorFunction · 0.85
msDebugFunction · 0.85

Tested by

no test coverage detected