title: Editing 8bpp indexed Bitmaps
body: <p>i'm trying to edit the pixels of a 8bpp. Since this <code>PixelFormat</code> is <code>indexed</code> i'm aware that it uses a Color Table to map the pixel values.</p>
  <p>Even though I can edit the bitmap by converting it to 24bpp, 8bpp editing is much faster (13ms vs 3ms). But, changing each value when accessing the 8bpp bitmap results in some random rgb colors even though the PixelFormat remains 8bpp.</p>
  <p>I'm currently developing in C# and the algorithm is as follows:</p>
  <ol>
  <li>Load original Bitmap at 8bpp</li>
  <li>Create Empty temp Bitmap with 8bpp with the same size as the original</li>
  <li>LockBits of both bitmaps and, using P/Invoke, calling C++ method where I pass the <code>Scan0</code> of each <code>BitmapData</code> object. (I used a C++ method as it offers better performance when iterating through the Bitmap's pixels)</li>
  <li>Create a <code>int[256]</code> palette according to some parameters and edit the temp bitmap bytes by passing the original's pixel values through the palette.</li>
  <li>UnlockBits.</li>
  </ol>
  <p>My question is how can I edit the pixel values without having the strange rgb colors. Or, even better, how can I edit the 8bpp bitmap's Color Table?</p>