• 伽马曲线调整图片


            private void Form1_Load(object sender, EventArgs e)
            {
                img = pictureBox1.Image = Image.FromFile("8.jpg");
            }
    
            Image img;
            private void button1_Click(object sender, EventArgs e)
            {
                using (Graphics g = pictureBox2.CreateGraphics())
                {
                    g.Clear(pictureBox2.BackColor);
                    using (Image tmp = SetGamma(img.Clone() as Image, hsbRed.Value, hsbGreen.Value, hsbBlue.Value))
                        pictureBox2.Image = new Bitmap(tmp);
                }
            }
            /// <summary>
            /// 伽马曲线调整
            /// </summary>
            /// <param name="img"></param>
            /// <param name="red"></param>
            /// <param name="green"></param>
            /// <param name="blue"></param>
            public Image SetGamma(Image img, double red, double green, double blue)
            {
                using (Bitmap tmp = img as Bitmap)
                {
                    Color c;
                    byte[] rG = CreateGammaArray(red);
                    byte[] gG = CreateGammaArray(green);
                    byte[] bG = CreateGammaArray(blue);
                    for (int i = 0; i < tmp.Width; i++)
                    {
                        for (int j = 0; j < tmp.Height; j++)
                        {
                            c = tmp.GetPixel(i, j);
                            tmp.SetPixel(i, j, Color.FromArgb(rG[c.R], gG[c.G], bG[c.B]));
                        }
                    }
                    rG = gG = bG = null;
                    return tmp.Clone() as Bitmap;
                }
            }
            /// <summary>
            /// 获取曲线数组
            /// </summary>
            /// <param name="color">色彩</param>
            /// <returns>数组</returns>
            private byte[] CreateGammaArray(double color)
            {
                byte[] gammaArray = new byte[256];
                for (int i = 1; i < 256; i++)
                    gammaArray[i] = (byte)Math.Min(255, (int)((255.0 * Math.Pow(i / 255.0, 1.0 / color)) + 0.5));
                return gammaArray;
            }
            private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
                label5.Text = string.Format("Red={0},Green={1},Blue={2}", hsbRed.Value, hsbGreen.Value, hsbBlue.Value);
                button1.PerformClick();
            }
    
            private void hsbGreen_Scroll(object sender, ScrollEventArgs e)
            {
                label5.Text = string.Format("Red={0},Green={1},Blue={2}", hsbRed.Value, hsbGreen.Value, hsbBlue.Value);
                button1.PerformClick();
            }
    
            private void hsbBlue_Scroll(object sender, ScrollEventArgs e)
            {
                label5.Text = string.Format("Red={0},Green={1},Blue={2}", hsbRed.Value, hsbGreen.Value, hsbBlue.Value);
                button1.PerformClick();
            }

  • 相关阅读:
    树状数组 浅显学习
    主席树 浅显学习
    B
    python测试开发面试之深浅拷贝
    2020年全网最全的自动化测试面试题及答案--吊打面试官就靠它了!
    软件测试员这个工作怎么样?做软件测试员这个职业有什么好处吗?
    软件测试能干到多少岁?写给像我相同迷茫的人
    python+requests实现接口自动化
    Python+selenium自动化测试之浏览器基础操作
    如何用 Python 做自动化测试【进阶必看】
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/4239494.html
Copyright © 2020-2023  润新知