Interface IGraphicsModule2
interface IGraphicsModule2
Extends IGraphicsModule
Graphics Module v2 extends IGraphicsModule and defines new methods to create surface, additional layers, image filters, shader and decoded image.
Methods
makeSurface()
Creates a new drawing surface with the specified width and height. A surface provides a rectangular area for rendering content. The surface is initially filled with transparent black (all pixel components set to 0).ISurface*makeSurface(SizeIsize)
Parameters
size
SizeI — Required
The SizeI (width and height) of the surface to be created.
Returns
ISurface*
A new surface ISurface instance initialized to transparent black.
Throws
InvalidArgumentError— if width or height is zero or negative in the size passed.
makeBlendLayer()
Creates a new blend layer that combines visual elements using the specified blend mode. A blend layer determines how content is combined with the content below it in the layer stack. The blend mode controls the mathematical operation used to combine pixel colors.IBlendLayer*makeBlendLayer(BlendModemode)
Parameters
mode
BlendMode — Required
The blend mode BlendMode to use for this layer
Returns
IBlendLayer*
A new blend layer IBlendLayer configured with the specified mode
makeImageFilterLayer()
Creates a new layer that applies image filtering effects to its children. An image filter layer processes the content of all its child layers through the specified image filter before compositing with layers below it.IImageFilterLayer*makeImageFilterLayer(IImageFilter*imageFilter)
Parameters
imageFilter
IImageFilter* — Required
The IImageFilter to apply to this layer’s children.
Returns
IImageFilterLayer*
A new IImageFilterLayer configured with the specified filter.
makeImageFilter()
Creates an image filter that renders a static image as part of a filter chain. This filter produces its source image as output, allowing it to be combined with other filters or used as a source in filter graphs. The source image must remain valid for the lifetime of the returned filter. The image is rendered with the specified sampling option asIImageFilter*makeImageFilter(IImage*image,ImageFilterQualityfilterQuality)
ImageFilterQuality.
Parameters
image
IImage* — Required
The source IImage to render through this filter.
filterQuality
ImageFilterQuality — Required
The sampling quality for transformed pixels
Returns
IImageFilter*
A new filter IImageFilter that renders the specified image.
makeBlendImageFilter()
Creates a filter that combines foreground and background image filters using a blend mode. When either input filter is null, the filter uses the source image from the filter chain instead. This allows for blending between filter results and the original content. When both filters are null, the operation blends the source content with itself. This can be useful with certain blend modes:IImageFilter*makeBlendImageFilter(BlendModemode,IImageFilter?background,IImageFilter?foreground)
- With MULTIPLY: Darkens the image
- With SCREEN: Lightens the image
- With OVERLAY: Increases contrast
Parameters
mode
BlendMode — Required
The BlendMode to use for blending.
background
IImageFilter? — Optional
Filter providing the bottom layer for blending, uses
source content if null.
foreground
IImageFilter? — Optional
Filter providing the top layer for blending, uses
source content if null.
Returns
IImageFilter*
A new filter IImageFilter that applies the specified blending operation.
makeBlurImageFilter()
Creates a filter that applies a Gaussian blur effect. Performs a two-dimensional Gaussian blur with independent control over the blur radius in each direction. The sigma values determine the blur radius, with larger values creating a wider blur effect. A sigma of 0 means no blur in that direction. The tile mode determines how pixels outside the source image are sampled when the blur kernel extends beyond the image bounds.IImageFilter*makeBlurImageFilter(floatsigmaX,floatsigmaY,TileModetileMode,IImageFilter?imageFilter)
Parameters
sigmaX
float — Required
The Gaussian sigma value for blurring along the X axis.
sigmaY
float — Required
The Gaussian sigma value for blurring along the Y axis.
tileMode
TileMode — Required
The TileMode for sampling outside bounds.
imageFilter
IImageFilter? — Optional
Input filter to blur, uses source content if null.
Returns
IImageFilter*
A new IImageFilter that performs the specified blur operation.
makeDropShadowImageFilter()
Creates a filter that applies a drop shadow effect. It generates the shadow by:IImageFilter*makeDropShadowImageFilter(Pointoffset,floatradiusX,floatradiusY,Colorcolor,IImageFilter?imageFilter)
- creating an alpha mask from the source content
- blurring the mask using the specified X and Y radii
- filling the result with the shadow color
- offsetting the shadow by the specified amount
- compositing the original content over the shadow
Parameters
offset
Point — Required
The distance to offset the shadow from its source
radiusX
float — Required
Horizontal blur radius for the shadow
radiusY
float — Required
Vertical blur radius for the shadow
color
Color — Required
The color of the shadow
imageFilter
IImageFilter? — Optional
Input filter to generate shadow from, uses source content if null
Returns
IImageFilter*
A new IImageFilter that applies the specified drop shadow
makeShaderImageFilter()
Creates a filter that generates content by evaluating a shader program. This filter ignores its input and instead produces output by evaluating the provided shader at each pixel location. The shader’s coordinate space is relative to the destination where the filter is applied. This allows the shader to respond to the final transformed space of the content. The shader must remain valid for the lifetime of the returned filter. Multiple filters may share the same shader object.IImageFilter*makeShaderImageFilter(IShader*shader)
Parameters
shader
IShader* — Required
The shader program to evaluate for output pixels
Returns
IImageFilter*
A new IImageFilter that renders using the specified shader
makeMatrixTransformImageFilter()
Creates a filter that transforms its input using an affine matrix. Applies affine transformation matrix to the input content. The matrix can represent any combination of translation, scale, rotation and skew. The filter quality parameter controls how pixels are sampled when the transformation requires interpolation.IImageFilter*makeMatrixTransformImageFilter(AffineMatrixmatrix,ImageFilterQualityfilterQuality,IImageFilter?imageFilter)
Parameters
matrix
AffineMatrix — Required
The affine matrix transformation to apply
filterQuality
ImageFilterQuality — Required
The sampling quality for transformed pixels
imageFilter
IImageFilter? — Optional
Input filter to transform, uses source content if null
Returns
IImageFilter*
A new filter that applies the specified transformation
makeMatrixConvolutionImageFilter()
Creates a filter that applies a custom convolution kernel to its input. Convolution is a fundamental image processing operation that computes each output pixel as a weighted sum of input pixels in a local neighborhood. The kernel defines the weights and size of this neighborhood. The kernel offset defines the center point of the convolution kernel, allowing for asymmetric filtering effects. This can be used to produce effects such as sharpening, blurring, edge detection, etc.IImageFilter*makeMatrixConvolutionImageFilter(SizekernelSize,float[]kernel,PointkernelOffset,floatgain,floatbias,TileModetileMode,boolconvolveAlpha,IImageFilter?imageFilter)
Parameters
kernelSize
Size — Required
Dimensions of the convolution kernel
kernel
float[] — Required
Array of weights in row-major order, must contain
kernelSize.width * kernelSize.height elements
kernelOffset
Point — Required
Origin point within the kernel
gain
float — Required
Scale factor applied to convolution result
bias
float — Required
Value added to scaled result
tileMode
TileMode — Required
The TileMode for sampling outside bounds
convolveAlpha
bool — Required
If true, the alpha channel is included in the convolution, else only RGB channel is included in convolution
imageFilter
IImageFilter? — Optional
Input filter to process, uses source content if null
Returns
IImageFilter*
A new filter that applies the specified convolution
Throws
InvalidArgumentError— if kernel array size doesn’t match kernelSize or if kernelOffset is outside kernel bounds
makeArithmeticImageFilter()
Creates a filter that blends two input filters using an arithmetic expression. Computes output colors using the formula: result = clamp(k1 * src * dst + k2 * src + k3 * dst + k4) where:IImageFilter*makeArithmeticImageFilter(floatk1,floatk2,floatk3,floatk4,IImageFilter?background,IImageFilter?foreground)
- src is the foreground color (0-1 per channel)
- dst is the background color (0-1 per channel)
- k1-k4 are coefficients controlling the blend
- clamp ensures results stay in valid 0-1 range
Parameters
k1
float — Required
First arithmetic coefficient
k2
float — Required
Second arithmetic coefficient
k3
float — Required
Third arithmetic coefficient
k4
float — Required
Fourth arithmetic coefficient
background
IImageFilter? — Optional
Background input filter, uses source content if null
foreground
IImageFilter? — Optional
Foreground input filter, uses source content if null
Returns
IImageFilter*
A new filter that applies the arithmetic operation
makeColorFilterImageFilter()
Creates a filter that applies the given color filter to the input. It applies a color transformation to each pixel of the input. The color filter must remain valid for the lifetime of the returned filter. Multiple filters may share the same color filter object. Common uses:IImageFilter*makeColorFilterImageFilter(IColorFilter*colorFilter,IImageFilter?imageFilter)
- Adjusting brightness, contrast, or saturation
- Applying color tints or photo filters
- Converting to grayscale
- Applying artistic color effects
- Color space conversion and correction
Parameters
colorFilter
IColorFilter* — Required
The IColorFilter to apply
imageFilter
IImageFilter? — Optional
Input filter to transform, uses source content if null
Returns
IImageFilter*
A new filter that applies the color filter
makeImageShader()
Creates a shader that fills an area by sampling from an image with tiling. The shader repeats or extends the source image based on the tile modes. The affine transformation matrix allows for:IShader*makeImageShader(IImage*image,TileModetileX,TileModetileY,AffineMatrix?matrix)
- Scaling the image pattern
- Rotating the pattern
- Skewing for perspective effects
- Translating the pattern origin
- Creating repeating background patterns
- Filling shapes with image textures
- Creating border patterns
- Applying transformed image fills
- Creating seamless texture tiles
Parameters
image
IImage* — Required
The source IImage to use for the shader
tileX
TileMode — Required
The TileMode for tiling in the horizontal direction
tileY
TileMode — Required
The TileMode for tiling in the vertical direction
matrix
AffineMatrix? — Optional
AffineMatrix to transform the image coordinates, if null, no transformation will be applied.
Returns
IShader*
A new IShader that samples from the image using the specified tiling and transformation
makeDecodedImage()
IImage*makeDecodedImage(u8[]encodedData)
Parameters
encodedData
u8[] — Required
Returns
IImage*

