[mapserver-dev] transparent color

Frank Warmerdam warmerdam at pobox.com
Sat Mar 27 16:46:48 EDT 2010


Folks,

In bug 1806 there is a report that COLOR -1 -1 -1 is not being treated as
transparent when classifying raster data. Investigating I find that the
code is checking for transparent as -255 -255 -255 using:

#define MS_TRANSPARENT_COLOR(color) (((color).red==-255 || (color).green==-255 
|| (color).blue==-255)?MS_TRUE:MS_FALSE)

In fact, -1 -1 -1 is the default value to which colors are initialized
and it is considered "invalid" according to:

#define MS_VALID_COLOR(color) (((color).red==-1 || (color).green==-1 || 
(color).blue==-1)?MS_FALSE:MS_TRUE)

I have found no material discussing such color values in the reference
documentation, though the mapserver tutorial does suggest using -1 -1 -1
as a color for classified data to make it transparent.

The vector code likely does effectively treat this as transparent, but
the raster code treats invalid, but not transparent as a special case meaning
use the underlying color of the raster data instead of applying a color
based on classification.  I hesitate to break this capability by treating
invalid as transparent.

Also,  I find in the mapsymbol.h include file that colorObj now has an
alpha field.  I'm not clear on how widely this is being used, or whether it
is intended to be the "future" of transparency.

Should we document -255 -255 -255 as transparent? Promote use of alpha?

Feedback is welcome!

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-dev mailing list