---
title: "histogramSize(forSourceFormat:)"
framework: metalperformanceshaders
role: symbol
role_heading: Instance Method
path: "metalperformanceshaders/mpsimagehistogram/histogramsize(forsourceformat:)"
---

# histogramSize(forSourceFormat:)

The amount of space the histogram will take up in the output buffer.

## Declaration

```swift
func histogramSize(forSourceFormat sourceFormat: MTLPixelFormat) -> Int
```

## Parameters

- `sourceFormat`: The pixel format of the source image, corresponding to the sourceTexture object of the doc://com.apple.metalperformanceshaders/documentation/MetalPerformanceShaders/MPSImageHistogram/encode(to:sourceTexture:histogram:histogramOffset:) method.

## Return Value

Return Value The number of bytes needed to store the histogram results.

## Discussion

Discussion This convenience function calculates the minimum amount of space needed in the output histogram for the results. The buffer should be at least this length and longer if the histogramOffset value in the encode(to:sourceTexture:histogram:histogramOffset:) method is non-zero.

## See Also

### Methods

- [init(device:histogramInfo:)](metalperformanceshaders/mpsimagehistogram/init(device:histograminfo:).md)
- [MPSImageHistogramInfo](metalperformanceshaders/mpsimagehistograminfo.md)
- [encode(to:sourceTexture:histogram:histogramOffset:)](metalperformanceshaders/mpsimagehistogram/encode(to:sourcetexture:histogram:histogramoffset:).md)
