欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解析C#彩色圖像灰度化算法的實現(xiàn)代碼詳解

 更新時間:2013年05月20日 10:07:20   作者:  
本篇文章是對C#中彩色圖像灰度化算法的實現(xiàn)進行了詳細的分析介紹,需要的朋友參考下
代碼如下所示:
復制代碼 代碼如下:

        public static Bitmap MakeGrayscale(Bitmap original)
        {
            //create a blank bitmap the same size as original
            Bitmap newBitmap = new Bitmap(original.Width, original.Height);
            //get a graphics object from the new image
            Graphics g = Graphics.FromImage(newBitmap);
            //create the grayscale ColorMatrix
            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
               new float[][]
              {
                 new float[] {.3f, .3f, .3f, 0, 0},
                 new float[] {.59f, .59f, .59f, 0, 0},
                 new float[] {.11f, .11f, .11f, 0, 0},
                 new float[] {0, 0, 0, 1, 0},
                 new float[] {0, 0, 0, 0, 1}
              });
            //create some image attributes
            System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();
            //set the color matrix attribute
            attributes.SetColorMatrix(colorMatrix);
            //draw the original image on the new image
            //using the grayscale color matrix
            g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
               0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
            //dispose the Graphics object
            g.Dispose();
            return newBitmap;
        }

相關文章

  • C#.NET 圖片水印添加代碼

    C#.NET 圖片水印添加代碼

    這篇文章主要為大家詳細介紹了C#.NET 圖片水印添加代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-07-07
  • C# [ImportDll()] 知識小結(jié)

    C# [ImportDll()] 知識小結(jié)

    今天小編就為大家分享一篇關于C# [ImportDll()] 知識小結(jié),小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • WPF+ASP.NET SignalR實現(xiàn)后臺通知功能的示例代碼

    WPF+ASP.NET SignalR實現(xiàn)后臺通知功能的示例代碼

    本文以一個簡單示例,簡述如何通過WPF+ASP.NET SignalR實現(xiàn)消息后臺通知以及數(shù)據(jù)的實時刷新,僅供學習分享使用,如有不足之處,還請指正
    2022-09-09
  • C#開發(fā)微信門戶及應用(2) 微信消息處理和應答

    C#開發(fā)微信門戶及應用(2) 微信消息處理和應答

    文章主要為大家詳細介紹了C#開發(fā)微信門戶及應用第二篇,微信消息處理和應答,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • c#中文轉(zhuǎn)unicode字符示例分享

    c#中文轉(zhuǎn)unicode字符示例分享

    本文介紹了中文轉(zhuǎn)unicode字符的方法,還有UNICODE字符轉(zhuǎn)為中文的方法,大家參考使用吧
    2014-01-01
  • Winform控件優(yōu)化之圓角按鈕1

    Winform控件優(yōu)化之圓角按鈕1

    這篇文章主要介紹了Winform控件優(yōu)化之圓角按鈕,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下
    2022-08-08
  • 使用linq to xml修改app.config示例(linq讀取xml)

    使用linq to xml修改app.config示例(linq讀取xml)

    這篇文章主要介紹了使用linq to xml修改app.config示例,需要的朋友可以參考下
    2014-02-02
  • C#集合本質(zhì)之鏈表的用法詳解

    C#集合本質(zhì)之鏈表的用法詳解

    本文詳細講解了C#集合本質(zhì)之鏈表的用法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-08-08
  • C#中String.LastIndexOf方法小結(jié)

    C#中String.LastIndexOf方法小結(jié)

    String.LastIndexOf()是C#中string類的一個方法,它用于在字符串中查找指定子字符串(或字符)最后一次出現(xiàn)的位置,并返回其索引,本文主要介紹了C#中String.LastIndexOf方法小結(jié),感興趣的可以了解一下
    2024-01-01
  • C# 使用動態(tài)庫DllImport("kernel32")讀寫ini文件的步驟

    C# 使用動態(tài)庫DllImport("kernel32")讀寫ini文件的步驟

    kernel32.dll是Windows中非常重要的32位動態(tài)鏈接庫文件,屬于內(nèi)核級文件,這篇文章主要介紹了C# 利用動態(tài)庫DllImport("kernel32")讀寫ini文件,需要的朋友可以參考下
    2023-05-05

最新評論