[mapserver-users] hue, saturation, value -> RGB

Michael Schulz mschulz at webgis.de
Thu Jun 6 06:40:32 PDT 2002


Hi,

below is a snipplet avenue-code, that we use to get the RGB-Values of classified
legends. Perhaps your client can use it to give you the RGB-Values: Basically,
you use it on a LegendObj to get the Symbols, then get the colors as a list of
rgb int values and e.g. write it to a textfile.

--- snip
  theClassesList = theLegend.GetClassifications
  symbols = theLegend.GetSymbols
  n = theClassesList.Count-1
  d = Dictionary.Make(0)
  for each e in 0..n
    aClass = theClassesList.Get(e)
    aSymbol = symbols.get(e)
    aColor = aSymbol.getColor.getRGBList
    R = aColor.get(0).asString
    G = aColor.get(1).asString
    B = aColor.get(2).asString
    aString = R+" "+G+" "+B
    aTextfile.WriteElt(aString)
    d.add (akey.Asstring, {aLabel,symbols.get(e)})
  end
---snip

HTH, Cheers, Michael


"Hankley, Chip" schrieb:

> Unfortunately they are built in functions that do the RGB<->HSV conversions.
> I've never tried this, but you might be able to manually convert the values
> from the ArcView flavor of HSV to the Photoshop flavor of HSV.
>
> So, for instance, in PS (and strangely ArcInfo...why they didn't use the
> same color model is beyond me) H is 0-360, and S and V are both 0 to 100.
>
> So, say you have an AV HSV color specified as 255 255 255
>
> This should be equivalent to a PS value of
>   H: 360 (or 0)
>   S: 100
>   V: 100
>
> Your formula for the conversion should be:
>
>   H_PS = (H_AV / 255) * 360
>   S_PS = (S_AV / 255) * 100
>   V_PS = (V_AV / 255) * 100
>
> where H_PS is the HUE value in Photoshop, and H_AV is the HUE value in
> ArcView, and so on.
>
> If you've got a long list, you could do all the conversions in a
> spreadsheet, then move over to PS.
>
> Hope that helps!
>
> Chip
>
> -----Original Message-----
> From: Pushkar Pradhan [mailto:pushkar at ERC.MsState.Edu]
> Sent: Wednesday, June 05, 2002 12:40 PM
> To: Hankley, Chip
> Cc: mapserver-users at lists.gis.umn.edu
> Subject: RE: [mapserver-users] hue, saturation, value -> RGB
>
> Thanks to everybody,
> I did it in photoshop, that exe program, but as Chip has said the Arcview
> values of H,S and V are different, thus most programs won't let me use a
> Saturation value of 255 etc.
> Are these avenue scripts inbuilt in arcview, can anybody point out how to
> use them to do conversion.
> > As Stephen pointed out, there are some good formulas via the Google search
> > page that you can wade through to figure it out...
> >
> > However, some words of caution.
> >
> > The way ArcView calculates HSV is a little different. Values for H, S, and
> V
> > all range from 0 to 255 (I believe). This is different from other HSV
> color
> > models. If you have access to ArcView, there are some simple avenue
> scripts
> > that will do the conversion for you (or you might be able to get your
> client
> > to do it).
> >
> > Chip
> >
> > -----Original Message-----
> > From: Stephen Woodbridge [mailto:woodbri at swoodbridge.com]
> > Sent: Wednesday, June 05, 2002 4:57 AM
> > To: Pushkar Pradhan
> > Cc: mapserver-users at lists.gis.umn.edu
> > Subject: Re: [mapserver-users] hue, saturation, value -> RGB
> >
> >
> > http://www.google.com/search?hl=en&q=hsv+to+rgb&btnG=Google+Search
> >
> > Pushkar Pradhan wrote:
> > >
> > > Hi,
> > > I have a client who has given me the color hue, saturation and value
> > > attributes for each shapefile. He got these values from arcview's legend
> > > table. Doesn anyone know how to translate these values to  pure R, G and
> B
> > > so that mapserver can understand it?
> > > Thanks,
> > >
> > > -Pushkar S. Pradhan
> >
>
> -Pushkar S. Pradhan

--
-----------------------------------------------------------
Michael Schulz                                in medias res
Dipl.-Geologe                              Gesellschaft für
                                Informationstechnologie mbH
                             Sautierstr. 38, 79104 Freiburg
                                     0761 55695-95 (Fax 96)
mschulz at webgis.de                             www.webgis.de







More information about the MapServer-users mailing list