[Reprint] the use of the small tip: setclip Method

Source: Internet
Author: User

To reduce the size of a file, a similar small image is often merged into a file. When the program is actually drawing, only a part of the image in the file can be displayed as needed. The setclip method in graphics implements this function.

The setclip method is used to display only a part of the content on the screen, so that the content of the image is displayed exactly in this part.

The setclip method is to set the "Perspective hole" on the screen, only the image content in the hole is displayed.

The setclip method is described as follows:

Public void setclip (int x, int y, int width, int height)

Where:

X -- the X coordinate in the upper left corner of the rectangle that can be displayed

Y -- y coordinate of the upper left corner of the display area

Width -- the width of the rectangle

Height -- giant height

Example:

G. setclip (10, 20, 20, 30 );

G. drawimage (image, 10, 20, graphics. Left | graphics. Top );

Only the starting position, height 30, width 20, and other parts of the image represented by the image object are displayed.

Note: After using setclip, You need to restore the default settings of the system so that the entire screen can be displayed:

G. setclip (0, 0, this. getwidth (), this. getheight ());

[Reprint] the use of the small tip: setclip Method

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.