kouroshparsa
asked on
HSB to RGB conversion
I want a code to convert HSB to RGB color system in vb net.
H=hue
S=saturation
B=brightness
I've tried various codes which were online (in various languages)
None of them work! so please only post a solution that works.
Thanks
H=hue
S=saturation
B=brightness
I've tried various codes which were online (in various languages)
None of them work! so please only post a solution that works.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the reply.
I get errors. I fixed some of them but there are still errors saying that the methods need to return a value:
for example, see the blocks of code in the attached code.
How to fix it?
If I can get this to work, I can translate it to vb net.
I get errors. I fixed some of them but there are still errors saying that the methods need to return a value:
for example, see the blocks of code in the attached code.
How to fix it?
If I can get this to work, I can translate it to vb net.
public HSB_RGB(Color c)
{
red = c.R;
green = c.G;
blue = c.B;
ToHLS();
}
public HSB_RGB(float hue, float luminance, float saturation)
{
this.hue = hue;
this.luminance = luminance;
this.saturation = saturation;
ToRGB();
}
public HSB_RGB(byte red, byte green, byte blue)
{
this.red = red;
this.green = green;
this.blue = blue;
}
These are constructors in C#, the equivalent in VB to the "New" Keyword. So you want something like:
Public Sub New (Color c)
red = c.R
...
End Sub
Then to use this you go:
Dim MyHSB_RGB As New HSB_RGB(Color.Brown)
lumins = MyHSB_RGB.Luminescence
ASKER
Yes, it compiles. Thanks ERobishaw.
I noticed that my values are not HSB values; they're HLS values.
Still, for my application it's very good.
though does anyone also know the HSB which i initially was looking for?
I noticed that my values are not HSB values; they're HLS values.
Still, for my application it's very good.
though does anyone also know the HSB which i initially was looking for?
(HLS = HSB)
Hue = Hue
L [uminence] = B[rightness]
S [aturation] = Saturation