温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-07-05 18:42:10 来源:网络 阅读:650 作者:OH51888 栏目:编程语言

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

    使用octreequantizer很方便:

隐藏行号 复制代码 代码
  1.  system.drawing.bitmap b = new System.Drawing.Bitmap("c:\original_image.gif");  
    
  2. System.Drawing.Image thmbnail = b.GetThumbnailImage(100,75,null,new IntPtr()); 
    
  3. OctreeQuantizer quantizer = new OctreeQuantizer ( 255 , 8 ) ; 
    
  4. using ( Bitmap quantized = quantizer.Quantize ( thmbnail ) ) 
    
  5. { 
    
  6.      quantized.Save("c:\thumnail.gif", System.Drawing.Imaging.ImageFormat.Gif); 
    
  7. } 
    
  8. octreequantizer grayquantizer = new GrayscaleQuantizer ( ) ; 
    
  9. using ( Bitmap quantized = grayquantizer.Quantize ( thmbnail ) ) 
    
  10. { 
    
  11.      quantized.Save("c:\thumnail.gif", System.Drawing.Imaging.ImageFormat.Gif); 
    
  12. } 
    
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI