screen dpi
-
ehowington
- Enthusiast

- Posts: 117
- Joined: Sat Sep 12, 2009 3:06 pm
screen dpi
anyone know a short example to collect the actual screen/monitor dpi?
Re: screen dpi
For Windows only:
Code: Select all
Debug GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #LOGPIXELSX)If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: screen dpi
Code: Select all
;retrieves the horizontal DPI of the desktop
Procedure.i Gui_GetDesktopDpiX()
Protected hDc.i
Protected hDpi.i
hDc = GetDC_(GetDesktopWindow_())
If hDc
hDpi = GetDeviceCaps_(hDc, #LOGPIXELSX)
ReleaseDC_(GetDesktopWindow_(), hDc)
EndIf
ProcedureReturn hDpi
EndProcedure
;retrieves the vertical DPI of the desktop
Procedure.i Gui_GetDesktopDpiY()
Protected hDc.i
Protected vDpi.i
hDc = GetDC_(GetDesktopWindow_())
If hDc
vDpi = GetDeviceCaps_(hDc, #LOGPIXELSY)
ReleaseDC_(GetDesktopWindow_(), hDc)
EndIf
ProcedureReturn vDpi
EndProcedure
It resizes a window to the physical iPhone screen size (not resolution).
It's from a editor for a iPhone game i was working on.
Code: Select all
;resizes the 3D view window to the iPhone screen size
Procedure Gui_Resize3DWnd2iPhoneSize(Scale.f)
Protected Width.i
Protected Height.i
Protected RelationX.f
Protected RelationY.f
RelationX = Gui_GetDesktopDpiX() / #iPhone_xDpi
RelationY = Gui_GetDesktopDpiY() / #iPhone_yDpi
Width = #iPhone_Width * RelationX * Scale
Height = #iPhone_Height * RelationY * Scale
ResizeWindow(Gui_3DWnd\PbNum, #PB_Ignore, #PB_Ignore, Width, Height)
EndProcedure
Re: screen dpi
Btw. there seems hardly any display where the horizontal and vertical DPI settings are different. I was wondering about this when i did some application code for DPI scaling and it seems like it only affects a few cases where a manufacturer puts a 16:9 panel into a 16:10 case.
It seems really rare and the differences are small when it happens.
It seems really rare and the differences are small when it happens.
