You have to copy the color palette too!
dstImage.Palette = source.Palette;
Btw. you should fix your pointers when using unsafe code!
http://msdn.microsoft.com/en-us/library/f58wzh21(VS.80).aspx[
^]
I used the following version of your snippet:
public static unsafe Bitmap CopyToNewBitmap(Bitmap source)
{
int width = source.Width;
int height = source.Height;
BitmapData srcData = source.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, source.PixelFormat);
byte* src = (byte*)srcData.Scan0.ToPointer();
Bitmap dstImage = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
dstImage.Palette = source.Palette;
BitmapData dstData = dstImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, dstImage.PixelFormat);
byte* dst = (byte*)dstData.Scan0.ToPointer();
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++, src++, dst++)
{
*dst = *src;
}
src = src + srcData.Stride - srcData.Width;
dst = dst + dstData.Stride - dstData.Width;
}
source.UnlockBits(srcData); dstImage.UnlockBits(dstData);
return dstImage;
}