private async void FetchDecodedImage()
        {
            try
            {
                Uri uri = MainPage.GenerateImageUri();
                ImageRequestBuilder builder = ImageRequestBuilder.NewBuilderWithSource(uri);
                if (GrayscaleRadioButton.IsChecked.Value)
                {
                    builder.SetPostprocessor(GrayscalePostprocessor);
                }
                else if (InvertRadioButton.IsChecked.Value)
                {
                    builder.SetPostprocessor(InvertPostprocessor);
                }

                ImageRequest    request = builder.Build();
                WriteableBitmap bitmap  = await _imagePipeline.FetchDecodedBitmapImageAsync(request);

                var image = new Image();
                image.Width  = image.Height = MainPage.VIEW_DIMENSION;
                image.Source = bitmap;
                ImageGrid.Items.Add(image);
            }
            catch (Exception)
            {
                // Invalid uri, try again
                FetchDecodedImage();
            }
        }
        private async void FetchDecodedImage()
        {
            try
            {
                Uri             uri    = MainPage.GenerateImageUri();
                WriteableBitmap bitmap = await _imagePipeline.FetchDecodedBitmapImageAsync(
                    ImageRequest.FromUri(uri));

                UpdateImageGrid(bitmap);
            }
            catch (Exception)
            {
                // Invalid uri, try again
                FetchDecodedImage();
            }
        }
Exemplo n.º 3
0
        public async Task TestClearCaches()
        {
            var request = _requestBuilder.Build();
            await _imagePipeline.FetchDecodedBitmapImageAsync(request).ConfigureAwait(false);

            Assert.IsTrue(_imagePipeline.IsInBitmapMemoryCache(request));
            Assert.IsTrue(await _imagePipeline.IsInDiskCacheAsync(request).ConfigureAwait(false));

            await _imagePipeline.ClearCachesAsync().ConfigureAwait(false);

            Assert.IsFalse(_imagePipeline.IsInBitmapMemoryCache(request));
            Assert.IsFalse(await _imagePipeline.IsInDiskCacheAsync(request).ConfigureAwait(false));
        }