BitmapEncoder/ decoder, memory stream and NotSupportedException c# .net
I have the following code:
MemoryStream imageStream;
public ImageVideoFrame(BitmapSource frame)
{
imageStream = new MemoryStream();
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(frame));
encoder.Save(imageStream);
imageStream.Seek(0, SeekOrigin.Begin);
}
public BitmapSource Frame
{
BitmapDecoder decoder = new PngBitmapDecoder(image,
开发者_StackOverflow BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
BitmapSource bitmapSource = decoder.Frames.First();
return bitmapSource;
}
used to compress images in memory to reduce memory usage. The problem with the above code is that I get a NotSupportedExcpetion Constructing the PngBitmapDecoder. When debugging the position of the imageStream is shown to be
精彩评论