3

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?

nimbudew
  • 958
  • 11
  • 28

1 Answers1

4

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.

David Božjak
  • 16,887
  • 18
  • 67
  • 98
  • I was using `JpegTools.AutoResizeAsync()` to do it until now. This is rather fast and saves an async call. – nimbudew Jul 02 '15 at 07:11