Esempio n. 1
0
        //ищем фрагмент в большом изображении
        public Point?Find(Bitmap source)
        {
            using (var wr = new ImageWrapper(source))
                foreach (var p in wr)
                {
                    var c = wr[p];
                    if (c == FeaturePoints[0].Color)
                    {
                        var offset = new Point(p.X - FeaturePoints[0].Location.X, p.Y - FeaturePoints[0].Location.Y);
                        //проверяем все особые точки
                        foreach (var fp in FeaturePoints)
                        {
                            var pp = fp.Location;
                            pp.Offset(offset);
                            if (wr[pp] != fp.Color)
                            {
                                goto next;
                            }
                        }
                        return(offset);
                    }
                    next :;
                }

            return(null);
        }
Esempio n. 2
0
        public SreenParserTemplate(Bitmap template)
        {
            var colors = new HashSet <Color>();

            using (var wr = new ImageWrapper(template))
                foreach (var p in wr)
                {
                    var c = wr[p];

                    if (!colors.Contains(c))
                    {
                        colors.Add(c);
                        FeaturePoints.Add(new ColorPoint {
                            Color = c, Location = p
                        });
                    }
                }
        }