How to check RGB color and How do I know if this Range is green or red?

Viewed 330
string greenImage = @"C:\Users\keti.p\Desktop\greenImage.jpg";
Bitmap bitMap = new Bitmap(greenImage);
int width = maxWidth / 2;
int height = maxHeight / 2;
Color c = bitMap.GetPixel(width, height);

Color color = Color.FromArgb(c.R, c.G, c.B);

I have this "color" Object,

For example, is this color green? Or is it red? or? What a ranger in green..

1 Answers

You want to check the hue of the colour using the GetHue HSL method of the Color type:

Color a = Color.Red;
Console.WriteLine(a.GetHue()); // 0
Color b = Color.Green;
Console.WriteLine(b.GetHue()); // 120

I believe the numbers should correspond to this chart:

strong text

Image source

Related