Transparent pixmaps in Mapserver 4.4.1

Sean Gillies sgillies at FRII.COM
Fri Jan 28 13:39:08 EST 2005


On Jan 28, 2005, at 11:31 AM, Camden Daily wrote:

> The problem ended up being with the way I was drawing my points in
> mapscript.  I had been drawing the image first, and then placing the
> points over it like this:
>
> // draw our image without the points
> $image = $map->draw();
> // add our point to the map
> $point->draw($map, $point_layer, $image, 0, "");
>
> But I guess since the rest of the map was drawn first, the transparent
> point symbols wouldn't actually be made transparent.
>
> I fixed it by instead creating a dummy layer and adding my points as
> features to it and then drawing the map, 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_ON);
> // 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);
>
> // set the symbol we'll use for our points
> $point_symbol = $map->getSymbolByName("house");
> $point_style->set("symbol", $point_symbol);
> $point_style->set("size", 40);
>
> $point_line = ms_newLineObj();
> $point_line->add($point);
> $point_shape = ms_newShapeObj(MS_SHAPE_POINT);
> $point_shape->add($point_line);
> $point_layer->addFeature($point_shape);
>
> // draw our image
> $image = $map->draw();
>
> And it works like a charm!  Thanks for all the help Sean.  I entered a
> mapscript bugzilla about the alpha value, and it appears MS_GD_ALPHA
> has been added as the new constant value for setting the transparency
> level.
>
>

You're welcome.

Sean

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



More information about the mapserver-users mailing list