title: C# - How to convert an Image into an 8-bit color Image?
body: <p>I need to convert a PNG Image loaded from a file into an 8 bit-per-pixel byte array used by another device (embedded programming).</p>
  
  <p>I'm copying over pixel by pixel into a new Image created with a 16-bit color - <code>Format16bppRgb565</code>, but I need <code>Format8bpp</code>, which is not present in the .NET Framework. (I cannot use <code>Format8bppIndexed</code> since the other device cannot handle indexed bitmaps)</p>
  
  <pre><code> Bitmap img = new Bitmap(imgPath);
   Bitmap img8 = new Bitmap(imgW, imgH, PixelFormat.Format16bppRgb565);
   for (int I = 0; I &lt;= img.Width - 1; I++) {
       for (int J = 0; J &lt;= img.Height - 1; J++) {
           img8.SetPixel(I, J, img.GetPixel(I, J));
       }
   }
  </code></pre>
  
  <p>So how can I convert an Image into an 8-bit per pixel byte array?</p>
  
  <ul>
  <li>Can I use the 8-bit indexed format and extract the bytes? - <code>Format8bppIndexed</code></li>
  <li>Can I calculate the pixel colors by reducing the 32-bit color R,G,B values to 8-bit?</li>
  <li>Is there a C# library that does this already?</li>
  <li>"The easiest way is to create a new 8 bit bitmap, and draw your 24 bit image onto it." - how?</li>
  </ul>