Created
May 19, 2018 17:48
-
-
Save lol97/70e1e011806cb035dc6f2d0c109f10ef to your computer and use it in GitHub Desktop.
Image Processing Brightness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void button1_Click(object sender, EventArgs e) | |
| { | |
| Bitmap bmp = new Bitmap(pictureBox1.Image); | |
| Bitmap bmp2 = new Bitmap(pictureBox1.Image); | |
| int r, g, b; | |
| Color c; | |
| int val = (int)Convert.ToInt16(textBox1.Text); | |
| Cursor = Cursors.WaitCursor; | |
| for(int i=0; i < bmp.Width; i++) | |
| { | |
| for (int j = 0; j < bmp.Height; j++) | |
| { | |
| c = bmp.GetPixel(i, j); | |
| r = c.R + val; | |
| g = c.G + val; | |
| b = c.B + val; | |
| if (r > 255) r = 255; | |
| if (g > 255) g = 255; | |
| if (b > 255) b = 255; | |
| if (r < 0) r = 0; | |
| if (g < 0) g = 0; | |
| if (b < 0) b = 0; | |
| bmp2.SetPixel(i, j, Color.FromArgb(r, g, b)); | |
| } | |
| } | |
| pictureBox2.Image = bmp2; | |
| Cursor = Cursors.Default; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment