|
|
Wie bekomme ich die aktuelle Bildschirmauflösung und Farbtiefe meines Monitors heraus?
Lösung:
Public Const HORZRES = 8 ' Breite in Pixel Public Const VERTRES = 10 ' Höhe in Pixel Public Const BITSPIXEL = 12 ' Anzahl Bits pro Pixel Public Const PLANES = 14 ' Anzahl Farbebenen Private Declare Function GetDesktopWindow& Lib "user32" () Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hDC As Long, ByVal nIndex As Long) As Long Private Declare Function ReleaseDC Lib "user32" _ (ByVal hwnd As Long, ByVal hDC As Long) As Long Public Function GetScreenInfo(nIndex As Long) As Long Dim DesktophWnd As Long ' Windows - Handle Dim hDC As Long ' Device Context Dim dummy As Long ' ' Handle für Desktop ermitteln: ' DesktophWnd = GetDesktopWindow() ' ' Device Context ermitteln: ' hDC = GetDC(DesktophWnd) ' ' Info holen: ' GetScreenInfo = GetDeviceCaps(hDC, nIndex) ' ' Device Context freigeben: ' dummy = ReleaseDC(DesktophWnd, hDC) End Function
Debug.Print "Auflösung horizontal: "; GetScreenInfo(HORZRES) Debug.Print "Auflösung vertikal: "; GetScreenInfo(VERTRES) Debug.Print "Bits pro Pixel: "; GetScreenInfo(BITSPIXEL) Debug.Print "Anzahl Farbebenen: "; GetScreenInfo(PLANES) Debug.Print "Anz. Farben: "; 2 ^ (GetScreenInfo(PLANES) * GetScreenInfo(BITSPIXEL))
Die interne Speicherorganisation ist bei Grafikkarten - je nach Modell - unterschiedlich:
Die Informationen werden in einer oder mehreren Farbebenen gespeichert, wobei für jeden Bildschirmpunkt pro Farbebene eine - je nach Farbtiefe - unterschiedliche Anzahl an Bits verwendet wird.
Die Anzahl der für ein Pixel verwendeten Bits erhält man durch multipilizieren der beiden Werte.
Die gebräuchlichsten Kombinationen sind:
|
|
|
|
---|---|---|---|
Standard VGA |
|
|
2 ^ (4 * 1) = 16 |
Super VGA |
|
|
2 ^ (1 * 8) = 256 |
High Color |
|
|
2 ^ (1 * 16) = 65.536 |
True Color |
|
|
2 ^ (1 * 32) = 4.294.967.296 |
Tip 6: Wie bekomme ich heraus, wieviele Twips ein Pixel hat?
|
|
© 1999 T. Prötzsch |
Erstellt am 31. Mai 1999 / geändert am 01. Juni 1999
|