![]() |
Skia
2D Graphics Library
|
#include <SkImageFilters.h>
Classes | |
struct | CropRect |
Public Types | |
enum class | Dither : bool { kNo = false , kYes = true } |
Static Public Member Functions | |
static sk_sp< SkImageFilter > | AlphaThreshold (const SkRegion ®ion, SkScalar innerMin, SkScalar outerMax, sk_sp< SkImageFilter > input, const CropRect &cropRect={}) |
Create a filter that updates the alpha of the image based on 'region'. More... | |
static sk_sp< SkImageFilter > | Arithmetic (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< SkImageFilter > | Blend (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< SkImageFilter > | Blend (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< SkImageFilter > | Blur (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< SkImageFilter > | Blur (SkScalar sigmaX, SkScalar sigmaY, sk_sp< SkImageFilter > input, const CropRect &cropRect={}) |
static sk_sp< SkImageFilter > | ColorFilter (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< SkImageFilter > | Compose (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< SkImageFilter > | DisplacementMap (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< SkImageFilter > | DropShadow (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< SkImageFilter > | DropShadowOnly (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< SkImageFilter > | Image (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< SkImageFilter > | Image (sk_sp< SkImage > image, const SkSamplingOptions &sampling) |
Create a filter that draws the image using the given sampling. More... | |
static sk_sp< SkImageFilter > | Magnifier (const SkRect &srcRect, SkScalar inset, sk_sp< SkImageFilter > input, const CropRect &cropRect={}) |
Create a filter that mimics a zoom/magnifying lens effect. More... | |
static sk_sp< SkImageFilter > | Magnifier (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< SkImageFilter > | 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={}) |
Create a filter that applies an NxM image processing kernel to the input image. More... | |
static sk_sp< SkImageFilter > | MatrixTransform (const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input) |
Create a filter that transforms the input image by 'matrix'. More... | |
static sk_sp< SkImageFilter > | Merge (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< SkImageFilter > | Merge (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< SkImageFilter > | Offset (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< SkImageFilter > | Picture (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< SkImageFilter > | Picture (sk_sp< SkPicture > pic) |
static sk_sp< SkImageFilter > | Shader (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< SkImageFilter > | Shader (sk_sp< SkShader > shader, Dither dither, const CropRect &cropRect={}) |
static sk_sp< SkImageFilter > | Tile (const SkRect &src, const SkRect &dst, sk_sp< SkImageFilter > input) |
Create a tile image filter. More... | |
static sk_sp< SkImageFilter > | Dilate (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< SkImageFilter > | Erode (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< SkImageFilter > | DistantLitDiffuse (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< SkImageFilter > | PointLitDiffuse (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< SkImageFilter > | SpotLitDiffuse (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< SkImageFilter > | DistantLitSpecular (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< SkImageFilter > | PointLitSpecular (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< SkImageFilter > | 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={}) |
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... | |
|
strong |
|
static |
Create a filter that updates the alpha of the image based on 'region'.
Pixels inside the region are made more opaque and pixels outside are made more transparent.
Specifically, if a pixel is inside the region, its alpha will be set to max(innerMin, pixel's alpha). If a pixel is outside the region, its alpha will be updated to min(outerMax, pixel's alpha).
region | The geometric region controlling the inner and outer alpha thresholds. |
innerMin | The minimum alpha value for pixels inside 'region'. |
outerMax | The maximum alpha value for pixels outside of 'region'. |
input | The input filter, or uses the source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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
k1,k2,k3,k4 | The four coefficients used to combine the foreground and background. |
enforcePMColor | If true, the RGB channels will be clamped to the calculated alpha. |
background | The background content, using the source bitmap when this is null. |
foreground | The foreground content, using the source bitmap when this is null. |
cropRect | Optional rectangle that crops the inputs and output. |
|
static |
This filter takes an SkBlendMode and uses it to composite the two filters together.
blender | The blender that defines the compositing operation |
background | The Dst pixels used in blending, if null the source bitmap is used. |
foreground | The Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output. |
|
static |
This filter takes an SkBlendMode and uses it to composite the two filters together.
mode | The blend mode that defines the compositing operation |
background | The Dst pixels used in blending, if null the source bitmap is used. |
foreground | The Src pixels used in blending, if null the source bitmap is used. @cropRect Optional rectangle to crop input and output. |
|
inlinestatic |
|
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.
sigmaX | The Gaussian sigma value for blurring along the X axis. |
sigmaY | The Gaussian sigma value for blurring along the Y axis. |
tileMode | The tile mode applied at edges . TODO (michaelludwig) - kMirror is not supported yet |
input | The input filter that is blurred, uses source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
static |
Create a filter that applies the color filter to the input filter results.
cf | The color filter that transforms the input image. |
input | The input filter, or uses the source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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)).
outer | The outer filter that evaluates the results of inner. |
inner | The inner filter that produces the input to outer. |
|
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.
radiusX | The distance to dilate along the x axis to either side of each pixel. |
radiusY | The distance to dilate along the y axis to either side of each pixel. |
input | The image filter that is dilated, using source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
xChannelSelector | RGBA channel that encodes the x displacement per pixel. |
yChannelSelector | RGBA channel that encodes the y displacement per pixel. |
scale | Scale applied to displacement extracted from image. |
displacement | The filter defining the displacement image, or null to use source. |
color | The filter providing the color pixels to be displaced. If null, it will use the source. |
cropRect | Optional rectangle that crops the color input and output. |
|
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).
direction | The direction to the distance light. |
lightColor | The color of the diffuse light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
kd | Diffuse reflectance coefficient. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
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).
direction | The direction to the distance light. |
lightColor | The color of the specular light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
ks | Specular reflectance coefficient. |
shininess | The specular exponent determining how shiny the surface is. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
static |
Create a filter that draws a drop shadow under the input content.
This filter produces an image that includes the inputs' content.
dx | The X offset of the shadow. |
dy | The Y offset of the shadow. |
sigmaX | The blur radius for the shadow, along the X axis. |
sigmaY | The blur radius for the shadow, along the Y axis. |
color | The color of the drop shadow. |
input | The input filter, or will use the source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
dx | The X offset of the shadow. |
dy | The Y offset of the shadow. |
sigmaX | The blur radius for the shadow, along the X axis. |
sigmaY | The blur radius for the shadow, along the Y axis. |
color | The color of the drop shadow. |
input | The input filter, or will use the source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
radiusX | The distance to erode along the x axis to either side of each pixel. |
radiusY | The distance to erode along the y axis to either side of each pixel. |
input | The image filter that is eroded, using source bitmap if this is null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
image | The image that is output by the filter, subset by 'srcRect'. |
srcRect | The source pixels sampled into 'dstRect' |
dstRect | The local rectangle to draw the image into. |
sampling | The sampling to use when drawing the image. |
|
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.
image | The image that is output by the filter. |
sampling | The sampling to use when drawing the image. |
|
static |
Create a filter that fills 'lensBounds' with a magnification of the input.
lensBounds | The outer bounds of the magnifier effect |
zoomAmount | The amount of magnification applied to the input image |
inset | The size or width of the fish-eye distortion around the magnified content |
sampling | The SkSamplingOptions applied to the input image when magnified |
input | The input filter that is magnified; if null the source bitmap is used |
cropRect | Optional rectangle that crops the input and output. |
|
static |
Create a filter that mimics a zoom/magnifying lens effect.
DEPRECATED: This factory does not accept enough parameters to fully specify the zoom effect, and derives the zoom based on the internal allocation size of a saveLayer. This makes its behavior brittle and respond poorly to SkCanvas transforms.
srcRect | |
inset | |
input | The input filter that is magnified, if null the source bitmap is used. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
kernelSize | The kernel size in pixels, in each dimension (N by M). |
kernel | The image processing kernel. Must contain N * M elements, in row order. |
gain | A scale factor applied to each pixel after convolution. This can be used to normalize the kernel, if it does not already sum to 1. |
bias | A bias factor added to each pixel after convolution. |
kernelOffset | An 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}). |
tileMode | How accesses outside the image are treated. TODO (michaelludwig) - kMirror is not supported yet |
convolveAlpha | If true, all channels are convolved. If false, only the RGB channels are convolved, and alpha is copied from the source image. |
input | The input image filter, if null the source bitmap is used instead. |
cropRect | Optional rectangle to which the output processing will be limited. |
|
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.
matrix | The matrix to apply to the original content. |
sampling | How the image will be sampled when it is transformed |
input | The image filter to transform, or null to use the source image. |
|
static |
Create a filter that merges the 'count' filters together by drawing their results in order with src-over blending.
filters | The input filter array to merge, which must have 'count' elements. Any null filter pointers will use the source bitmap instead. |
count | The number of input filters to be merged. |
cropRect | Optional rectangle that crops all input filters and the output. |
|
inlinestatic |
Create a filter that merges the results of the two filters together with src-over blending.
first | The first input filter, or the source bitmap if this is null. |
second | The second input filter, or the source bitmap if this null. |
cropRect | Optional rectangle that crops the inputs and output. |
|
static |
Create a filter that offsets the input filter by the given vector.
dx | The x offset in local space that the image is shifted. |
dy | The y offset in local space that the image is shifted. |
input | The input that will be moved, if null the source bitmap is used instead. |
cropRect | Optional rectangle to crop the input and output. |
|
inlinestatic |
|
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.
pic | The picture that is drawn for the filter output. |
targetRect | The drawing region for the picture. |
|
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).
location | The location of the point light. |
lightColor | The color of the diffuse light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
kd | Diffuse reflectance coefficient. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
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).
location | The location of the point light. |
lightColor | The color of the specular light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
ks | Specular reflectance coefficient. |
shininess | The specular exponent determining how shiny the surface is. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
shader | The shader that fills the result image |
|
static |
|
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.
location | The location of the spot light. |
target | The location that the spot light is point towards |
falloffExponent | Exponential falloff parameter for illumination outside of cutoffAngle |
cutoffAngle | Maximum angle from lighting direction that receives full light |
lightColor | The color of the diffuse light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
kd | Diffuse reflectance coefficient. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
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.
location | The location of the spot light. |
target | The location that the spot light is point towards |
falloffExponent | Exponential falloff parameter for illumination outside of cutoffAngle |
cutoffAngle | Maximum angle from lighting direction that receives full light |
lightColor | The color of the specular light source. |
surfaceScale | Scale factor to transform from alpha values to physical height. |
ks | Specular reflectance coefficient. |
shininess | The specular exponent determining how shiny the surface is. |
input | The input filter that defines surface normals (as alpha), or uses the source bitmap when null. |
cropRect | Optional rectangle that crops the input and output. |
|
static |
Create a tile image filter.
src | Defines the pixels to tile |
dst | Defines the pixel region that the tiles will be drawn to |
input | The input that will be tiled, if null the source bitmap is used instead. |