2
votes

I'm developing an app using Windows Phone 8.1 where I'm loading an image from the PictureLibrary into a BitmapImage and displaying it in a 150 pixels square.

What I need is to be able to, after selecting an image, open a control where the user can select an area to crop the image to a 150 pixels square, similar to this.

Were I using Windows Phone 8, I would be able to achieve this using PhotoChooserTask, as pointed out in this question.

The beta version of Lumia Imaging SDK had the EditingSession, as shown here, but it was only available when the SDK was in beta, as answered here.

It seems there's no built-in Windows Phone 8.1 control to do this, nor an easy way to do so.

1

1 Answers

1
votes

I am not aware of a UI control to do this for you. To crop an image using the Lumia Imaging SDK add a cropFilter to a FilterEffect and render it. Starting with a source, I will assume that you will have a StorageFile, so a StorageFileImageSource will be perfect for you.

StorageFile sourceFile = ...
using (var source = new StorageFileImageSource(sourceFile))
using (var filterEffect = new FilterEffect(source))
using (var renderer = new JpegRenderer(filterEffect))
{
   filterEffect.Filters = new [] { new CropFilter(x, y, 150, 150));

   var result = await renderer.RenderAsync();
}

To familiarize yourself with the Lumia Imaging SDK I suggest starting with the Core Concepts documentation page