Virtual Buffer Color Depth

Fastgraph supports virtual buffer color depths of 8 bits per pixel (256 colors, or palette-based), 16 bits per pixel (64K colors, or high color) and 24 and 32 bits per pixel (16.7 million colors, or true color). This section will discuss each color depth in detail. High color and true color virtual buffers are collectively called direct color virtual buffers.

For compatibility with earlier versions of Fastgraph for Windows, virtual buffers default to 256 colors, but you can change this behavior with the fg_vbdepth() function. It accepts a single integer parameter that defines the default virtual buffer color depth; it must be 8, 16, 24, or 32. For example, in the code snippet


hVB1 = fg_vballoc(width1,height1);
hVB2 = fg_vballoc(width2,height2);


hVB1 := fg_vballoc(width1,height1);
hVB2 := fg_vballoc(width2,height2);

Visual Basic:

Call fg_vbinit
hVB1 = fg_vballoc(width1, height1)
Call fg_vbdepth(16)
hVB2 = fg_vballoc(width2, height2)

the first virtual buffer will be a 256-color virtual buffer, and the second virtual buffer will be a high color (16-bit) virtual buffer. The color depth defined with fg_vbdepth() remains in effect until you call fg_vbdepth() or fg_vbinit() again. You can use virtual buffers of different color depths in the same program, but if you copy data between virtual buffers, the color depths of the source and destination virtual buffers must be the same.

The fg_getdepth() function returns the color depth of the active virtual buffer. It returns the color depth in bits per pixel, which is of course the number of bits needed to store one pixel in the virtual buffer. If we need to know how many different colors the active virtual buffer supports, we can calculate this as 2n, where n is the color depth returned by fg_getdepth().

<< Prev

Next >>

Fastgraph Home Page


copyright 2001 Ted Gruber Software, Inc.