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

  1. /************************************************************************
  2.  *                                    *
  3.  * xwd bitmap information                        *
  4.  *                                    *
  5.  * Version 1.50 (23-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 "xwd.h"
  15.  
  16. int main(int argc, char** argv)
  17. {
  18.         int  i;
  19.         char c;
  20.         xwd_header hdr;
  21.         xwd_colour xcol;
  22.         FILE *file;
  23.  
  24.         if(argc>1 && strcmp(argv[argc-1],"-c")!=0)
  25.                 file = fopen(argv[argc-1],"r");
  26.         else
  27.                 file = stdin;
  28.  
  29.         if(file == 0)
  30.         {
  31.                 fprintf(stderr,"Could not open file\n");
  32.                 return(1);
  33.         }
  34.         
  35.         read_struct(BE, (BYTE*)&hdr, xwd_header_descr, file);
  36.  
  37.         printf("Size header (structure)        : %d (%d)\n", hdr.header_size,
  38.                                                             sizeof(xwd_header));
  39.         printf("XWD_FILE_VERSION               : %d \n", hdr.file_version);
  40.         printf("Pixmap format                  : %d \n", hdr.pixmap_format);
  41.         printf("Pixmap depth                   : %d \n", hdr.pixmap_depth);
  42.         printf("Pixmap width x height          : %d x %d\n", hdr.pixmap_width,
  43.                                                              hdr.pixmap_height);
  44.         printf("Bits per pixel                 : %d \n", hdr.bits_per_pixel);
  45.         printf("Bitmap X offset                : %d \n", hdr.xoffset);
  46.         printf("Byte order MSB/LSB First       : %d \n", hdr.byte_order);
  47.         printf("Bit order MSB/LSB First        : %d \n", hdr.bitmap_bit_order);
  48.         printf("Bitmap unit                    : %d \n", hdr.bitmap_unit);
  49.         printf("Bytes per scanline             : %d \n", hdr.bytes_per_line);
  50.         printf("Bitmap scanline pad            : %d \n", hdr.bitmap_pad);
  51.         printf("Class of colourmap             : %d \n", hdr.visual_class);
  52.         printf("Z red mask                     : %d \n", hdr.red_mask);
  53.         printf("Z green mask                   : %d \n", hdr.green_mask);
  54.         printf("Z blue mask                    : %d \n", hdr.blue_mask);
  55.         printf("Log2 of distinct colour values : %d \n", hdr.bits_per_rgb);
  56.         printf("Number of entries in colourmap : %d \n", hdr.colourmap_entries);
  57.         printf("Number of colour structures    : %d \n", hdr.ncolours);
  58.         printf("Window width x height          : %d x %d\n", hdr.window_width,
  59.                                                              hdr.window_height);
  60.         printf("Window position upper left X,Y : %d x %d\n", hdr.window_x,
  61.                                                              hdr.window_y);
  62.         printf("Window border width            : %d \n", hdr.window_bdrwidth);
  63.  
  64.         if(argc>1 && strcmp(argv[1],"-c")==0)
  65.         {
  66.                 printf("\n");
  67.  
  68.                 /* skip additional info in header */
  69.  
  70.                 for(i=sizeof(xwd_header); i<hdr.header_size; i++)
  71.                         c = fgetc(file);
  72.  
  73.                 printf("%-10s : %8s %5s %5s %5s %5s\n",
  74.                              "Colour Map","Pixel","Red","Green","Blue","Flags");
  75.  
  76.                 /* read colour map */
  77.  
  78.                 for(i=0; i<hdr.ncolours; i++)
  79.                 {
  80.                         read_struct(BE, (BYTE*)&xcol, xwd_colour_descr, file);
  81.  
  82.                         printf("%10d : %08X  %04X  %04X  %04X  %02X\n",i,
  83.                                                                 xcol.pixel,
  84.                                                                 xcol.red,
  85.                                                                 xcol.green,
  86.                                                                 xcol.blue,
  87.                                                                 xcol.flags);
  88.                 }
  89.         }
  90.  
  91.         fclose(file);
  92.  
  93.         return(0);
  94. }
  95.