[mapserver-dev] transparent color
Stephen Woodbridge
woodbri at swoodbridge.com
Sat Mar 27 20:05:28 EDT 2010
Frank Warmerdam wrote:
> 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.
Frank,
It is my understanding the -1 -1 -1 in the vector code just uses the
underlying color, ie: it does not set a new color for the pixel. This is
how we draw a "transparent" polygon where OUTLINECOLOR is set to a valid
color and you only get the outline and the polygon does not blot out the
underlying image.
I may have propagated the notion that this was "transparent" but maybe
there is a better name for this.
Behaviorally what is the difference between INVALID and TRANSPARENT. I
would assume that a true transparent color would "tint" the area with
its color while allowing the underlying colors to show through. This
would be the behavior of using the Alpha channel.
I believe the alpha channel stuff was added as part of the AGG code.
-Steve W
> 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,
More information about the mapserver-dev
mailing list