title: How to convert Bitmap image to byte array in wp7?
body: <pre><code>using (MemoryStream ms = new MemoryStream())
  {
      image.CreateOptions = BitmapCreateOptions.None;
      image.UriSource = new Uri("/Images/chef.png", UriKind.Relative);              
  
      WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
      LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight,0,95);
      ms.Seek(0, 0);
      byte[] data = new byte[ms.Length];
      ms.Read(data, 0, data.Length);
      ms.Close();
   }
  </code></pre>
  
  <p>I am getting NullReferenceException at image, but my path is also correct and image also exists.</p>
  
  <pre><code>WriteableBitmap LoadedPhoto = new WriteableBitmap(image);
  </code></pre>
  
  <p>Is anything goes wrong.</p>