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.