GDI introduction
Author is not detailed
1. Introduction GDI is a subsystem in Windows XP, which is mainly responsible for outputting information about the display screen and the print device, which is an application programming interface implemented by the C class. As the name suggests, GDI is the successor of previous version of GDI. For compatibility, Windows XP still supports previous version of GDI, but when developing new applications, the developers should use GDI to meet graphic output, because GDI previous The GDI in the Windows version has been optimized and added a lot of new features. GDI as a graphical device interface allows the application developer to output the screen and the printer information, there is no need to consider the details of the specific display device, and they only need to call some methods of the GDI library output to complete the graphics operation, the real drawing work These methods are handed over to specific device drivers, and GDI makes graphics hardware and applications to isolate each other. Thus makes developers write equipment-independent applications very easy. 2.GDI New Function (1) Gradient Brushes GDI allows users to create a painting brush along path or straight lines to fill in Shapes, paths, region, and gradual painting The brush can also draw a straight line, curve, path. When you fill a shape (Shapes) with a line-shaped painting, the color can gradually change along the shape. (2) Cardinal SPlines GDI supports the base spline function, while GDI does not support. The base spline is a large curve that is connected in a set of single curves in order to connect. The spline is specified by a range of points and passes through each specified point. Since the base spline is smooth through every point in the group (no sharp corners), it is more accurate than the path created with a linear connection. Below is a graphic created by two methods, one uses a base spline, one uses a straight line. (3) Persistent Path Objects In GDI, the path belongs to the device description table (DC), and the path will be destroyed after the painting. In GDI , the drawing works by the Graphics object, you can create a few path objects separated from Graphics, and the path object is not broken when the drawing is operated so that you can use the same path object multiple times. (4) Transformations & Matrix Objects GDI provides matrix objects, a very powerful tool that makes the pattern of rotation, translation, and zoom code become very easy. A matrix object is always associated with a graphic transformation. For example, the path object (PATH) has a transform method, and one of its parameters can accept the address of the matrix object, and it can be drawn according to the transformation matrix. . The following graphic is an example before and after a graphical transformation, and the transformation is turned until the zoom is scaled. (5) Scalable Regions GDI Improve GDI in the region (Regions), in GDI, RegionS is stored in the device coordinates, and the only operation of the REGONS unique to graphically transform is translated to the region.
GDI uses the World Coordinate Storage Area (Regions), allowing any graphic transformation to the region (such as scaling as shown), graphical transformation to transform matrix storage, the following example is an example (zoom, rotation, translation) before and after a region transform (zoom, rotation, translation (6) Alpha Blending You may notice the graphic displayed above, the red unpaged area has a portion of the crossover area with the transformation zone, which is achieved by the ALPHA Blending (mixing) supported by GDI . Using Alpha Fusion, you can specify the transparency of the fill color, the transparent color is fused to each other, the more transparent the color, the more clear the background color display, the four ellipses shown below are filled with the same color, but due to ownership Different transparens exhibit different display effects. (7) Multiple image format support. Image possess a lightweight position in the graphical interface program, GDI In addition to supporting GDI supported graphics format such as BMP, GrPhics Interchange Format, PNG Image format such as Exchangeable Image File, Tiff (Tag Image File Format), you can use these image files directly in the program without considering the compressed algorithms used. (8) Others. GDI will also support other technologies, such as reloading, color correction, metadata, graphic containers, perhaps these features we will in future WindowsXP or Microsoft Visualstudio. See it in NET. 3. Change Device Contexts, Handles, and GraphlicS Objects If you have used GDI to write applications (DC) The concept is very familiar, the device description table is a data structure used by Windows, which is used to store specific device capabilities and how to reload some items on the device. Moreover, the device description table of the video device is also related to a particular window. First, you have to get a device descriptor table, and then pass this handle as a parameter to the GDI graphics draw function when graphically drawn. Of course, you can also pass it to a function of obtaining or setting the device description table. With GDI functions, you don't have to use handles or device descriptions. Instead, you can simply create a graphics (Graphics), then call it in the object-oriented programming manner, such as MyGraphicsObject.drawline (parameters). Graphics object is the core of GDI , just as the device description table is the core of GDI, the device descriptor table (DC) and graphics objects play a similar role in different environments, but both There is a difference in this quality. The former uses handle-based programming methods and the latter uses object-oriented programming methods.