Function

vImagePremultipliedAlphaBlendDarken_RGBA8888(_:_:_:_:)

Performs alpha compositing of two RGBA8888 images using the darken blend mode to produce a premultiplied result.

Declaration

func vImagePremultipliedAlphaBlendDarken_RGBA8888(_ srcTop: UnsafePointer<vImage_Buffer>, _ srcBottom: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ flags: vImage_Flags) -> vImage_Error

Parameters

srcTop

A pointer to a vImage buffer structure that contains data for the top source image.

srcBottom

A pointer to a vImage buffer structure that contains data for the bottom source image.

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.

flags

The options to use when performing the compositing. If you plan to perform your own tiling or use multithreading, pass kvImageDoNotTile.

Return Value

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

Discussion

For each pixel:

// For color channels:
uint8_t destColor = MIN( topColor +    ((255 - srcTopAlpha) *  srcBotomColor + 127) / 255,
                         bottomColor + ((255 - srcBottomAlpha) * srcTopColor + 127) / 255);
 
// For the alpha channel:
uint8_t alpha =  srcTopAlpha + ((255 - srcTopAlpha) * srcBottomAlpha + 127)/255;

This function can work in place provided the following are true:

  • For each buffer, buf, that overlaps with dest, buf->data is equal to dest->data.

  • If an overlapping buffer has a different rowBytes from dest, kvImageDoNotTile is also passed in the flags

See Also

Performing Premultiplied Alpha Compositing With Blend Modes

func vImagePremultipliedAlphaBlendMultiply_RGBA8888(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, vImage_Flags) -> vImage_Error

Performs alpha compositing of two RGBA8888 images using the multiply blend mode to produce a premultiplied result.

func vImagePremultipliedAlphaBlendScreen_RGBA8888(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, vImage_Flags) -> vImage_Error

Performs alpha compositing of two RGBA8888 images using the screen blend mode to produce a premultiplied result.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software