×

LensBlurEffect Class

Applies blur to an image in a way similar to how out-of-focus areas are rendered by a lens, an effect also known as bokeh.

Inheritance Hierarchy

System..::..Object  Nokia.Graphics.Imaging..::..LensBlurEffect

Namespace: Nokia.Graphics.ImagingAssembly: Nokia.Graphics.Imaging (in Nokia.Graphics.Imaging.dll) Version: 255.255.255.255

Syntax

C#
public sealed class LensBlurEffect : IClosable, 
	IImageProvider, IImageConsumer, __ILensBlurEffectPublicNonVirtuals
Visual Basic
Public NotInheritable Class LensBlurEffect 
	Implements IClosable, IImageProvider, IImageConsumer, __ILensBlurEffectPublicNonVirtuals
Visual C++
public ref class LensBlurEffect sealed : IClosable, 
	IImageProvider, IImageConsumer, __ILensBlurEffectPublicNonVirtuals

Examples

C#

This sample takes CameraCaptureTask result photo and applies a LensBlur effect to it.

async void CaptureTask_Completed(object sender, PhotoResult e)
{
    const string imageFile = @"Assets\mask.jpg";
    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

        using (var source = new StreamImageSource(e.ChosenPhoto))
        using (var maskSource = new StorageFileImageSource(file))
        using (var segmentation = new InteractiveForegroundSegmenter(source))
        using (var lensBlurEffect = new LensBlurEffect(source, new LensBlurPredefinedKernel(LensBlurPredefinedKernelShape.Circle, 20)))
        {
            segmentation.AnnotationsSource = maskSource; 
            segmentation.ForegroundColor = Color.FromArgb(255, 255, 255, 255); 
            segmentation.BackgroundColor = Color.FromArgb(255, 255, 238, 51); 
            segmentation.Quality = 0.5;
                    
            lensBlurEffect.KernelMap = segmentation;

            // Create a target where the filtered image will be rendered to
            var target = new WriteableBitmap((int)ImageControl.ActualWidth, (int)ImageControl.ActualHeight);

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

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

Visual C++


Last updated 19 June 2014

Back to top

×