Entwickler-Ecke

Multimedia / Grafik - Auflösung des Monitor in ppi abfragen


jjturbo - Do 24.09.15 08:19
Titel: Auflösung des Monitor in ppi abfragen
Moin Forum,

kann man irgendwie die tatsächliche Auflösung des Monitors in ppi ermitteln?

Wenn ich zum Beispiel das ausführe:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function Screen_ppi: Integer;
var
  DC: HDC;
begin
  DC := GetDC(GetDesktopWindow);  // Device-Context des Desktops
  try
    Result := GetDeviceCaps(DC, LOGPIXELSX);
  finally
    ReleaseDC(0, DC);
  end;
end;

bekomme ich einen Rückgabewert von 96ppi (Das finde ich auch in der Systemsteuerung).
Das bedeutet doch wenn ich jetzt zum Beispiel ein TPanel mit einer Breite von 960 Pixeln auf meiner Form habe sollte es auf dem Monitor eine Breite von exakt 10 Zoll haben, oder? Tatsächlich sind es allerdings nur 7,55 Zoll. Wenn ich dann mal rückwärts rechne komme ich auf 127ppi.
Kann mir das mal jemand erklären?

Gruß Oliver


Delete - Do 24.09.15 10:14

Zitat:
GetDeviceCaps reports info that the display driver provides. If the display driver declines to report any info, GetDeviceCaps calculates the info based on fixed calculations. If the display driver reports invalid info, GetDeviceCaps returns the invalid info. Also, if the display driver declines to report info, GetDeviceCaps might calculate incorrect info because it assumes either fixed DPI (96 DPI) or a fixed size (depending on the info that the display driver did and didn’t provide). Unfortunately, a display driver that is implemented to the Windows Display Driver Model (WDDM) (introduced in Windows Vista) causes GDI to not get the info, so GetDeviceCaps must always calculate the info.

GetDeviceCaps function [https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396]

Sicherstellen, dass Anwendungen auf Bildschirmen mit hohen DPI-Werten ordnungsgemäß angezeigt werden [https://msdn.microsoft.com/de-de/library/windows/desktop/dd756596%28v=vs.85%29.aspx]