int DiferentPixels = 0;
Bitmap first = new Bitmap(\"First.jpg\");
Bitmap second = new Bitmap(\"Second.jpg\");
Bitmap container = new Bitmap(first.Width, first.Height
For speed, resize the images to something very small (16x12, for example) and do the pixel comparison. If it is a near match, then try it at higher resolution.
One obvious change would be call GetPixel
only once per Bitmap
, and then work with the returned Color
structs directly:
for (int i = 0; i < first.Width; ++i)
{
for (int j = 0; j < first.Height; ++j)
{
Color secondColor = second.GetPixel(i, j);
Color firstColor = first.GetPixel(i, j);
if (firstColor != secondColor)
{
DiferentPixels++;
container.SetPixel(i, j, Color.Red);
}
else
{
container.SetPixel(i, j, firstColor);
}
}
}