I'd like to learn how to code some very basic image editing in Visual Studio. I'm using the openFileDialog to load a picture into a pictureBox. I've found some loops on the internet that are designed to convert color on a pixel by pixel basis, but for various reasons (that differ with each code sample) none work. What is the correct way to add to (or subtract from), for example, the red value, to change the tint of an image in a pictureBox? I'm using C#.
Thank you
EDIT: Here is an example of something that's at least a starting point:
Bitmap bmp = (Bitmap)Bitmap.FromFile(pictureBox1.ImageLocation);
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
bmp.GetPixel(x, y);
bmp.SetPixel(x, y, Color.FromArgb(128, 0, 128));
}
}
pictureBox1.Image = bmp;
MessageBox.Show("Done");
This allows me to get the image pixel by pixel, and change the color, in this case, to purple. Of course, that's not what I want to do. What I want to do, is get the original RGB value of each pixel, and increase or decrease the values. In other words, perform some very basic color correction.
How do I get the current RGB of each pixel, and set the RGB of the new pixel?
I have also seen this posted as an example. The problem is, I don't see how to use ModifyHue:
var bmp = new Bitmap(pictureBox1.ImageLocation);
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color oldColor = bmp.GetPixel(x, y);
Color newColor = ModifyHue(oldColor);
bmp.SetPixel(x, y, newColor);
}
}
pictureBox1.Image = bmp;
I realize I should have posted code samples the first time around. Thank you