Syntax
Success = BrushSetInterpolationMode(Brush, InterpolationMode)
Description
Sets the interpolation mode used by an image or gradient brush when it needs to be scaled, rotated, or otherwise transformed during rendering. This affects the visual quality of the rendered brush pattern.
Parameters
Brush
The handle of the brush whose interpolation mode is to be set.
InterpolationMode
An integer constant specifying the desired interpolation mode.
Use one of the following:
#PG_InterpolationMode_Linear : (Default) Uses linear interpolation. Good balance of quality and performance.
#PG_InterpolationMode_Nearest : Uses nearest-neighbor interpolation. Fast but can look blocky when scaled up.
#PG_InterpolationMode_Cubic : Uses cubic interpolation. Higher quality than linear, slightly slower.
#PG_InterpolationMode_MultiSampleLinear : Uses multiple linear samples. Can improve quality on some GPUs. (Direct2D specific?)
#PG_InterpolationMode_Anisotropic : Uses anisotropic filtering. Best quality for textures viewed at sharp angles, potentially slower. (Direct2D specific?)
#PG_InterpolationMode_HighQualityCubic: A higher-quality cubic interpolation. (Direct2D specific?)
Return Value
Returns #True if the interpolation mode was successfully set, or #False if the
brush handle was invalid or the mode was unsupported by the current rendering backend.
Remarks
Choosing the right interpolation mode is a trade-off between rendering quality and performance. `Nearest` is fastest but lowest quality, while modes like `Anisotropic` or `HighQualityCubic` offer better visuals at a higher computational cost. `Linear` is often a good default. Note that some modes might be specific to certain rendering backends (like Direct2D).
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyImage = CreateImg(10, 10) ; Small image
MyBrush = CreateBrushImg(MyImage)
If MyBrush
Debug "Default Mode: " + BrushGetInterpolationMode(MyBrush)
; Set to Nearest Neighbor for blocky scaling, good for pixel art graphics
BrushSetInterpolationMode(MyBrush, #PG_InterpolationMode_Nearest)
Debug "Mode after setting Nearest: " + BrushGetInterpolationMode(MyBrush)
; Set back to Linear
BrushSetInterpolationMode(MyBrush, #PG_InterpolationMode_Linear)
Debug "Mode after setting Linear: " + BrushGetInterpolationMode(MyBrush)
FreeBrush(MyBrush)
EndIf
If MyImage : FreeImg(MyImage) : EndIf
StopProGUI()
See Also
BrushGetInterpolationMode, ImgSetInterpolationMode
Supported OS
Windows, Linux