Direct Color Virtual Buffers

When a high color virtual buffer is active, fg_setcolorrgb() translates its three 8-bit RGB color components to their equivalent 16-bit encoded color value and then sets the current color to that value. The fg_maprgb() function performs this same translation and returns the encoded color as its function value. It does not update the current color, but passing its return value to fg_setcolor() will do so. The following sets of calls each show three different ways of defining the same color for high color virtual buffers:

C/C++:

fg_setcolorrgb(0,0,0);
fg_setcolor(fg_maprgb(0,0,0));
fg_setcolor(0);
fg_setcolorrgb(255,255,255);
fg_setcolor(fg_maprgb(255,255,255));
fg_setcolor(0xFFFF);
fg_setcolorrgb(0,0,255);
fg_setcolor(fg_maprgb(0,0,255));
fg_setcolor(31);

Delphi:

fg_setcolorrgb(0,0,0);
fg_setcolor(fg_maprgb(0,0,0));
fg_setcolor(0);
fg_setcolorrgb(255,255,255);
fg_setcolor(fg_maprgb(255,255,255));
fg_setcolor($FFFF);
fg_setcolorrgb(0,0,255);
fg_setcolor(fg_maprgb(0,0,255));
fg_setcolor(31);

Visual Basic:

Call fg_setcolorrgb(0, 0, 0)
Call fg_setcolor(fg_maprgb(0, 0, 0))
Call fg_setcolor(0)
Call fg_setcolorrgb(255, 255, 255)
Call fg_setcolor(fg_maprgb(255, 255, 255))
Call fg_setcolor(&HFFFF)
Call fg_setcolorrgb(0, 0, 255)
Call fg_setcolor(fg_maprgb(0, 0, 255))
Call fg_setcolor(31)

When a true color virtual buffer is active, fg_setcolorrgb() translates its three 8-bit RGB color components to their equivalent 32-bit xRGB encoded color value and then sets the current color to that value. The fg_maprgb() function performs this same translation and returns the encoded color as its function value. It does not update the current color, but passing its return value to fg_setcolor() will do so (by default, the high-order byte will be zero, so you can use the xRGB color value with both 24-bit and 32-bit true color virtual buffers). The following sets of calls each show three different ways of defining the same color for true color virtual buffers:

C/C++:

fg_setcolorrgb(0,0,0);
fg_setcolor(fg_maprgb(0,0,0));
fg_setcolor(0);
fg_setcolorrgb(255,0,127);
fg_setcolor(fg_maprgb(255,0,127));
fg_setcolor(0xFF007F);
fg_setcolorrgb(0,0,255);
fg_setcolor(fg_maprgb(0,0,255));
fg_setcolor(255);

Delphi:

fg_setcolorrgb(0,0,0);
fg_setcolor(fg_maprgb(0,0,0));
fg_setcolor(0);
fg_setcolorrgb(255,0,127);
fg_setcolor(fg_maprgb(255,0,127));
fg_setcolor($FF007F);
fg_setcolorrgb(0,0,255);
fg_setcolor(fg_maprgb(0,0,255));
fg_setcolor(255);

Visual Basic:

Call fg_setcolorrgb(0, 0, 0)
Call fg_setcolor(fg_maprgb(0, 0, 0))
Call fg_setcolor(0)
Call fg_setcolorrgb(255, 0, 127)
Call fg_setcolor(fg_maprgb(255, 0, 127))
Call fg_setcolor(&HFF007F)
Call fg_setcolorrgb(0, 0, 255)
Call fg_setcolor(fg_maprgb(0, 0, 255))
Call fg_setcolor(255)

Note that direct color virtual buffers always use RGB values between 0 and 255, whether we're using a high color or a true color buffer. Increasing RGB values produce more intense colors.

The fg_unmaprgb() function provides the inverse capability of fg_maprgb(): it extracts the individual RGB components from an encoded color value. The first fg_unmaprgb() parameter is the color value, encoded in the 5/6/5 or 5/5/5 format for high color virtual buffers, or the xRGB format for true color virtual buffers. The remaining three parameters, passed by reference, respectively receive the red, green, and blue color components. Each RGB component will be between 0 and 255. The fg_unmaprgb() function is meaningful only for direct color virtual buffers.

The fg_getcolor() function returns the current color, as defined in the most recent call to fg_setcolorrgb() or fg_setcolor(). It has no parameters and returns the current color as its function value. The fg_getcolor() return value is encoded in the 5/6/5 or 5/5/5 format for high color virtual buffers, or the xRGB format for true color virtual buffers.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.