Drawing with GDI +

Source: Internet
Author: User
Use GDI + Interface graphic usage GDI It is much simpler and easier to meet user needs. GDI + Provides many practical features, such as smooth lines, graphic translation, rotation, scaling, and so on.

1. UseGDI +Draw a straight line

1)Create paint brush
Pen (color (255, 0, 0, 0), 2.0f );

2)Create a graphic object

CDC * PDC = getdc ();

Graphics graphics (PDC-> m_hdc)

3)Draw a straight line

Graphics. drawline (& pen, 0, 0,100,100 );

4)ReleaseDC

Releasedc (PDC );

2. Parameter settings

1)Set paint brush Parameters

Pen (color (255, 0, 0, 0), 2.0f);

Pen. setstartcap (linecapround );//Modify the start line header type. Here is the circle header.

Pen. setendcap (linecapround );//Modify the end line header type. Here is the Arrow

Pen. setdashstyle (dashstyledot );//Modify the line format. Here is the dot line.

2)Set graphic Object Attributes

Graphics. setsmoothingmode (smoothingmodeantialias );//Anti-aliasing

3) Draw a straight line

Graphics. drawline (& pen, 10, 10,110,110 );

The preceding two steps show thatGDI +Drawing is very simple, and through simple parameters
You can easily draw the desired image.

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.