<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBitmapImageRep/setPixel(_:atX:y:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBitmapImageRep(im)setPixel:atX:y:"
  },
  "title" : "setPixel(_:atX:y:)"
}
-->

# setPixel(_:atX:y:)

Sets the bitmap image representation’s pixel at the specified coordinates to the specified raw pixel values.

```
func setPixel(_ p: UnsafeMutablePointer<Int>, atX x: Int, y: Int)
```

## Parameters

`p`

An array of integers representing the raw pixel values. The values must be in an order appropriate to the object’s bitmap format. Small pixel sample values should be passed as an integer value. Floating point values should be cast `int[]`.

`x`

The x-axis coordinate of the pixel.

`y`

The y-axis coordinate of the pixel.

## See Also

[`bitmapFormat`](/documentation/AppKit/NSBitmapImageRep/bitmapFormat)

The format of the bitmap image representation.



---

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)