当前位置:首页 > .Net中使用GDI+提高gif图片画质的代码

.Net中使用GDI+提高gif图片画质的代码

点击次数:1593  更新日期:2010-12-28
\n

  在.net中使用GDI+来提高gif图片画质,这就是“Octree” 算法。“Octree”算法允许我们插入自己的算法来量子化我们的图像。


\n

  使用octreequantizer很方便:


\n

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);
  }


\n

  主要代码就这么多,是不是很简单呢?


\n

本文由设计家园 http://www.dwww.cn 收集整理

\n