I was looking for the fastest way to convert a Bitmap to 8bpp. I found 2 ways:
1.
public static System.Drawing.Image Conver
I don't know why there is something strange about the Bitmap created by the FromHbitmap
method, but I do know that you can fix it by using Bitmap bmpClone = (Bitmap)bmp.Clone();
and doing the LockBits on bmpClone.
Also, I found that if you use bmp.Clone()
, you cannot Dispose() of bmp until you have finished with the clone.
This also works and let's you dispose of the negative stride image sooner rather than later:
Bitmap bmp = null;
using (Bitmap bmpT = CopyToBpp(bmpO, 1))
{
bmp = new Bitmap(bmpT);
}