<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGraphicsContext/init(bitmapImageRep:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGraphicsContext(cm)graphicsContextWithBitmapImageRep:"
  },
  "title" : "init(bitmapImageRep:)"
}
-->

# init(bitmapImageRep:)

Creates a new graphics context using the specified bitmap image representation object as the context destination.

```
init?(bitmapImageRep bitmapRep: NSBitmapImageRep)
```

## Parameters

`bitmapRep`

The [`NSBitmapImageRep`](/documentation/AppKit/NSBitmapImageRep) object to use as the destination.

## Return Value

The created [`NSGraphicsContext`](/documentation/AppKit/NSGraphicsContext) object, or `nil` if the object could not be created.

## Discussion

This method accepts only single plane [`NSBitmapImageRep`](/documentation/AppKit/NSBitmapImageRep) instances. It is the equivalent of using [`init(attributes:)`](/documentation/AppKit/NSGraphicsContext/init(attributes:)) and passing `bitmapRep` as the value for the dictionary’s [`destination`](/documentation/AppKit/NSGraphicsContext/AttributeKey/destination) key.

---

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)