日期:2014-05-17 浏览次数:20920 次
/// <summary>
/// 锐化
/// </summary>
/// <param name="b">原始Bitmap</param>
/// <param name="val">锐化程度。取值[0,1]。值越大锐化程度越高</param>
/// <returns>锐化后的图像</returns>
public static Bitmap KiSharpen(Bitmap b, float val)
{
if (b == null)
{
return null;
}
int w = b.Width;
int h = b.Height;
try
{
Bitmap bmpRtn = new Bitmap(w, h, PixelFormat.Format24bppRgb);
BitmapData srcData = b.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
BitmapData dstData = bmpRtn.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
unsafe
{
byte* pIn = (byte*)srcData.Scan0.ToPointer();
&