<!--
{
  "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 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVMutablePixelBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "s:9CoreVideo20CVMutablePixelBufferV"
  },
  "title" : "CVMutablePixelBuffer"
}
-->

# CVMutablePixelBuffer

CVMutablePixelBuffer provides read-write access to the pixel data and attachments.

```
struct CVMutablePixelBuffer
```

## Topics

### Classes

[`class Pool`](/documentation/CoreVideo/CVMutablePixelBuffer/Pool)

Manage and recycle pixel buffer backings.

### Initializers

[`init(CVPixelBufferCreationAttributes) throws`](/documentation/CoreVideo/CVMutablePixelBuffer/init(_:))

Creates a CVPixelBuffer with given attributes. It allocates the necessary memory based on the dimensions,
pixel format and extended pixels described in the `CVPixelBuffer/Attributes`.

[`init(unsafeBacking: IOSurface, matching: CVPixelBufferCreationAttributes) throws`](/documentation/CoreVideo/CVMutablePixelBuffer/init(unsafeBacking:matching:))

Creates a CVPixelBuffer backed by the given `ioSurface`. The CVPixelBuffer will retain the `ioSurface`.
**IMPORTANT** If you are using IOSurface to share CVPixelBuffers between processes
and those CVPixelBuffers are allocated via a CVPixelBufferPool, it is important
that the CVPixelBufferPool does not reuse CVPixelBuffers whose IOSurfaces are still
in use in other processes.
CoreVideo and IOSurface will take care of this for if you use IOSurfaceCreateMachPort
and IOSurfaceLookupFromMachPort, but NOT if you pass IOSurfaceIDs.

[`init(unsafeBuffer: sending CVPixelBuffer)`](/documentation/CoreVideo/CVMutablePixelBuffer/init(unsafeBuffer:))

Initialize a mutable pixel buffer by transferring existing CVPixelBuffer value.

### Instance Properties

[`var attachments: CVMutablePixelBuffer.Attachments`](/documentation/CoreVideo/CVMutablePixelBuffer/attachments)

Access attachments of this pixel buffer.

### Instance Methods

[`func accessUnsafeMutableRawPlaneBytes<R>(([(properties: CVPixelBufferPlaneProperties, bytes: UnsafeMutableRawBufferPointer)]) throws -> sending R) rethrows -> sending R`](/documentation/CoreVideo/CVMutablePixelBuffer/accessUnsafeMutableRawPlaneBytes(_:))

Access the pixels in the planes contained within this buffer. The base address is locked for writing
during the execution of the block.

[`func fillExtendedPixels() -> Bool`](/documentation/CoreVideo/CVMutablePixelBuffer/fillExtendedPixels())

Fills the extended pixels of the pixel buffer.
This method replicates the edge pixels to fill the entire extended region of the image.

[`func withUnsafeBuffer<R>((CVPixelBuffer) throws -> sending R) rethrows -> sending R`](/documentation/CoreVideo/CVMutablePixelBuffer/withUnsafeBuffer(_:))

## Relationships

### Conforms To

[`Escapable`](/documentation/Swift/Escapable)

[`ViewRepresentable`](/documentation/CoreAI/InferenceValue/ViewRepresentable)

[`Sendable`](/documentation/Swift/Sendable)

[`CVBufferRepresentable`](/documentation/CoreVideo/CVBufferRepresentable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`MutableViewRepresentable`](/documentation/CoreAI/InferenceValue/MutableViewRepresentable)

[`CVPixelBufferRepresentable`](/documentation/CoreVideo/CVPixelBufferRepresentable)

[`CVImageBufferRepresentable`](/documentation/CoreVideo/CVImageBufferRepresentable)

---

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)