Chinaunix首页 | 论坛 | 博客
  • 博客访问: 492625
  • 博文数量: 23
  • 博客积分: 7960
  • 博客等级: 少将
  • 技术积分: 1345
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-11 04:05
文章分类

全部博文(23)

文章存档

2010年(1)

2009年(2)

2008年(20)

我的朋友

分类: 系统运维

2008-11-01 22:58:40

    ///
    /// 彩色图片转化为黑白
    ///

    ///
    ///
    public static Bitmap ConvertToGrayscale(Bitmap bitmap)
    {
        Bitmap bm = new Bitmap(bitmap.Width, bitmap.Height);
        for (int y = 0; y < bm.Height; y++)
        {
            for (int x = 0; x < bm.Width; x++)
            {
                Color c = bitmap.GetPixel(x, y);
                int rgb = (int)(c.R * 0.3 + c.G * 0.59 + c.B * 0.11);
                bm.SetPixel(x, y, Color.FromArgb(rgb, rgb, rgb));
            }
        }
        return bm;
    }
阅读(1504) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~