Function

vImageAffineWarp_ARGB8888

Applies an affine transformation to an ARGB8888 source image.

Declaration

vImage_Error vImageAffineWarp_ARGB8888(const vImage_Buffer *src, const vImage_Buffer *dest, void *tempBuffer, const vImage_AffineTransform *transform, const Pixel_8888 backColor, vImage_Flags flags);

Parameters

src

A pointer to a vImage buffer structure that contains the source image whose data you want to transform.

dest

A pointer to a vImage buffer data structure. You're responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.

tempBuffer

A pointer to a temporary buffer. If you pass NULL, the function allocates the buffer, then deallocates it before returning. Alternatively, you can allocate the buffer yourself, in which case you're responsible for deallocating it when you no longer need it.

If you want to allocate the buffer yourself, see Allocating Temporary Buffer Memory for information on how to determine the minimum size that you must allocate.

transform

The affine transformation matrix to apply to the source image.

backColor

A background color. Pass a pixel value only if you also set the kvImageBackgroundColorFill flag.

flags

The options to use when applying the rotation.

To specify how vImage handles pixel locations beyond the edge of the source image, you must set exactly one of the following flags: kvImageBackgroundColorFill or kvImageEdgeExtend.

If you want vImage to use a higher quality, but slower resampling filter, set the kvImageHighQualityResampling flag.

If you plan to perform your own tiling or use multithreading, set the kvImageDoNotTile flag.

This function ignores the kvImageLeaveAlphaUnchanged flag.

Return Value

kvImageNoError; otherwise, one of the error codes described in Data Types and Constants.

Discussion

This function maps each pixel in the source image [x, y] to a new position [x’, y’] in the destination image, using this formula:

(x', y') = (x, y) * transform

where transform is the 3x3 affine transformation matrix.

Allocating Temporary Buffer Memory

If you want to allocate the memory for the tempBuffer parameter yourself, call this function twice, as follows:

  1. To determine the minimum size for the temporary buffer, the first time you call this function, pass the kvImageGetTempBufferSize flag. Pass the same values for all other parameters that you intend to use for the second call. The function returns the required minimum size, which should be a positive value. (A negative returned value indicates an error.) The kvImageGetTempBufferSize flag prevents the function from performing any processing other than to determine the minimum buffer size.

  2. After you allocate enough space for a buffer of the returned size, call the function a second time, passing a valid pointer in the tempBuffer parameter. This time, don't pass the kvImageGetTempBufferSize flag.

See Also

Single-Precision Affine Transformation

vImageAffineWarp_ARGBFFFF

Applies an affine transformation to an ARGBFFFF source image.

vImageAffineWarp_ARGB16U

Applies an affine transformation to an ARGB16U source image.

vImageAffineWarp_ARGB16S

Applies an affine transformation to an ARGB16S source image.

vImageAffineWarp_PlanarF

Applies an affine transformation to a PlanarF source image.

vImageAffineWarp_Planar8

Applies an affine transformation to a Planar8 source image.