<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/rotate(_:backgroundColor:destination:)-9bnb6",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC14InterleavedFx4VRszrlE6rotate_15backgroundColor11destinationyAC8RotationO_Sf_S3ftSgAEy_AGGtF"
  },
  "title" : "rotate(_:backgroundColor:destination:)"
}
-->

# rotate(_:backgroundColor:destination:)

Rotates a 32-bit-per-channel, four-channel interleaved pixel buffer.

```
func rotate(_ rotation: vImage.Rotation, backgroundColor: Pixel_FFFF? = (0, 0, 0, 0), destination: vImage.PixelBuffer<Format>)
```

## Parameters

`rotation`

An enumeration that specifies the rotation angle.

`backgroundColor`

An optional background color. If you pass `nil`, the operation uses the [`kvImageEdgeExtend`](/documentation/Accelerate/kvImageEdgeExtend) flag to extend the edges of the image infinitely.

`destination`

The destination pixel buffer.

## Discussion

Use this function to either rotate an image by a multiple of 90° or by an angle, which you specify in degrees or radians.

When you specify a rotation that’s a multiple of 90° (such as [`vImage.Rotation.clockwise270Degrees`](/documentation/Accelerate/vImage/Rotation/clockwise270Degrees)), this function maps the center point of the source image to the center point of the destination image. It doesn’t scale or resample; instead, the function copies individual pixels unchanged to new locations.

The 90° and 270° rotations don’t rotate around the true center of the image if either of the following is true:

- The parities of the source height and the destination width don’t match. For example, the source height is odd and the destination width is even.
- The parities of the source width and the destination height don’t match. For example, the source width is odd and the destination height is even.

The 0° and 180° rotations don’t rotate around the true center of the image if either of the following is true:

- The parities of the source height and the destination height don’t match. For example, the source height is odd and the destination height is even.
- The parities of the source width and the destination width don’t match. For example, the source width is odd and the destination width is even.

To overcome this limitation, specify [`vImage.Rotation.angleInRadians(_:)`](/documentation/Accelerate/vImage/Rotation/angleInRadians(_:)) or [`vImage.Rotation.angleInDegrees(_:)`](/documentation/Accelerate/vImage/Rotation/angleInDegrees(_:)) to invoke the high-level rotate function.

## See Also

  <doc://com.apple.accelerate/documentation/Accelerate/applying-geometric-transforms-to-images>



---

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)