Esempio n. 1
0
        public Point Find()
        {
            this.bitmap = WowScreen.GetBitmap();

            Score best = Score.ScorePoints(FindRedPoints());

            if (previousLocation != Point.Empty && best == null)
            {
                previousLocation = Point.Empty;
                best             = Score.ScorePoints(FindRedPoints());
            }

            previousLocation = Point.Empty;
            if (best != null)
            {
                previousLocation = best.point;
            }

            BitmapEvent?.Invoke(this, new BobberBitmapEvent {
                Point = new Point(previousLocation.X, previousLocation.Y), Bitmap = this.bitmap
            });

            this.bitmap.Dispose();

            return(previousLocation == Point.Empty ? Point.Empty : WowScreen.GetScreenPositionFromBitmapPostion(previousLocation));
        }
Esempio n. 2
0
        private void RenderColour(bool renderMatchedArea)
        {
            var bitmap = new System.Drawing.Bitmap(256, 256);

            var points = new List <Point>();

            for (var i = 0; i < 256; i++)
            {
                for (var g = 0; g < 256; g++)
                {
                    var r = (byte)this.FindColourValue;
                    var b = (byte)i;

                    if (this.pixelClassifier.Mode == PixelClassifier.ClassifierMode.Blue)
                    {
                        r = (byte)i;
                        b = (byte)this.FindColourValue;
                    }

                    if (pixelClassifier.IsMatch(r, (byte)g, b))
                    {
                        points.Add(new Point(i, g));
                    }
                    bitmap.SetPixel(i, g, Color.FromArgb(r, g, b));
                }
            }

            if (ScreenCapture == null)
            {
                ScreenCapture     = WowScreen.GetBitmap();
                renderMatchedArea = true;
            }

            this.ColourDisplay.Source = bitmap.ToBitmapImage();
            this.WowScreenshot.Source = ScreenCapture.ToBitmapImage();

            if (renderMatchedArea)
            {
                Dispatch(() =>
                {
                    MarkEdgeOfRedArea(bitmap, points);
                    this.ColourDisplay.Source = bitmap.ToBitmapImage();
                });

                Dispatch(() =>
                {
                    Bitmap bmp = new Bitmap(ScreenCapture);
                    MarkHighlightOnBitmap(bmp);
                    this.WowScreenshot.Source = bmp.ToBitmapImage();
                });
            }
        }
        public Point Find()
        {
            this.bmp = WowScreen.GetBitmap();

            const int targetOffset = 15;

            var widthLower   = 0;
            var widthHigher  = bmp.Width;
            var heightLower  = 0;
            var heightHigher = bmp.Height;

            var targetRedLb   = targetColor.R - targetOffset;
            var targetRedHb   = targetColor.R + targetOffset;
            var targetBlueLb  = targetColor.B - targetOffset;
            var targetBlueHb  = targetColor.B + targetOffset;
            var targetGreenLb = targetColor.G - targetOffset;
            var targetGreenHb = targetColor.G + targetOffset;

            var pos = new Point(0, 0);

            for (int i = widthLower; i < widthHigher; i++)
            {
                for (int j = heightLower; j < heightHigher; j++)
                {
                    pos.X = i;
                    pos.Y = j;
                    var colorAt = WowScreen.GetColorAt(pos, bmp);
                    if (colorAt.R > targetRedLb &&
                        colorAt.R < targetRedHb &&
                        colorAt.B > targetBlueLb &&
                        colorAt.B < targetBlueHb &&
                        colorAt.G > targetGreenLb &&
                        colorAt.G < targetGreenHb)
                    {
                        BitmapEvent?.Invoke(this, new BobberBitmapEvent {
                            Point = new Point(i, j), Bitmap = bmp
                        });
                        return(WowScreen.GetScreenPositionFromBitmapPostion(pos));
                    }
                }
            }

            BitmapEvent?.Invoke(this, new BobberBitmapEvent {
                Point = Point.Empty, Bitmap = bmp
            });
            bmp.Dispose();
            return(Point.Empty);
        }
        private void RenderColour(bool renderMatchedArea)
        {
            var bitmap = new System.Drawing.Bitmap(256, 256);

            var points = new List <Point>();

            for (var b = 0; b < 256; b++)
            {
                for (var g = 0; g < 256; g++)
                {
                    if (pixelClassifier.IsMatch((byte)this.RedValue, (byte)g, (byte)b))
                    {
                        points.Add(new Point(b, g));
                    }
                    bitmap.SetPixel(b, g, System.Drawing.Color.FromArgb(this.RedValue, g, b));
                }
            }

            if (ScreenCapture == null)
            {
                ScreenCapture     = WowScreen.GetBitmap();
                renderMatchedArea = true;
            }

            this.ColourDisplay.Source = bitmap.ToBitmapImage();
            this.WowScreenshot.Source = ScreenCapture.ToBitmapImage();

            if (renderMatchedArea)
            {
                Dispatch(() =>
                {
                    MarkEdgeOfRedArea(bitmap, points);
                    this.ColourDisplay.Source = bitmap.ToBitmapImage();
                });

                Dispatch(() =>
                {
                    Bitmap bmp = new Bitmap(ScreenCapture);
                    MarkRedOnBitmap(bmp);
                    this.WowScreenshot.Source = bmp.ToBitmapImage();
                });
            }
        }
 private void Capture_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     ScreenCapture = WowScreen.GetBitmap();
     RenderColour(true);
 }