Windows GDI+ — это API на основе классов для программистов C/C++. Она позволяет приложениям использовать графику и форматированный текст как на дисплее, так и на принтере. Приложения на основе API-интерфейса Microsoft Win32 не обращаются к графическому оборудованию напрямую. Вместо этого GDI+ взаимодействует с драйверами устройств от имени приложений. GDI+ также поддерживается Microsoft Win64.
Где применимо
Функции и классы GDI+ не поддерживаются для использования в службе Windows. Попытка использовать эти функции и классы из службы Windows может привести к непредвиденным проблемам, например к снижению производительности службы и исключениям или ошибкам времени выполнения.
При использовании интерфейса GDI+ API не следует разрешать приложению скачивать произвольные шрифты из ненадежных источников. Операционная система требует повышенных привилегий, чтобы гарантировать, что все установленные шрифты являются доверенными.
Аудитория разработчиков
Интерфейс на основе классов GDI+ C++ предназначен для использования программистами C/C++. Знание графического пользовательского интерфейса Windows и архитектуры, управляемой сообщениями, является обязательным.
Требования к среде выполнения
GDI+ можно использовать во всех приложениях на основе Windows. Интерфейс GDI+ появился в Windows XP и Windows Server 2003. Сведения о том, какие операционные системы требуются для использования определенного класса или метода, см. в разделе «Дополнительные сведения» документации по классу или методу.
GDI Utility Services
The following table lists the miscellaneous GDI utility services. These services include debugging support, getting and setting the last error, several conversion services that convert from one character encoding type to another, a sort routine, and others.
Function
Description
Brings down the system in a controlled manner when the caller discovers an unrecoverable inconsistency.
Causes a breakpoint in the current process to occur.
Prints the specified debug message to the kernel debugger.
Returns the last error code logged by GDI for the calling thread.
Notifies the system that a specified device is inoperable or unresponsive.
Determines whether the language pack is installed on the system.
Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value. The return value is rounded up or down to the nearest integer.
Converts the specified ANSI source string into a Unicode string using the current ANSI code page.
Converts an ANSI source string into a wide character string using the specified code page.
Probes a structure for read accessibility.
Probes a structure for read and write accessibility.
Causes GDI to report an error code, which can be retrieved by an application.
Performs a quick-sort on the specified list.
Converts the specified Unicode string into an ANSI string using the current ANSI code page.
Converts a wide character string into an ANSI source string using the specified code page.
DirectDraw and GDI
GDI automatically enables DirectDraw when the display driver is initialized. To provide better interaction between DirectDraw and the graphics DDI portion of the driver, a driver that also supports the DirectDraw DDI can implement or call the following functions:
DrvDeriveSurface A driver-implemented function that wraps a GDI driver surface around a DirectDraw driver surface, allowing any GDI drawing to DirectDraw video memory or AGP surfaces to be hardware accelerated (rather than being drawn in software via the DIB engine). Typically, if the driver already supports off-screen device bitmaps, this function should require only a few additional lines of code.
DrvDeriveSurface improves the performance of DirectDraw applications that also use GDI, and it also eliminates cursor flicker when a software cursor is used with DirectDraw or Direct3D applications.
Driver-called functions that use the DirectDraw heap manager for all off-screen memory management. DrvCreateDeviceBitmap should call HeapVidMemAllocAligned to request DirectDraw to allocate space for GDI bitmaps; DrvDeleteDeviceBitmap should call VidMemFree to free this allocation.
DirectDraw has priority over the graphics DDI portion of the driver for off-screen memory allocation. The driver should hook the DirectDraw DdFreeDriverMemory callback, which allows the driver to remove GDI surfaces from off-screen memory to make space for higher priority DirectDraw surface allocations.
GDI Utility Services
The following table lists the miscellaneous GDI utility services. These services include debugging support, getting and setting the last error, several conversion services that convert from one character encoding type to another, a sort routine, and others.
Function
Description
Brings down the system in a controlled manner when the caller discovers an unrecoverable inconsistency.
Causes a breakpoint in the current process to occur.
Prints the specified debug message to the kernel debugger.
Returns the last error code logged by GDI for the calling thread.
Notifies the system that a specified device is inoperable or unresponsive.
Determines whether the language pack is installed on the system.
Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value. The return value is rounded up or down to the nearest integer.
Converts the specified ANSI source string into a Unicode string using the current ANSI code page.
Converts an ANSI source string into a wide character string using the specified code page.
Probes a structure for read accessibility.
Probes a structure for read and write accessibility.
Causes GDI to report an error code, which can be retrieved by an application.
Performs a quick-sort on the specified list.
Converts the specified Unicode string into an ANSI string using the current ANSI code page.
Converts a wide character string into an ANSI source string using the specified code page.
GDI Support for Surfaces
For each PDEV, a driver must support the DrvEnableSurface function. DrvEnableSurface sets up the surface to be drawn on and associates it with the PDEV. The driver must also support the DrvDisableSurface function to disable created surfaces. Because GDI creates and maintains the surface, the driver relies on several GDI service functions, listed in the following table, to implement the enabling and disabling of surfaces.
Function Name
Purpose
Associates a surface with a PDEV and defines the drawing operations the driver writer wants to hook out for that surface. It uses the PDEV’s default palette and style steps. The driver must make this call for the primary surface during the execution of DrvEnableSurface](/windows/win32/api/winddi/nf-winddi-drvenablesurface)» data-linktype=»absolute-path»>DrvEnableSurface. The driver must also make this call when it enables a secondary surface before locking the surface to write on it.
(Printers only) Enables a printer driver to determine whether its printer job has been terminated.
Creates a standard format DIB» data-linktype=»absolute-path»>DIB bitmap. GDI can perform all drawing operations on this type of surface.
Creates a device-dependent bitmap which the driver is responsible for drawing on (although it can be created as a DIB, in which case the driver can call back to have GDI draw on it).
Creates a device-managed surface» data-linktype=»absolute-path»>device-managed surface. The driver is responsible for managing certain drawing operations for this surface. The function returns a handle that the driver manages.
Deletes a surface (DIB, device-dependent bitmap, or device-managed surface).
Fills a specified rectangle on a surface with a given color, effectively erasing it. This function should be called only to erase the surface of a GDI bitmap.
Locks the kernel-mode handle of a DirectDraw surface.
(Printers only) Marks a surface as a banding surface.
Notifies GDI about the attributes of a surface that was created by the driver.
Releases the lock on a given DirectDraw specified surface.
Unlocks a surface when the driver has finished a drawing operation (to be called when disabling a secondary surface).