[comp.windows.ms.programmer] WinApps detecting 24-bit Video Drivers

bert@helix.nih.gov (Bert Tyler) (11/05/90)

How should a WinApp check for the presence of a 24-bit (IE, > 256 colors)
video driver?

When I wrote WINFRACT, I had access to a 16-color driver (vanilla VGA)
and a 256-color driver (the 8514/A), and didn't consider 24-bit video
drivers at all.  Now I'm getting a little concerned that the program
won't act correctly if it finds itself on a 256-color driver.

Given that WINFRACT is, for other reasons, pretty much limited to the
256-color world at the moment, I would like it to treat a 24-bit video
driver just like a 256-color driver (I'm assuming that Windows will
automatically handle the fact that *my* 256 colors can be different
from the *other guy's* 256 colors).

So, anyway, what is going to happen to the current detection logic
(copied below) if it finds itself on a 24-bit video driver?  What
should I be doing differently?

(At the moment, 'iNumColors' and 'colors' are both declared 'int').

---------------------------

    hDC = GetDC(NULL);
    iPalSize    = GetDeviceCaps (hDC, SIZEPALETTE);
    iRasterCaps = GetDeviceCaps (hDC, RASTERCAPS);
    iRasterCaps = (iRasterCaps & RC_PALETTE) ? TRUE : FALSE;
    if (iRasterCaps)
       iNumColors = GetDeviceCaps(hDC, SIZEPALETTE);
    else
       iNumColors = GetDeviceCaps(hDC, NUMCOLORS);
    ReleaseDC(NULL,hDC);

    colors = iNumColors;
    if (colors != 2 && colors != 16 && colors != 256) {
        /* NOTE:  the next two statements were *reversed* in the
        public versions of WINFRACT - oops */
        if (colors > 16) colors = 256;
        if (colors > 2) colors = 16;
        }

chrisg@microsoft.UUCP (Chris GUZAK) (11/07/90)

In article <599@nih-csl.nih.gov> bert@helix.nih.gov (Bert Tyler) writes:
>How should a WinApp check for the presence of a 24-bit (IE, > 256 colors)
>video driver?

24 bit and 16 bit displays will return -1 for NUMCOLORS (since
GetDeviceCaps() only returns 16 bits.  You can also check
NUMPLANES * BITSPIXEL > 8 also indicates a > 256 color device.

Palettes will be mapped to nearest colors on these devices so
you will get what you expect.

People should be careful with the returns from NUMPLANES and
BITSPIXEL.  Improper use of these parameters are almost always
the cause of regular windows programs not running on 24 bit
displays.

Chris Guzak