| Framework | Accelerate/vImage |
| Companion guide | |
| Declared in | Conversion.h |
Conversion functions change an image from one image format into another. These functions work with the formats supported by vImage (Planar8, PlanarF, ARGB8888, ARGBFFFF, RGBA8888, and RGBAFFFF) but they can also change between a supported format to one that’s not supported by vImage (such as RGB565). Conversion functions can also fill buffers with a color, overwrite channels, permute channels, flatten data, and clip data.
Conversion functions use a vImage buffer structure (vImage_Buffer—see vImage Data Types and Constants Reference) to receive and supply image data. This buffer contains a pointer to image data, the height and width (in pixels) of the image data, and the number of row bytes. You actually pass a pointer to a vImage buffer structure. For some functions, you can provide a pointer to the same vImage buffer structure for the source images and the destination image because the function “works in place”. That is , the source and destination images can occupy the same memory if the they are strictly aligned pixel for pixel.
vImageSelectChannels_ARGB8888
vImageSelectChannels_ARGBFFFF
vImageOverwriteChannels_ARGB8888
vImageOverwriteChannels_ARGBFFFF
vImageOverwriteChannelsWithScalar_ARGB8888
vImageOverwriteChannelsWithScalar_ARGBFFFF
vImageOverwriteChannelsWithScalar_Planar8
vImageOverwriteChannelsWithScalar_PlanarF
vImageOverwriteChannelsWithPixel_ARGB8888
vImageOverwriteChannelsWithPixel_ARGBFFFF
These convenience functions allow you to convert between various interleaved (or chunky) formats that vImage does not explicitly support (and that may have less than or more than four channels) and the formats that vImage supports explicitly. You can represent some non-interleaved formats as well. The functions are not fast or vectorized.
vImageConvert_PlanarToChunky8
vImageConvert_PlanarToChunkyF
vImageConvert_ChunkyToPlanar8
vImageConvert_ChunkyToPlanarF
vImageConvert_Planar8To16U
vImageConvert_Planar8toARGB1555
vImageConvert_Planar8toARGB8888
vImageConvert_Planar8toPlanarF
vImageConvert_Planar8toRGB565
vImageConvert_Planar8toRGB888
vImageConvert_PlanarFtoRGBFFF
vImageConvert_PlanarFtoARGBFFFF
vImageConvert_PlanarFtoPlanar16F
vImageConvert_PlanarFtoPlanar8
vImageConvert_Planar16FtoPlanarF
vImageConvert_FTo16S
vImageConvert_FTo16U
vImageConvert_ARGB1555toARGB8888
vImageConvert_ARGB1555toPlanar8
vImageConvert_ARGB8888toARGB1555
vImageConvert_ARGB8888toPlanar8
vImageConvert_ARGB8888toRGB565
vImageConvert_ARGB8888toRGB888
vImageConvert_ARGBFFFFtoPlanarF
vImageConvert_RGB565toPlanar8
vImageConvert_RGB565toARGB8888
vImageConvert_RGB888toARGB8888
vImageConvert_RGB888toPlanar8
vImageConvert_RGBFFFtoPlanarF
Fills an ARGB8888 buffer with a specified color.
vImage_Error vImageBufferFill_ARGB8888 ( const vImage_Buffer *dest, const Pixel_8888 color, vImage_Flags flags );
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data created with the fill color. When you no longer need the data buffer, you must deallocate the memory.
The color to fill the buffer with.
Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Conversion.hFills an ARGBFFFF buffer with a specified color.
vImage_Error vImageBufferFill_ARGBFFFF ( const vImage_Buffer *dest, const Pixel_FFFF color, vImage_Flags flags );
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data created with the fill color. When you no longer need the data buffer, you must deallocate the memory.
The color to fill the buffer with.
Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Conversion.hClips the pixel values of an image in PlanarF format, using the provided minimum and maximum values.
vImage_Error vImageClip_PlanarF ( const vImage_Buffer *src, const vImage_Buffer *dest, Pixel_F maxFloat, Pixel_F minFloat, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to clip.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.
A maximum pixel value. The function clips larger values to this value in the destination image.
A maximum pixel value. The function clips smaller values to this value in the destination image.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Conversion.hConverts an image in a special planar format—in which each pixel value is a 16-bit signed integer— to a PlanarF format.
vImage_Error vImageConvert_16SToF ( const vImage_Buffer *src, const vImage_Buffer *dest, float offset, float scale, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image (for which each pixel value is a 16-bit signed integer) whose data you want to overwrite.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data in PlanarF format. When you no longer need the data buffer, you must deallocate the memory.
The offset value to add to each pixel.
The value to multiply each pixel by.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The function changes each pixel value to a floating-point value, scales each value and then adds the offset value. The calculation is
resultPixel = (float) sourcePixel * scale + offset |
The functions vImageConvert_16SToF and vImageConvert_FTo16S are inverse transformations when you use the same offset and scale values for each. (The inversion is not precise due to round-off error.) This requires the two functions to use these values differently (and in a different order).
Conversion.hConverts an image in a special planar format—in which each pixel value is a 16-bit unsigned integer— to a PlanarF format.
vImage_Error vImageConvert_16UToF ( const vImage_Buffer *src, const vImage_Buffer *dest, float offset, float scale, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image (for which each pixel value is a 16-bit unsigned integer) whose data you want to overwrite.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data in PlanarF format. When you no longer need the data buffer, you must deallocate the memory.
The offset value to add to each pixel.
The value to multiply each pixel by.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Each pixel value is changed to a floating-point value, then scaled and offset by the provided values. The calculation is
resultPixel = SATURATED_CLIP_SHRT_MIN_to_SHRT_MAX( (sourcePixel |
- offset) / scale + 0.5f) |
The functions vImageConvert_16SToF and vImageConvert_FTo16S are inverse transformations when you use the same offset and scale values for each. (The inversion is not precise due to round-off error.) This requires the two functions to use these values differently (and in a different order).
Conversion.hConverts an image in a special planar format—in which each pixel value is a 16-bit unsigned integer—to a Planar8 image.
vImage_Error vImageConvert_16UToPlanar8 ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The conversion from 16-bit to 8-bit values is:
uint8_t result = (srcPixel * 255 + 32767) / 65535 |
You can also use this function to convert a 4-channel interleaved 16U image to an ARGB8888. image. Simply multiply the width of the destination buffer by four.
Conversion.hConverts an ARGB1555 image to an ARGB8888 image.
vImage_Error vImageConvert_ARGB1555toARGB8888 ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the converted data. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The ARGB1555 format has 16-bit pixels with 1 bit for alpha and 5 bits each for red, green, and blue. The function calculates the 8-bit pixels in the destination image as follows:
Pixel8 alpha = 1bitAlphaChannel * 255 |
Pixel8 red = (5bitRedChannel * 255 + 15) / 31 |
Pixel8 green = (5bitGreenChannel * 255 + 15) / 31 |
Pixel8 blue = (5bitBlueChannel * 255 + 15) / 31 |
Conversion.hSeparates an ARGB1555 image into four Planar8 images.
vImage_Error vImageConvert_ARGB1555toPlanar8 ( const vImage_Buffer *src, const vImage_Buffer *destA, const vImage_Buffer *destR, const vImage_Buffer *destG, const vImage_Buffer *destB, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to separate.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the alpha channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the red channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the green channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the blue channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The ARGB1555 format has 16-bit pixels with 1 bit for alpha and 5 bits each for red, green, and blue. The function calculates the 8-bit pixels in the destination image as follows:
Pixel8 alpha = 1bitAlphaChannel * 255 |
Pixel8 red = (5bitRedChannel * 255 + 15) / 31 |
Pixel8 green = (5bitGreenChannel * 255 + 15) / 31 |
Pixel8 blue = (5bitBlueChannel * 255 + 15) / 31 |
This function works in place for one destination buffer; the others must be allocated separately.
Conversion.hConverts an ARGB8888 image into an ARGB1555 image.
vImage_Error vImageConvert_ARGB8888toARGB1555 ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the converted image data. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The ARGB1555 format has 16-bit pixels with 1 bit for alpha and 5 bits each for red, green, and blue. The function calculates the 16-bit pixels in the destination image as follows:
uint32_t alpha = (8bitAlphaChannel + 127) / 255 |
uint32_t red = (8bitRedChannel * 31 + 127) / 255 |
uint32_t green = (8bitGreenChannel * 31 + 127) / 255 |
uint32_t blue = (8bitBlueChannel * 31 + 127) / 255 |
uint16_t ARGB1555pixel = (alpha << 15) | (red << 10) | (green << 5) | blue |
Conversion.hSeparates an ARGB8888 image into four Planar8 images.
vImage_Error vImageConvert_ARGB8888toPlanar8 ( const vImage_Buffer *srcARGB, const vImage_Buffer *destA, const vImage_Buffer *destR, const vImage_Buffer *destG, const vImage_Buffer *destB, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to separate.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the alpha channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the red channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the green channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a Planar8 image equivalent to the blue channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source image, and the destA, destR, destG, and destB destination buffers, must have the same height and the same width. This function works in place for one destination buffer. The others must be allocated separately.
Conversion.hConverts an ARGB8888 image into an RGB565 image.
vImage_Error vImageConvert_ARGB8888toRGB565 ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the data in RGB565 format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The alpha channel in the ARGB8888 image is ignored. (The RGB565 format has 16-bit pixels with 5 bits for red, 6 for green, and 5 for blue.) The function calculates the pixels in the destination image as follows:
uint32_t red = (8bitRedChannel * (31*2) + 255) / (255*2) |
uint32_t green = (8bitGreenChannel * 63 + 127) / 255 |
uint32_t blue = (8bitBlueChannel * 31 + 127) / 255 |
uint16_t RGB565pixel = (red << 11) | (green << 5) | blue |
Conversion.hConverts an ARGB8888 image into an RGB888 image.
vImage_Error vImageConvert_ARGB8888toRGB888 ( const vImage_Buffer *argbSrc, const vImage_Buffer *rgbDest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the argbSrc data buffer. On return, the data buffer pointed to by this structure contains the data in RGB888 format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The red, green, and blue channels are simply copied.
Conversion.hSeparates an ARGBFFFF image into four PlanarF images.
vImage_Error vImageConvert_ARGBFFFFtoPlanarF ( const vImage_Buffer *srcARGB, const vImage_Buffer *destA, const vImage_Buffer *destR, const vImage_Buffer *destG, const vImage_Buffer *destB, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to separate.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a PlanarF image equivalent to the alpha channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a PlanarF image equivalent to the red channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a PlanarF image equivalent to the green channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains data for a PlanarF image equivalent to the blue channel of the source image. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source image, and the destA, destR, destG, and destB destination buffers, must have the same height and the same width. This function works in place for one destination buffer. The others must be allocated separately.
Conversion.hSeparates a source image into a collection of corresponding planar destination images, one for each 8-bit channel of the original image.
vImage_Error vImageConvert_ChunkyToPlanar8 ( const void *srcChannels[], const vImage_Buffer *destPlanarBuffers[], unsigned int channelCount, size_t srcStrideBytes, vImagePixelCount srcWidth, vImagePixelCount srcHeight, size_t srcRowBytes, vImage_Flags flags );
An array of pointers to channels of the source image. Each pointer points to the start of the data for one source channel.
An array of vImage buffer structures, each of which contains image data in Planar8 format. Each structure must have the same width and height values, but may have different row byte values. On return, the data buffer in each vImage buffer structure contains a planar image equivalent to the corresponding channel of the source image.
The number of channels in the source image.
The number of bytes from one pixel value in a given channel to the next pixel of that channel (within a row). This value must be the same for all channels.
The number of pixels in a row. This value must be the same for all channels in the source image, and for all the destination buffers.
The number of rows. This value must be the same for all channels in the source image, and for all the destination buffers.
The number of bytes from the beginning of a channel row to the beginning of the next row of the channel. This value must be the same for all channels of the source image. (It does not have the be the same as the rowBytes values of the destination buffers. Each destination buffer can have its own rowBytes value.)
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Conversion.hSeparates a source image into a collection of corresponding planar destination images, one for each floating-point channel of the original image.
vImage_Error vImageConvert_ChunkyToPlanarF ( const void *srcChannels[], const vImage_Buffer *destPlanarBuffers[], unsigned int channelCount, size_t srcStrideBytes, vImagePixelCount srcWidth, vImagePixelCount srcHeight, size_t srcRowBytes, vImage_Flags flags );
An array of pointers to channels of the source image. Each pointer points to the start of the data for one source channel.
An array of vImage buffer structures, each of which contains image data in PlanarF format. Each structure must have the same width and height values, but may have different row byte values. On return, the data buffer in each each vImage buffer structure contains a planar image equivalent to the corresponding channel of the source image.
The number of channels in the source image.
The number of bytes from one pixel value in a given channel to the next pixel of that channel (within a row). This value must be the same for all channels.
The number of pixels in a row. This value must be the same for all channels in the source image, and for all the destination buffers.
The number of rows. This value must be the same for all channels in the source image, and for all the destination buffers.
The number of bytes from the beginning of a channel row to the beginning of the next row of the channel. This value must be the same for all channels of the source image. (It does not have the be the same as the rowBytes values of the destination buffers. Each destination buffer can have its own rowBytes value.)
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Conversion.hConverts a PlanarF image into a special format in which each pixel is a 16-bit signed integer.
vImage_Error vImageConvert_FTo16S ( const vImage_Buffer *src, const vImage_Buffer *dest, float offset, float scale, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image converted to 16-bit signed integer format. When you no longer need the data buffer, you must deallocate the memory.
The offset value to subtract from every pixel.
The scale value to divide each pixel by.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Each pixel value is first offset and scaled by the provided values, and then changed to a 16-bit signed integer (rounded and clipped as necessary). The calculation is as follows:
resultPixel = SATURATED_CLIP_0_to_USHRT_MAX( (srcPixel - offset) |
/ scale + 0.5f) |
The functions vImageConvert_16SToF and vImageConvert_FTo16S are inverse transformations when you use the same offset and scale values for each. (The inversion is not precise due to round-off error.) This requires the two functions to use these values differently (and in a different order).
Conversion.hConverts a PlanarF image into a special format in which each pixel is a 16-bit unsigned integer.
vImage_Error vImageConvert_FTo16U ( const vImage_Buffer *src, const vImage_Buffer *dest, float offset, float scale, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image converted to 16-bit unsigned integer format. When you no longer need the data buffer, you must deallocate the memory.
The offset value to subtract from every pixel.
The scale value to divide each pixel by.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Each pixel value is first offset and scaled by user-supplied values, and then changed to a 16-bit unsigned integer (rounded and clipped as necessary). The calculation is as follows:
resultPixel = SATURATED_CLIP_0_to_USHRT_MAX( (sourcePixel - offset) |
/ scale + 0.5f) |
The functions vImageConvert_16UToF and vImageConvert_FTo16U are inverse transformations when you use the same offset and scale values for each. (The inversion is not precise due to round-off error.) This requires the two functions to use these values differently (and in a different order).
Conversion.hConverts a Planar16F image to a PlanarF image.
vImage_Error vImageConvert_Planar16FtoPlanarF ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image converted to PlanarF format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The Planar16F format is identical to the OpenEXR format; it uses 16-bit floating-point numbers. In conformance with IEEE-754, the function quiets signaling NaNs during the conversion. (OpenEXR-1.2.1 does not do this.)
Conversion.hConverts a Planar8 image to a 16U image .
vImage_Error vImageConvert_Planar8To16U ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The function converts from 8-bit to 16-bit values as follows:
uint16_t result = (srcPixel * 65535 + 127 ) / 255 |
You can also use this function to convert an ARGB8888 image to a 4-channel interleaved 16U image. Simply multiply the width of the destination buffer by four.
Conversion.hCombines four Planar8 images into one ARGB1555 image.
vImage_Error vImageConvert_Planar8toARGB1555 ( const vImage_Buffer *srcA, const vImage_Buffer *srcR, const vImage_Buffer *srcG, const vImage_Buffer *srcB, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the Planar8 image to use as the alpha channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data in ARGB1555 format (16-bit pixels with 1 bit for alpha and 5 bits each for red, green, and blue). When you no longer need the data buffer, you must deallocate the memory. The destination buffer can be the same as the source buffer.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
This function calculates the 8-bit pixels in the destination image as follows:
Pixel8 alpha = 1bitAlphaChannel * 255 |
Pixel8 red = (5bitRedChannel * 255 + 15) / 31 |
Pixel8 green = (5bitGreenChannel * 255 + 15) / 31 |
Pixel8 blue = (5bitBlueChannel * 255 + 15) / 31 |
Conversion.hCombines four Planar8 images into one ARGB8888 image.
vImage_Error vImageConvert_Planar8toARGB8888 ( const vImage_Buffer *srcA, const vImage_Buffer *srcR, const vImage_Buffer *srcG, const vImage_Buffer *srcB, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the Planar8 image to use as the alpha channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image in ARGB8888 format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source and destination buffers must have the same height and width.
Conversion.hConverts a Planar8 image to a PlanarF image.
vImage_Error vImageConvert_Planar8toPlanarF ( const vImage_Buffer *src, const vImage_Buffer *dest, Pixel_F maxFloat, Pixel_F minFloat, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image converted to PlanarF format. When you no longer need the data buffer, you must deallocate the memory.
The maximum pixel value for the destination image.
The minimum pixel value for the destination image.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
This function transforms a Planar8 image to a PlanarF image, using a minFloat value and a maxFloat value to specify the range of values for the PlanarF image. The function maps each source pixel value(which can be in the range of 0 to 255 inclusive) linearly into the range minFloat to maxFloat, using the following mapping (where i is the old pixel value):
new pixel value = i* (maxFloat - minFloat)/255.0f + minFloat |
The two buffers must have the same number of rows and the same number of columns.
Conversion.hCombines three Planar8 images into one RGB565 image.
vImage_Error vImageConvert_Planar8toRGB565 ( const vImage_Buffer *srcR, const vImage_Buffer *srcG, const vImage_Buffer *srcB, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the Planar8 image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image in RGB565 format (16-bit pixels with 5 bits for red, 6 for green, and 5 for blue). When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The function calculates the pixels in the destination image as follows:
uint32_t red = (8bitRedChannel * (31*2) + 255) / (255*2) |
uint32_t green = (8bitGreenChannel * 63 + 127) / 255 |
uint32_t blue = (8bitBlueChannel * 31 + 127) / 255 |
uint16_t RGB565pixel = (red << 11) | (green << 5) | blue |
Conversion.hCombines three Planar8 images into one RGB888 image.
vImage_Error vImageConvert_Planar8toRGB888 ( const vImage_Buffer *planarRed, const vImage_Buffer *planarGreen, const vImage_Buffer *planarBlue, const vImage_Buffer *rgbDest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the Planar8 image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the Planar8 image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image in RGB888 format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source and destination buffers must have the same height and width.
Conversion.hCombines four PlanarF images into one ARGBFFFF image.
vImage_Error vImageConvert_PlanarFtoARGBFFFF ( const vImage_Buffer *srcA, const vImage_Buffer *srcR, const vImage_Buffer *srcG, const vImage_Buffer *srcB, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the PlanarF image to use as the alpha channel of the destination image.
A pointer to vImage buffer structure that contains the PlanarF image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the PlanarF image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the PlanarF image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data in ARGBFFFF format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source and destination buffers must have the same height and width.
Conversion.hConverts a PlanarF image to a Planar16F image.
vImage_Error vImageConvert_PlanarFtoPlanar16F ( const vImage_Buffer *src, const vImage_Buffer *dest, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image converted to Planar16F format. The destination buffer can be the same as the source buffer. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
Planar16F pixels are 16-bit floating-point numbers, conforming to the OpenEXR standard. Denormals, NaNs. and +/– Infinity are supported. In conformance with IEEE-754, all signaling NaNs are quieted during the conversion (OpenEXR-1.2.1 does not do this.)
Conversion.hConverts a PlanarF image to a Planar8 image, clipping values to the provided minimum and maximum values.
vImage_Error vImageConvert_PlanarFtoPlanar8 ( const vImage_Buffer *src, const vImage_Buffer *dest, Pixel_F maxFloat, Pixel_F minFloat, vImage_Flags flags );
A pointer to a vImage buffer structure that contains the source image whose data you want to convert.
A pointer to a vImage buffer data structure. You are responsible for filling out the height, width, and rowBytes fields of this structure, and for allocating a data buffer of the appropriate size. The destination data buffer can be the same as the src data buffer. On return, the data buffer pointed to by this structure contains the destination image converted to Planar8 format. When you no longer need the data buffer, you must deallocate the memory.
A maximum pixel value. The function clips larger values to this value in the destination image.
A minimum pixel value. The function clips smaller values to this value in the destination image.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The minimum and maximum value determine the mapping of intensity values to the destination image. The mapping is:
if oldPixel < minFloat |
newPixel = 0 |
if minfloat <= oldPixel <= maxFloat |
newPixel = (oldPixel - minFloat) * 255.0f / (maxFloat - minFloat) |
if oldPixel > maxFloat |
newPixel = 255 |
The source and destination buffers must have the same height and width.
Conversion.hCombines three PlanarF images into one RGBFFF image.
vImage_Error vImageConvert_PlanarFtoRGBFFF ( const vImage_Buffer *planarRed, const vImage_Buffer *planarGreen, const vImage_Buffer *planarBlue, const vImage_Buffer *rgbDest, vImage_Flags flags );
A pointer to vImage buffer structure that contains the PlanarF image to use as the red channel of the destination image.
A pointer to vImage buffer structure that contains the PlanarF image to use as the green channel of the destination image.
A pointer to vImage buffer structure that contains the PlanarF image to use as the blue channel of the destination image.
A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image in RGBFFF format. When you no longer need the data buffer, you must deallocate the memory.
The options to use when performing this operation. Set the kvImageDoNotTile flag if you plan to perform your own tiling or use multithreading.
kvImageNoError, otherwise one of the error codes described in vImage Data Types and Constants Reference.
The source and destination buffers must have the same height and width.
Conversion.hCombines a collection of planar source images into a single interleaved destination image, with one 8-bit channel for each