Example #1
0
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the main screen.
//   This gives us the pixelscale for system-DPI-aware applications.
MCGFloat MCWin32GetLogicalToScreenScale(void)
{
	// TODO - determine the correct value on Win8.1 - this may depend on the display in question

	uint32_t t_x, t_y;
	/* UNCHECKED */ MCWin32GetScreenDPI(t_x, t_y);

	return (MCGFloat) MCMax(t_x, t_y) / NORMAL_DENSITY;
}
Example #2
0
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the given monitor.
//   For system-DPI-aware applications this will be the global system DPI value.
//   For Per-Monitor-DPI-aware applications, this will be the effective DPI scale of the given monitor
bool MCWin32GetMonitorPixelScale(HMONITOR p_monitor, MCGFloat &r_pixel_scale)
{
	uint32_t t_xdpi, t_ydpi;

	// try to get per-monitor DPI setting
	if (!MCWin32GetDPIForMonitor(p_monitor, t_xdpi, t_ydpi) &&
		// fallback to the global system DPI setting
		!MCWin32GetScreenDPI(t_xdpi, t_ydpi))
			return false;

	r_pixel_scale = (MCGFloat)MCMax(t_xdpi, t_ydpi) / NORMAL_DENSITY;

	return true;
}
Example #3
0
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the main screen.
//   This gives us the pixelscale for system-DPI-aware applications.
MCGFloat MCWin32GetLogicalToScreenScale(void)
{
	// TODO - determine the correct value on Win8.1 - this may depend on the display in question

	// IM-2014-08-08: [[ Bug 12372 ]] If pixel scaling is disabled, then
	// we don't need to scale from logical -> screen.
	if (!MCResGetUsePixelScaling())
		return 1.0;

	uint32_t t_x, t_y;
	/* UNCHECKED */ MCWin32GetScreenDPI(t_x, t_y);

	return (MCGFloat) MCMax(t_x, t_y) / NORMAL_DENSITY;
}
Example #4
0
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the given monitor.
//   For system-DPI-aware applications this will be the global system DPI value.
//   For Per-Monitor-DPI-aware applications, this will be the effective DPI scale of the given monitor
bool MCWin32GetMonitorPixelScale(HMONITOR p_monitor, MCGFloat &r_pixel_scale)
{
	UINT t_xdpi, t_ydpi;
	HRESULT t_result;
	
	// try to get per-monitor DPI setting
	if (!MCWin32GetDPIForMonitor(t_result, p_monitor, kMCWin32MDTDefault, &t_xdpi, &t_ydpi) ||
		t_result != S_OK)
	{
		// fallback to the global system DPI setting
		uint32_t t_screen_xdpi, t_screen_ydpi;
		if (!MCWin32GetScreenDPI(t_screen_xdpi, t_screen_ydpi))
			return false;
		t_xdpi = t_screen_xdpi;
		t_ydpi = t_screen_ydpi;
	}

	r_pixel_scale = (MCGFloat)MCMax(t_xdpi, t_ydpi) / NORMAL_DENSITY;

	return true;
}