<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [UMN_MAPSERVER-USERS] Mapserver Color Binding: Blue and Green swapped (bug?)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Thanks, Milo. But I am confident that I converted my colours correctly out of MapInfo. My resulting RGB values are what they should be for the colour it should draw. Just that it draws it based on RBG. Which makes sense, looking at the code snipped that Frank supplied. It clearly uses the second value for blue, and the third for green.<BR>
<BR>
Regards,<BR>
<BR>
Jacob<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: UMN MapServer Users List on behalf of Milo van der Linden<BR>
Sent: Thu 11/1/2007 14:49<BR>
To: MAPSERVER-USERS@LISTS.UMN.EDU<BR>
Subject: Re: [UMN_MAPSERVER-USERS] Mapserver Color Binding: Blue and Green swapped (bug?)<BR>
<BR>
Extra note:<BR>
<BR>
MapInfo uses a large integer to describe it's internaly used colors.<BR>
Here is a C# function to convert MapInfo color code to RGB: as you can<BR>
see, the MapInfo color code is in format BGR instead of RGB.<BR>
<BR>
Maybe this has to do with your problem?<BR>
<BR>
<BR>
&nbsp;private static Color miColorCodeToRGB(Int32 miColorCode)<BR>
&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iRed;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iGreen;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 iBlue;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 _miColorCode;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _miColorCode = miColorCode;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //lColor = lColor \ &amp;H100&nbsp; 'divide<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //iGreen = lColor Mod &amp;H100 'get green component<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iRed = _miColorCode % 0x100;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _miColorCode = _miColorCode / 0x100;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iGreen = _miColorCode % 0x100;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _miColorCode = _miColorCode / 0x100;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iBlue = _miColorCode % 0x100;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Color _Color = Color.FromArgb(255,iBlue, iGreen, iRed);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return _Color;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Color.Transparent;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
<BR>
Frank Warmerdam schreef:<BR>
&gt; Delfos, Jacob wrote:<BR>
&gt;&gt; Hi List<BR>
&gt;&gt;<BR>
&gt;&gt; I am trying to make use of the colour binding feature, and it<BR>
&gt;&gt; basically works, except... the colours are not quite right. My<BR>
&gt;&gt; colours do not match those in MapInfo, although I can make MapInfo<BR>
&gt;&gt; emulate the MapServer colours by swapping blue and green around. So<BR>
&gt;&gt; basically: my RGB values are interpreted by MapServer as RBG.<BR>
&gt;&gt;<BR>
&gt;&gt; This happens for polygons as well as lines (haven't tried points). My<BR>
&gt;&gt; data has been translated from MapInfo to PostGIS.<BR>
&gt;&gt;<BR>
&gt;&gt; I tried to lodge a bug in Trac, but it says &quot;TICKET_CREATE privileges<BR>
&gt;&gt; are required to perform this operation&quot;<BR>
&gt;&gt;<BR>
&gt;&gt; Does anyone know more about this colour problem?<BR>
&gt;<BR>
&gt; Jacob,<BR>
&gt;<BR>
&gt; With some pointers from Howard, I found this segment of code in<BR>
&gt; bindColorAttribute() in maputil.c:<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; attribute-&gt;red = atoi(tokens[0]);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; attribute-&gt;blue = atoi(tokens[1]);<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; attribute-&gt;green = atoi(tokens[2]);<BR>
&gt;<BR>
&gt;<BR>
&gt; I think this is responsible.&nbsp; If you are building from source, try just<BR>
&gt; changing it to the more obvious organization.&nbsp; I'd also suggest you<BR>
&gt; file a bug in Trac on the issue we will see if there is a subtle reason<BR>
&gt; for this, or it's just a typo.<BR>
&gt;<BR>
&gt; To file bugs you need an OSGeo Userid.&nbsp; The pointer to get an osgeo<BR>
&gt; userid which you can use to login with is under the title &quot;Important<BR>
&gt; Notice&quot; on the <A HREF="http://trac.osgeo.org/mapserver">http://trac.osgeo.org/mapserver</A> page.&nbsp; The same userid<BR>
&gt; can be used for other OSGeo services like subversion, and other<BR>
&gt; trac instances (like GDAL's).<BR>
&gt;<BR>
&gt; Best regards,<BR>
<BR>
<BR>
--<BR>
<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
<BR>
Milo van der Linden<BR>
skype: milovanderlinden &lt;skype:milovanderlinden?add&gt;<BR>
mlinden@zeelandnet.nl &lt;<A HREF="mailto:mlinden@zeelandnet.nl">mailto:mlinden@zeelandnet.nl</A>&gt;<BR>
milovanderlinden@gmail.com &lt;<A HREF="mailto:milovanderlinden@gmail.com">mailto:milovanderlinden@gmail.com</A>&gt;<BR>
milo@3dsite.nl &lt;<A HREF="mailto:milo@3dsite.nl">mailto:milo@3dsite.nl</A>&gt;<BR>
<A HREF="http://www.3dsite.nl">http://www.3dsite.nl</A><BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
<BR>
De informatie in dit bericht reflecteert mijn persoonlijke mening en<BR>
niet die van een bedrijf of instantie. Aan de informatie kunnen geen<BR>
rechten worden ontleend. Indien dit bericht onderdeel is van een forum,<BR>
mailing-list of community dan gelden automatisch de bij het betreffende<BR>
medium behorende voorwaarden. The information in this message reflects<BR>
my personal opinion and not that of a company or public body. All rights<BR>
reserved.If this message is contained in a mailing-list or community,<BR>
the rights on the medium are automatically adapted.<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>