C # process images into various effects

Source: Internet
Author: User

Original Image: ISINBAEVA

 

I. Negative Effects
Principle: The GetPixel method obtains the value of each pixel, and then uses the SetPixel method to set the reversed color value to the corresponding vertex.
:

Code implementation:

Negative Film Effect
Private void button#click (object sender, EventArgs e)
{
// Display the image as a negative film
Try
{
Int Height = this. pictureBox1.Image. Height;
Int Width = this. pictureBox1.Image. Width;
Bitmap newbitmap = new Bitmap (Width, Height );
Bitmap oldbitmap = (Bitmap) this. pictureBox1.Image;
Color pixel;
For (int x = 1; x <Width; x ++)
{
For (int y = 1; y <Height; y ++)
{
Int r, g, B;
Pixel = oldbitmap. GetPixel (x, y );
R = 255-pixel. R;
G = 255-pixel. G;
B = 255-pixel. B;
Newbitmap. SetPixel (x, y, Color. FromArgb (r, g, B ));
}
}
This. pictureBox1.Image = newbitmap;
}
Catch (Exception ex)
{
MessageBox. Show (ex. Message, "Message prompt", MessageBoxButtons. OK, MessageBoxIcon. Information );
}
}

 

Ii. Embossed Effect

Principle: subtract the pixel value of the image pixel from the pixel value of the adjacent pixel, add 128, and use it as the value of the new pixel.

:

Code implementation:

Embossed Effect
Private void button#click (object sender, EventArgs e)
{
// Display the image with relief effect
Try
{
Int Height = this. pictureBox1.Image. Height;
Related Article

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.