title: The image header is unrecognized. (Exception from HRESULT: 0x88982F61) in Windows Phone 8 application
body: <p>Here is my code... </p>
  
  <pre><code>    public async Task SetLargeImageAsync(byte[] imageBytes,
          bool storeBytesInObject = false)
      {
  
          var tcs = new TaskCompletionSource&lt;string&gt;();
  
          SmartDispatcher.BeginInvoke(() =&gt;
          {
              using (MemoryStream ms = new MemoryStream(imageBytes))
              {
  
                  if (storeBytesInObject)
                      this.LargeImageBytes = imageBytes;
  
                  BitmapImage image = new BitmapImage();
  
                  image.SetSource(ms);
  
                  this.LargeImage = image;
  
                  tcs.SetResult(string.Empty);
              }
          });
  
          await tcs.Task;
      }
  </code></pre>
  
  <p>I am sending bytes into stream. This works fine; it is showing an image.</p>
  
  <p>But I am getting the following exception sometimes:</p>
  
  <blockquote>
    <p>The image header is unrecognized. (Exception from HRESULT: 0x88982F61) 
    at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
      at MS.Internal.XcpImports.BitmapSource_SetSource(BitmapSource bitmapSource, CValue&amp; byteStream)
      at System.Windows.Media.Imaging.BitmapSource.SetSourceInternal(Stream streamSource)
      at System.Windows.Media.Imaging.BitmapImage.SetSourceInternal(Stream streamSource)
      at System.Windows.Media.Imaging.BitmapSource.SetSource(Stream streamSource)</p>
  </blockquote>
  
  <p>What is the problem? Is there any problem with different types of images?</p>
  
  <p>I found somewhere that we should use following code for seeking beginning position:</p>
  
  <pre><code>ms.Seek(0, SeekOrigin.Begin)
  </code></pre>
  
  <p>Is it true? What is the solution for that?  </p>