Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Portrait picture orientation bug?

Using sdk 3 , When i render a portrait picture taken from a Windows 10 mobile it appears stretched with wrong orientation . How to fix it ? Is it Os bug or Sdk bug ?

        m_image = new Lumia.Imaging.StorageFileImageSource(file);
        m_renderer = new SwapChainPanelRenderer(m_image, panel);
        await m_renderer.RenderAsync();   

sample

like image 839
yannis Avatar asked Dec 30 '25 06:12

yannis


1 Answers

It's true, there appears to be a bug in the Lumia Imaging SDK when it comes to EXIF orientation and rendering on GPU.

That said, there is an easy workaround. When you first load an IImageProvider from an StorageFile, make a temporray bitmap and use that as a source in your other rendering operations. That way you will only take the penalty of a CPU-only render operation once, in the most limited possible scenario. All your other rendering operations will the optimally GPU accelerated.

Here is a helper method to use when using a StorageFile as a source:

public static async Task<IImageProvider> CreateImageSourceFromFile(StorageFile file)
{
    using (var source = new StorageFileImageSource(file))
    using (var renderer = new BitmapRenderer(source) { RenderOptions = RenderOptions.Cpu })
    {
        var bitmap = await renderer.RenderAsync();
        return new BitmapImageSource(bitmap);
    }
}
like image 51
David Božjak Avatar answered Jan 05 '26 09:01

David Božjak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!