Applying Nokia Imaging SDK Filters on Image in Windows Phone 8

In the previous post, we have seen how we use the Nokia Imaging SDK in Windows Phone 8 App. In this post; we would see how we apply the Nokia Imaging SDK filter on the image in Windows Phone 8.

Let’s have a simple layout; the following design shows that, we have an image control named ImageSample.

Also, let’s have an app bar button; using it’s click event we could apply the filter to the image.

Now before we start, do some coding; You need to add these namespaces explicitly.

Here’s the sample application would work; application would start by opening the PhotoChooserTask; and you need to choose a photo from it.

On Completed event of the PhotoChooserTask, we would apply the filter to the image.

If the TaskResult is OK, that means you have selected an image from the Photo Album; then only we would display the image.

Also you see in the above code, we are using a Writable Bitmap which fills the imageStream object of type MemoryStream.

Now, using the width and height is very important in this case. If you provide different width and height other than the image’s width and height; you could end up having run time errors.

To apply filter on the image; you need to have the EditingSession class object. It uses the Nokia.Graphics.Imaging namespace.

As we have discussed earlier, an app bar button click would apply the filter to the image. In the following code; the Buffer is taken from the MemoryStream object. Then we are having the EditingSession object. Note that, InputImageFormat.Jpeg is not mandatory; you could opt out that.

Also we are adding the filter to the EditingSession object. In this example, it’s a CartoonFilter.

The important part here is to apply the Width and Height of the image.

Then using the RenderToImageAsync method of EditingSession object, we apply the filter.

Let’s run the application. As discussed earlier; the app would go directly to the Photos application to choose a photo.

We are selecting from the saved pictures folder.

The original image is displayed as follows.

On Cartoon app bar button click; the filter is applied to the image.

Hope this post is useful.