Syntax
DpiX = DrawGetDPI(*DPI_Y.Integer=#Null)
Description
Retrieves the current horizontal and optionally vertical Dots Per Inch (DPI) values being used by the active drawing context for scaling calculations.
Parameters
*DPI_Y.Integer (optional)
A pointer to an integer variable that will receive the
current vertical DPI value. If #Null, only the horizontal DPI is returned.
Return Value
Returns the current horizontal DPI value as an Integer. Returns 0 or #False if
called outside a BeginDraw() / EndDraw() block.
Remarks
This function allows querying the DPI setting currently applied to the drawing context, which determines the scaling factor for DIP-based coordinates and sizes. This value might differ from the window's native DPI if DrawDPI() was used to override the default. The default DPI returned by this function when drawing begins is the native DPI of the output target (window or image).
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(255, 255, 255), 1)
CurrentDpiX = DrawGetDPI(@CurrentDpiY)
Debug "Initial Draw DPI - X: " + Str(CurrentDpiX) + ", Y: " + Str(CurrentDpiY)
; Change DPI
DrawDPI(192)
CurrentDpiX = DrawGetDPI(@CurrentDpiY)
Debug "Changed Draw DPI - X: " + Str(CurrentDpiX) + ", Y: " + Str(CurrentDpiY)
; Restore default
DrawDPI(#PG_DrawDPI_Auto)
CurrentDpiX = DrawGetDPI(@CurrentDpiY)
Debug "Restored Draw DPI - X: " + Str(CurrentDpiX) + ", Y: " + Str(CurrentDpiY)
EndProcedure
MyWindow = CreateWindow(0, 0, 300, 150, "Get Draw DPI Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
DrawDPI, DrawGetDPIScaleX, DrawGetDPIScaleY, BeginDraw, EndDraw
Supported OS
Windows, Linux