Quartz Display Services provides a number of functions to retrieve information about display state and display modes. This article briefly covers a few of these functions. For a complete list, see Quartz Display Services Reference.
Getting Display State Information
Getting Display Mode Information
Quartz Display Services includes several accessor functions that report current properties of the display hardware, properties that are also found in the current display mode dictionary. Because these functions query the hardware directly rather than consulting the current display mode, they provide the most accurate information available about the display (display mode properties are subject to change by the device driver). These functions, listed next, are straightforward to use:
Function | Description |
---|---|
| Returns the drawable width of a display in pixel units. |
| Returns the drawable height of a display in pixel units. |
| Returns the number of bits used to represent a pixel in the frame buffer. |
| Returns the number of bits used to represent a pixel component in the frame buffer. |
| Returns the number of components used to represent a pixel in the frame buffer. |
| Returns the number of bytes per row in the frame buffer. |
The API includes other accessor functions that report additional information about the current configuration and state of the display. The following table lists a representative sample of these functions:
Function | Description |
---|---|
| Returns a Boolean value indicating whether a display is active or drawable). |
| Returns a Boolean value indicating whether a display is built-in, such as the internal display in portable systems. |
| Returns a Boolean value indicating whether a display is the main display. |
| Returns the width and height of a display in millimeters. |
| Returns a Boolean value indicating whether Quartz is using OpenGL-based window acceleration (Quartz Extreme) to render in a display. |
Each online display has a current display mode and a set of available display modes. The device driver uses information in the current display mode to configure the display.
You can retrieve the values of the properties in a display mode dictionary with the CFDictionaryGetValue
function. Then, you may need to cast the returned value to the appropriate data type. Listing 1 shows how to retrieve several mode properties and cast them to a base data type.
Listing 1 Getting display mode properties
CFNumberRef number; |
CFBoolean booleanValue; |
Boolean gui; |
long mode, refresh, ioflags; |
CFDictionaryRef currentMode = CGDisplayCurrentMode (kCGDirectMainDisplay); |
number = CFDictionaryGetValue (currentMode, kCGDisplayMode); |
CFNumberGetValue (number, kCFNumberLongType, &mode); |
number = CFDictionaryGetValue (currentMode, kCGDisplayRefreshRate); |
CFNumberGetValue (number, kCFNumberLongType, &refresh); |
booleanValue = CFDictionaryGetValue (currentMode, kCGDisplayModeUsableForDesktopGUI); |
gui = CFBooleanGetValue (booleanValue); |
number = CFDictionaryGetValue (currentMode, kCGDisplayIOFlags); |
CFNumberGetValue (number, kCFNumberLongType, &ioflags); |
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-06-28)