Esempio n. 1
0
        private void ExecuteTakeScreenshotCommand()
        {
            //var file = File.ReadAllBytes(
            //    @"d:\source\c#\AutoRaid\AutoRaid.Tests\TestData\victory_screen_all_heroes_max.png");

            using var ms = new MemoryStream(_adbService.GetScreenshot())
                  {
                      Position = 0
                  };
            var image = new BitmapImage();

            image.BeginInit();
            image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
            image.CacheOption   = BitmapCacheOption.OnLoad;
            image.UriSource     = null;
            image.StreamSource  = ms;
            image.EndInit();

            var croppedImage = new CroppedBitmap(image, new Int32Rect(1500, 20, 80, 80));

            Screenshot = image;
            Cropped    = croppedImage;

            var thumbnail = CreateResizedImage(croppedImage, 16, 16, 0);

            using var bitmap = ConvertToBitmap(thumbnail);
            var blackWhiteResult = CreateBlackAndWhite(bitmap);

            Scaled = ConvertToImageSource(blackWhiteResult.bitmap);
            Hash.Clear();
            Hash.AddRange(blackWhiteResult.hash);
        }
Esempio n. 2
0
        public void GetScreenshot_ReturnsValidArray()
        {
            var result = _adbService.GetScreenshot();

            Assert.True(result.Length > 100);
        }