BMP Helper FunctionsThere are three additional functions that work with BMP files. The fg_bmppal() function retrieves the palette of a BMP image. Its first parameter is a BMP file name, terminated by a zero byte as with fg_showbmp(). Its second parameter is the name of the array that will receive the BMP palette values. The palette values are returned as RGB color components, each between 0 and 255. The first three bytes of this array will contain the RGB values for color 0, the next three for color 1, and so forth. The array size in bytes must be at least three times the number of colors in the BMP image. If successful, the fg_bmppal() function return value is the number of colors in the BMP palette (usually 2, 16, or 256), or 0 if the BMP file does not contain a palette (this will be the case for 24-bit BMP files). The possible error return values are -1 (file not found) and -2 (file is not a BMP file). You can also specify NULL for the second fg_bmppal() parameter (pass nil^ for Delphi, ByVal 0 for Visual Basic, or BYVAL %NULL for PowerBASIC). In this case, the function will return the image's color depth but no palette values. The fg_bmphead() function retrieves a BMP file header. The first fg_bmphead() parameter is the name of a BMP file (terminated by a zero byte), and the second is the name of a buffer that will receive the BMP header (the buffer size must be at least 54 bytes). If successful, fg_bmphead() returns zero. Otherwise, the return value is -1 if the specified file was not found, or -2 if it is not a BMP file. The fg_bmpsize() function returns the width and height of a BMP image. Its first parameter is the name of a buffer containing the BMP file header returned by fg_bmphead(), and its second and third parameters receive the image width and height in pixels. If the BMP file header is not valid, fg_bmpsize() returns -1 for the width and height parameters.
|
 
copyright 2001 Ted Gruber Software, Inc.