Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

BmpBitmapDecoder fails to load image from MemoryStream with NotSupportedException

$
0
0
ImageConverter converter = new ImageConverter();
            byte[] byteBmpImage = (byte[])converter.ConvertTo(bmpImage, typeof(byte[]));

            MemoryStream ms = new MemoryStream(byteBmpImage);

            BmpBitmapDecoder decoder2 = new BmpBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            BitmapSource bitmapSource2 = decoder2.Frames[0];

In the above code i'm trying to convert Bitmap object to BitmapSource using BmpBitmapDecoder. But  BmpBitmapDecoder works only with Stream object(from physical location or Uri). It is not supporting MemoryStream. Is there any way to overcome this?

When I tried to use memory stream it was throwing following error.

The Codec cannot use the type of stream provided.

Any solution/suggestion would be helpful.

Thanks.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>