Displaying Direct Color Bitmaps

Fastgraph includes several functions for displaying direct color bitmaps; they are very similar to the functions for displaying 256-color bitmaps. When using a high color virtual buffer, these functions expect the bitmap to be a series of two-byte pixels, with each byte encoded in the 5/6/5 RGB format (some DirectX implementations use a 5/5/5 RGB high color format). For true color virtual buffers, they expect the bitmap to be a series of three-byte RGB values, stored blue byte first, then green byte, then red.

The fg_drawdcb() function displays regular direct color bitmaps (by regular, we mean a bitmap that is neither clipped nor reversed). Its first parameter is the name of the bitmap array, the second is the bitmap width in pixels, and the last is the bitmap height in pixels. The fg_drawdcb() function displays the bitmap with its lower left corner at the graphics cursor position.

Suppose we want to display the 9x5 triangle bitmap in the middle of a 640x480 virtual buffer. To do this, its lower left corner must be at the screen space position (316,241). The following code does the trick:

C/C++ and Delphi:

fg_move(316,241);
fg_drawdcb(triangle,9,5);

Visual Basic:

Call fg_move(316, 241)
Call fg_drawdcb(triangle(0), 9, 5)

The fg_drawdcb() function does not perform clipping when displaying a direct color bitmap. If you want the bitmap to be constrained by the clipping limits, use fg_clipdcb() instead of fg_drawdcb(). The fg_clipdcb() function takes the same three parameters as fg_drawdcb() and also displays the bitmap with its lower left corner at the graphics cursor position.

When using fg_clipdcb(), you may establish a graphics position beyond the virtual buffer extents, including negative coordinates (recall that the clipping limits default to the virtual buffer extents). For example, we could display our direct color triangle bitmap four pixels beyond the active virtual buffer's left edge with these calls:

C/C++ and Delphi:

fg_move(-4,50);
fg_clipdcb(triangle,9,5);

Visual Basic:

Call fg_move(-4, 50)
Call fg_clipdcb(triangle(0), 9, 5)

In this case, only the rightmost five pixels of each bitmap row would be displayed.

The fg_revdcb() function displays a direct color bitmap reversed (that is, mirrored about the y axis) without clipping. It takes the same three parameters as fg_drawdcb() and also displays the bitmap with its lower left corner at the graphics cursor position.

The fg_flipdcb() function combines the effects of fg_revdcb() and fg_clipdcb(). It displays a reversed direct color bitmap constrained by the current clipping limits. It takes the same three parameters as fg_drawdcb() and also displays the bitmap with its lower left corner at the graphics cursor position.

The fg_putdcb() function is the same as fg_drawdcb() except it does not consider zero-value pixels to be transparent. Because it does not need to check for transparent pixels, fg_putdcb() is faster than fg_drawdcb(). Using fg_putdcb() is recommended for cases where transparency is not an issue.

Sometimes you may need to include black pixels in a direct color bitmap. The easiest way to do this is with fg_putdcb(), but that includes no provision for transparent pixels. Suppose, for example, that you want to display a bitmap containing both black pixels and transparent pixels. The easiest solution is to use an RGB value that is almost zero but will still appear black when displayed. For high color bitmaps, we recommend 0821 hex for black pixels (0821 hex has the low-order bit set for each color component in a 5/6/5 encoded RGB value). For true color bitmaps, use the three bytes 01,01,01 to represent a black pixel.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.