C # drawimage Function

Source: Internet
Author: User

1.Drawimage


6.1 drawimage (image, Int, INT)

6.1 drawimage (image, rectangle)

6.2 drawimage (image, rectangle [Destrect


], Rectangle [Srcrect


], Graphicsunit)

In the specified position and draw according to the specified sizeImage

The specified part of the object.

Rectangle [Destrect


]
It specifies the position and size of the image to be drawn. Scale the image to fit the rectangle.

Rectangle [Srcrect


]
It specifies Image

The part of the object to be drawn.

Used for interpolation to control image quality; cut Images

Private void formatepaint (Object sender, system. Windows. Forms. painteventargs E)
{// Interpolation controls Image Quality
Graphics G = E. graphics;
Bitmap BMP = new Bitmap ("a006.jpg ");
G. fillrectangle (brushes. White, this. clientrectangle );
Int width = BMP. width;
Int Height = BMP. height;
G. drawimage (
BMP,
New rectangle (200,200 ),
New rectangle (0, 0, width, height ),
Graphicsunit. pixel );
G. interpolationmode = interpolationmode. nearestneighbor;
G. drawimage (
BMP,
New rectangles (10,250,200,200 ),
New rectangle (0, 0, width, height ),
Graphicsunit. pixel );
G. interpolationmode = interpolationmode. highqualitybicubic;
G. drawimage (
BMP,
New rectangles (250,250,200,200 ),
New rectangle (0, 0, width, height ),
Graphicsunit. pixel );
}
Private void formatepaint (Object sender, system. Windows. Forms. painteventargs E)

{// Cut the image

Graphics G = E. graphics;
Bitmap BMP = new Bitmap ("a006.jpg ");
G. fillrectangle (brushes. White, this. clientrectangle );
Int width = BMP. width;
Int Height = BMP. height;
G. drawimage (
BMP,
New rectangle (200,200 ),
New rectangle (150,150 ),
Graphicsunit. pixel );
}
6.3 drawimage (image, point [3])
It can be used for image deformation, turning, and rotating.
Specify coordinates in the upper left corner at the first point.
Second, specify the coordinates in the upper-right corner.
Third, specify coordinates in the lower left corner.
Private void formatepaint (Object sender, system. Windows. Forms. painteventargs E)
{// Image deformation
Graphics G = E. graphics;
Bitmap BMP = new Bitmap ("a006.jpg ");
G. fillrectangle (brushes. White, this. clientrectangle );
Point [] destinationpoints = {
New Point (0, 0 ),
New Point (100,0 ),
New Point (50,100 )};
G. drawimage (BMP, destinationpoints );
}

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.