title: converting bitmap to 8bpp grayscale outputs as 8bpp coloured index in c#
body: <p>I'm trying to convert bitmap to 8bpp grayscale with the code below</p>
  
  <pre><code>private Bitmap ConvertPixelformat(ref Bitmap Bmp)
  {
         Bitmap myBitmap = new Bitmap(Bmp);
          // Clone a portion of the Bitmap object.
          Rectangle cloneRect = new Rectangle(0, 0, Bmp.Width, Bmp.Height);
          PixelFormat format = PixelFormat.Format8bppIndexed;
          Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
          var pal = cloneBitmap.Palette;
  
          for (i = 0; i &lt; cloneBitmap.Palette.Entries.Length; ++i)
          {
              var entry = cloneBitmap.Palette.Entries[i];
              var gray = (int)(0.30 * entry.R + 0.59 * entry.G + 0.11 * entry.B);
              pal.Entries[i] = Color.FromArgb(gray, gray, gray);
          }
          cloneBitmap.Palette = pal;
          cloneBitmap.SetResolution(500.0F, 500.0F);
          return cloneBitmap;
  }
  </code></pre>
  
  <p>Checking the properties of the bitmap image shows that the bit depth is correctly set to 8bpp but not as a grayscale rather it is a coloured index 8bpp.  Kindly guide on what to do.</p>