CodeItBetter Programming Another VB Programming Blog

How to Get Color Depth

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'Graphics - How to Get Color Depth

Option Explicit
 
Private Const PLANES& = 14
Private Const BITSPIXEL& = 12
Private Declare Function GetDeviceCaps& Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long)
Private Declare Function GetDC& Lib "user32" (ByVal hwnd As Long)
Private Declare Function ReleaseDC& Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long)
 
Private Function ColorDepth() As Integer
    Dim nPlanes As Integer, BitsPerPixel As Integer, dc As Long
    dc = GetDC(0)
    nPlanes = GetDeviceCaps(dc, PLANES)
    BitsPerPixel = GetDeviceCaps(dc, BITSPIXEL)
    ReleaseDC 0, dc
    ColorDepth = nPlanes * BitsPerPixel
End Function
 
'How can I call this function:
Private Sub Form_Load()
    MsgBox ColorDepth & " Bit"
End Sub
Filed under: Graphics Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.