Ejemplo n.º 1
0
 public bool Compare(Sbmp b, int x, int y)
 {
     if (x + Width > b.Width || y + Height > b.Height)
     {
         return(false);
     }
     for (int i = x, ii = 0; ii < Width; i++, ii++)
     {
         for (int j = y, jj = 0; jj < Height; j++, jj++)
         {
             var c = b.GetPixel(i, j);
             if (Types[Colors[ii, jj]].A == 0)
             {
                 if (Types.Count(v => v == c) != 0)
                 {
                     return(false);
                 }
             }
             else
             {
                 if (c != Types[Colors[ii, jj]])
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        internal static Rectangle GetRect(Sbmp b)
        {
            var x = -1;
            var w = -1;

            for (var i = 0; i < b.Width; i++)
            {
                var counter = 0;
                for (var j = 0; j < b.Height; j++)
                {
                    if (b.GetPixel(i, j).R != 255 && x == -1)
                    {
                        x = i;
                        w = 0;
                        break;
                    }
                    if (x != -1 && b.GetPixel(i, j).R == 255)
                    {
                        counter++;
                    }
                }
                if (counter != b.Height)
                {
                    w++;
                }
                else
                {
                    break;
                }
            }
            var y = -1;
            var h = -1;

            for (var j = 0; j < b.Height; j++)
            {
                var counter = 0;
                for (var i = 0; i < b.Width; i++)
                {
                    if (b.GetPixel(i, j).R != 255 && y == -1)
                    {
                        y = j;
                        h = 0;
                        break;
                    }
                    if (y != -1 && b.GetPixel(i, j).R == 255)
                    {
                        counter++;
                    }
                }
                if (counter != b.Width)
                {
                    h++;
                }
                else
                {
                    break;
                }
            }
            return(new Rectangle(x, y, w, h));
        }
Ejemplo n.º 3
0
        private bool Ch4()
        {
            var res = false;
            var sw  = new Stopwatch();
            var r   = Imports.NativeMethods.GetAbsoluteClientRect(BdoP.MainWindowHandle);
            var X   = r.X;
            var Y   = r.Y;
            var CAX = X + r.Width / 2;
            var CAY = Y + r.Height / 2;

            sw.Start();
            while (!res && sw.ElapsedTicks < TimeSpan.FromMilliseconds(time).Ticks)
            {
                var b = new Sbmp(_sc);

                var Filtr = new System.Drawing.Rectangle(CAX - 409, CAY - 216, 38, 10);
                if (_mfiltr.Compare(b, Filtr))
                {
                    res = true;
                    b.Dispose();
                    break;
                }
                b.Dispose();
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
            }
            sw.Stop();
            return(res);
        }
Ejemplo n.º 4
0
        public bool Compare(Sbmp b, int x, int y, int threshold, int npc)
        {
            if (x + Width > b.Width || y + Height > b.Height)
            {
                return(false);
            }
            var counter = 0;

            for (int i = x, ii = 0; ii < Width; i++, ii++)
            {
                for (int j = y, jj = 0; jj < Height; j++, jj++)
                {
                    var c = b.GetPixel(i, j);
                    var e = Types[Colors[ii, jj]];
                    if (Math.Abs(c.R - e.R) <= threshold && Math.Abs(c.G - e.G) <= threshold &&
                        Math.Abs(c.B - e.B) <= threshold)
                    {
                        counter++;
                    }
                }
            }
            double all  = Width * Height;
            var    proc = counter * 100 / all;

            return(proc >= npc);
        }
Ejemplo n.º 5
0
 public bool Compare(Sbmp b, Rectangle r)
 {
     for (int i = 0, ii = r.X; i < Width; i++, ii++)
     {
         for (int j = 0, jj = r.Y; j < Height; j++, jj++)
         {
             var c = b.GetPixel(ii, jj);
             var e = GetPixel(i, j);
             if (c != e)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 6
0
 public bool Compare(Sbmp b, Rectangle r, out Point pt)
 {
     for (var i = r.X; i <= r.X + r.Width - Width; i++)
     {
         for (var j = r.Y; j <= r.Y + r.Height - Height; j++)
         {
             if (Compare(b, i, j))
             {
                 pt = new Point(i, j);
                 return(true);
             }
         }
     }
     pt = new Point(-1, -1);
     return(false);
 }
Ejemplo n.º 7
0
        internal static Sbmp Threshold(Sbmp bq)
        {
            var b = bq.Copy();

            for (var i = 0; i < b.Width; i++)
            {
                for (var j = 0; j < b.Height; j++)
                {
                    var c = b.GetPixel(i, j);
                    if (Math.Abs(c.R - c.G) < 120 && Math.Abs(c.G - c.B) < 120 && Math.Abs(c.R - c.B) < 120)
                    {
                        b.SetPixel(i, j, Color.FromArgb(255, 255, 255, 255));
                    }
                    else
                    {
                        b.SetPixel(i, j, Color.FromArgb(255, 0, 0, 0));
                    }
                }
            }
            return(b);
        }
Ejemplo n.º 8
0
        private bool Ch3()
        {
            var res = false;
            var sw  = new Stopwatch();

            sw.Start();
            while (!res && sw.ElapsedTicks < TimeSpan.FromMilliseconds(time).Ticks)
            {
                var s = new Sbmp(_sc);
                if (s.GetPixel(0, 0).A != 0)
                {
                    res = true;
                    s.Dispose();
                    break;
                }
                s.Dispose();
                System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
            }
            sw.Stop();
            return(res);
        }
Ejemplo n.º 9
0
        public bool Compare(Sbmp b, Rectangle r, int threshold, int npc)
        {
            var counter = 0;

            for (int i = 0, ii = r.X; i < Width; i++, ii++)
            {
                for (int j = 0, jj = r.Y; j < Height; j++, jj++)
                {
                    var c = b.GetPixel(ii, jj);
                    var e = GetPixel(i, j);
                    if (Math.Abs(c.R - e.R) <= threshold && Math.Abs(c.G - e.G) <= threshold &&
                        Math.Abs(c.B - e.B) <= threshold)
                    {
                        counter++;
                    }
                }
            }
            double all  = Width * Height;
            var    proc = counter * 100 / all;

            return(proc >= npc);
        }