FLI and FLC Low-Level Functions

Fastgraph's low-level flic functions provide the ability to play flic files one frame at a time. This is desirable when your program must perform other tasks between frames, or for playing two or more flic files at the same time. To use the low-level flic functions, call fg_flicopen() for each flic file. The first fg_flicopen() parameter is the flic file name. The second parameter is a 16-byte array that will receive a context descriptor for the flic file. You must create a context descriptor with fg_flicopen() for each flic file you'll access with the low-level flic file functions. The context descriptor is then passed to other functions when accessing the flic file. If successful, fg_flicopen() fills the context descriptor, positions the flic file at the first frame, and returns zero. The possible error return values are -1 (file not found) and -2 (file is not an FLI or FLC file).

The fg_flicplay() function plays one or more frames from a flic file and leaves the file positioned at the beginning of the next frame. Its three parameters are the same as for fg_showflic() except the first parameter is a context descriptor instead of a flic file name. The fg_flicskip() function advances over flic file frames. Its first parameter is the flic file's context descriptor, and its second parameter is the number of frames to skip (if the frame count is negative, the file position is reset to the first frame). Both functions return the number of frames played (or skipped), which may be less than the number of frames requested if the end-of-file is reached. The last low-level flic function, fg_flicdone(), closes a flic file previously opened with fg_flicopen(). Its only parameter is the flic file's context descriptor.

The following code shows how to play the flic file GLASS.FLI one frame at a time using the low-level flic functions. We first open the flic file with fg_flicopen(), which returns a 16-byte context descriptor for the file. If the file was opened successfully, we play each frame by calling fg_flicplay() in a loop. This itself does not actually display the frames but plays them in the active virtual buffer, so after each frame we call fg_vbscale() to display it in the client area. Eventually we'll reach the end-of-file, indicated by an fg_flicplay() return value of zero. When this occurs, we call fg_flicdone().

C/C++:

int Frames, Status;
char Context[16];
Status = fg_flicopen("GLASS.FLI",Context);
if (Status == 0)
{
   do
   {
      Frames = fg_flicplay(Context,1,0);
      if (Frames > 0)
         fg_vbscale(0,fg_getmaxx(),0,fg_getmaxy(),
                    0,cxClient-1,0,cyClient-1);
   }
   while (Frames > 0);
   fg_flicdone(Context);
}

Delphi:

var
  Frames, Status : integer;
  Context : array [1..16] of byte;
begin
  Status := fg_flicopen('GLASS.FLI'+chr(0),Context);
  if Status = 0 then
  repeat
    begin
      Frames := fg_flicplay(Context,1,0);
      if Frames > 0 then
        fg_vbscale(0,fg_getmaxx,0,fg_getmaxy,
                   0,cxClient-1,0,cyClient-1);
    end;
  until Frames = 0;
  fg_flicdone(Context);

Visual Basic:

Dim Frames As Long, Status As Long
Dim Context(16) As Byte
Status = fg_flicopen("GLASS.FLI", Context(0))
If Status = 0 Then
   Do
      Frames = fg_flicplay(Context(0), 1, 0)
      If Frames > 0 Then
         Call fg_vbscale(0, fg_getmaxx(), 0, fg_getmaxy(),
                         0, cxClient - 1, 0, cyClient - 1)
      End If
   Loop While Frames > 0
   Call fg_flicdone(Context(0))
End If

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.