I am trying to use this to figure out if a color is light or dark
Evaluate whether a HEX value is dark or light
Now. It takes in a int
The problem, as I see it, is your calculation of rgb
. You add the values together which gives you a number between 0 and 3*255 which clearly isn't the value your method expect. You will have to calculate it like this
int rgb = (int)color.R << 16 + (int)color.G << 8 + color.B;
which should be equivalent to this (except for the alpha-value you don't use)
int rgb = color.ToArgb();
Lastly, as you can see in Chris Haas answer, you can skip this step by converting directly to an int.