tags:

views:

14

answers:

0

Hello,

I have this code to decode a memory stream, but, its not woring, I get this error: "No imaging component suitable to complete this operation was found."

MemoryStream stream = new MemoryStream(value, false);
                stream.Seek(0, SeekOrigin.Begin);
                JpegBitmapDecoder JpegBitmapDecoder = new JpegBitmapDecoder(
                    stream, BitmapCreateOptions.None,
                    BitmapCacheOption.None);

                image.Source = JpegBitmapDecoder.Frames[0];
                image.Height = hh;
                image.Width = ww;
                stream.Close();
                UIVisual.Background = null;
                UIVisual.Child = image;
                UIVisual.UpdateLayout();
                image = null;

And here is how I converted the image to bytes:

    JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder();

    jpgEncoder.Frames.Add(bitmapFrame);
    Byte[] _imageArray;
    MemoryStream memStream = new MemoryStream();
    jpgEncoder.Save(memStream);
    return memStream.ToArray();

so, I store memStream.ToArray() to use it later, I create MemoryStream from the stored memStream.ToArray() and use it with JpegBitmapDecoder like the code above.

Why I can't retrieve the stored bytes ?? is there some wrong I doing ?? Thanks