Skip to content
Snippets Groups Projects
Commit 814f23cc authored by Per Hedbor's avatar Per Hedbor
Browse files

Even better color space search support. Now it starts to search in _worse_...

Even better color space search support. Now it starts to search in _worse_ colorspaces than the one requested if there is no color for the wanted colorspace.

Rev: lib/modules/_Image_XPM.pmod:1.3
parent 24cee32f
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,31 @@ static mapping parse_color( array color ) ...@@ -4,13 +4,31 @@ static mapping parse_color( array color )
for(int i=0; i<sizeof(color); i+=2 ) for(int i=0; i<sizeof(color); i+=2 )
if(lower_case(color[i+1]) != "none") if(lower_case(color[i+1]) != "none")
res[color[i]] = Colors.parse_color( color[i+1] ); res[color[i]] = Colors.parse_color( color[i+1] );
return res; return sizeof(res)?res:0;
} }
static array find_color( mapping in, string space ) static array find_color( mapping in, string space )
{ {
return in && (in[space||"s"] || in->c || in->g || in->g4 || in->m); if(!in) return 0;
} switch(space)
{
default:
case "s":
if(in->s) return in->s;
case "c":
if(in->c) return in->c;
case "g":
if(in->g) return in->g;
case "g4":
if(in->g4) return in->g4;
case "m":
if(in->m) return in->m;
if(in->s) return in->s;
}
if(sizeof(in))
return values(in)[0];
return 0;
}
mapping _decode( string what, void|mapping opts ) mapping _decode( string what, void|mapping opts )
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment