Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert HSB to RGB

Status
Not open for further replies.

mattscotney

Programmer
Jul 31, 2002
57
AU
Hi all,

I can get the hue, saturation and brightness of a color using the following code:

hue = Color.FromArgb(r, g, b).GetHue()
sat = Color.FromArgb(r, g, b).GetSaturation()
bri = Color.FromArgb(r, g, b).GetBrightness()

But how do I convert the hue, saturation and brightness levels back to RGB?

Code would be great, although the mathematical formulas or even just an algorithm and I should be able to work it out.

Thanks in advance,
Matt
 
Hi Matt,

if you still need it, the easiest way to convert HSB colors to RGB is to use the WINDOWS API Function "ColorHLSToRGB" from "Shlwapi.dll". It is described in the MSDN Help.

Regards,

Shamsuddin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top