home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / sprtools / c / clr_info < prev    next >
Encoding:
Text File  |  1994-07-18  |  1.9 KB  |  71 lines

  1. /************************************************************************
  2.  *                                    *
  3.  * clear bitmap information                        *
  4.  *                                    *
  5.  * Version 2.01 (25-Aug-1993)                        *
  6.  *                                    *
  7.  * (C) 1993 DEEJ Technology PLC                        *
  8.  *                                    *
  9.  ************************************************************************/
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include "io.h"
  14. #include "clear.h"
  15.  
  16. int main(int argc, char** argv)
  17. {
  18.         int  i,r,g,b;
  19.         FILE *file;
  20.         clear_hdr hdr;
  21.         char creator[256];
  22.  
  23.         if(argc>1 && strcmp(argv[argc-1],"-c")!=0)
  24.                 file = fopen(argv[argc-1],"r");
  25.         else
  26.                 file = stdin;
  27.  
  28.         if(file == 0)
  29.         {
  30.                 fprintf(stderr,"Could not open file\n");
  31.                 return(1);
  32.         }
  33.         
  34.         i = 0;
  35.         while((creator[i++] = fgetc(file)) > 0);
  36.  
  37.         read_struct(LE, (BYTE*)&hdr, clear_hdr_descr, file);
  38.  
  39.         printf("Creator        : %s\n",creator);
  40.         printf("Version        : %d.%d\n",hdr.version/100,hdr.version%100);
  41.         printf("Width, Height  : %d,%d\n",hdr.width,hdr.height);
  42.         printf("Bits Per Pixel : %d\n",hdr.bpp);
  43.  
  44.         if(argc>1 && strcmp(argv[1],"-c")==0)
  45.         {
  46.                 printf("\n");
  47.  
  48.                 if(hdr.bpp>8)
  49.                 {
  50.                         fprintf(stderr,"No colour map with BPP > 8\n");
  51.                 }
  52.                 else
  53.                 {
  54.                         printf("%-10s : %5s %5s %5s\n",
  55.                                "Colour Map","Red","Green","Blue");
  56.  
  57.                         for(i=0; i<(1<<hdr.bpp); i++)
  58.                         {
  59.                                 r = fgetc(file);
  60.                                 g = fgetc(file);
  61.                                 b = fgetc(file);
  62.                                 printf("%10d : %5d %5d %5d\n",i,r,g,b);
  63.                         }
  64.                 }
  65.         }
  66.  
  67.         fclose(file);
  68.  
  69.         return(0);
  70. }
  71.