Next, let's talk about how to turn an image into a reversed color. In fact, each pixel has four values, which are alpha, red, green, and blue. They are the basic elements of the color, at least I think so. The value range of each element is [0,255], that is, between 0 and 255. So the function for implementing the reversed color effect is calculated as follows,
/// <Summary>
/// Reversed the image
/// </Summary>
/// <Param name = "mybm"> original image </param>
/// <Param name = "width"> length of the original image </param>
/// <Param name = "height"> height of the original image </param>
/// <Returns> reversed image </returns>
Public Bitmap RePic (Bitmap mybm, int width, int height)
{
Bitmap bm = new Bitmap (width, height); // initialize the object of the image after record processing
Int x, y, resultR, resultG, resultB;
Color pixel;
For (x = 0; x <width; x ++)
{
For (y = 0; y {
Pixel = mybm. GetPixel (x, y); // obtain the pixel value of the current coordinate.
ResultR = 255-pixel. R; // anti-red
ResultG = 255-pixel. G; // reverse green
ResultB = 255-pixel. B; // anti-blue
Bm. SetPixel (x, y, Color. FromArgb (resultR, resultG, resultB); // plot
}
}
Return bm; // returns the reversed image.
}
The last step is to use pictureBox to display the image in the form.