0

I have used code snipped from the documentation of Lumia Imaging SDK. I have Fileopenpicker in my code and calls the viewActivated method. In this method i used the lumia imaging sdk BlurEffect code which you can find here. There are no errors but i can't get my image blurred.

Here is my full code which i used:

private void Button_Click(object sender, RoutedEventArgs e)
    {
        ImagePath = string.Empty;
        FileOpenPicker filePicker = new FileOpenPicker();
        filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        filePicker.ViewMode = PickerViewMode.Thumbnail;

        // Filter to include a sample subset of file types
        filePicker.FileTypeFilter.Clear();
        filePicker.FileTypeFilter.Add(".bmp");
        filePicker.FileTypeFilter.Add(".png");
        filePicker.FileTypeFilter.Add(".jpeg");
        filePicker.FileTypeFilter.Add(".jpg");

        filePicker.PickSingleFileAndContinue();
        view.Activated += viewActivated;

    }



    private async void  viewActivated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args1)
    {
        //throw new NotImplementedException();

        FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;

        if (args != null)
        {
            if (args.Files.Count == 0) return;

            view.Activated -= viewActivated;
            StorageFile storageFile = args.Files[0];
            var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
            var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
            await bitmapImage.SetSourceAsync(stream);

            var decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream);
            RealImage.Source = bitmapImage;

            // A blur effect is initialized with selected image stream as source.
            IRandomAccessStream fileStream = await storageFile.OpenAsync(FileAccessMode.Read);
            var imageStream = new RandomAccessStreamImageSource(fileStream);
            using (var filterEffect = new FilterEffect(imageStream))
            {
                // Initialize the filter and add the filter to the FilterEffect collection
                var filter = new BlurFilter(10);

                filterEffect.Filters = new IFilter[] { filter };

                // Create a target where the filtered image will be rendered to
                var target = new WriteableBitmap(400, 400);

                // Create a new renderer which outputs WriteableBitmaps
                using (var renderer = new WriteableBitmapRenderer(filterEffect, target))
                {
                    // Render the image with the filter(s)
                    await renderer.RenderAsync();

                    // Set the output image to Image control as a source
                    BlurredImage.Source = target;
                }


            }


        }

    }
Saad Anees
  • 1,255
  • 1
  • 15
  • 32
  • Can you describe the result you are seing? Do you get an exception, or is the result just visually different than what you expect? Have you tried with a different kernel size, the BlurFilter has a range from [0, 255] so it could be that you just need a larger value than "10" to see a noticeable difference. – David Božjak Jul 10 '15 at 13:54
  • @DavidBožjak there is no possible result i can tell. No exception either. I tried 100 for Blur range and it didn't have any impact on it. I also debugged line by line. The code runs fine. – Saad Anees Jul 11 '15 at 14:16
  • Hm, can't really see what is going wrong. What version of the SDK are you using? Does it work if you apply another filter - is it strictly a blur filter problem? – David Božjak Jul 11 '15 at 17:42

0 Answers0