256-Color Virtual Buffers

Fastgraph's default virtual buffer color depth is 256 colors. Each pixel in a 256-color virtual buffer can assume a value between 0 and 255. These pixel values serve as indices into a data structure called a logical palette. The logical palette entries and the Windows palette manager ultimately determine the actual colors displayed when copying pixels from a virtual buffer to a window's client area. For instance, if a logical palette defines color 24 to be yellow, pixels whose value is 24 will be displayed as yellow. If you're familiar with using 256-color graphics modes in DOS, it might be helpful to think of a logical palette as the Windows equivalent of the VGA or SVGA video DAC registers. 256-color virtual buffers are often designated 8bpp (8 bits per pixel).

When fg_vbpaste() or fg_vbscale() blits a virtual buffer to the window's client area, two things occur. First, of course, is copying or scaling the virtual buffer contents to the requested position in the client area. Second, and less obvious, is the interfacing with the Windows palette manager that determines the colors in which the blitted pixels are displayed.

Each 256-color virtual buffer includes its own independent 256-color palette that defines the RGB components for that virtual buffer. If the virtual buffer palette exactly matches the colors in the active logical palette, there is much less for the palette manager to do, which translates to better performance during blitting. To associate the active logical palette's colors with the active virtual buffer, call fg_vbcolors() after opening a 256-color virtual buffer for the first time, as shown here.

C/C++:

fg_vbopen(hVB);
fg_vbcolors();

Delphi:

fg_vbopen(hVB);
fg_vbcolors;

Visual Basic:

Call fg_vbopen(hVB)
Call fg_vbcolors

Note that you don't need to call fg_vbcolors() every time you open a 256-color virtual buffer, just the first time. In addition, a logical palette must be active (that is, created and realized) when calling fg_vbcolors(). It is not necessary to use fg_vbcolors() with high color and true color virtual buffers.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.