changing color brightness

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to change brightness of a color at run-time. I can get all the
components: Hue, Saturation, Brightness from Color object, and I can
obviously change these values but how can I create a new color based on
these new values?

Color oColor = Color.FromArgb(129, 129, 129);

float fNewHue = oColor.GetHue() + 10;
float fNewSaturation = oColor.GetSaturation() + 0.1F;
float fNewBrightness = oColor.GetBrightnes() + 0.1F;

// how can I build a new color based on these values?

Color oNewColor = Color.FromHSV(fNewHue, fNewSaturation, fNewBrightness); //
DOESN'T EXIST

Does anybody have a source for HSV to RGB (C# preferably), or is there a
work-around in .NET?

Thanks,
VR
 
Hi Vr,

As for the converting HSV/HSB format color to RGB format problem, currently
there hasn't been any buildin interfaces in the .net framework to do this.
But we can do it via our own function according to the convert algorithm.
Here is a kb article discussing on the convertion (which is using C++)

#How To Converting Colors Between RGB and HLS (HBS)
http://support.microsoft.com/?id=29240

Also, there is some other former threads and tech articles related to this
problem:

#Subject: Re: convert HSB color to RGB,
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=uct6gVDUCHA.1676%
40tkmsftngp12&rnum=6&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26q%3D.net%
2Bcolor%2Bconvert%2Brgb%2Bto%2Bhsb

#Interactive Color Wheel
http://r0k.us/graphics/SIHwheel.html

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Back
Top