最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#圖像處理之木刻效果實現(xiàn)方法

 更新時間:2015年04月24日 11:43:07   作者:滄海一粟……  
這篇文章主要介紹了C#圖像處理之木刻效果實現(xiàn)方法,可實現(xiàn)類似木刻效果的黑白照效果,需要的朋友可以參考下

本文實例講述了C#圖像處理之木刻效果實現(xiàn)方法。分享給大家供大家參考。具體如下:

//木刻效果
public Bitmap PFilterMuKe(Bitmap src)
{
 try
 {
  Bitmap a = new Bitmap(src);
  Rectangle rect = new Rectangle(0, 0, a.Width, a.Height);
  System.Drawing.Imaging.BitmapData bmpData = a.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
  int stride = bmpData.Stride;
  unsafe
  {
   byte* pIn = (byte*)bmpData.Scan0.ToPointer();
   byte* P;
   int R, G, B;
   int temp = 0;
   for (int y = 0; y < a.Height; y++)
   {
   for (int x = 0; x < a.Width; x++)
   {
    P = pIn;
    B = P[0];
    G = P[1];
    R = P[2];
    temp = (byte)((B + G + R) / 3);
    if (temp >= 122.5)
    {
    P[2] = 0;
    P[1] = 0;
    P[0] = 0;
    }
    else
    {
    P[2] = (byte)255;
    P[1] = (byte)255;
    P[0] = (byte)255;
    }
    pIn += 3;
   }
   pIn += stride - a.Width * 3;
   }
  }
  a.UnlockBits(bmpData);
  return a;
 }
 catch (Exception e)
 {
  MessageBox.Show(e.Message.ToString());
  return null;
 }
}

原圖:

效果圖:

希望本文所述對大家的C#程序設(shè)計有所幫助。

相關(guān)文章

最新評論

多伦县| 溆浦县| 唐河县| 竹溪县| 宾川县| 赞皇县| 姜堰市| 太和县| 江北区| 伊通| 万全县| 宝清县| 新民市| 新民市| 四会市| 横峰县| 西青区| 望谟县| 桦甸市| 吴堡县| 德化县| 尉犁县| 泸西县| 阜宁县| 三江| 攀枝花市| 宝山区| 华蓥市| 萍乡市| 措勤县| 疏勒县| 铁岭市| 明水县| 云梦县| 兴业县| 广南县| 靖远县| 丹东市| 彝良县| 托里县| 浦北县|