|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
namespace D.Net.Clipboard
{
public static class ImagesComparer
{
public static bool Equals(Image first, Image second)
{
if (first == null || second == null) return false;
if (first.Width != second.Width) return false;
if (first.Height != second.Height) return false;
if (first.RawFormat.Guid != second.RawFormat.Guid) return false;
if (first.PixelFormat != second.PixelFormat) return false;
bool ok = true;
for (int i = 0; i < first.Width; i++)
{
for(int j = 0; j < first.Height; j++)
{
String img1_ref = ((Bitmap)first).GetPixel(i, j).ToString();
String img2_ref = ((Bitmap)second).GetPixel(i, j).ToString();
if (img1_ref != img2_ref)
{
ok = false;
}
}
}
return ok;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.