Главная страница | назад





Article #15741: How many colors will my display mode support

 Question and Answer Database

FAQ741D.txt   How many colors will my display mode support
Category   :Windows API
Platform    :All
Product    :All 32 bit  

Question:
How do I find the number of colors the current display mode
supports?



Answer:
You can find the color depth of a display context in the following
manner:

GetDeviceCaps(Form1.Canvas.Handle, BITSPIXEL) *
GetDeviceCaps(Form1.Canvas.Handle, PLANES)

Will give you the total number of bits used to color a pixel. possible
Return values of:

1 = 2 colors bpp
4 = 16 colors bpp
8 = 256 colors bpp
15 = 32768 colors (will return 16 on most drivers) bpp
16 = 65535 colors bpp
24 = 16,777,216 colors bpp
32 = 16,777,216 colors (same as 24) bpp

You can use:

NumberOfColors := (1 shl
   (GetDeviceCaps(Form1.Canvas.Handle, BITSPIXEL) *
    GetDeviceCaps(Form1.Canvas.Handle, PLANES));

 to calculate the total number of colors.



7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99