| version 1.1 | | version 1.2 |
|---|
| | |
| * Routines for reading and writing IFF files | | * Routines for reading and writing IFF files |
| * | | * |
| * $Log$ | | * $Log$ |
| * Revision 1.1 1999/06/14 22:04:40 donut | | * Revision 1.2 2003/03/09 06:34:09 donut |
| * Initial revision | | * change byte typedef to sbyte to avoid conflict with win32 byte which is unsigned |
| | | * |
| | | * Revision 1.1.1.1 1999/06/14 22:04:40 donut |
| | | * Import of d1x 1.37 source. |
| * | | * |
| * Revision 1.43 1994/12/08 19:03:17 john | | * Revision 1.43 1994/12/08 19:03:17 john |
| * Added code to use cfile. | | * Added code to use cfile. |
| | |
| #define mskHasTransparentColor 2 | | #define mskHasTransparentColor 2 |
| | | |
| //Palette entry structure | | //Palette entry structure |
| typedef struct pal_entry {byte r,g,b;} pal_entry; | | typedef struct pal_entry {sbyte r,g,b;} pal_entry; |
| | | |
| //structure of the header in the file | | //structure of the header in the file |
| typedef struct iff_bitmap_header { | | typedef struct iff_bitmap_header { |
| | |
| short type; //see types above | | short type; //see types above |
| short transparentcolor; //which color is transparent (if any) | | short transparentcolor; //which color is transparent (if any) |
| short pagewidth,pageheight; //width & height of source screen | | short pagewidth,pageheight; //width & height of source screen |
| byte nplanes; //number of planes (8 for 256 color image) | | sbyte nplanes; //number of planes (8 for 256 color image) |
| byte masking,compression; //see constants above | | sbyte masking,compression; //see constants above |
| byte xaspect,yaspect; //aspect ratio (usually 5/6) | | sbyte xaspect,yaspect; //aspect ratio (usually 5/6) |
| pal_entry palette[256]; //the palette for this bitmap | | pal_entry palette[256]; //the palette for this bitmap |
| ubyte *raw_data; //ptr to array of data | | ubyte *raw_data; //ptr to array of data |
| short row_size; //offset to next row | | short row_size; //offset to next row |
| | |
| int convert_ilbm_to_pbm(iff_bitmap_header *bmheader) | | int convert_ilbm_to_pbm(iff_bitmap_header *bmheader) |
| { | | { |
| int x,y,p; | | int x,y,p; |
| byte *new_data,*destptr,*rowptr; | | sbyte *new_data,*destptr,*rowptr; |
| int bytes_per_row,byteofs; | | int bytes_per_row,byteofs; |
| ubyte checkmask,newbyte,setbit; | | ubyte checkmask,newbyte,setbit; |
| | | |
| MALLOC( new_data, byte, bmheader->w * bmheader->h ); | | MALLOC( new_data, sbyte, bmheader->w * bmheader->h ); |
| if (new_data == NULL) return IFF_NO_MEM; | | if (new_data == NULL) return IFF_NO_MEM; |
| | | |
| destptr = new_data; | | destptr = new_data; |
| | |
| | | |
| //if bm->bm_data is set, use it (making sure w & h are correct), else | | //if bm->bm_data is set, use it (making sure w & h are correct), else |
| //allocate the memory | | //allocate the memory |
| int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,byte *palette,grs_bitmap *prev_bm) | | int iff_parse_bitmap(FFILE *ifile,grs_bitmap *bm,int bitmap_type,sbyte *palette,grs_bitmap *prev_bm) |
| { | | { |
| int ret; //return code | | int ret; //return code |
| iff_bitmap_header bmheader; | | iff_bitmap_header bmheader; |
| | |
| | | |
| //like iff_read_bitmap(), but reads into a bitmap that already exists, | | //like iff_read_bitmap(), but reads into a bitmap that already exists, |
| //without allocating memory for the bitmap. | | //without allocating memory for the bitmap. |
| int iff_read_into_bitmap(char *ifilename,grs_bitmap *bm,byte *palette) | | int iff_read_into_bitmap(char *ifilename,grs_bitmap *bm,sbyte *palette) |
| { | | { |
| int ret; //return code | | int ret; //return code |
| FFILE ifile; | | FFILE ifile; |