<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIBlendKernel",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIBlendKernel"
  },
  "title" : "CIBlendKernel"
}
-->

# CIBlendKernel

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

```
class CIBlendKernel
```

## 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.

```c
#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

[`init(source:)`](/documentation/CoreImage/CIBlendKernel/init(source:))

Creates a custom blend kernel from a program string.

### Applying a Kernel to Filter an Image

[`apply(foreground:background:)`](/documentation/CoreImage/CIBlendKernel/apply(foreground:background:))

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

### Builtin Blend Kernels

[`clear`](/documentation/CoreImage/CIBlendKernel/clear)

A blend kernel that returns a clear color.

[`color`](/documentation/CoreImage/CIBlendKernel/color)

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

[`colorBurn`](/documentation/CoreImage/CIBlendKernel/colorBurn)

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

[`colorDodge`](/documentation/CoreImage/CIBlendKernel/colorDodge)

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

[`componentAdd`](/documentation/CoreImage/CIBlendKernel/componentAdd)

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

[`componentMax`](/documentation/CoreImage/CIBlendKernel/componentMax)

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

[`componentMin`](/documentation/CoreImage/CIBlendKernel/componentMin)

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

[`componentMultiply`](/documentation/CoreImage/CIBlendKernel/componentMultiply)

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

[`darken`](/documentation/CoreImage/CIBlendKernel/darken)

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

[`darkerColor`](/documentation/CoreImage/CIBlendKernel/darkerColor)

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

[`destination`](/documentation/CoreImage/CIBlendKernel/destination)

A blend kernel that returns the background input image.

[`destinationAtop`](/documentation/CoreImage/CIBlendKernel/destinationAtop)

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

[`destinationIn`](/documentation/CoreImage/CIBlendKernel/destinationIn)

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

[`destinationOut`](/documentation/CoreImage/CIBlendKernel/destinationOut)

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

[`destinationOver`](/documentation/CoreImage/CIBlendKernel/destinationOver)

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

[`difference`](/documentation/CoreImage/CIBlendKernel/difference)

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

[`divide`](/documentation/CoreImage/CIBlendKernel/divide)

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

[`exclusion`](/documentation/CoreImage/CIBlendKernel/exclusion)

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

[`exclusiveOr`](/documentation/CoreImage/CIBlendKernel/exclusiveOr)

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

[`hardLight`](/documentation/CoreImage/CIBlendKernel/hardLight)

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

[`hardMix`](/documentation/CoreImage/CIBlendKernel/hardMix)

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

[`hue`](/documentation/CoreImage/CIBlendKernel/hue)

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

[`lighten`](/documentation/CoreImage/CIBlendKernel/lighten)

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

[`lighterColor`](/documentation/CoreImage/CIBlendKernel/lighterColor)

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

[`linearBurn`](/documentation/CoreImage/CIBlendKernel/linearBurn)

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

[`linearDodge`](/documentation/CoreImage/CIBlendKernel/linearDodge)

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

[`linearLight`](/documentation/CoreImage/CIBlendKernel/linearLight)

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

[`luminosity`](/documentation/CoreImage/CIBlendKernel/luminosity)

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

[`multiply`](/documentation/CoreImage/CIBlendKernel/multiply)

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

[`overlay`](/documentation/CoreImage/CIBlendKernel/overlay)

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

[`pinLight`](/documentation/CoreImage/CIBlendKernel/pinLight)

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

[`saturation`](/documentation/CoreImage/CIBlendKernel/saturation)

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

[`screen`](/documentation/CoreImage/CIBlendKernel/screen)

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

[`softLight`](/documentation/CoreImage/CIBlendKernel/softLight)

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

[`source`](/documentation/CoreImage/CIBlendKernel/source)

A blend kernel that returns the foreground input image.

[`sourceAtop`](/documentation/CoreImage/CIBlendKernel/sourceAtop)

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

[`sourceIn`](/documentation/CoreImage/CIBlendKernel/sourceIn)

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

[`sourceOut`](/documentation/CoreImage/CIBlendKernel/sourceOut)

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

[`sourceOver`](/documentation/CoreImage/CIBlendKernel/sourceOver)

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

[`subtract`](/documentation/CoreImage/CIBlendKernel/subtract)

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

[`vividLight`](/documentation/CoreImage/CIBlendKernel/vividLight)

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

### Instance Methods

[`apply(foreground:background:colorSpace:)`](/documentation/CoreImage/CIBlendKernel/apply(foreground:background:colorSpace:))



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)