Fastgraph for Windows FADE program
----------------------------------

The FADE program shows how to perform palette fades with Fastgraph for
Windows. A palette fade is a special effect in which an image's colors
gradually change until they reach a set of target colors. Two similar
variations, fade in and fade out, are the most popular types of palette
fades. The fade in starts with an image displayed with all its logical
palette values set to black, and we gradually increase the logical palette
color components until they reach the image's original colors. The fade out
does just the opposite: we start with the original image and gradually
decrease the logical palette color components until they are all zero. This
results in a completely black image. The files in the FADE distribution are:

   FADE.TXT      this file (ASCII text format)
   FADE.WRI      this file (Windows Write 3.1 format)
   FADE.EXE      16-bit Windows executable
   MOUSE.PCX     PCX image file used to demonstrate palette fades

   FADE.C        C source code
   FADE.PAS      Pascal source code
   FADE.RC       C and Pascal resource script file
   FADE.H        header file referenced in FADE.RC and FADE.C

   FADE.FRM      Visual Basic 4.0 source code
   FADE.VBP      Visual Basic 4.0 project file

   FADE.DPR      Delphi project file
   FADE.RES      Delphi resource file
   FADEU.PAS     Delphi source code unit
   FADEU.FRM     Delphi graphical form file

How the program works: C and Pascal
-----------------------------------

The FADE program demonstrates both the fade in and fade out palette fades
with a 320x200 PCX file. The FadeIn and FadeOut selections on the top-level
menu are mutually exclusive. That is, when one is enabled, the other is
grayed out. After the program's WM_CREATE handler sets up the device context
and default logical palette, it creates a 320x200 virtual buffer and loads
the PCX file into it. We then use fg_getdacs() to retrieve the original image
colors into the original array. Note that we're only interested in the 236
non-system colors (colors 10 to 245).

Clicking on FadeOut activates the IDM_FADEOUT handler, which calls the
do_fadeout() function. This function gradually turns the image to black with
a "fade out" palette fade. It starts by copying the contents of the original
array to the current array. The function then begins a loop that decrements
each nonzero color component in current. Once we've checked all 236
non-system colors, we call fg_setdacs() to update the logical palette with
the color values from the current array. This produces one step of the
palette fade. If we're using a high color or true color display driver, we
call fg_vbscale() to blit the image after each step because these color modes
are not palette-based. We continue this process until all color components
are zero, at which time the image is invisible and the palette fade is done.
Finally, we use EnableMenuItem() to disable the FadeOut menu item and enable
the FadeIn item, and then use DrawMenuBar() so the menu bar reflects these
changes. Note that when the fade out completes, the pixels comprising the
image are not color 0. We've just changed the logical palette colors so all
non-system colors are black.

Clicking on FadeIn activates the IDM_FADEIN handler, which calls the
do_fadein() function to restore the original image colors through a "fade in"
palette fade. It is very similar to the do_fadeout() function, but it starts
by setting all elements in the current array to zero. The loop increments
each color component in current until they've reached their original values,
which are stored in the original array.

How the program works: Delphi
-----------------------------

The FADE program demonstrates both the fade in and fade out palette fades
with a 320x200 PCX file. The FadeIn and FadeOut selections on the top-level
menu are mutually exclusive. That is, when one is enabled, the other is
grayed out. After the program's FormCreate() procedure sets up the device
context and default logical palette, it creates a 320x200 virtual buffer and
loads the PCX file into it. We then use fg_getdacs() to retrieve the original
image colors into the original array. Note that we're only interested in the
236 non-system colors (colors 10 to 245).

Clicking on FadeOut activates the FadeOut() procedure, which calls the
do_fadeout() function. This function gradually turns the image to black with
a "fade out" palette fade. It starts by copying the contents of the original
array to the current array. The function then begins a loop that decrements
each nonzero color component in current. Once we've checked all 236
non-system colors, we call fg_setdacs() to update the logical palette with
the color values from the current array. This produces one step of the
palette fade. If we're using a high color or true color display driver, we
call fg_vbscale() to blit the image after each step because these color modes
are not palette-based. We continue this process until all color components
are zero, at which time the image is invisible and the palette fade is done.
Finally, we disable the FadeOut menu item and enable the FadeIn item. Note
that when the fade out completes, the pixels comprising the image are not
color 0. We've just changed the logical palette colors so all non-system
colors are black.

Clicking on FadeIn activates the FadeIn() procedure, which calls the
do_fadein() function to restore the original image colors through a "fade in"
palette fade. It is very similar to the do_fadeout() function, but it starts
by setting all elements in the current array to zero. The loop increments
each color component in current until they've reached their original values,
which are stored in the original array.

How the program works: Visual Basic
-----------------------------------

The FADE program demonstrates both the fade in and fade out palette fades
with a 320x200 PCX file. The FadeIn and FadeOut selections on the top-level
menu are mutually exclusive. That is, when one is enabled, the other is
grayed out. After the program's FormLoad() function sets up the device
context and default logical palette, it creates a 320x200 virtual buffer and
loads the PCX file into it. We then use fg_getdacs() to retrieve the original
image colors into the original array. Note that we're only interested in the
236 non-system colors (colors 10 to 245).

Clicking on FadeOut activates the mnuFadeOut_Click() function. This function
gradually turns the image to black with a "fade out" palette fade. It starts
by copying the contents of the Original array to the Current array. The
function then begins a loop that decrements each nonzero color component in
Current. Once we've checked all 236 non-system colors, we call fg_setdacs()
to update the logical palette with the color values from the Current array.
This produces one step of the palette fade. If we're using a high color or
true color display driver, we call fg_vbscale() to blit the image after each
step because such color depths are not palette-based. We continue this
process until all color components are zero, at which time the image is
invisible and the palette fade is done. Finally, we disable the FadeOut menu
item and enable the FadeIn item. Note that when the fade out completes, the
pixels comprising the image are not color 0. We've just changed the logical
palette colors so all non-system colors are black.

Clicking on FadeIn activates the mnuFadeIn_Click() function to restore the
original image colors through a "fade in" palette fade. It is very similar to
mnuFadeOut_Click(), but it starts by setting all elements in the Current
array to zero. The loop increments each color component in Current until
they've reached their original values, which are stored in the Original
array.

For more information about Fastgraph for Windows, contact:
----------------------------------------------------------

Ted Gruber Software
P.O. Box 13408
Las Vegas, NV  89112

(702) 735-1980 (voice)
(702) 735-4603 (fax)
(702) 796-7134 (bbs)

email: fastgraph@aol.com
ftp: ftp.accessnv.com\fg\Windows
web: http://www.fastgraph.com
