none
[UWP] Save an IImageProvider in png format using Lumia Imaging SDK v3

    Question

  • Is there any way to save an IImageProvider in PNG format using Lumia Imaging SDK? Like, JpegRenderer can be used to save an IImageProvider in JPEG format.

    I know how to do it with BitmapEncoder but don't know how to do the same using lumia imaging sdk. Please help me out


    Clipr : Best ever clipping tool in Windows Phone!
    Download here

    Tuesday, January 5, 2016 6:42 PM

Answers

  • Use the BitmapEncoder.

    There isn't a PngRenderer, but you can use a SoftwareBitmapRenderer then set it on BitmapEncoder.SetSoftwareBitmap.

    • Marked as answer by venu238 Thursday, January 7, 2016 6:00 PM
    Tuesday, January 5, 2016 8:48 PM

All replies

  • Use the BitmapEncoder.

    There isn't a PngRenderer, but you can use a SoftwareBitmapRenderer then set it on BitmapEncoder.SetSoftwareBitmap.

    • Marked as answer by venu238 Thursday, January 7, 2016 6:00 PM
    Tuesday, January 5, 2016 8:48 PM
  • Thank you Rob,

    Here is the working code if any one needs

    using (var softwareBitmapRenderer = new SoftwareBitmapRenderer(imageSource))
    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
    using (var softwareBitmap = await softwareBitmapRenderer.RenderAsync().AsTask().ConfigureAwait(false))
    {
        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
        encoder.SetSoftwareBitmap(softwareBitmap);
        await encoder.FlushAsync();
    }


    Clipr : Best ever clipping tool in Windows Phone!
    Download here

    Thursday, January 7, 2016 6:03 PM