Enum DpiType
- Namespace
- VisioForge.Core.Types
- Assembly
- VisioForge.Core.dll
Identifies the dots per inch (DPI) setting for a monitor.
public enum DpiTypeFields
Effective = 0-
The effective DPI. This value should be used when determining the correct scale factor for scaling UI elements. This incorporates the scale factor set by the user for this specific display.
The effective DPI is the recommended value for most applications. It represents the combination of the physical DPI of the display and any user-configured scaling settings in the operating system.
For example, a 4K display might have a raw DPI of 192, but if the user has set 150% scaling, the effective DPI would be 144 (96 * 1.5).
Angular = 1-
The angular DPI. This DPI ensures rendering at a compliant angular resolution on the screen. This does not include the scale factor set by the user for this specific display.
Angular DPI represents the DPI value that would provide a consistent viewing angle across different displays when viewed at their intended distance. This is useful for ensuring text and UI elements appear at consistent physical sizes regardless of screen size.
This value is typically used in specialized scenarios where physical size consistency is more important than following user preferences.
Raw = 2-
The raw DPI. This value is the linear DPI of the screen as measured on the screen itself. Use this value when you want to read the pixel density and not the recommended scaling setting. This does not include the scale factor set by the user for this specific display and is not guaranteed to be a supported DPI value.
Raw DPI represents the actual physical pixel density of the display, calculated from the screen's physical dimensions and resolution. This value ignores all scaling settings and provides the true hardware characteristics of the display.
This value is useful for applications that need to know the exact physical characteristics of the display, such as image editing software that needs to display content at actual size, or applications that perform custom DPI scaling calculations.
Note that this value may not correspond to any standard DPI scaling level supported by the operating system, and should not be used directly for UI scaling without additional calculations.
Examples
// Get the effective DPI for proper UI scaling
var dpiType = DpiType.Effective;
uint dpiX, dpiY;
GetDpiForMonitor(monitor, dpiType, out dpiX, out dpiY);
// Calculate scale factor
float scaleFactor = dpiX / 96.0f; // 96 DPI is the standard baseline
Remarks
This enumeration provides different methods for querying DPI values from a display device. Each value represents a different interpretation of DPI that may be useful in different scenarios.
When developing DPI-aware applications, the VisioForge.Core.Types.DpiType.Effective value is typically the most appropriate choice as it includes user scaling preferences. The VisioForge.Core.Types.DpiType.Angular and VisioForge.Core.Types.DpiType.Raw values are useful for specialized scenarios where you need the physical characteristics of the display.