Click here to Skip to main content
15,913,854 members

Comments by wf0007 (Top 7 by date)

wf0007 26-Nov-13 21:19pm View    
Deleted
When I get the HSL int array and I put HSL array to HSL2RGB method to get the RGB color value, but I found the value is different from the value put the TestInt method and RGB2HSL method to get the HSL array.
wf0007 26-Nov-13 21:13pm View    
Deleted
Please see the code below: I put the IntRgb array to this method and get another int array to show the HSL but I can not get the right color through these methods, I will put the HSL2RGB method at the end.
public static int[] RGB2HSL( int[] rgb)
{
double R = rgb[0]/255d;
double G = rgb[1]/255d;
double B = rgb[2]/255d;
double H = 0d;
double S = 0d;
double L = 0d;
double v;
double m;
double vm;
double R2, G2, B2;

v = Math.max(Math.max(R,G),B );
m = Math.min( Math.min(R,G), B);
L = (m+v)/2.0;

vm = v-m;
S = vm;

if ( S > 0 )
{
if( L <= 0.5 )
S = S/(v+m);
else
S = S/(2.0 -v -m);

R2 = (v-R)/vm;
G2 = (v-G)/vm;
B2 = (v-B)/vm;
if ( R==v)
{
if( G == m )
H = 5.0 + B2;
else
H = 1.0 - G2;
}
else
if ( G == v )
{
if ( B == m )
H = 1.0 + R2;
else
H = 3.0 - B2;
}
else
{
if ( R == m )
H = 3.0 + G2;
else
H = 5.0 - R2;
}

H = H/6.0;
}

return new int[] { (int)Math.round(H), (int)Math.round(S*100d), (int)Math.round(L*100d) };
}

wf0007 26-Nov-13 8:12am View    
I use this int array to convert to HSL(Hue, Saturation, Lightness), I find there are display some error value, so I need to confirm whether this method is right.
wf0007 14-Nov-13 8:12am View    
Thank you for your solution
wf0007 13-Nov-13 20:32pm View    
No,It is a web application,sorry for reply it now.