I have tryed this but have exception - Operation is not valide due to current state of the object
private BitmapFrame backconvertor(byte[] incomingBuffer)
{
BitmapImage bmpImage = new BitmapImage();
MemoryStream mystream = new MemoryStream(incomingBuffer);
bmpImage.StreamSource = mystream;
BitmapFrame bf = BitmapFrame.Create(bmpImage);
return bf;
}
Error rising when I am trying to
return backconvertor(buff);
in other function (buff - is ready!)
Documentation indicates that in order to initialize the image, you need to do it between
BeginInit
andEndInit
. That is:Or, you can pass the stream to the constructor:
See http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.begininit.aspx for an example and more discussion of
BeginInit
.