<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImageRep/bitsPerSample",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImageRep(py)bitsPerSample"
  },
  "title" : "bitsPerSample"
}
-->

# bitsPerSample

The number of bits per sample in the object (if the object is a planar image, this property contains the number of bits per sample per plane).

```
var bitsPerSample: Int { get set }
```

## Discussion

The number of bits used to specify each component of data in a single pixel (for example, a value of 8 for an RGBA image means that each pixel is comprised of four 8-bit values) or [`NSImageRepMatchesDevice`](/documentation/AppKit/NSImageRepMatchesDevice).

A subclass can set this property when loading image data to notify the parent class of how many bits each sample uses. Specifying a value that differs from the actual image data does not change the bit depth of the image.

## See Also

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

The number of bits allocated for each pixel in each plane of data.

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

The number of components for each pixel.

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

A Boolean value that indicates whether the image data is in a planar configuration.



---

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)