I have a loop that gets pixelcolors from an image and try to see if they are the same as the Color I passed into the method as parameter.
I tried the Equals
method but it doesn't work. I also tried the ToKnown
method.
It looks like that match doesn't work beacuse the values that synthesize the two colors don't match.
Example:
With GetPixel:
{Name=ff000000, ARGB=(255, 0, 0, 0)}
Color.Black:
{Name=Black, ARGB=(255, 0, 0, 0)}
if (pixelColor.ToArgb().Equals(startingOffsetColor.ToArgb())) { }
The code above works, but I still want to know if there is any better method or any method that can reduce any CPU overhead, because I'm using this inside a loop statement.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…