Gamma curve adjustment picture

Source: Internet
Author: User

        Private voidForm1_Load (Objectsender, EventArgs e) {img= pictureBox1.Image = Image.FromFile ("8.jpg");        } Image img; Private voidButton1_Click (Objectsender, EventArgs e) {            using(Graphics g =Picturebox2.creategraphics ())                {g.clear (Picturebox2.backcolor); using(Image tmp = SetGamma (IMG). Clone () asImage, Hsbred.value, Hsbgreen.value, Hsbblue.value)) Picturebox2.image=NewBitmap (TMP); }        }        /// <summary>        ///Gamma curve Adjustment/// </summary>        /// <param name= "img" ></param>        /// <param name= "Red" ></param>        /// <param name= "Green" ></param>        /// <param name= "Blue" ></param>         PublicImage SetGamma (Image img,DoubleRedDoubleGreenDoubleBlue) {            using(Bitmap tmp = img asBitmap)                {Color C; byte[] RG =Creategammaarray (red); byte[] GG =Creategammaarray (green); byte[] BG =Creategammaarray (blue);  for(inti =0; I < TMP. Width; i++)                {                     for(intj =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; returnTmp. Clone () asBitmap; }        }        /// <summary>        ///get an array of curves/// </summary>        /// <param name= "Color" >Color</param>        /// <returns>Array</returns>        Private byte[] Creategammaarray (Doublecolor) {            byte[] Gammaarray =New byte[ the];  for(inti =1; I < the; i++) Gammaarray[i]= (byte) Math.min (255, (int)((255.0* MATH.POW (I/255.0,1.0/color)) +0.5)); returnGammaarray; }        Private voidHscrollbar1_scroll (Objectsender, ScrollEventArgs e) {Label5. Text=string. Format ("red={0},green={1},blue={2}", Hsbred.value, Hsbgreen.value, Hsbblue.value); Button1.        PerformClick (); }        Private voidHsbgreen_scroll (Objectsender, ScrollEventArgs e) {Label5. Text=string. Format ("red={0},green={1},blue={2}", Hsbred.value, Hsbgreen.value, Hsbblue.value); Button1.        PerformClick (); }        Private voidHsbblue_scroll (Objectsender, ScrollEventArgs e) {Label5. Text=string. Format ("red={0},green={1},blue={2}", Hsbred.value, Hsbgreen.value, Hsbblue.value); Button1.        PerformClick (); }

Gamma curve adjustment picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.