Comparison operators are not defined for System.Drawing.Color, so you need to implement your own comparison methods. I suggest using an extension method, for example:
static class ColorExtensions
{
public static bool Between(this Color c, Color a, Color b)
{
}
public static bool LessOrEqual(this Color a, Color b)
{
}
public static bool MoreOrEqual(this Color a, Color b)
{
}
}
so you can use
var color = img.GetPixel(bottomRightc.X, y);
if(color.LessOrEqual(Color.FromArgb(255, 255, 255, 255) &&
color.MoreOrEqual(Color.FromArgb(255, 166, 166, 166)))
{
return false;
}
or
if(img.GetPixel(bottomRightc.X, y).Between(
Color.FromArgb(255, 166, 166, 166),
Color.FromArgb(255, 255, 255, 255)))
{
return false;
}
source
share