Applies a Core Graphics affine transformation to an ARGB16S source image.
SDKs
- iOS 7.0+
- macOS 10.9+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Accelerate
Declaration
func vImageAffineWarpCG_ARGB16S(_ src: Unsafe Pointer<v Image _Buffer>, _ dest: Unsafe Pointer<v Image _Buffer>, _ tempBuffer: Unsafe Mutable Raw Pointer!, _ transform: Unsafe Pointer<v Image _CGAffine Transform>, _ backColor: Unsafe Pointer<Int16>!, _ flags: v Image _Flags) -> v Image _Error
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
, androw
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.Bytes 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
kv
flag.Image Background Color Fill 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:
kv
orImage Background Color Fill kv
.Image Edge Extend If you want vImage to use a higher quality, but slower resampling filter, set the
kv
flag.Image High Quality Resampling If you plan to perform your own tiling or use multithreading, set the kvImageDoNotTile flag.
This function ignores the
kv
flag.Image Leave Alpha Unchanged
Return Value
kv
; otherwise, one of the error codes described in Data Types and Constants.
Discussion
Core Graphics types use float values in 32-bit and double values in 64-bit. This convenience method takes the Core Graphics affine transform type directly so that you don’t have to use a different function for 64-bit applications.
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 temp
parameter yourself, call this function twice, as follows:
To determine the minimum size for the temporary buffer, the first time you call this function, pass the
kv
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.) TheImage Get Temp Buffer Size kv
flag prevents the function from performing any processing other than to determine the minimum buffer size.Image Get Temp Buffer Size After you allocate enough space for a buffer of the returned size, call the function a second time, passing a valid pointer in the
temp
parameter. This time, don't pass theBuffer kv
flag.Image Get Temp Buffer Size