gif默认就是Format8bppIndexedBitmap OriginalBitmap=new Bitmap(Server.MapPath("aaa.bmp"));
OriginalBitmap.Save(Server.MapPath("cc.gif"),ImageFormat.Gif);
Bitmap OutBitmap = new Bitmap(Server.MapPath("ccc.gif"));
Response.Write(OutBitmap.PixelFormat+"<br>");

解决方案 »

  1.   

    这个我知道,Format8bppIndexed就是256色,我要生成16色的,那就是Format4bppIndexed了,那该怎么弄呢?还有32色的怎么生成呢?PixelFormat枚举中并没有32色的定义啊
      

  2.   

    GIF is not a lossy compression. It isn't the quality that's bad, it's the
    color table. GDI+ will always convert your image to 8bpp from 32bpp using
    a default "rainbow" paletteFor more, please have a look at 
    http://www.dotnet247.com/247reference/msgs/28/140382.aspxAlso there are some useful links of MS knowledge.
      

  3.   

    感谢qiushuiwuhen(秋水无恨) 和TheAres(班门斧) 
    我现在用看微软的HOW TO: Save a .gif File with a New Color Table By Using Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;en-us;319061
    我用上面给出的示例代码试了一下,好像还可以,不过生成的图像是灰度的,不知道怎么才能生成彩色16色或32色的?她的代码中说可以自己写生成调色板的算法,可我一点也不懂啊~~