This is how to do it in Delphi courtesy of Zarko Gajic - shouldn't be
too tricky to convert

uses Math;

type
   TRGBColor = record
     Red,
     Green,
     Blue : Byte;
   end;

   THSBColor = record
     Hue,
     Saturnation,
     Brightness : Double;
   end;

function RGBToHSB(rgb : TRGBColor) : THSBColor;
var
   minRGB, maxRGB, delta : Double;
   h , s , b : Double ;
begin
   H := 0.0 ;
   minRGB := Min(Min(rgb.Red, rgb.Green), rgb.Blue) ;
   maxRGB := Max(Max(rgb.Red, rgb.Green), rgb.Blue) ;
   delta := ( maxRGB - minRGB ) ;
   b := maxRGB ;
   if (maxRGB <> 0.0) then s := 255.0 * Delta / maxRGB
   else s := 0.0;
   if (s <> 0.0) then
   begin
     if rgb.Red = maxRGB then h := (rgb.Green - rgb.Blue) / Delta
     else
       if rgb.Green = maxRGB then h := 2.0 + (rgb.Blue - rgb.Red) /
Delta
       else
         if rgb.Blue = maxRGB then h := 4.0 + (rgb.Red - rgb.Green) /
Delta
   end
   else h := -1.0;
   h := h * 60 ;
   if h < 0.0 then h := h + 360.0;
   with result do
   begin
     Hue := h;
     Saturnation := s * 100 / 255;
     Brightness := b * 100 / 255;
   end;
end; 



 
John Sutton 
 

-----Original Message-----
From: Darren [mailto:[EMAIL PROTECTED] 
Sent: 11 December 2008 16:34
To: Palm Developer Forum
Subject: RGB565 to HSV

(Palm OS5.0 - OS5.49)
hello,
am in the process of developing a desk-accessorized colour-picker, and
would appreciate any conversion algorithms and or code, that converts
RGB565 value (31,63,31) to hue, saturation and value.

many thanks, much appreciated

Darren 



--
For information on using the ACCESS Developer Forums, or to unsubscribe,
please see http://www.access-company.com/developers/forums/

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to