views:

162

answers:

2
+3  A: 

You have to convert the image from indexed to non indexed. Try this code to convert it:

    public Bitmap CreateNonIndexedImage(Image src)
    {
        Bitmap newBmp = new Bitmap(src.Width, src.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        using (Graphics gfx = Graphics.FromImage(newBmp)) {
            gfx.DrawImage(src, 0, 0);
        }

        return newBmp;
    }
Oskar Kjellin
A: 

try the following

Bitmap myBitmap = new Bitmap(@"c:\file.bmp");
MessageBox.Show(myBitmap.PixelFormat.ToString());

If you get "Format8bppIndexed" then the color of each pixel of the Bitmap is replaced by an index into a table of 256 Colors. and therefor each pixel is represented by only one byte. you can get an array of colors:

if (myBitmap.PixelFormat == PixelFormat.Format8bppIndexed) {
    Color[] colorpal = myBitmap.Palette.Entries;
}
Oops