/// <summary> /// Returns true if the subregion of the other image matches the region at (x,y) of this image. /// </summary> public bool Matches(int at_x, int at_y, Image other, Rectangle region) { if (at_x < 0 || at_y < 0 || (at_x + region.Width) > Width || (at_y + region.Height) > Height) { throw new Exception("Invalid selection(s)"); } if (Width != other.Width || Height != other.Height) { return(false); } else { Color[,] image1 = GetPixels(new Rectangle(at_x, at_y, region.Width, region.Height)); Color[,] image2 = other.GetPixels(region); int width = image1.GetLength(0); int height = image1.GetLength(1); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (image1[x, y] == image2[x, y]) { return(false); } } } return(true); } }
/// <summary> /// Returns true if the images have the same pixels. /// </summary> public bool Matches(Image other) { if (Width != other.Width || Height != other.Height) { return(false); } else { Color[,] image1 = GetPixels(new Rectangle(0, 0, Width, Height)); Color[,] image2 = other.GetPixels(new Rectangle(0, 0, Width, Height)); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { if (image1[x, y] == image2[x, y]) { return(false); } } } return(true); } }