---
title: bitsPerSample
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nsimagerep/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).

## Declaration

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

## Discussion

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. 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

### Related Documentation

- [bitsPerPixel](appkit/nsbitmapimagerep/bitsperpixel.md)
- [samplesPerPixel](appkit/nsbitmapimagerep/samplesperpixel.md)
- [isPlanar](appkit/nsbitmapimagerep/isplanar.md)

### Specifying Information About the Representation

- [colorSpaceName](appkit/nsimagerep/colorspacename.md)
- [hasAlpha](appkit/nsimagerep/hasalpha.md)
- [isOpaque](appkit/nsimagerep/isopaque.md)
- [pixelsHigh](appkit/nsimagerep/pixelshigh.md)
- [pixelsWide](appkit/nsimagerep/pixelswide.md)
- [layoutDirection](appkit/nsimagerep/layoutdirection.md)
- [Device-Specific Value](appkit/device-specific-value.md)
