Image: Menu ItemsThe BMP|Open handler first obtains a file name through the Open File dialog box. If successful, we call fg_bmphead() to read the BMP file header and verify that the file really is a BMP file. If not, we display a message box and return. If we get this far, then we do have a BMP file, so we call fg_bmppal() to determine the number of colors in the BMP image, storing the result in the global variable nColors. Next we call fg_bmpsize() to get the BMP image width and height, storing these values in the global variables cxBuffer and cyBuffer. We then call SwitchBuffers() to release the current virtual buffer and create a new virtual buffer with dimensions equal to those of the BMP file we're loading. Next, fg_showbmp() loads the BMP file into the virtual buffer, and fg_vbscale() makes it visible in the client area. Finally, we enable the remaining items on the BMP menu and disable all items on the other menus except Open and Make. The BMP|Make handler obtains the name of the BMP file to create through a Save File dialog box. If successful, we call fg_makebmp() to create a BMP file with the same color depth as the original image. The BMP|Details handler displays the image dimensions and color depth in a message box, using the values obtained during BMP|Open processing. The PCX|Open handler is very similar to the BMP|Open handler. Note that we specify the FG_AT_XY flag in the fg_showpcx() flags parameter. This overrides the image positioning information in the PCX header, which might specify a position other than (0,0). The PCX|Make handler obtains the name of the PCX file to create through a Save File dialog box. If successful, we call fg_makepcx() to create a 256-color PCX file if the original image was palette-based, or a 24-bit PCX file if the original image was a direct color image. The PCX|Details handler displays the image dimensions and color depth in a message box, using the values obtained during PCX|Open processing. The JPEG|Open handler first obtains a file name through the Open File dialog box. If successful, we call fg_jpeghead() to read the JPEG file header and verify that the file really is a baseline JPEG file. If not, we display a message box and return. If we get this far, then we do have a baseline JPEG file, so we set the nColors global to zero (because JPEG files are always direct color images). We then call fg_jpegsize() to obtain the image dimensions and SwitchBuffers() to perform the required virtual buffer setup. Next, we call fg_showjpeg() to load the JPEG file into the virtual buffer, and then call fg_vbscale() to display the image in the client area. Finally, we enable the Details item on the JPEG menu and disable all items on the other menus except Open and Make. The JPEG|Details handler displays information about the JPEG file, using values obtained during the JPEG|Open processing. Because JPEG files are always direct color images, we always display the image color depth as 24-bit RGB. The FLI/FLC|Open handler first obtains the name of an FLI or FLC file and then calls fg_flichead() to read the flic file header. After making sure we have indeed selected a flic file, we set the nColors global to 256 (because flic files are always 256-color images) and call fg_flicsize() to obtain the image dimensions. The SwitchBuffers() function then performs the virtual buffer setup. We then call fg_flicopen() to set up the 16-byte context descriptor for the low-level flic file functions, fg_flicplay() to load the first frame into the virtual buffer, and fg_vbscale() to make it visible in the client area. Next, we extract the frame count from offsets 6 and 7 in the flic file header. Finally, we enable the remaining items in the FLI/FLC menu and disable the Details items in the other menus. The FLI/FLC|Play handler plays the flic file continuously with fg_showflic(). The flic file plays until the Escape key is pressed. After this, we call fg_flicskip() with a negative frame count to rewind the flic file, so the next call to fg_flicplay() will start with the first frame. The FLI/FLC|Frame handler calls fg_flicplay() to play the next frame from the flic file. If fg_flicplay() returns a zero frame count, we've reached the end of file, so we rewind the flic file and again call fg_flicplay() to replay the first frame. In any case, we then call fg_vbscale() to make the frame visible in the client area. The FLI/FLC|Reset handler calls fg_flicskip() with a negative frame count to rewind the flic file, and then calls fg_flicplay() to play the first frame. As usual, fg_vbscale() makes the first frame visible. The FLI/FLC|Details handler displays information about the flic file, using values obtained during the FLI/FLC|Open processing. Because flic files always contain 256 colors, we instead display the frame count, which is a more meaningful metric than the color depth for flic files. The AVI|Open handler first obtains a file name through the Open File dialog box. If successful, we call fg_avihead() to read the AVI file header and verify that the file really is an AVI file. If not, we display a message box and return. If we get this far, then we do have an AVI file, so we call fg_avipal() to determine the number of colors in the AVI image, storing the result in the global variable nColors. Next we call fg_avisize() to obtain the image dimensions. The SwitchBuffers() function then performs the virtual buffer setup. We then call fg_aviopen() to set up the 48-byte context descriptor for the low-level AVI functions. If successful, we call fg_aviplay() to load the first frame into the virtual buffer, and fg_vbscale() to make it visible in the client area. Finally, we enable the remaining items in the AVI menu and disable the Details items in the other menus. The AVI|Play handler plays the AVI file continuously with fg_showavi(). The AVI file plays until the Escape key is pressed. After this, we call fg_aviskip() with a negative frame count to rewind the AVI file, so the next call to fg_aviplay() will start with the first frame. The AVI|Frame handler calls fg_aviplay() to play the next frame from the AVI file. If fg_aviplay() returns a zero frame count, we've reached the end of file, so we rewind the AVI file and again call fg_aviplay() to replay the first frame. In any case, we then call fg_vbscale() to make the frame visible in the client area. The AVI|Reset handler calls fg_aviskip() with a negative frame count to rewind the AVI file, and then calls fg_aviplay() to play the first frame. As usual, fg_vbscale() makes the first frame visible. The AVI|Details handler displays information about the AVI file, using values obtained during the AVI|Open processing.
|
 
copyright 2001 Ted Gruber Software, Inc.