Syntax
Success = ImgSetProperty(Img, Property, Value)
Description
Sets a specific property for the given ProGUI image object.
Parameters
Img
The handle of the ProGUI image object whose property is to be set.
Property
The property to set. Currently defined properties are:
#PG_Img_SnapToSize : Boolean flag. If #True, when drawing this image scaled, the drawing dimensions will snap to the exact dimensions of the best-matching alternate size (ImgAddSize) instead of strictly adhering to the requested drawing size. Default is #False.
Value
The value to assign to the property. For #PG_Img_SnapToSize, this should be #True or #False.
Return Value
Returns #True if the property was successfully set, or #False if the image handle or property constant was invalid.
Remarks
The #PG_Img_SnapToSize property is useful for icons or pixel-perfect assets where you want to ensure that if an exact size match (or a close one managed via ImgAddSize) is available, it's drawn at its native resolution rather than being scaled slightly to fit the requested drawing dimensions, which might introduce unwanted anti-aliasing or blurring depending on the interpolation mode.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Assume "icon_16.png" and "icon_32.png" exist
Icon16 = LoadImg("icon_16.png")
Icon32 = LoadImg("icon_32.png")
If Icon16 And Icon32
; Add 32x32 as an alternate size for the 16x16 icon
ImgAddSize(Icon16, Icon32)
; Enable snap-to-size behavior
ImgSetProperty(Icon16, #PG_Img_SnapToSize, #True)
Debug "Snap-to-size enabled for Icon16."
; ... Drawing code ...
; When DrawImg(Icon16, x, y, 30, 30) is called,
; it might select Icon32 but draw it exactly at 32x32 pixels
; instead of scaling it down to 30x30 DIPs equivalent.
FreeImg(Icon32)
FreeImg(Icon16)
EndIf
StopProGUI()
See Also
Supported OS
Windows, Linux