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

Function LutFromGimpLine

mapdrawgdal.c:1212–1255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1210/************************************************************************/
1211
1212static int LutFromGimpLine( char *lut_line, GByte *lut )
1213
1214{
1215 char wrkLUTDef[1000];
1216 int i, count = 0;
1217 char **tokens;
1218
1219 /* cleanup white space at end of line (DOS LF, etc) */
1220 i = strlen(lut_line) - 1;
1221 while( i > 0 && isspace(lut_line[i]) )
1222 lut_line[i--] = '\0';
1223
1224 while( *lut_line == 10 || *lut_line == 13 )
1225 lut_line++;
1226
1227 /* tokenize line */
1228 tokens = CSLTokenizeString( lut_line );
1229 if( CSLCount(tokens) != 17 * 2 )
1230 {
1231 CSLDestroy( tokens );
1232 msSetError(MS_MISCERR,
1233 "GIMP curve file appears corrupt.",
1234 "LutFromGimpLine()" );
1235 return -1;
1236 }
1237
1238 /* Convert to our own format */
1239 wrkLUTDef[0] = '\0';
1240 for( i = 0; i < 17; i++ )
1241 {
1242 if( atoi(tokens[i*2]) >= 0 )
1243 {
1244 if( count++ > 0 )
1245 strlcat( wrkLUTDef, ",", sizeof(wrkLUTDef));
1246
1247 snprintf( wrkLUTDef + strlen(wrkLUTDef), sizeof(wrkLUTDef)-strlen(wrkLUTDef),
1248 "%s:%s", tokens[i*2], tokens[i*2+1] );
1249 }
1250 }
1251
1252 CSLDestroy( tokens );
1253
1254 return ParseDefaultLUT( wrkLUTDef, lut );
1255}
1256
1257/************************************************************************/
1258/* ParseGimpLUT() */

Callers 1

ParseGimpLUTFunction · 0.85

Calls 3

msSetErrorFunction · 0.85
strlcatFunction · 0.85
ParseDefaultLUTFunction · 0.85

Tested by

no test coverage detected