top5
    /// <summary> 
    /// 彩色图片转化为黑白 
    /// </summary> 
    /// <param name="source"></param> 
    /// <returns></returns> 
    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; 
    }

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-12-21
  • 2022-01-28
  • 2021-11-26
  • 2022-12-23
  • 2021-12-17
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2022-02-14
  • 2021-12-31
  • 2021-11-17
  • 2021-08-06
  • 2021-05-18
相关资源
相似解决方案