C#圖像亮度調(diào)整的方法
更新時間:2015年04月24日 09:50:43 作者:滄海一粟……
這篇文章主要介紹了C#圖像亮度調(diào)整的方法,涉及C#操作圖像亮度的相關(guān)技巧,需要的朋友可以參考下
本文實例講述了C#圖像亮度調(diào)整的方法。分享給大家供大家參考。具體如下:
//定義數(shù)字圖象處理之(亮度調(diào)整函數(shù)) private static Bitmap BrightnessP(Bitmap a, int 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++,p++) { temp = (int)(p[0] + v); temp = (temp > 255) ? 255 : temp < 0 ? 0 : temp; p[0] = (byte)temp; } p += stride - a.Width * 3; } } a.UnlockBits(bmpData); return a; }
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
C#實現(xiàn)Excel動態(tài)生成PivotTable
這篇文章主要為大家詳細(xì)介紹了C#實現(xiàn)Excel動態(tài)生成PivotTable的相關(guān)方法,感興趣的小伙伴們可以參考一下2016-04-04DevExpress實現(xiàn)GridView當(dāng)無數(shù)據(jù)行時提示消息
這篇文章主要介紹了DevExpress實現(xiàn)GridView當(dāng)無數(shù)據(jù)行時提示消息,需要的朋友可以參考下2014-08-08