title: C# - Converting 8-bit or 16-bit grayscale raw pixel data
body: <p>I need to be able to convert 8-bit or 16-bit grayscale pixel data into a file format that the .NET framework can support.</p>
  
  <p>The data I have available is the width, height, orientation (bottom-left) and the pixel format as 4096 shades of gray (12-bit resolution) packed in 2 bytes per pixel.</p>
  
  <p>So for example each pixel ranges from 0 to 4096, and each pixel is 2 bytes.</p>
  
  <p>I have already tried using PixelFormat.Format16bppGrayScale with the Bitmap constructor, and it throws a GDI+ exception.  Everything I have read says that this format is not supported and that MSDN is wrong.</p>
  
  <p>I want to convert this pixel buffer into a .NET Bitmap format (such as Format32bppArgb) with as little image quality loss as possible.</p>
  
  <p>Anyone know how?</p>