3
votes

How can I resize an image using the Lumia Imaging SDK? The documentation seems to be very poor and I cannot find any examples/methods to resize (not crop) the image on Windows Phone 8.1.

Which methods can I use?

1

1 Answers

4
votes

You should set the Size property on the renderer. That will resize the image to the size you want.

Looking at the JpegRenderer (https://msdn.microsoft.com/en-us/library/lumia.imaging.jpegrenderer_members.aspx) set the Size to what you want the size to be. In addition you can set the OutputOption property (https://msdn.microsoft.com/en-us/library/lumia.imaging.outputoption.aspx) if you want the contents to be Stretched or to preserve aspect ratio instead.

A quick example:

using (var source = ...)
using (var renderer = new JpegRenderer(source))
{
   renderer.Size = new Size(800, 600);
   renderer.OutputOption = OutputOption.Stretch;

   var result = await renderer.RenderAsync();
}

If you are using a BitmapRenderer or a WriteableBitmapRenderer and pass in the (writeable)bitmap the renderer will automatically resize the contents to the size of that image.