zoukankan      html  css  js  c++  java
  • C#图片处理之:Gamma校正 .

    gamma值是用曲线表示的,这是一种人的眼睛对光的一种感应曲线,其中包括了物理量、身理感官及心理的感知度。  -- 摘自百度知道
     

    用C#做Gamma校正的操作也很简单。

            /**//// <summary>
            
    /// Gamma校正
            
    /// </summary>
            
    /// <param name="bmp">输入Bitmap</param>
            
    /// <param name="val">[0 <-明- 1 -暗-> 2]</param>
            
    /// <returns>输出Bitmap</returns>

            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;
                }

            }
  • 相关阅读:
    欧拉代码005
    欧拉计划003
    欧拉计划004
    欧拉计划006
    欧拉计划002
    LINUXS3C2440SJA1000驱动程序笔记
    WPF实现窗体内容分割
    InotifyPropertyChanged接口实现简单数据绑定
    C#的6种常用集合类大比拼
    WPF获取窗体或控件句柄
  • 原文地址:https://www.cnblogs.com/chennie/p/2324595.html
Copyright © 2011-2022 走看看