PCX Display

The fg_showpcx() function displays an image stored in a PCX file. It can position the image using the coordinate information in the PCX header, or such that its upper left corner is at the graphics cursor position in the active virtual buffer. The first fg_showpcx() parameter is the name of the PCX 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.




If specified, display the image relative to the current graphics position. If not, display the image at the position indicated in PCX header.


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


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


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 PCX files.

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

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




fg_showpcx('MOUSE.PCX'+chr(0),FG_AT_XY or FG_KEEPCOLORS);

Visual Basic:

Call fg_move(16, 16)
Call fg_showpcx(App.Path & "\MOUSE.PCX", FG_AT_XY + FG_KEEPCOLORS)

In Visual Basic, prefixing the file name string with the App.Path property makes fg_showpcx() look for the file in the directory where the application's project (VBP) file resides when running the application from Visual Basic's development environment, or from the directory where the EXE file resides when running the application as an executable. If we don't do this, Visual Basic programs will look in the Visual Basic directory when running from the development environment. The PowerBASIC versions of the Fastgraph examples that require this capability include an AppPath() function that behaves the same way.

<< Prev

Next >>

Fastgraph Home Page


copyright 2001 Ted Gruber Software, Inc.