Documentation for iff.library Software written and distributed by: Robert W. Albrecht Jr. 1457 Zion Way Ventura, CA 93003 iff.library Version 1.3 (public domain) This is crippled version of "iff.library" that can be used by your C program to load IFF images. If you want the full featured version of iff.library send $20 to the above address with your name and address. This software is in the public domain and may not be sold or distributed with commercial software. Version 2 of iff.library may be distributed with commercial software with no royalties for the $20 license fee. Two Example Programs Included Both of the programs have the same command syntax and they must be executed from the CLI: ??? ShoPict displays almost any IFF image on a custom screen by loading the IFF image directly into the BitMap of the custom screen. ShoPict will now print the currently loaded picture if you press the 'P' key. ShoPict was modified to handle over scan pictures. ShoImg allocates and loads an Image structure from an IFF file and displays it on the screen. Iff.library does the memory managment. Setting up to use iff.library Iff.library is accessed through a set of assembly language connection routines. The assembly source to these routines is provided in the file "iff.asm". You will need to assemble iff.asm unless you have Aztec C 3.6A (or compatable) for which there is a ".o" file. Once iff.asm is assembled you will have to link it with your program. You will also have to copy iff.library to the libs: directory on your system disk. There is now an Amiga.lib compatable iff.o called iff.ami. In your program you will have to: 1) Include the proper header file. #include "ifflib.h" 2) Declare a global library base pointer; void *IFFBase; 3) Open iff.library. if( !(IFFBase = OpenLibrary(IFFNAME,1L)) ) /* abort */ Now you are ready to call the functions in iff.library. Description of Functions ------------------------------------------------------------------ name: IFFalloc synopsis: void *IFFalloc(size,type) long size; unsigned short type; function: Allocates and clears a block of memory using the Amiga AllocMem function. The size of the block is saved so your program doesn't have to remember it. arguments: size - The requested size of the block of memory, four extra bytes will be added to store the size of the block. type - The type of Amiga memory you want to allocate; CHIP for "CHIP" memory, FAST for "FAST" memory, and DONTCARE if you don't care what type you allocate. Note: Graphic images need to be in CHIP memory. return: NULL (0L) is returned if the block can't be allocated, otherwise a pointer to the allocated block is returned. see also: IFFfree --------------------------------------------------------------------- name: IFFfree synopsis: void IFFfree(ptr) function: Frees memory allocated by IFFalloc. argument: ptr - a pointer to a block of memory obtained from IFFalloc. return: None note: IFFfree is used to free the colors obtained from GetIFF_image or GetIFF_bitmap. see also: IFFalloc --------------------------------------------------------------------- name: GetIFF_bitmap synopsis: short GetIFF_bitmap(name,bmap,colors,ncolors,allocate) char *name; struct BitMap **bmap; unsigned short **colors; unsigned short *ncolors; unsigned short allocate; function: To load and optionally allocate a BitMap and colors from an IFF file. arguments: name - A null terminated string containing the name of the iff IFF file to load. bmap - A pointer to a pointer to a BitMap structure. If you decide let this function allocate the structure the pointer will be set to the newly allocated BitMap. colors - A pointer to an array of color values, one for each color. The colors are organized in the native Amiga format (RGB 4 bits per gun right justified). If you decide to let this function allocate the colors the pointer will be set to the newly allocated block. ncolors - A pointer to a variable that will be set to the number of colors in the IFF file. allocate - Set to ALLOC if you want the colors and BitMap allocated by this function. Otherwise set to NOALLOC. return: Zero is returned if the operation was successful, otherwise one of the error codes in ifflib.h is returned. see also: RlsBitMap IFFfree note: The BitMap structure is defined in graphics/gfx.h --------------------------------------------------------------------- name: GetIFF_image synopsis: short GetIFF_image(name,image,colors,ncolors,allocate) char *name; struct Image **image; unsigned short **colors; unsigned short *ncolors; unsigned short allocate; function: To load and optionally allocate a Image and colors from an IFF file. arguments: name - A null terminated string containing the name of the iff IFF file to load. image - A pointer to a pointer to an Image structure. If you decide let this function allocate the structure the pointer will be set to the newly allocated Image. colors - A pointer to an array of color values, one for each color. The colors are organized in the native Amiga format (RGB 4 bits per gun right justified). If you decide to let this function allocate the colors the pointer will be set to the newly allocated block. ncolors - A pointer to a variable that will be set to the number of colors in the IFF file. allocate - Set to ALLOC if you want the colors and Image allocated by this function. Otherwise set to NOALLOC. return: Zero is returned if the operation was successful, otherwise one of the error codes in ifflib.h is returned. see also: RlsImage IFFfree note: The Image structure is defined in intuition/intuition.h --------------------------------------------------------------------- name: QueryIFF synopsis: short QueryIFF(name,bmHdr) char *name; BitMapHeader *bmHdr; function: To retrieve information about a image in a IFF file. arguments: name - A null terminated string containing the name of an IFF file. bmHdr - A pointer to a BitMapHeader structure. When this function returns the BitMapHeader will be filled with the information about the image in the IFF file. In order to get the original screen ViewModes from the IFF file, if this information is there in the form of a CAMG chunk, you must set the bmHdr.viewmodes = GETVIEWMODES. If bmHdr.viewmodes field is changed after the call then the ViewModes were obtained from the IFF file. You should never assume that the ViewModes can be obtained from the file because this feature was not supported prior to V1.3 of IFF.library. Also most IFF files don't contain this information. return: Zero is returned if the operation was successful, otherwise one of the error codes in ifflib.h is returned. note: The BitMapHeader structure is defined in ifflib.h --------------------------------------------------------------------- name: RlsBitMap synopsis: void RlsBitMap(bmap) struct BitMap *bmap; function: Frees the memory allocated for a BitMap structure by GetIFF_bitmap. The BitMap structure is allocated in two parts, one for the structure itself and one for the bit- planes. argument: bmap - A pointer to a BitMap structure obtained from GetIFF_bitmap. return: None see also: GetIFF_bitmap --------------------------------------------------------------------- name: RlsImage synopsis: void RlsImage(image) struct Image *image; function: Frees the memory allocated for a Image structure by GetIFF_image. The Image structure is allocated in two parts, one for the structure itself and one for the bit- planes. argument: image - A pointer to a Image structure obtained from GetIFF_image. return: None see also: GetIFF_image ---------------------------------------------------------------------- Revision history: 2/89 1.0 Initial Revision 5/89 1.1 Fixed bug in library Expunge routine and added the picture printing program. Added a object module that is compatable with Alink. 5/89 1.2 Made de-compression routine much faster by coding it in assembly language. Also reduced size. (4044 to 3776) 6/89 1.3 Modified iff.library such that the original screen ViewModes will be saved into the BitMapHeader structure if they are present in the form of a CAMG chunk. Eliminated the PrntPict program and allowed the picture to be printed from ShoPict if the 'P' key is pressed. Added support for over scan pictures in ShoPict.