<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/calculateHDRStats(for:)-6lwmz",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)calculateHDRStatsForIOSurface:"
  },
  "title" : "calculateHDRStats(for:)"
}
-->

# calculateHDRStats(for:)

Given an IOSurface, use the receiving Core Image context to calculate its
HDR statistics (content headroom and content average light level)
and then update the surface’s attachments to store the values.

```
func calculateHDRStats(for surface: IOSurfaceRef)
```

## Parameters

`surface`

A mutable `IOSurfaceRef` for which to calculate and attach statistics.

## Discussion

If the `IOSurface` has a Clean Aperture rectangle then only pixels within
that rectangle are considered.

---

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)