/// <summary>
/// 曲线
/// </summary>
/// <param name="red">红</param>
/// <param name="green">绿</param>
/// <param name="blue">蓝</param>
public void SetGamma(double red, double green, double blue)
{
Bitmap temp = (Bitmap)_currentBitmap;
Bitmap bmap = (Bitmap)temp.Clone();
Color c;
byte[] redGamma = CreateGammaArray(red);
byte[] greenGamma = CreateGammaArray(green);
byte[] blueGamma = CreateGammaArray(blue);
for (int i = 0; i < bmap.Width; i++)
{
for (int j = 0; j < bmap.Height; j++)
{
c = bmap.GetPixel(i, j);
bmap.SetPixel(i, j, Color.FromArgb(redGamma[c.R], greenGamma[c.G], blueGamma[c.B]));
}
}
_currentBitmap = (Bitmap)bmap.Clone();
}
/// <summary>
/// 获取曲线数组
/// </summary>
/// <param name="color">色彩</param>
/// <returns>数组</returns>
private byte[] CreateGammaArray(double color)
{
byte[] gammaArray = new byte[256];
for (int i = 0; i < 256; ++i)
{
gammaArray[i] = (byte)Math.Min(255, (int)((255.0 * Math.Pow(i / 255.0, 1.0 / color)) + 0.5));
}
return gammaArray;
}