3198:Finding the color depth of a canvas
KEYWORDS: Canvas, colors, depth, image, DeviceCaps AREA: Application Interop
When programming graphics in Windows, it it often desirable
to know the number of colors available for a given canvas.
This information is available through the GetDeviceCaps()
functon.
The color depth of a canvas is calculated by multiplying
the number of bits per pixel that is required for a
given canvas by the number of planes the canvas uses.
You can find the color depth of a canvas in by using the
following code:
TotalNumBitsPerPixel :=
GetDeviceCaps(Canvas.Handle, BITSPIXEL) *
GetDeviceCaps(Canvas.Handle, PLANES)
Will give you the total number of bits used to color a pixel.
Return values of:
1 = 2 colors (monochrome)
4 = 16 colors
8 = 256 colors
15 = 32,768 colors
16 = 65,536 colors
24 = 16,777,216 colors
TI