Skia
2D Graphics Library
SkImageFilters Class Reference

#include <SkImageFilters.h>

Classes

struct  CropRect
 

Public Types

enum class  Dither : bool { kNo = false , kYes = true }
 

Static Public Member Functions

static sk_sp< SkImageFilterArithmetic (SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, bool enforcePMColor, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground, const CropRect &cropRect={})
 Create a filter that implements a custom blend mode. More...
 
static sk_sp< SkImageFilterBlend (SkBlendMode mode, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
 This filter takes an SkBlendMode and uses it to composite the two filters together. More...
 
static sk_sp< SkImageFilterBlend (sk_sp< SkBlender > blender, sk_sp< SkImageFilter > background, sk_sp< SkImageFilter > foreground=nullptr, const CropRect &cropRect={})
 This filter takes an SkBlendMode and uses it to composite the two filters together. More...
 
static sk_sp< SkImageFilterBlur (SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that blurs its input by the separate X and Y sigmas. More...
 
static sk_sp< SkImageFilterBlur (SkScalar sigmaX, SkScalar sigmaY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterColorFilter (sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that applies the color filter to the input filter results. More...
 
static sk_sp< SkImageFilterCompose (sk_sp< SkImageFilter > outer, sk_sp< SkImageFilter > inner)
 Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are treated as the source bitmap passed to 'outer', i.e. More...
 
static sk_sp< SkImageFilterCrop (const SkRect &rect, SkTileMode tileMode, sk_sp< SkImageFilter > input)
 Create a filter that applies a crop to the result of the 'input' filter. More...
 
static sk_sp< SkImageFilterCrop (const SkRect &rect, sk_sp< SkImageFilter > input)
 
static sk_sp< SkImageFilterDisplacementMap (SkColorChannel xChannelSelector, SkColorChannel yChannelSelector, SkScalar scale, sk_sp< SkImageFilter > displacement, sk_sp< SkImageFilter > color, const CropRect &cropRect={})
 Create a filter that moves each pixel in its color input based on an (x,y) vector encoded in its displacement input filter. More...
 
static sk_sp< SkImageFilterDropShadow (SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that draws a drop shadow under the input content. More...
 
static sk_sp< SkImageFilterDropShadowOnly (SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor color, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except that the resulting image does not include the input content. More...
 
static sk_sp< SkImageFilterEmpty ()
 Create a filter that always produces transparent black. More...
 
static sk_sp< SkImageFilterImage (sk_sp< SkImage > image, const SkRect &srcRect, const SkRect &dstRect, const SkSamplingOptions &sampling)
 Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given filter quality. More...
 
static sk_sp< SkImageFilterImage (sk_sp< SkImage > image, const SkSamplingOptions &sampling)
 Create a filter that draws the image using the given sampling. More...
 
static sk_sp< SkImageFilterMagnifier (const SkRect &lensBounds, SkScalar zoomAmount, SkScalar inset, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that fills 'lensBounds' with a magnification of the input. More...
 
static sk_sp< SkImageFilterMatrixConvolution (const SkISize &kernelSize, const SkScalar kernel[], SkScalar gain, SkScalar bias, const SkIPoint &kernelOffset, SkTileMode tileMode, bool convolveAlpha, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that applies an NxM image processing kernel to the input image. More...
 
static sk_sp< SkImageFilterMatrixTransform (const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
 Create a filter that transforms the input image by 'matrix'. More...
 
static sk_sp< SkImageFilterMerge (sk_sp< SkImageFilter > *const filters, int count, const CropRect &cropRect={})
 Create a filter that merges the 'count' filters together by drawing their results in order with src-over blending. More...
 
static sk_sp< SkImageFilterMerge (sk_sp< SkImageFilter > first, sk_sp< SkImageFilter > second, const CropRect &cropRect={})
 Create a filter that merges the results of the two filters together with src-over blending. More...
 
static sk_sp< SkImageFilterOffset (SkScalar dx, SkScalar dy, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that offsets the input filter by the given vector. More...
 
static sk_sp< SkImageFilterPicture (sk_sp< SkPicture > pic, const SkRect &targetRect)
 Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and the picture's internal cull rect. More...
 
static sk_sp< SkImageFilterPicture (sk_sp< SkPicture > pic)
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, std::string_view childShaderName, sk_sp< SkImageFilter > input)
 Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder. More...
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, SkScalar sampleRadius, std::string_view childShaderName, sk_sp< SkImageFilter > input)
 As above, but 'sampleRadius' defines the sampling radius of 'childShaderName' relative to the runtime shader produced by 'builder'. More...
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
 Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder. More...
 
static sk_sp< SkImageFilterRuntimeShader (const SkRuntimeShaderBuilder &builder, SkScalar maxSampleRadius, std::string_view childShaderNames[], const sk_sp< SkImageFilter > inputs[], int inputCount)
 As above, but 'maxSampleRadius' defines the sampling limit on coordinates provided to all child shaders. More...
 
static sk_sp< SkImageFilterShader (sk_sp< SkShader > shader, const CropRect &cropRect={})
 Create a filter that fills the output with the per-pixel evaluation of the SkShader. More...
 
static sk_sp< SkImageFilterShader (sk_sp< SkShader > shader, Dither dither, const CropRect &cropRect={})
 
static sk_sp< SkImageFilterTile (const SkRect &src, const SkRect &dst, sk_sp< SkImageFilter > input)
 Create a tile image filter. More...
 
static sk_sp< SkImageFilterDilate (SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that dilates each input pixel's channel values to the max value within the given radii along the x and y axes. More...
 
static sk_sp< SkImageFilterErode (SkScalar radiusX, SkScalar radiusY, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that erodes each input pixel's channel values to the minimum channel value within the given radii along the x and y axes. More...
 
static sk_sp< SkImageFilterDistantLitDiffuse (const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the diffuse illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 
static sk_sp< SkImageFilterPointLitDiffuse (const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the diffuse illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 
static sk_sp< SkImageFilterSpotLitDiffuse (const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the diffuse illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 
static sk_sp< SkImageFilterDistantLitSpecular (const SkPoint3 &direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the specular illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 
static sk_sp< SkImageFilterPointLitSpecular (const SkPoint3 &location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the specular illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 
static sk_sp< SkImageFilterSpotLitSpecular (const SkPoint3 &location, const SkPoint3 &target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
 Create a filter that calculates the specular illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors). More...
 

Member Enumeration Documentation

◆ Dither

enum SkImageFilters::Dither : bool
strong
Enumerator
kNo 
kYes 

Member Function Documentation

◆ Arithmetic()

static sk_sp<SkImageFilter> SkImageFilters::Arithmetic ( SkScalar  k1,
SkScalar  k2,
SkScalar  k3,
SkScalar  k4,
bool  enforcePMColor,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground,
const CropRect cropRect = {} 
)
static

Create a filter that implements a custom blend mode.

Each output pixel is the result of combining the corresponding background and foreground pixels using the 4 coefficients: k1 * foreground * background + k2 * foreground + k3 * background + k4

Parameters
k1,k2,k3,k4The four coefficients used to combine the foreground and background.
enforcePMColorIf true, the RGB channels will be clamped to the calculated alpha.
backgroundThe background content, using the source bitmap when this is null.
foregroundThe foreground content, using the source bitmap when this is null.
cropRectOptional rectangle that crops the inputs and output.

◆ Blend() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Blend ( sk_sp< SkBlender blender,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground = nullptr,
const CropRect cropRect = {} 
)
static

This filter takes an SkBlendMode and uses it to composite the two filters together.

Parameters
blenderThe blender that defines the compositing operation
backgroundThe Dst pixels used in blending, if null the source bitmap is used.
foregroundThe Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output.

◆ Blend() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Blend ( SkBlendMode  mode,
sk_sp< SkImageFilter background,
sk_sp< SkImageFilter foreground = nullptr,
const CropRect cropRect = {} 
)
static

This filter takes an SkBlendMode and uses it to composite the two filters together.

Parameters
modeThe blend mode that defines the compositing operation
backgroundThe Dst pixels used in blending, if null the source bitmap is used.
foregroundThe Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output.

◆ Blur() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Blur ( SkScalar  sigmaX,
SkScalar  sigmaY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
inlinestatic

◆ Blur() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Blur ( SkScalar  sigmaX,
SkScalar  sigmaY,
SkTileMode  tileMode,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that blurs its input by the separate X and Y sigmas.

The provided tile mode is used when the blur kernel goes outside the input image.

Parameters
sigmaXThe Gaussian sigma value for blurring along the X axis.
sigmaYThe Gaussian sigma value for blurring along the Y axis.
tileModeThe tile mode applied at edges . TODO (michaelludwig) - kMirror is not supported yet
inputThe input filter that is blurred, uses source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ ColorFilter()

static sk_sp<SkImageFilter> SkImageFilters::ColorFilter ( sk_sp< SkColorFilter cf,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that applies the color filter to the input filter results.

Parameters
cfThe color filter that transforms the input image.
inputThe input filter, or uses the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ Compose()

static sk_sp<SkImageFilter> SkImageFilters::Compose ( sk_sp< SkImageFilter outer,
sk_sp< SkImageFilter inner 
)
static

Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are treated as the source bitmap passed to 'outer', i.e.

result = outer(inner(source)).

Parameters
outerThe outer filter that evaluates the results of inner.
innerThe inner filter that produces the input to outer.

◆ Crop() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Crop ( const SkRect rect,
sk_sp< SkImageFilter input 
)
inlinestatic

◆ Crop() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Crop ( const SkRect rect,
SkTileMode  tileMode,
sk_sp< SkImageFilter input 
)
static

Create a filter that applies a crop to the result of the 'input' filter.

Pixels within the crop rectangle are unmodified from what 'input' produced. Pixels outside of crop match the provided SkTileMode (defaulting to kDecal).

NOTE: The optional CropRect argument for many of the factories is equivalent to creating the filter without a CropRect and then wrapping it in ::Crop(rect, kDecal). Explicitly adding Crop filters lets you control their tiling and use different geometry for the input and the output of another filter.

Parameters
rectThe cropping geometry
tileModeThe tilemode applied to pixels outside of 'crop'
inputThe input filter that is cropped, uses source image if this is null

◆ Dilate()

static sk_sp<SkImageFilter> SkImageFilters::Dilate ( SkScalar  radiusX,
SkScalar  radiusY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that dilates each input pixel's channel values to the max value within the given radii along the x and y axes.

Parameters
radiusXThe distance to dilate along the x axis to either side of each pixel.
radiusYThe distance to dilate along the y axis to either side of each pixel.
inputThe image filter that is dilated, using source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ DisplacementMap()

static sk_sp<SkImageFilter> SkImageFilters::DisplacementMap ( SkColorChannel  xChannelSelector,
SkColorChannel  yChannelSelector,
SkScalar  scale,
sk_sp< SkImageFilter displacement,
sk_sp< SkImageFilter color,
const CropRect cropRect = {} 
)
static

Create a filter that moves each pixel in its color input based on an (x,y) vector encoded in its displacement input filter.

Two color components of the displacement image are mapped into a vector as scale * (color[xChannel], color[yChannel]), where the channel selectors are one of R, G, B, or A.

Parameters
xChannelSelectorRGBA channel that encodes the x displacement per pixel.
yChannelSelectorRGBA channel that encodes the y displacement per pixel.
scaleScale applied to displacement extracted from image.
displacementThe filter defining the displacement image, or null to use source.
colorThe filter providing the color pixels to be displaced. If null, it will use the source.
cropRectOptional rectangle that crops the color input and output.

◆ DistantLitDiffuse()

static sk_sp<SkImageFilter> SkImageFilters::DistantLitDiffuse ( const SkPoint3 direction,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
directionThe direction to the distance light.
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ DistantLitSpecular()

static sk_sp<SkImageFilter> SkImageFilters::DistantLitSpecular ( const SkPoint3 direction,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a distant light source, interpreting the alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
directionThe direction to the distance light.
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ DropShadow()

static sk_sp<SkImageFilter> SkImageFilters::DropShadow ( SkScalar  dx,
SkScalar  dy,
SkScalar  sigmaX,
SkScalar  sigmaY,
SkColor  color,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that draws a drop shadow under the input content.

This filter produces an image that includes the inputs' content.

Parameters
dxThe X offset of the shadow.
dyThe Y offset of the shadow.
sigmaXThe blur radius for the shadow, along the X axis.
sigmaYThe blur radius for the shadow, along the Y axis.
colorThe color of the drop shadow.
inputThe input filter, or will use the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ DropShadowOnly()

static sk_sp<SkImageFilter> SkImageFilters::DropShadowOnly ( SkScalar  dx,
SkScalar  dy,
SkScalar  sigmaX,
SkScalar  sigmaY,
SkColor  color,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except that the resulting image does not include the input content.

This allows the shadow and input to be composed by a filter DAG in a more flexible manner.

Parameters
dxThe X offset of the shadow.
dyThe Y offset of the shadow.
sigmaXThe blur radius for the shadow, along the X axis.
sigmaYThe blur radius for the shadow, along the Y axis.
colorThe color of the drop shadow.
inputThe input filter, or will use the source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ Empty()

static sk_sp<SkImageFilter> SkImageFilters::Empty ( )
static

Create a filter that always produces transparent black.

◆ Erode()

static sk_sp<SkImageFilter> SkImageFilters::Erode ( SkScalar  radiusX,
SkScalar  radiusY,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that erodes each input pixel's channel values to the minimum channel value within the given radii along the x and y axes.

Parameters
radiusXThe distance to erode along the x axis to either side of each pixel.
radiusYThe distance to erode along the y axis to either side of each pixel.
inputThe image filter that is eroded, using source bitmap if this is null.
cropRectOptional rectangle that crops the input and output.

◆ Image() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Image ( sk_sp< SkImage image,
const SkRect srcRect,
const SkRect dstRect,
const SkSamplingOptions sampling 
)
static

Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given filter quality.

Similar to SkCanvas::drawImageRect. The returned image filter evaluates to transparent black if 'image' is null.

Parameters
imageThe image that is output by the filter, subset by 'srcRect'.
srcRectThe source pixels sampled into 'dstRect'
dstRectThe local rectangle to draw the image into.
samplingThe sampling to use when drawing the image.

◆ Image() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Image ( sk_sp< SkImage image,
const SkSamplingOptions sampling 
)
inlinestatic

Create a filter that draws the image using the given sampling.

Similar to SkCanvas::drawImage. The returned image filter evaluates to transparent black if 'image' is null.

Parameters
imageThe image that is output by the filter.
samplingThe sampling to use when drawing the image.

◆ Magnifier()

static sk_sp<SkImageFilter> SkImageFilters::Magnifier ( const SkRect lensBounds,
SkScalar  zoomAmount,
SkScalar  inset,
const SkSamplingOptions sampling,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that fills 'lensBounds' with a magnification of the input.

Parameters
lensBoundsThe outer bounds of the magnifier effect
zoomAmountThe amount of magnification applied to the input image
insetThe size or width of the fish-eye distortion around the magnified content
samplingThe SkSamplingOptions applied to the input image when magnified
inputThe input filter that is magnified; if null the source bitmap is used
cropRectOptional rectangle that crops the input and output.

◆ MatrixConvolution()

static sk_sp<SkImageFilter> SkImageFilters::MatrixConvolution ( const SkISize kernelSize,
const SkScalar  kernel[],
SkScalar  gain,
SkScalar  bias,
const SkIPoint &  kernelOffset,
SkTileMode  tileMode,
bool  convolveAlpha,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that applies an NxM image processing kernel to the input image.

This can be used to produce effects such as sharpening, blurring, edge detection, etc.

Parameters
kernelSizeThe kernel size in pixels, in each dimension (N by M).
kernelThe image processing kernel. Must contain N * M elements, in row order.
gainA scale factor applied to each pixel after convolution. This can be used to normalize the kernel, if it does not already sum to 1.
biasA bias factor added to each pixel after convolution.
kernelOffsetAn offset applied to each pixel coordinate before convolution. This can be used to center the kernel over the image (e.g., a 3x3 kernel should have an offset of {1, 1}).
tileModeHow accesses outside the image are treated. TODO (michaelludwig) - kMirror is not supported yet
convolveAlphaIf true, all channels are convolved. If false, only the RGB channels are convolved, and alpha is copied from the source image.
inputThe input image filter, if null the source bitmap is used instead.
cropRectOptional rectangle to which the output processing will be limited.

◆ MatrixTransform()

static sk_sp<SkImageFilter> SkImageFilters::MatrixTransform ( const SkMatrix matrix,
const SkSamplingOptions sampling,
sk_sp< SkImageFilter input 
)
static

Create a filter that transforms the input image by 'matrix'.

This matrix transforms the local space, which means it effectively happens prior to any transformation coming from the SkCanvas initiating the filtering.

Parameters
matrixThe matrix to apply to the original content.
samplingHow the image will be sampled when it is transformed
inputThe image filter to transform, or null to use the source image.

◆ Merge() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Merge ( sk_sp< SkImageFilter > *const  filters,
int  count,
const CropRect cropRect = {} 
)
static

Create a filter that merges the 'count' filters together by drawing their results in order with src-over blending.

Parameters
filtersThe input filter array to merge, which must have 'count' elements. Any null filter pointers will use the source bitmap instead.
countThe number of input filters to be merged.
cropRectOptional rectangle that crops all input filters and the output.

◆ Merge() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Merge ( sk_sp< SkImageFilter first,
sk_sp< SkImageFilter second,
const CropRect cropRect = {} 
)
inlinestatic

Create a filter that merges the results of the two filters together with src-over blending.

Parameters
firstThe first input filter, or the source bitmap if this is null.
secondThe second input filter, or the source bitmap if this null.
cropRectOptional rectangle that crops the inputs and output.

◆ Offset()

static sk_sp<SkImageFilter> SkImageFilters::Offset ( SkScalar  dx,
SkScalar  dy,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that offsets the input filter by the given vector.

Parameters
dxThe x offset in local space that the image is shifted.
dyThe y offset in local space that the image is shifted.
inputThe input that will be moved, if null the source bitmap is used instead.
cropRectOptional rectangle to crop the input and output.

◆ Picture() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Picture ( sk_sp< SkPicture pic)
inlinestatic

◆ Picture() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Picture ( sk_sp< SkPicture pic,
const SkRect targetRect 
)
static

Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and the picture's internal cull rect.

If 'pic' is null, the returned image filter produces transparent black.

Parameters
picThe picture that is drawn for the filter output.
targetRectThe drawing region for the picture.

◆ PointLitDiffuse()

static sk_sp<SkImageFilter> SkImageFilters::PointLitDiffuse ( const SkPoint3 location,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
locationThe location of the point light.
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ PointLitSpecular()

static sk_sp<SkImageFilter> SkImageFilters::PointLitSpecular ( const SkPoint3 location,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a point light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

Parameters
locationThe location of the point light.
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ RuntimeShader() [1/4]

static sk_sp<SkImageFilter> SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
SkScalar  maxSampleRadius,
std::string_view  childShaderNames[],
const sk_sp< SkImageFilter inputs[],
int  inputCount 
)
static

As above, but 'maxSampleRadius' defines the sampling limit on coordinates provided to all child shaders.

Like the single-child variant with a sample radius, this can be used to inform Skia that the runtime shader guarantees that all dynamic children (defined in childShaderNames) will be evaluated with coordinates at most 'maxSampleRadius' away from the coordinate provided to the runtime shader itself.

This requires a GPU backend or SkSL to be compiled in.

◆ RuntimeShader() [2/4]

static sk_sp<SkImageFilter> SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
SkScalar  sampleRadius,
std::string_view  childShaderName,
sk_sp< SkImageFilter input 
)
static

As above, but 'sampleRadius' defines the sampling radius of 'childShaderName' relative to the runtime shader produced by 'builder'.

If greater than 0, the coordinate passed to childShader.eval() will be up to 'sampleRadius' away (maximum absolute offset in 'x' or 'y') from the coordinate passed into the runtime shader.

This allows Skia to provide sampleable values for the image filter without worrying about boundary conditions.

This requires a GPU backend or SkSL to be compiled in.

◆ RuntimeShader() [3/4]

static sk_sp<SkImageFilter> SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
std::string_view  childShaderName,
sk_sp< SkImageFilter input 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder.

The shader is defined in the image filter's local coordinate system, so it will automatically be affected by SkCanvas' transform.

This variant assumes that the runtime shader samples 'childShaderName' with the same input coordinate passed to to shader.

This requires a GPU backend or SkSL to be compiled in.

Parameters
builderThe builder used to produce the runtime shader, that will in turn fill the result image
childShaderNameThe name of the child shader defined in the builder that will be bound to the input param (or the source image if the input param is null). If empty, the builder can have exactly one child shader, which automatically binds the input param.
inputThe image filter that will be provided as input to the runtime shader. If null the implicit source image is used instead

◆ RuntimeShader() [4/4]

static sk_sp<SkImageFilter> SkImageFilters::RuntimeShader ( const SkRuntimeShaderBuilder builder,
std::string_view  childShaderNames[],
const sk_sp< SkImageFilter inputs[],
int  inputCount 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader produced by the SkRuntimeShaderBuilder.

The shader is defined in the image filter's local coordinate system, so it will automatically be affected by SkCanvas' transform.

This requires a GPU backend or SkSL to be compiled in.

Parameters
builderThe builder used to produce the runtime shader, that will in turn fill the result image
childShaderNamesThe names of the child shaders defined in the builder that will be bound to the input params (or the source image if the input param is null). If any name is null, or appears more than once, factory fails and returns nullptr.
inputsThe image filters that will be provided as input to the runtime shader. If any are null, the implicit source image is used instead.
inputCountHow many entries are present in 'childShaderNames' and 'inputs'.

◆ Shader() [1/2]

static sk_sp<SkImageFilter> SkImageFilters::Shader ( sk_sp< SkShader shader,
const CropRect cropRect = {} 
)
inlinestatic

Create a filter that fills the output with the per-pixel evaluation of the SkShader.

The shader is defined in the image filter's local coordinate system, so will automatically be affected by SkCanvas' transform.

Like Image() and Picture(), this is a leaf filter that can be used to introduce inputs to a complex filter graph, but should generally be combined with a filter that as at least one null input to use the implicit source image.

Returns an image filter that evaluates to transparent black if 'shader' is null.

Parameters
shaderThe shader that fills the result image

◆ Shader() [2/2]

static sk_sp<SkImageFilter> SkImageFilters::Shader ( sk_sp< SkShader shader,
Dither  dither,
const CropRect cropRect = {} 
)
static

◆ SpotLitDiffuse()

static sk_sp<SkImageFilter> SkImageFilters::SpotLitDiffuse ( const SkPoint3 location,
const SkPoint3 target,
SkScalar  falloffExponent,
SkScalar  cutoffAngle,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  kd,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the diffuse illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

The spot light is restricted to be within 'cutoffAngle' of the vector between the location and target.

Parameters
locationThe location of the spot light.
targetThe location that the spot light is point towards
falloffExponentExponential falloff parameter for illumination outside of cutoffAngle
cutoffAngleMaximum angle from lighting direction that receives full light
lightColorThe color of the diffuse light source.
surfaceScaleScale factor to transform from alpha values to physical height.
kdDiffuse reflectance coefficient.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ SpotLitSpecular()

static sk_sp<SkImageFilter> SkImageFilters::SpotLitSpecular ( const SkPoint3 location,
const SkPoint3 target,
SkScalar  falloffExponent,
SkScalar  cutoffAngle,
SkColor  lightColor,
SkScalar  surfaceScale,
SkScalar  ks,
SkScalar  shininess,
sk_sp< SkImageFilter input,
const CropRect cropRect = {} 
)
static

Create a filter that calculates the specular illumination from a spot light source, using alpha channel of the input as the height profile of the surface (to approximate normal vectors).

The spot light is restricted to be within 'cutoffAngle' of the vector between the location and target.

Parameters
locationThe location of the spot light.
targetThe location that the spot light is point towards
falloffExponentExponential falloff parameter for illumination outside of cutoffAngle
cutoffAngleMaximum angle from lighting direction that receives full light
lightColorThe color of the specular light source.
surfaceScaleScale factor to transform from alpha values to physical height.
ksSpecular reflectance coefficient.
shininessThe specular exponent determining how shiny the surface is.
inputThe input filter that defines surface normals (as alpha), or uses the source bitmap when null.
cropRectOptional rectangle that crops the input and output.

◆ Tile()

static sk_sp<SkImageFilter> SkImageFilters::Tile ( const SkRect src,
const SkRect dst,
sk_sp< SkImageFilter input 
)
static

Create a tile image filter.

Parameters
srcDefines the pixels to tile
dstDefines the pixel region that the tiles will be drawn to
inputThe input that will be tiled, if null the source bitmap is used instead.

The documentation for this class was generated from the following file: