Device independence is one of the chief features of Microsoft® Windows®. Applications can draw and print output on a variety of devices. The software that supports this device independence is contained in two dynamic-link libraries. The first, Gdi.dll, is referred to as the graphics device interface (GDI); the second is referred to as a device driver. The name of the second depends on the device where the application draws output. For example, if the application draws output in the client area of its window on a VGA display, this library is Vga.dll; if the application prints output on an Epson FX-80 printer, this library is Epson9.dll.
“设备无关”是Microsoft Windows主要特性之一,应用程序可在各种设备上打印和输出。软件的这种设备无关特性需要两个动态链接库的支持:第一,Gdi.dll,作为图像设备接口(GDI)参考;第二个是关于设备驱动的。其中第二个动态链接库根据应用程序的图像输出的设备来命名。例如:如果应用程序在VAG显示器上向窗口的客户区域绘制,那么库名就是VAG.gll;如果程序向Epson FX-80打印机输出,库名就是Epson9.dll。
An application must inform GDI to load a particular device driver and, once the driver is loaded, to prepare the device for drawing operations (such as selecting a line color and width, a brush pattern and color, a font typeface, a clipping region, and so on). These tasks are accomplished by creating and maintaining a device context (DC). A DC is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations. Unlike most of the structures, an application never has direct access to the DC; instead, it operates on the structure indirectly by calling various functions.
一个应用程序必须通知GDI去加载一个特定的设备驱动,并且一旦驱动加载成功,设备就准备开始绘制操作(比如设置线条的颜色和宽度,笔刷的模式和颜色,字体,一个剪辑区域等等),这些任务通过创建和维护一个设备内容(DC)完成。DC是一个结构,它定义了一系列图形对象和与之相关的属性以及影响输出效果的图像模式。图像对象包括一个绘制线条的画笔,一个用于绘画和填充的笔刷,一份拷贝或者屏幕滚动部分位图,一个定义个一系列可用颜色的调色板,一个剪辑区域和其他的操作以及一条绘制和打印的路径。不像大多数其他的结构,一个应用程序不能直接访问一个DC;相反,它通过简介调用各种函数去操作这个结构。