Is the number of pixels per inch standard for all PC PCs? (LogPixelsX) in a call to GetDeviceCaps WinAPI

On Windows PC displays, I don't mean Windows CE or PDAs, etc.

Explanation
Some of the people below mistakenly thought that I was asking what DPI (dots per inch) were on monitors. What I am asking is the value for LogPixelsX in the GetCaps API call :

LOGPIXELSX Number of pixels per logical inch of screen width.

In the examples I saw, it is set to 88, regardless of the DPI of the screen. It seems to be a constant like Magic Number.

In a related Question, I use GetDeviceCaps to calculate the current DPI on-screen font. All the code samples I found have:

Const LOGPIXELSX = 88

Is it universally the same for all monitors (even widescreen and regular monitors)? And if not, how can I find it for the current display. (MSDN indicates that it is the same for all monitors on a specific computer.

In a system with multiple display monitors, this value is the same for all monitors.

+7
windows dpi
source share
5 answers

To answer your clarification of the question:

LOGPIXELSX is a parameter that you pass to GetDeviceCaps to get the current resolution of the monitor (technically this is the horizontal resolution, but all modern displays have equal horizontal and vertical resolution). Yes, always 88 — if you wanted a different value from GetDeviceCaps, you would pass a different value. For example, to get the number of bits per pixel, you must pass the BITSPIXEL constant, which is 12. These magic constants are defined in the Windows API WINGDI.h file.

A note in MSDN does not refer to a parameter, but to a return value.

+11
source share

Windows will always have 96 DPI for resolution, unless you change it in the display settings. In XP, you will find it in the "Advanced" dialog box under "Screen Properties" → "Settings"; I do not know where it is found in other versions of Windows.

You are correct that GetDeviceCaps (LOGPIXELSX) will return DPI, with the exception of one small caveat. Starting with Vista, Windows may lie to you about your actual configured resolution. To get the right picture of the configuration, you need to make your DPI-aware application. Here, the Microsoft page provides some details, with particular emphasis on changes coming in Windows 7.

http://msdn.microsoft.com/en-us/library/dd464659(VS.85).aspx

And one more link:

http://msdn.microsoft.com/en-us/library/ms701681(VS.85).aspx

+6
source share

See SetProcessDPIAware () (for Vista) and GetDeviceCaps (...) for a DPI.

XP has 96 or 120 dpi. Vista actually has a slider for setting through the "continuum" of DPI settings. In Vista, DWM will take care of scaling up your applications unless you explicitly indicate that you are aware of DPI. For XP, you should plan both 96 and 120.

+2
source share

In the case of an image, the image resolution (DPIX, DPIY) must be taken at a different constant resolution of the monitor. Conversion to pixels for a dpi image is as follows:

public struct RECT_TAG { public int iLeft; public int iTop; public int iHeight; public int iWidth; } public static RECT_TAG ConvertTwipsToPixels(RECT_TAG pobjRect, int plXDPI, int plYDPI) { pobjRect.iLeft = pobjRect.iLeft * plXDPI / 1440; pobjRect.iTop = pobjRect.iTop * plYDPI / 1440; pobjRect.iWidth = pobjRect.iWidth * plXDPI / 1440; pobjRect.iHeight = pobjRect.iHeight * plYDPI / 1440; return pobjRect; } 
+1
source share

The two standard DPI settings on Windows are 96 dpi (normal size) and 120 dpi (large size). I'm sure there is a Win32 call to get this setting, but I'm not sure where to send you, MSDN can get your answer.

edit: I have to clarify what Windows I mean Windows XP

0
source share

All Articles