Syntax
ImgSetInterpolationMode(Img, InterpolationMode)
Description
Sets the default interpolation mode used when the specified ProGUI image is drawn scaled (e.g., via DrawImg() with dimensions different from the source).
Parameters
Img
The handle of the ProGUI image object whose interpolation mode is to be set.
InterpolationMode
The desired interpolation mode constant.
#PG_InterpolationMode_Linear : Bilinear interpolation (default, smooth).
#PG_InterpolationMode_Nearest : Nearest neighbor (pixelated, fast).
#PG_InterpolationMode_Cubic : Bicubic interpolation.
#PG_InterpolationMode_MultiSampleLinear : Uses multiple samples for linear interpolation (Direct2D only).
#PG_InterpolationMode_Anisotropic : Anisotropic filtering (Direct2D only).
#PG_InterpolationMode_HighQualityCubic : Higher quality bicubic interpolation (Direct2D only).
Return Value
This function does not return a value.
Remarks
The interpolation mode affects the visual quality when an image is scaled up or down during drawing. The default is #PG_InterpolationMode_Linear. For pixel art, #PG_InterpolationMode_Nearest is often preferred. Setting the mode on the image sets the default for subsequent draw operations involving that image; the mode can sometimes be overridden temporarily (e.g., via brush settings).
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
PixelArtImage = LoadImg("pixel_art.png") ; Assume pixel_art.png exists
If PixelArtImage
Debug "Default Interpolation Mode: " + ImgGetInterpolationMode(PixelArtImage)
; Set mode to nearest neighbor for crisp pixel art scaling
ImgSetInterpolationMode(PixelArtImage, #PG_InterpolationMode_Nearest)
Debug "New Interpolation Mode: " + ImgGetInterpolationMode(PixelArtImage)
; Now drawing this image scaled will use nearest neighbor by default
; ... DrawImg(PixelArtImage, 0, 0, ImgGetWidth(PixelArtImage)*4, ImgGetHeight(PixelArtImage)*4) ...
FreeImg(PixelArtImage)
EndIf
StopProGUI()
See Also
ImgGetInterpolationMode, DrawImg, BrushSetInterpolationMode
Supported OS
Windows, Linux