Asp.net(C#)-彩色图片转化为黑白
生活随笔
收集整理的這篇文章主要介紹了
Asp.net(C#)-彩色图片转化为黑白
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
??? /// <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;?
????}
????/// 彩色圖片轉化為黑白?
????/// </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;?
????}
轉載于:https://www.cnblogs.com/top5/archive/2009/09/29/1576280.html
總結
以上是生活随笔為你收集整理的Asp.net(C#)-彩色图片转化为黑白的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 排序算法全分析
- 下一篇: 给Repeater、Datalist和D