Transparent pixmaps in Mapserver 4.4.1

Sean Gillies sgillies at FRII.COM
Thu Jan 27 17:21:41 EST 2005


On Jan 27, 2005, at 3:13 PM, Camden Daily wrote:

> I'm having difficulties displaying pngs with transparent backgrounds
> as symbols in 4.4.1.  I've read up on the bugs regarding this issue,
> and the fix appears to be to add the line "TRANSPARENCY ALPHA" to the
> layer containing the transparent symbols.
>
> I draw my layer that contains my symbols using mapscript like this:
>
> // create a temp layer to hold our points
> $point_layer = ms_newLayerObj($map);
> $point_layer->set("name", "markers");
> $point_layer->set("type", MS_LAYER_POINT);
> $point_layer->set("status", MS_DEFAULT);
> // 1000 is the value used to set transparency to "alpha"
> $point_layer->set("transparency", 1000);
>
> // create a class and style for this layer
> $point_class = ms_newClassObj($point_layer);
> $point_style = ms_newStyleObj($point_class);
> $point_symbol = $map->getSymbolByName("house");
> $point_style->set("symbol", $point_symbol);
> $point_style->set("size", 40);
>
> I had to dig a little to find out that transparency of 1000 = alpha
> (maybe need to define MS_ALPHA=1000 in mapscript?).  The layer
> displays fine, but the symbol backgrounds aren't transparent.
>

Camden, the PHP mapscript maintainers may have overlooked MS_ALPHA.
Let them know through Bugzilla.  At any rate, the alpha transparency is
only needed when you are trying to render a transparent background
symbol onto a 24-bit map (like a JPEG).  It has no positive effect for
8-bit output (such as a GIF).  In that case, you should make sure that
your symbol background is set properly and omit the transparency
directive.

cheers,
Sean

--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list