0
Answer

Can't convert to Format8bppIndexed with LockBits, Why?

TomHL

TomHL

19y
3.5k
1

Hello,

I wrote a method to convert image's color table.

public class convert
{
    public static Bitmap bmp_convert(System.Drawing.Image pic)
    {
   
        Bitmap b = new Bitmap (pic);
        BitmapData bmData =b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format16bppArgb1555);
        b.UnlockBits(bmData);

        return b;
    }
}

unfortunately, I can't convert my image to Format8bppIndexed (or any indexed format) while to the other formats I can...(like: Format16bppArgb1555),why? and how can I fix it?