public class BitmapExtensions { public bool Contains(this Bitmap template, Bitmap bmp) { const int divisor = 4; const int epsilon = 10; ExhaustiveTemplateMatching etm = new ExhaustiveTemplateMatching(0.9f); TemplateMatch[] tm = etm.ProcessImage(new ResizeNearestNeighbor(template.Width / divisor, template.Height / divisor).Apply(template), new ResizeNearestNeighbor(bmp.Width / divisor, bmp.Height / divisor).Apply(bmp)); if (tm.Length == 1) { Rectangle tempRect = tm[0].Rectangle; if(Math.Abs(bmp.Width / divisor - tempRect.Width) < epsilon && Math.Abs(bmp.Height / divisor - tempRect.Height) < epsilon) { return true; } } return false; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)