BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RGB algorithms

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
smartdude80
Guest





PostPosted: Wed Nov 16, 2005 8:51 pm    Post subject: RGB algorithms Reply with quote



Whats the algorithm used to get and set luminance, saturation, and hue for a
24-bit RGB color?


Back to top
Bruce Salzman
Guest





PostPosted: Wed Nov 16, 2005 9:00 pm    Post subject: Re: RGB algorithms Reply with quote




"smartdude80" <smartdude81 (AT) comcast (DOT) net> wrote

Quote:
Whats the algorithm used to get and set luminance, saturation, and
hue for a
24-bit RGB color?

http://www.dcs.ed.ac.uk/home/mxr/gfx/faqs/colorconv.faq


see section 5.3

--
Bruce



Back to top
smartdude80
Guest





PostPosted: Wed Nov 16, 2005 11:27 pm    Post subject: Re: RGB algorithms Reply with quote



Quote:
http://www.dcs.ed.ac.uk/home/mxr/gfx/faqs/colorconv.faq

see section 5.3

--
Bruce


I looked here and found what i was looking for but the hue formula looks
real complicated to me:

Hue = cos^(-1) [(0.5*(R-G)+(R-B)) / ( ((R-G)^2 + (R-B)(G-B))^(0.5) )]

Can anyone translate this into a C expression? R, G, and B are of course
red, blue, and green. Im guessing the ^ symbol means exponent but i dont
know why they have cos^(-1).






Back to top
Bruce Salzman
Guest





PostPosted: Thu Nov 17, 2005 12:15 am    Post subject: Re: RGB algorithms Reply with quote


"smartdude80" <smartdude81 (AT) comcast (DOT) net> wrote

Quote:
http://www.dcs.ed.ac.uk/home/mxr/gfx/faqs/colorconv.faq

see section 5.3

--
Bruce


I looked here and found what i was looking for but the hue formula
looks
real complicated to me:

Hue = cos^(-1) [(0.5*(R-G)+(R-B)) / ( ((R-G)^2 +
(R-B)(G-B))^(0.5) )]

Can anyone translate this into a C expression? R, G, and B are of
course
red, blue, and green. Im guessing the ^ symbol means exponent but i
dont
know why they have cos^(-1).

cos^(-1) is inverse cosine (or arccosine).


double hue = acos((0.5 * (R-G)+(R-B))/sqrt((R-G)*(R-G) +
(R-B)*(G-B)));

--
Bruce



Back to top
Steve Aletto
Guest





PostPosted: Thu Nov 17, 2005 10:03 am    Post subject: Re: RGB algorithms Reply with quote

Quote:
Whats the algorithm used to get and set luminance, saturation,
and hue for a
24-bit RGB color?

Have a look at ColorHLSToRGB and ColorRGBToHLS:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/shlwapi/gdi/palette.asp

HTH,

Steve.



Back to top
smartdude80
Guest





PostPosted: Mon Nov 21, 2005 7:52 pm    Post subject: Re: RGB algorithms Reply with quote

Quote:
cos^(-1) is inverse cosine (or arccosine).

double hue = acos((0.5 * (R-G)+(R-B))/sqrt((R-G)*(R-G) +
(R-B)*(G-B)));

--
Bruce


I wound up finding source code (that actually works) for doing this type of
conversion on the internet. Thanks anyways.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.