C#图片处理之:Gamma校正 .
2012-01-17 13:59
323 查看
gamma值是用曲线表示的,这是一种人的眼睛对光的一种感应曲线,其中包括了物理量、身理感官及心理的感知度。 -- 摘自百度知道
用C#做Gamma校正的操作也很简单。
public static Bitmap KiGamma(Bitmap bmp, float val)
...{
if (bmp == null)
...{
return null;
}
// 1表示无变化,就不做
if (val == 1.0000f) return bmp;
try
...{
Bitmap b = new Bitmap(bmp.Width, bmp.Height);
Graphics g = Graphics.FromImage(b);
ImageAttributes attr = new ImageAttributes();
attr.SetGamma(val, ColorAdjustType.Bitmap);
g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attr);
g.Dispose();
return b;
}
catch
...{
return null;
}
}
用C#做Gamma校正的操作也很简单。
public static Bitmap KiGamma(Bitmap bmp, float val)
...{
if (bmp == null)
...{
return null;
}
// 1表示无变化,就不做
if (val == 1.0000f) return bmp;
try
...{
Bitmap b = new Bitmap(bmp.Width, bmp.Height);
Graphics g = Graphics.FromImage(b);
ImageAttributes attr = new ImageAttributes();
attr.SetGamma(val, ColorAdjustType.Bitmap);
g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, attr);
g.Dispose();
return b;
}
catch
...{
return null;
}
}
相关文章推荐
- C#图片处理之:亮度和对比度的校正 .
- C#图片处理之:Gamma校正
- C#图片处理之:亮度和对比度的校正
- C#图片处理之:亮度和对比度的校正
- C#图片处理之:Gamma校正
- C#图片处理之:Gamma校正
- C#图片处理之:亮度和对比度的校正
- C# 图片处理之:彩色图片转为黑白图 .
- C#word(2007)操作类--新建文档、添加页眉页脚、设置格式、添加文本和超链接、添加图片、表格处理、文档格式转化
- C# 图片处理之:旋转图片任意角度
- c#处理图片rgb、伽马、饱和度、黑白
- C# 处理图片百分比缩放-未测试
- 图像处理-光照规整-Gamma校正
- C#绘制图片的几个处理方法
- 最全的C#图片处理帮助类ImageHelper
- C#的图片处理类,生成高质量缩略图,代码已测试过,效果很好
- C# 处理图片
- C#图像处理(5):无损保存图片
- C# ASP.NET 图片处理的代码
- C#图片处理基本应用(裁剪,缩放,清晰度,水印)