/// <summary> /// Matches until difference is more than total tolerance. /// </summary> /// <param name="fast_bitmap"></param> /// <param name="sub_rect"></param> /// <returns></returns> public bool IsIn(FastBitmap fast_bitmap, Point basepoint, int tolerance) { int total = 0; for (int y = 0; y < this.Height; y++) { for (int x = 0; x < this.Width; x++) { total += BitmapAnalyzer.AbsoluteDiff(this.GetColor(x, y), fast_bitmap.GetColor(basepoint.X + x, basepoint.Y + y)); if (total > tolerance) { return(false); } } } return(true); }
public static bool IsMatch(FastBitmap fast_bitmap1, FastBitmap fast_bitmap2, int total_tolerance) { if (fast_bitmap1.Width != fast_bitmap2.Width || fast_bitmap1.Height != fast_bitmap2.Height) { return(false); } int total = 0; for (int y = 0; y < fast_bitmap1.Height; y++) { for (int x = 0; x < fast_bitmap1.Width; x++) { total += BitmapAnalyzer.AbsoluteDiff(fast_bitmap1.GetColor(x, y), fast_bitmap2.GetColor(x, y)); if (total > total_tolerance) { return(false); } } } return(true); }
public static Bitmap BoundingBitmap(Bitmap bmp, int bound_color, out Rectangle crop_rect) { crop_rect = BoundingRectangle(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), bound_color); return(BitmapAnalyzer.CropBitmap(bmp, crop_rect)); }