Determining Color Pallette Depth 
Author Message
 Determining Color Pallette Depth

I need to determine the color palette depth a display is running when my
program starts up. Does anyone know how this is done?

Thanks.

John Russell



Sat, 19 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

Give this routine a try ....

      'determine number of color bits supported.
        BitsPerPixel = GetDeviceCaps(frmIn.hDC, BITSPIXEL)
        NbrPlanes = GetDeviceCaps(frmIn.hDC, PLANES)
        ColorBits = (BitsPerPixel * NbrPlanes)

      Select Case ColorBits
        Case 32:   RgnCnt = 256    '16M colors:  8 bits for blue
        Case 24:   RgnCnt = 256    '16M colors:  8 bits for blue
        Case 16:   RgnCnt = 256    '64K colors:  5 bits for blue
        Case 15:   RgnCnt = 32     '32K colors:  5 bits for blue
        Case 8:    RgnCnt = 64     '256 colors:  64 dithered blues
        Case 4:    RgnCnt = 64     '16 colors :  64 dithered blues
        Case Else: ColorBits = 4
                   RgnCnt = 64     '16 colors assumed: 64 dithered blues
      End Select

Print ColorBits, RgnCnt
---

Public Const PLANES = 14       '  Number of planes
Public Const BITSPIXEL = 12    '  Number of bits per pixel

Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex
As Long) As Long

--
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/



: I need to determine the color palette depth a display is running when my
: program starts up. Does anyone know how this is done?
:
: Thanks.
:
: John Russell
:
:



Sat, 19 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

Randy --

FYI, AFAIK, GetDeviceCaps will never return 15 bitspixel: it is unable to
distinguish between 32K and 64K colors (and frankly, so am I <g>).

Jim Deutch
MS Dev MVP



Quote:
> Give this routine a try ....

>       'determine number of color bits supported.
>         BitsPerPixel = GetDeviceCaps(frmIn.hDC, BITSPIXEL)
>         NbrPlanes = GetDeviceCaps(frmIn.hDC, PLANES)
>         ColorBits = (BitsPerPixel * NbrPlanes)

>       Select Case ColorBits
>         Case 32:   RgnCnt = 256    '16M colors:  8 bits for blue
>         Case 24:   RgnCnt = 256    '16M colors:  8 bits for blue
>         Case 16:   RgnCnt = 256    '64K colors:  5 bits for blue
>         Case 15:   RgnCnt = 32     '32K colors:  5 bits for blue
>         Case 8:    RgnCnt = 64     '256 colors:  64 dithered blues
>         Case 4:    RgnCnt = 64     '16 colors :  64 dithered blues
>         Case Else: ColorBits = 4
>                    RgnCnt = 64     '16 colors assumed: 64 dithered blues
>       End Select



Sun, 20 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

You can use the API call GetDeviceCaps(Form1.hDC, BITSPIXEL) and
GetDeviceCaps(Form1.hDC, PLANES) to get the bits/per plane and planes
values. If you multiply these values you should get the display depth.
If you find a way to distinguish 15-bit from 16-bit displays drop me
a line because these calls always give 16!

Quote:
>  I need to determine the color palette depth a display is running when my
>  program starts up. Does anyone know how this is done?

>  Thanks.

>  John Russell

Robert Chafer
Digital iD Picture Systems



Sun, 20 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

Probably quite right. :)

 This was a routine I found somewhere, so included all for completeness.

--
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/



: Randy --
:
: FYI, AFAIK, GetDeviceCaps will never return 15 bitspixel: it is unable to
: distinguish between 32K and 64K colors (and frankly, so am I <g>).
:
: Jim Deutch
: MS Dev MVP
:


: > Give this routine a try ....
: >
: >       'determine number of color bits supported.
: >         BitsPerPixel = GetDeviceCaps(frmIn.hDC, BITSPIXEL)
: >         NbrPlanes = GetDeviceCaps(frmIn.hDC, PLANES)
: >         ColorBits = (BitsPerPixel * NbrPlanes)
: >    
: >       Select Case ColorBits
: >         Case 32:   RgnCnt = 256    '16M colors:  8 bits for blue
: >         Case 24:   RgnCnt = 256    '16M colors:  8 bits for blue
: >         Case 16:   RgnCnt = 256    '64K colors:  5 bits for blue
: >         Case 15:   RgnCnt = 32     '32K colors:  5 bits for blue
: >         Case 8:    RgnCnt = 64     '256 colors:  64 dithered blues
: >         Case 4:    RgnCnt = 64     '16 colors :  64 dithered blues
: >         Case Else: ColorBits = 4
: >                    RgnCnt = 64     '16 colors assumed: 64 dithered
blues
: >       End Select
:
:



Sun, 20 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

Tim Roberts slapped me silly once for including the "15", and he writes
video drivers, so he should know <g>.

The really funny thing was, a week later, someone from NetQuest (currently
known as Aditi) posted a cut-and-paste of my (since corrected) reply,
including the "15".  Guess he missed the correction.

Jim Deutch



Quote:
> Probably quite right. :)

>  This was a routine I found somewhere, so included all for completeness.

> --
> Randy Birch, MVP Visual Basic



Mon, 21 Feb 2000 03:00:00 GMT  
 Determining Color Pallette Depth

Sorry, I don't know how to tell 15- from 16-bit video.

Jim Deutch
MS Dev MVP

Quote:
> Did you ever find out how to distinguish between 16 and 15-bit, I have
> some code which saves device dependent bitmaps and it is quite
> important. The code just does not work in 15-bit.

> Robert Chafer
> Digital iD Picture Systems




Fri, 25 Feb 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Determining Color Pallette Depth

2. Determining Color Pallette Depth

3. Determining Color Pallette Depth

4. Determine color depth

5. How do I determine the display color depth?

6. How to Determine Color Depth?

7. Determine system color depth?

8. Determining color depth?

9. How to Determine Color Depth?

10. Determining color depth?

11. How to Determine Color Depth?

12. determining display color depth in VB4?

 

 
Powered by phpBB® Forum Software