title: how to convert a jpeg in an array into a bitmap
body: <p>I have a functioning application in c#/.net that currently accepts raw image data in a bayer format from a set of embedded cameras and converts them to jpeg images.  To save transmission time, I have modified the embedded devices to encode the images as jpegs prior to transmission.  I'm an experienced embedded programmer but a total c#/.net noob.  I have managed to modify the application to save the arrays to file with a jpeg name using this snippet: ( the offset of 5 is to skip header data in the transmission frame)</p>
  
  <pre><code>FileStream stream = File.Create(fileName);
  BinaryWriter writer = new BinaryWriter(stream);
  writer.Write(multiBuff.msgData, 5, multiBuff.dataSize - 5);
  writer.Close();
  </code></pre>
  
  <p>The files open up fine, but now I want to treat the data as a bitmap without having to save &amp; load from file.  I tried the following on the data array:</p>
  
  <pre><code>MemoryStream stream = new MemoryStream(data);
  BinaryReader reader = new BinaryReader(stream);
  byte[] headerData = reader.ReadBytes(5);
  Bitmap bmpImage = new Bitmap(stream);
  </code></pre>
  
  <p>But this throws a parameter not valid exception.  As a newbie, I'm a little overwhelmed with all the classes and methods for images and it seems like what I'm doing should be commonplace, but I can't find any examples in the usual places.  Any ideas?</p>