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

C#圖像對比度調(diào)整的方法

 更新時間:2015年04月24日 09:54:35   作者:滄海一粟……  
這篇文章主要介紹了C#圖像對比度調(diào)整的方法,涉及C#實現(xiàn)圖像對比度操作的相關(guān)技巧,需要的朋友可以參考下

本文實例講述了C#圖像對比度調(diào)整的方法。分享給大家供大家參考。具體如下:

//定義對比度調(diào)整函數(shù)
private static Bitmap ContrastP(Bitmap a, double v)
{
 System.Drawing.Imaging.BitmapData bmpData = a.LockBits(new Rectangle(0, 0, a.Width, a.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
 int bytes = a.Width * a.Height * 3;
 IntPtr ptr = bmpData.Scan0;
 int stride = bmpData.Stride;
 unsafe
 {
  byte* p = (byte*)ptr;
  int temp;
  for (int j = 0; j < a.Height; j++)
  {
   for (int i = 0; i < a.Width * 3; i++)
   {
   temp = (int)((p[0] - 127) * v + 127);
   temp = (temp > 255) ? 255 : temp < 0 ? 0 : temp;
   p[0] = (byte)temp;
   p++;
   }
   p += stride - a.Width * 3;
  }
 }
 a.UnlockBits(bmpData);
 return a;
}

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

相關(guān)文章

最新評論