BrushSetDpiScaling

Syntax

Success = BrushSetDpiScaling(Brush, isEnabled.b)

Description

Enables or disables automatic DPI scaling for the specified brush. When enabled, certain brush properties (like gradient points or image dimensions used in scale calculations) may be automatically adjusted based on the current window's DPI setting.

Parameters

Brush
The handle of the brush whose DPI scaling behavior is to be set.

isEnabled.b
Set to #True to enable automatic DPI scaling, or #False to disable it.

Return Value

Returns #True if the setting was successfully applied, or #False if the brush handle was invalid.

Remarks

Disabling DPI scaling ensures that the brush pattern maintains its defined size in DIPs regardless of the monitor's scaling factor. This is useful for textures or patterns that should not scale with the UI. Enabling it (the default) allows gradients defined in DIPs or images used as patterns to scale appropriately on high-DPI displays.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyImage = CreateImg(50, 50, RGB(255, 165, 0)) ; Orange square
MyBrush = CreateBrushImg(MyImage)

If MyBrush
  ; Default is usually enabled
  Debug "DPI Scaling Enabled (Default): " + Str(BrushGetDpiScaling(MyBrush))
    
  ; Disable DPI scaling for the brush
  BrushSetDpiScaling(MyBrush, #False)
  Debug "DPI Scaling Enabled (After Disable): " + Str(BrushGetDpiScaling(MyBrush))

  ; Re-enable DPI scaling
  BrushSetDpiScaling(MyBrush, #True)
  Debug "DPI Scaling Enabled (After Re-enable): " + Str(BrushGetDpiScaling(MyBrush))

  FreeBrush(MyBrush)
EndIf

If MyImage : FreeImg(MyImage) : EndIf

StopProGUI()

See Also

BrushGetDpiScaling, WindowGetDpiScaleX

Supported OS

Windows, Linux