The difference between GDI GDI +

Source: Internet
Author: User

GDI + is the next version of GDI, which has been well improved and easier to use. One of the benefits of GDI is that you don't have to know any details about how the data is rendered on the device, and GDI + is better at implementing this advantage, that is, GDI is a low-level API, you may also want to know the device, and GDI + is a top API, you don't have to know the device. For example, if you want to set the foreground and background color of a control, simply set the BackColor and ForeColor properties.

Changes in programming patterns
"GDI uses a stateful model, whereas GDI + uses a stateless"--gdi is stateful, GDI + is stateless.

1. No longer use device environment or handle
When using GDI drawing, you must specify a device environment (DC) that associates a window or device with a handle pointer to the device environment class, and all drawing operations are related to that handle. Instead of using the device environment or handle, GDI + uses the Graphics object instead. Similar to the device environment, a graphics object also has a window associated with it and contains related properties that are required for drawing operations. However, only the Graphics object has a connection to the device environment handle, and the rest of the objects, such as pen, Brush, image, and font, no longer use the device environment.

2, Pen, Brush,font,image and other objects are graphic objects Independent
The brush object can be created separately from the graphical object used to provide the drawing method, and the graphics drawing method directly takes the pen object as its own parameter, thus avoiding tedious switching in GDI using SelectObject, similar to brush, Path, Image, font, and so on.

3. "Current Position"
A special location called "Current position" is always present in GDI drawing operations, such as drawing lines. Each time the line is drawn with this current position as the starting point, the end point position of the line becomes the current position after the draw line operation is finished. The reason for setting the current position is to improve the efficiency of the line-drawing operation, because in some cases, a straight line is always connected to another line. With the automatic update of the current position, you can avoid having to give two points of coordinates each time you draw a line. Although it is necessary, it is always more often to draw a line alone, so GDI + cancels this "current position" to avoid errors in drawing that are caused when the "current position" is not determined, instead of specifying the coordinates of the line starting and ending point directly in the DrawLine.

4. Drawing and filling
GDI always lets shape outlines be drawn and populated using the same drawing function, such as rectangle. Contour drawing requires a brush, while filling an area requires a paint brush. That is, regardless of whether we need to fill the drawn shape, we need to specify a brush, otherwise GDI is populated with the default brush. This approach does bring us a lot of inconvenience, and now GDI + separates shape contour drawing and fill operations in different ways, such as DrawRectangle and FillRectangle, respectively, to draw and fill a rectangle.

5, the operation of the area
GDI provides many area creation functions, such as CreateRectRgn, Createellpticrgn, CreateRoundRectRgn, CreatePolygonRgn, and CreatePolyPolygonRgn. Admittedly, these functions have brought us a lot of convenience. However, in GDI +, in order to facilitate the introduction of the region to matrix transformation Operations, GDI + simplifies the method of general zone creation, and the more complex zone creation is referred to path takeover. Because the path object is separate from the device environment, it can be specified directly in the region constructor.

====================================================================
GDI + and GDI differences and some new features

"GDI + and GDI"

1. GDI is hardware-accelerated, and GDI + is not, and gdi+2.0 is faster than GDI +.

2. GDI is stateful, and GDI + is stateless.

3. GDI drawings use the device environment and handles, and GDI + is all managed by the graphics class.

4. GDI plots can use SelectObject to switch drawing objects frequently, while GDI + 's graphical objects are independent.

5. There is a "current location" (Global Zone) in GDI to improve drawing performance, and GDI + cancels it to avoid unintended errors when drawing without the "current position".

6. GDI always binds the brush and brush together, and you must specify a brush even if you do not need to populate an area, while GDI + can use different functions to separate the brushes and brushes.


"GDI + new Features"

1. Improved color management. GDI + not only provides more colors to choose from, it supports alpha channel compositing, but it also preserves compatibility with other colors.

2. The drawing supports anti-aliasing. By setting the related properties of GDI + objects, GDI + can work with the relevant display driver to complete the anti-aliasing function when drawing, which makes the drawing more smooth and beautiful, and the whole process is computed automatically by GDI + objects.

3. Provide a gradient brush. GDI + extends the functionality of GDI by providing linear gradients and path gradient brushes to fill graphics, paths, and regions, and even to draw lines, curves, and so on.

4. Stand-alone Path object. GDI + uses a Graphics object for drawing operations and separates the path operation from the Graphics object, providing a graphics class for use by the user without worrying about the object being affected by the operation of the Graphics object. This allows you to use the same operand to make multiple path draw operations.

5. Spline curve. GDI + encapsulates the method of drawing cardinal splines and Bezier spline curves.

6. Deformation and matrix operations. GDI + provides a powerful matrix class to transform operations such as matrix rotation, error-cutting, panning, and scaling to produce complex new graphics.

7. Multi-image format support. GDI + in the graphics processing capabilities, through GDI +, users can access a variety of formats of picture files, conversion file format, but also for image re-coloring, color correction, eliminate aliasing and other image processing.

Http://www.cnblogs.com/lidabo/p/3701252.html

The difference between GDI GDI +

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.