<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGDisplayBestModeForParameters(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGDisplayBestModeForParameters"
  },
  "title" : "CGDisplayBestModeForParameters(_:_:_:_:_:)"
}
-->

# CGDisplayBestModeForParameters(_:_:_:_:_:)

Returns information about the display mode closest to a specified depth and screen size.

```
func CGDisplayBestModeForParameters(_ display: CGDirectDisplayID, _ bitsPerPixel: Int, _ width: Int, _ height: Int, _ exactMatch: UnsafeMutablePointer<boolean_t>?) -> CFDictionary?
```

## Parameters

`display`

The identifier of the display to optimize.

`bitsPerPixel`

Optimal display depth in bits per pixel. Note that this value is not the same as pixel depth, which is the number of bits per channel or component.

`width`

Optimal display width in pixel units.

`height`

Optimal display height in pixel units.

`exactMatch`

A pointer to a Boolean variable. On return, its value is `true` if an exact match in display depth, width, and height is found; otherwise, `false`. If this information is not needed, pass `NULL`.

## Return Value

A display mode dictionary, or `NULL` if the display is invalid. The dictionary is owned by the system and you should not release it. The dictionary contains information about the display mode closest to the specified depth and screen size. For a list of the properties in a display mode dictionary, see [Display Mode Standard Properties](/documentation/CoreGraphics/display-mode-standard-properties) and [Display Mode Optional Properties](/documentation/CoreGraphics/display-mode-optional-properties). For general information about using dictionaries, see <doc://com.apple.documentation/documentation/CoreFoundation/CFDictionary>.

## Discussion

This function tries to find an optimal display mode for the specified display. The function first tries to find a mode with the specified pixel depth and dimensions equal to or greater than the specified width and height. If no depth match is found, it tries to find a mode with greater depth and the same or greater dimensions. If a suitable display mode is not found, this function simply returns the current display mode.

### Special Considerations

This deprecated function selects a display mode closest to the specified parameters. Starting in OS X v10.6 new display mode APIs should be used to query display modes so that an application can tailor its definition of “best” to its graphics and memory needs.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)