rotate(_:backgroundColor:destination:)
Rotates an 8-bit planar pixel buffer.
Declaration
func rotate(_ rotation: vImage.Rotation, backgroundColor: Pixel_8? = Pixel_8(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 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), 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(_:) or vImage.Rotation.angleInDegrees(_:) to invoke the high-level rotate function.
See Also
Related Documentation
Rotating images
rotate(_:backgroundColor:useFloat16Accumulator:destination:)rotate(_:backgroundColor:destination:)rotate(_:backgroundColor:useFloat16Accumulator:destination:)rotate(_:backgroundColor:destination:)rotate(_:backgroundColor:destination:)rotate(_:backgroundColor:useFloat16Accumulator:destination:)rotate(_:backgroundColor:destination:)vImage.Rotation