ImgGetInterpolationMode

Syntax

InterpolationMode = ImgGetInterpolationMode(Img)

Description

Retrieves 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 retrieved.

Return Value

Returns the current interpolation mode constant for the image (e.g., #PG_InterpolationMode_Linear, #PG_InterpolationMode_Nearest). Returns a default value (#PG_InterpolationMode_Linear) or #False if the image handle is invalid.

Possible return values:

#PG_InterpolationMode_Linear            : Default. Good balance of speed and quality. Bilinear filtering.
#PG_InterpolationMode_Nearest           : Fastest, pixelated result. Good for pixel art. Nearest neighbor filtering.
#PG_InterpolationMode_Cubic             : Smoother results than linear, slower. Bicubic filtering.
#PG_InterpolationMode_MultiSampleLinear : Uses multiple samples, potentially smoother edges.
#PG_InterpolationMode_Anisotropic       : High quality, good for textures viewed at angles.
#PG_InterpolationMode_HighQualityCubic  : Highest quality cubic filtering, slowest.

Remarks

The interpolation mode affects the visual quality when an image is scaled up or down during drawing. The default is usually #PG_InterpolationMode_Linear. For pixel art, #PG_InterpolationMode_Nearest is often preferred.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyImage = LoadImg("icon.png") ; Assume icon.png exists

If MyImage
    CurrentMode = ImgGetInterpolationMode(MyImage)
    Select CurrentMode
        Case #PG_InterpolationMode_Linear: Debug "Interpolation: Linear"
        Case #PG_InterpolationMode_Nearest: Debug "Interpolation: Nearest Neighbor"
        ; Add other cases if needed
        Default: Debug "Interpolation: Unknown/Other"
    EndSelect

    ; Change mode to Nearest Neighbor
    ImgSetInterpolationMode(MyImage, #PG_InterpolationMode_Nearest)
    Debug "Interpolation set to Nearest Neighbor."

    CurrentMode = ImgGetInterpolationMode(MyImage)
    If CurrentMode = #PG_InterpolationMode_Nearest
        Debug "Verification successful."
    EndIf

    FreeImg(MyImage)
EndIf

StopProGUI()

See Also

ImgSetInterpolationMode, DrawImg

Supported OS

Windows, Linux