[Mapserver-users] RE: Color not accurate in dynamic layer.

Sean Gillies sgillies at frii.com
Sat Nov 29 15:11:22 EST 2003


On Saturday, November 29, 2003, at 11:08  AM, YC Nyon wrote:

> Hi,
>
> My application plots points dynamically from a database. The user can 
> select
> the color and symbol used.
> All is fine.
>
> However, the color is not accurate when they are other layers switched 
> on.
> These layers also has labels with the use of buffer and outlines 
> colors.
> My point that should be green turn out to be grey. When I zoom in, the 
> color
> is green. I'm think there is somethiing with the PNG color table. If i 
> set
> the output to jpeg, everything is correct.
>
> Anyone encountered this before? Using PHP-MS 4.0 on windows.
>
> regards
> Nyon
> <wrong_color.png><correct_color.png>

Nyon,

There are three entries in Bugzilla which may be related:

http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=306
http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=397
http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=475

It may be that the 8-bit color palette for your PNG is already filled
when it comes time to draw the symbol.  You may not think that you are
using many colors because you only have 2 layers ... the culprit is
the antialiasing you use for the country labels.  Examine them closely
and you will see that there are many many different colors used.  In
the image you named 'wrong_color.png', the labels have exhausted the
color palette and so GD is limited to choosing an existing color instead
of green.  No label appears for the grey triangle because MapServer
cannot add white to the palette and is using the map's background color.
In the second image you provide, the labels have not quite
exhausted the palette and so a green color can be added.

One solution would be to draw the point with its symbol and label
before you draw and label the countries.  This means raising it in
the order of layers within the map file.  Not a great solution,
particularly if you need these symbols to be drawn over the
countries, but should work.

Another solution that has occurred to me is that you could define a
new layer in your map file, make it the first layer, and define
for it a class and style that use the same green color that you
want to use layer for your points.  This would serve the purpose of
getting that color into the palette early before all the available
colors are taken by the antialiased labels.

cheers,
Sean

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




More information about the mapserver-users mailing list