2

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.

Community
  • 1
  • 1
undefined
  • 660
  • 7
  • 18

1 Answers1

1

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

David Božjak
  • 16,887
  • 18
  • 67
  • 98
  • I was planning on using the Lumia's SDK CropFilter to crop it, but unfortunately there's no control on it. Therefore, I'm trying to develop a control where I can select the area and apply it'sw coordinates on the CropFilter. – undefined Aug 30 '15 at 15:56
  • Yes, you will have to make the selection control yourself - Lumia Imaging SDK doesn't provide any UI controls. – David Božjak Aug 30 '15 at 18:30