How do I resize an image using the Lumia Imaging SDK?

How do I resize an image using the Lumia Imaging SDK? The documentation seems to be very bad and I cannot find examples / methods for resizing (not cropping) an image on Windows Phone 8.1.

What methods can I use?

+3


source to share


1 answer


You must set the "Size" property in the renderer. This will resize the image to the required size.

Looking at JpegRenderer ( https://msdn.microsoft.com/en-us/library/lumia.imaging.jpegrenderer_members.aspx ) set the size to whatever you want. Alternatively, you can set the OutputOption property ( https://msdn.microsoft.com/en-us/library/lumia.imaging.outputoption.aspx ) if you want the content to be stretched or to keep the aspect ratio instead.

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 use BitmapRenderer or WriteableBitmapRenderer and pass in a (bitmap) bitmap, the rendering will automatically resize the content to the size of that image.

+4


source







All Articles