# $ K +Example: High Color Fish Tank

By today's standards, the artwork in the Fastgraph fish tank is rather primitive. The FishHC example is an improved version of the fish tank that uses a 640x480 high color virtual buffer. Unlike the 256-color version of the fish tank, the fish sprites in FishHC animate within themselves by moving their tails and fins. In addition, FishHC adds a water wheel (implemented as a flic file) and a translucent bubble (implemented as a direct color bitmap).

The FishHC program is also a good example of how to mix objects of different color depths in Fastgraph programs. FishHC uses high color virtual buffers, but it uses true color (24-bit) and palette-based (256-color) image files. The background is a 24-bit JPEG image, which fg_showjpeg() automatically reduces to the high color format. The fish sprites are stored in 256-color PCX files, each with a different palette, but are retrieved and displayed as direct color bitmaps. The water wheel is a 256-color FLC file that has a different palette than the PCX files.

Using a high color virtual buffer eliminates the need for the 256-color image files to have the same palette. It also lets us use the Windows system colors in the image files. The only concern is the order in which we load the images. Recall that whenever we display a 256-color image file in a direct color virtual buffer, Fastgraph updates the virtual palette with the color information stored in the image file. When we load each PCX file that contains a fish sprite, fg_showpcx() modifies the virtual palette. If we load the water wheel FLC file last, the virtual palette will always contain the water wheel's color values, so its colors will automatically be correct when we play the individual FLC frames. If we really did need to load the PCX files last, we could instead read the virtual palette values with fg_getdacs() after playing the first frame of the FLC file, then use fg_setdacs() to set the virtual palette to the FLC colors after the loading the last PCX.

Source code for FishHC will not be presented here, but its C source code is included in the FishHC subdirectory of the Fastgraph examples directory.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.