在.net中使用GDI+来提高gif图片的保存画质,这就是“Octree“ 算法。“Octree“ 算法允许我们插入自己的算法来量子化我们的图像。
使用octreequantizer很方便:
隐藏行号 复制代码 ?代码
system.drawing.bitmap b = new System.Drawing.Bitmap("c:\original_image.gif");
System.Drawing.Image thmbnail = b.GetThumbnailImage(100,75,null,new IntPtr());
OctreeQuantizer quantizer = new OctreeQuantizer ( 255 , 8 ) ;
using ( Bitmap quantized = quantizer.Quantize ( thmbnail ) )
{
quantized.Save("c:\thumnail.gif", System.Drawing.Imaging.ImageFormat.Gif);
}
octreequantizer grayquantizer = new GrayscaleQuantizer ( ) ;
using ( Bitmap quantized = grayquantizer.Quantize ( thmbnail ) )
{
quantized.Save("c:\thumnail.gif", System.Drawing.Imaging.ImageFormat.Gif);
}
本文转自 OH51888 51CTO博客,原文链接:http://blog.51cto.com/rozbo/1240770,如需转载请自行联系原作者