Beispiel #1
0
        public BlockParser()
        {
            imgGuess = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/MinesweeperSolver;component/Images/one.png")));
            imgTwo   = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/MinesweeperSolver;component/Images/three.png")));
            imgFour  = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/MinesweeperSolver;component/Images/five.png")));
            imgSix   = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/MinesweeperSolver;component/Images/seven.png")));
        }
Beispiel #2
0
        internal AsyncResultCaptureSampleDummy(AsyncResultCaptureSample captureSample)
        {
            this.Sample       = captureSample.Sample;
            this.SampleSize   = captureSample.SampleSize;
            this.RejectDetail = captureSample.RejectDetail;

            var image = BitmapSourceHelper.ToBitmapSource(captureSample.Sample.Image,
                                                          captureSample.Sample.Width,
                                                          captureSample.Sample.Height,
                                                          captureSample.Sample.HorizontalImageResolution,
                                                          captureSample.Sample.VerticalImageResolution);

            if (image.CanFreeze)
            {
                image.Freeze();
            }

            this.CaptureImage = image;
        }
Beispiel #3
0
        public void SetCurrentImage(ImageInfo image)
        {
            using (var bmp = new Bitmap(image.FilePath).ToARGBBitmap())
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    foreach (var a in image.Annotations)
                    {
                        var x = (int)(bmp.Width * (a.Cx - a.Width / 2));
                        var y = (int)(bmp.Height * (a.Cy - a.Height / 2));
                        var w = (int)(bmp.Width * a.Width);
                        var h = (int)(bmp.Height * a.Height);

                        g.DrawRectangle(pen, x, y, w, h);
                    }
                }
                CurrentImage = BitmapSourceHelper.LoadBitmap(bmp);
            }
        }
Beispiel #4
0
 public void SetCurrentImage(ImageInfo image)
 {
     SelectedImage = image;
     if (image != null)
     {
         using (var bmp = new Bitmap(image.FilePath).ToARGBBitmap())
         {
             ViewImage = BitmapSourceHelper.LoadBitmap(bmp);
         }
         _bboxes.Clear();
         _bboxes.Add(new Annotation {
             Class = -1, Label = "-- ALL --", Cx = -1, Cy = -1, Width = 0, Height = 0
         });
         foreach (var a in image.Annotations)
         {
             _bboxes.Add(a);
         }
         OnPropertyChanged("BBoxes");
     }
 }
Beispiel #5
0
        private void setOffset(DataStream gs)
        {
            PixelColor[,] test = BitmapSourceHelper.GetPixels(new BitmapImage(new Uri(@"pack://application:,,,/MinesweeperSolver;component/Images/test.png")));

            int testWidth  = 5;
            int testHeight = 5;

            byte[] buffer = new byte[testWidth * 4 * testHeight];
            PixelColor[,] pixels = new PixelColor[testWidth, testHeight];
            for (int x = 0; x < screenWidth - 5; x += 5)
            {
                for (int y = 0; y < screenHeight - 5; y += 5)
                {
                    for (int line = 0; line < testHeight; line++)
                    {
                        gs.Position = (line + y) * screenWidth * 4 + x * 4;
                        gs.Read(buffer, testWidth * 4 * line, testWidth * 4);
                    }

                    for (int a = 0; a < testWidth; a++)
                    {
                        for (int b = 0; b < testHeight; b++)
                        {
                            int offset = b * testWidth * 4 + (a * 4);
                            pixels[b, a].Red   = buffer[offset + 2];
                            pixels[b, a].Green = buffer[offset + 1];
                            pixels[b, a].Blue  = buffer[offset + 0];
                        }
                    }

                    if (BlockParser.CompareImages(pixels, test))
                    {
                        int    finalX;
                        int    finalY;
                        byte[] pixel = new byte[4];
                        for (finalX = x; finalX > 0; finalX--)
                        {
                            gs.Position = y * screenWidth * 4 + finalX * 4;
                            gs.Read(pixel, 0, 4);
                            if (compareInt(pixel[0], 58, 9) &&
                                compareInt(pixel[1], 52, 9) &&
                                compareInt(pixel[2], 47, 9))
                            {
                                break;
                            }
                        }
                        for (finalY = y; finalY > 0; finalY--)
                        {
                            gs.Position = finalY * screenWidth * 4 + x * 4;
                            gs.Read(pixel, 0, 4);
                            if (compareInt(pixel[0], 58, 9) &&
                                compareInt(pixel[1], 52, 9) &&
                                compareInt(pixel[2], 47, 9))
                            {
                                break;
                            }
                        }
                        xoffset = finalX - 3;
                        yoffset = finalY - 1;
                        return;
                    }
                }
            }
        }