home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * Starbase bitmap information *
- * *
- * Version 1.00 (21-Jun-1992) *
- * 2.00 (23-Aug-1993) *
- * *
- * (C) 1992/3 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "sb.h"
-
- #define CSIZE 256
-
- float cmap[CSIZE][3];
-
- bf_header hdr;
-
- int main(int argc, char** argv)
- {
- int i,j,r,g,b;
- uint *ptr;
- FILE *file;
-
- if(argc>1 && strcmp(argv[argc-1],"-c")!=0)
- file = fopen(argv[argc-1],"r");
- else
- file = stdin;
-
- if(file == 0)
- {
- fprintf(stderr,"Could not open file\n");
- return(1);
- }
-
- read_struct(BE, (BYTE*)&hdr, bf_header_descr, file);
-
- printf("file id : %s\n",hdr.file_id);
- printf("revision : %d\n",hdr.rev);
- printf("device id : %s\n",hdr.device_id);
- printf("bitmap offset : %d\n",hdr.bm_loc);
- printf("end of bitmap : %d\n",hdr.eod_loc);
- printf("x,y start : %d,%d\n",hdr.xstart,hdr.ystart);
- printf("x,y length : %d,%d\n",hdr.xlen,hdr.ylen);
- printf("data format : %d\n",hdr.bm_mode);
- printf("bits per pixel : %d\n",hdr.depth);
- printf("pixel alignment : %d\n",hdr.pixel_align);
- printf("number of banks : %d\n",hdr.num_banks);
- printf("display enable : %d\n",hdr.disp_en);
- printf("colour map mode : %d\n",hdr.cmap_mode);
- printf("colour map size : %d\n",hdr.csize);
- printf("background index : %d\n",hdr.back_index);
-
- if(argc>1 && strcmp(argv[1],"-c")==0)
- {
- printf("\n");
-
- if(hdr.csize>256)
- {
- fprintf(stderr,"colour map is > 256\n");
- }
- else
- {
- fread(&cmap,sizeof(float),hdr.csize*3,file);
-
- printf("%-10s : %5s %5s %5s\n",
- "Colour Map","Red","Green","Blue");
-
- for(i=0; i<hdr.csize; i++)
- {
- for(j=0; j<3; j++)
- {
- ptr = (uint*)&cmap[i][j];
- *ptr = endian(BE,*ptr);
- }
-
- r = (int)(cmap[i][0]*255.0); r=(r>255) ? 255:r;
- g = (int)(cmap[i][1]*255.0); g=(g>255) ? 255:g;
- b = (int)(cmap[i][2]*255.0); b=(b>255) ? 255:b;
-
- printf("%10d : %5d %5d %5d\n",i,r,g,b);
- }
- }
- }
-
- fclose(file);
-
- return(0);
- }
-