public CartoonWrapperFilter()
            : base()
        {
            Name = "Cartoon";
            ShortDescription = "Cartoon";

            _cartoonFilter = new CartoonFilter();
        }
Exemplo n.º 2
0
        public MarvelFilter()
            : base()
        {
            Name = "Marvel";
            ShortDescription = "Cartoon";

            _cartoonFilter = new CartoonFilter {DistinctEdges = DefaultDistinctEdges};
        }
Exemplo n.º 3
0
        public MarvelFilter()
        {
            Name = "Marvel";
            ShortDescription = "Cartoon";

            Filter = new CartoonFilter {DistinctEdges = DefaultDistinctEdges};

            CreateControl();
        }
Exemplo n.º 4
0
        public MarvelFilter()
            : base()
        {
            Name             = "Marvel";
            ShortDescription = "Cartoon";

            _cartoonFilter = new CartoonFilter {
                DistinctEdges = DefaultDistinctEdges
            };
        }
Exemplo n.º 5
0
        public MarvelFilter()
        {
            Name             = "Marvel";
            ShortDescription = "Cartoon";

            Filter = new CartoonFilter {
                DistinctEdges = DefaultDistinctEdges
            };

            CreateControl();
        }
Exemplo n.º 6
0
        private async Task <bool> ApplyFilterAsync(StorageFile file)
        {
            // Open a stream for the selected file.
            IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read);

            string errorMessage = null;

            try
            {
                // Show thumbnail of original image.
                _thumbnailImageBitmap.SetSource(fileStream);
                OriginalImage.Source = _thumbnailImageBitmap;

                // Rewind stream to start.
                fileStream.Seek(0);

                // A cartoon effect is initialized with selected image stream as source.
                var imageStream = new RandomAccessStreamImageSource(fileStream);
                _cartoonEffect = new FilterEffect(imageStream);

                // Add the cartoon filter as the only filter for the effect.
                var cartoonFilter = new CartoonFilter();
                _cartoonEffect.Filters = new[] { cartoonFilter };

                // Render the image to a WriteableBitmap.
                var renderer = new WriteableBitmapRenderer(_cartoonEffect, _cartoonImageBitmap);
                _cartoonImageBitmap = await renderer.RenderAsync();

                _cartoonImageBitmap.Invalidate();

                // Set the rendered image as source for the cartoon image control.
                CartoonImage.Source = _cartoonImageBitmap;
            }
            catch (Exception exception)
            {
                errorMessage = exception.Message;
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                var dialog = new MessageDialog(errorMessage);
                await dialog.ShowAsync();

                return(false);
            }

            return(true);
        }
        private async void PickImageCallback(object sender, PhotoResult e)
        {
            if (e.TaskResult != TaskResult.OK || e.ChosenPhoto == null)
            {
                return;
            }

            try
            {
                // Show thumbnail of original image.
                _thumbnailImageBitmap.SetSource(e.ChosenPhoto);
                OriginalImage.Source = _thumbnailImageBitmap;

                // Rewind stream to start.
                e.ChosenPhoto.Position = 0;

                // A cartoon effect is initialized with selected image stream as source.
                var imageStream = new StreamImageSource(e.ChosenPhoto);
                _cartoonEffect = new FilterEffect(imageStream);

                // Add the cartoon filter as the only filter for the effect.
                var cartoonFilter = new CartoonFilter();
                _cartoonEffect.Filters = new[] { cartoonFilter };

                // Render the image to a WriteableBitmap.
                var renderer = new WriteableBitmapRenderer(_cartoonEffect, _cartoonImageBitmap);
                _cartoonImageBitmap = await renderer.RenderAsync();

                // Set the rendered image as source for the cartoon image control.
                CartoonImage.Source = _cartoonImageBitmap;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }

            SaveButton.IsEnabled = true;
        }
        private async void PickImageCallback(object sender, PhotoResult e)
        {
            if (e.TaskResult != TaskResult.OK || e.ChosenPhoto == null)
                return;

            try
            {
                // Show thumbnail of original image.
                _thumbnailImageBitmap.SetSource(e.ChosenPhoto);
                OriginalImage.Source = _thumbnailImageBitmap;

                // Rewind stream to start.                     
                e.ChosenPhoto.Position = 0;
                                
                // A cartoon effect is initialized with selected image stream as source.
                var imageStream = new StreamImageSource(e.ChosenPhoto);
                _cartoonEffect = new FilterEffect(imageStream);

                // Add the cartoon filter as the only filter for the effect.
                var cartoonFilter = new CartoonFilter();
                _cartoonEffect.Filters = new[] { cartoonFilter };

                // Render the image to a WriteableBitmap.
                var renderer = new WriteableBitmapRenderer(_cartoonEffect, _cartoonImageBitmap);
                _cartoonImageBitmap = await renderer.RenderAsync();

                // Set the rendered image as source for the cartoon image control.
                CartoonImage.Source = _cartoonImageBitmap;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
                return;
            }

            SaveButton.IsEnabled = true;
        }
        private async Task<bool> ApplyFilterAsync(StorageFile file)
        {
            // Open a stream for the selected file.
            IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read);

            string errorMessage = null;

            try
            {
                // Show thumbnail of original image.
                _thumbnailImageBitmap.SetSource(fileStream);
                OriginalImage.Source = _thumbnailImageBitmap;

                // Rewind stream to start.                     
                fileStream.Seek(0);

                // A cartoon effect is initialized with selected image stream as source.
                var imageStream = new RandomAccessStreamImageSource(fileStream);
                _cartoonEffect = new FilterEffect(imageStream);

                // Add the cartoon filter as the only filter for the effect.
                var cartoonFilter = new CartoonFilter();
                _cartoonEffect.Filters = new[] { cartoonFilter };

                // Render the image to a WriteableBitmap.
                var renderer = new WriteableBitmapRenderer(_cartoonEffect, _cartoonImageBitmap);
                _cartoonImageBitmap = await renderer.RenderAsync();
                _cartoonImageBitmap.Invalidate();

                // Set the rendered image as source for the cartoon image control.
                CartoonImage.Source = _cartoonImageBitmap;
            }
            catch (Exception exception)
            {
                errorMessage = exception.Message;
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                var dialog = new MessageDialog(errorMessage);
                await dialog.ShowAsync();
                return false;
            }

            return true;
        }