BMP Display

The fg_showbmp() function displays an image stored in a BMP file. It can display an image such that its upper left corner is either at (0,0), or at the graphics cursor position in the active virtual buffer. The first fg_showbmp() parameter is the name of the BMP file (it may include a path name). The file name must be terminated with a null character, so Delphi programmers will need to store a zero byte as the last character of the file name string. The second parameter is a series of flags that controls how the image is displayed. The following table summarizes these flags.

Flag

Meaning

FG_AT_XY

If specified, display the image relative to the current graphics position. If not, display the image relative to (0,0).

FG_IGNOREPALETTE

If specified, display the image using the current palette. If not, use the palette values stored in the BMP file. Not meaningful for 24-bit BMP files.

FG_FROMBUFFER

If specified, get the image data from the fg_imagebuf() buffer. If not, get the image data from the BMP file.

FG_KEEPCOLORS

If specified, disable color reduction and remapping. If not, enable color reduction and remapping to avoid using the Windows system colors. Not meaningful for 24-bit BMP files.

The fg_showbmp() function returns 0 if successful, 1 if the specified file wasn't found, 2 if the file is not a BMP file, 3 if the BMP color depth is not compatible with the active virtual buffer's color depth, 4 if the BMP file is an unsupported RLE (compressed) BMP file, and 5 if there was an error allocating memory. The incompatible color depth error occurs when you try to display a 24-bit BMP file in a 256-color virtual buffer.

For example, the code shown here will display the file LEAVES.BMP with its upper left corner at the screen space position (16,16) in the active virtual buffer, using the palette values stored in the BMP file, and with automatic color reduction disabled:

C/C++:

fg_move(16,16);
fg_showbmp("LEAVES.BMP",FG_AT_XY | FG_KEEPCOLORS);

Delphi:

fg_move(16,16);
fg_showbmp('LEAVES.BMP'+chr(0),FG_AT_XY or FG_KEEPCOLORS);

Visual Basic:

Call fg_move(16, 16)
Call fg_showbmp(App.Path & "\LEAVES.BMP", FG_AT_XY+FG_KEEPCOLORS)

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.