Class

CIBlendKernel

A GPU-based image processing routine that is optimized for blending two images.

Declaration

@interface CIBlendKernel : CIColorKernel

Overview

The blend kernel function has the following characteristics:

  • It has two arguments of type __sample (Core Image Kernel Language) or sample_t (Metal Shading Language), representing the foreground and background images.

  • Its return type is vec4 (Core Image Kernel Language) or float4 (Metal Shading Language); that is, it returns a pixel color for the output image.

A blend kernel routine receives as input single-pixel colors (one sampled from each input image) and computes a final pixel color (output using the return keyword). For example, the Metal Shading Language source below implements a filter that returns the average of its two input images.

#include <CoreImage/CoreImage.h>
 
float4 averageBlend(sample_t foreground, sample_t background) {
    return (foreground + background) / 2.0;
}

Generally, the extent of the output image is the union of the extents of the foreground and background images.

Topics

Creating a Kernel

+ kernelWithString:

Creates a custom blend kernel from a program string.

Deprecated

Applying a Kernel to Filter an Image

- applyWithForeground:background:

Creates a new image using the blend kernel and specified foreground and background images.

Builtin Blend Kernels

clear

A blend kernel that returns a clear color.

color

A blend kernel that uses the luminance values of the background with the hue and saturation values of the foreground image.

colorBurn

A blend kernel that darkens the background image samples to reflect the foreground image samples.

colorDodge

A blend kernel that brightens the background image samples to reflect the foreground image samples.

componentAdd

A blend kernel that adds color components to achieve a brightening effect.

componentMax

A blend kernel that creates an image using the maximum values of two input images.

componentMin

A blend kernel that creates an image using the minimum values of two input images.

componentMultiply

A blend kernel that multiplies the color components of its input images.

darken

A blend kernel that creates an image using the darker values of two input images.

darkerColor

A blend kernel that creates an image using the darker color of two input images.

destination

A blend kernel that returns the background input image.

destinationAtop

A blend kernel that places the background over the foreground and crops based on the visibility of the foreground.

destinationIn

A blend kernel that places the background over the foreground and crops based on the visibility of both.

destinationOut

A blend kernel that uses the background image to define what to take out of the foreground image.

destinationOver

A blend kernel that places the background image over the input foreground image.

difference

A blend kernel that creates an image using the difference between the background and foreground images.

divide

A blend kernel that divides the background image sample color with the foreground image sample color.

exclusion

A blend kernel that produces an effect similar to difference blending but with lower contrast.

exclusiveOr

A blend kernel that returns either the foreground or background image if the other contains a clear color.

hardLight

A blend kernel that either multiplies or screens colors, depending on the source image sample color.

hardMix

A blend kernel that adds two images together, setting each color channel value to either 0 or 1.

hue

A blend kernel that uses the luminance and saturation values of the background image with the hue of the foreground image.

lighten

A blend kernel that creates an image using the lighter values of two input images.

lighterColor

A blend kernel that creates an image using the lighter color of two input images.

linearBurn

A blend kernel that darkens the background image samples to reflect the foreground image samples while also increasing contrast.

linearDodge

A blend kernel that lightens the background image samples to reflect the foreground image samples while also increasing contrast.

linearLight

A blend kernel that burns or dodges colors by changing brightness, depending on the blend color.

luminosity

A blend kernel that uses the hue and saturation of the background image with the luminance of the foreground image.

multiply

A blend kernel that multiplies the background image sample color with the foreground image sample color.

overlay

A blend kernel that either multiplies or screens the foreground image samples with the background image samples, depending on the background color.

pinLight

A blend kernel that conditionally replaces background image samples with source image samples depending on the brightness of the source image samples.

saturation

A blend kernel that uses the luminance and hue values of the background image with the saturation of the foreground image.

screen

A blend kernel that multiplies the inverse of the foreground image samples with the inverse of the background image samples.

softLight

A blend kernel that either darkens or lightens colors, depending on the foreground image sample color.

source

A blend kernel that returns the foreground input image.

sourceAtop

A blend kernel that places the foreground over the background and crops based on the visibility of the background.

sourceIn

A blend kernel that places the foreground over the background and crops based on the visibility of both.

sourceOut

A blend kernel that uses the foreground image to define what to take out of the background image.

sourceOver

A blend kernel that places the foreground image over the input background image.

subtract

A blend kernel that subtracts the background image sample color from the foreground image sample color.

vividLight

A blend kernel that burns or dodges colors by changing contrast, depending on the blend color.

Relationships

Inherits From

See Also

Custom Filters

Writing Custom Kernels

Write your own custom kernels in either the Core Image Kernel Language or the Metal Shading Language.

CIKernel

A GPU-based image processing routine used to create custom Core Image filters.

CIColorKernel

A GPU-based image processing routine that processes only the color information in images, used to create custom Core Image filters.

CIWarpKernel

A GPU-based image processing routine that processes only the geometry information in an image, used to create custom Core Image filters.

CISampler

An object that retrieves pixel samples for processing by a filter kernel.