BorderImgSetInterpolationMode

Syntax

Success = BorderImgSetInterpolationMode(Border, InterpolationMode)

Description

Sets the interpolation mode used when scaling or stretching parts of an image border object. This affects the visual quality when border slices are resized. This command is only applicable to borders created with CreateBorderImg().

Parameters

Border
The handle of the image border object.

InterpolationMode
The desired interpolation mode. Use one of the #PG_InterpolationMode_* constants:

#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.

Return Value

Returns #True if the mode was successfully set, or #False if the border handle is invalid or not an image border.

Remarks

The default interpolation mode is typically #PG_InterpolationMode_Linear. Choosing the right mode depends on the source image and the desired visual outcome versus performance requirements. This setting applies to both the border image and its mask, if present.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyImage = CreateImg(30, 30, RGB(200, 200, 200)) ; Placeholder image

If MyImage
  MyBorder = CreateBorderImg(MyImage, 0, 10, 10, 10, 10)

  If MyBorder
    ; Set interpolation to nearest neighbor for a pixelated look when scaled
    If BorderImgSetInterpolationMode(MyBorder, #PG_InterpolationMode_Nearest)
      Debug "Border image interpolation mode set to Nearest."
      ; Now draw the border scaled up to see the effect
      ; DrawBorder(MyBorder, 50, 50, 200, 200)
    EndIf
    FreeBorder(MyBorder)
  EndIf
  FreeImg(MyImage)
EndIf

StopProGUI()

See Also

CreateBorderImg, BorderImgGetInterpolationMode

Supported OS

Windows, Linux