Displaying Images from FGI Libraries

The ability to display images stored in library files is the primary purpose of Fastgraph/Image. The process of using an FGI library within a program involves opening the library, displaying the desired images from the library, and finally closing the library. This section will discuss the Fastgraph/Image functions that perform these tasks.

Each Fastgraph/Image example program presented in the help file uses an FGI library named EXAMPLE.FGI (the Fastgraph/Image SETUP program places EXAMPLE.FGI in the each Examples subdirectory). This library contains these seven files:

CLOUDS.PCX

320x200 256-color PCX image of sky and clouds

CORAL.BMP

320x200 256-color BMP image of a coral reef

FISH.MAP

56x30 256-color bitmap of a fish, suitable for fg_drwimage()

BRODWY18.FGF

Broadway 18 font file from Fastgraph/Fonts

GLASS.FLI

320x200 flic file of a magnifying glass in motion

AQUARIUM.JPG

640x480 JPEG image of an aquarium background

CLOCK.AVI

148x148 24-bit AVI file of a clock face with moving hands

The fgi_open() function opens an FGI library. Its only parameter is the name of the FGI library file, terminated by a null character (that is, a zero byte). The function's return value is a file handle that you use to reference the FGI library in later operations. If the return value is zero, it means fgi_open() could not open the specified FGI library. To close an FGI library, pass the file handle to fgi_close().

Once you've opened an FGI library, you can use fgi_display() to display images stored in the library. The fgi_display() function's first parameter is the name of the image to display, terminated by a null character. This is the same name specified on the FGILIB command line when the image was added to the library. Its second parameter is a series of flags identical to those passed to Fastgraph's corresponding image display functions. The final parameter is the file handle for the FGI library containing the specified image, as returned by fgi_open().

The fgi_display() function's return value is zero if the image display was successful. If the return value is -1, an error occurred while reading the FGI file (probably because the file handle was not valid). A return value of -2 means the image file was not found in the library associated with the specified handle, while -3 indicates the image file is not a supported image type.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.