home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * xwd bitmap information *
- * *
- * Version 1.50 (23-Aug-1993) *
- * *
- * (C) 1993 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "xwd.h"
-
- int main(int argc, char** argv)
- {
- int i;
- char c;
- xwd_header hdr;
- xwd_colour xcol;
- 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, xwd_header_descr, file);
-
- printf("Size header (structure) : %d (%d)\n", hdr.header_size,
- sizeof(xwd_header));
- printf("XWD_FILE_VERSION : %d \n", hdr.file_version);
- printf("Pixmap format : %d \n", hdr.pixmap_format);
- printf("Pixmap depth : %d \n", hdr.pixmap_depth);
- printf("Pixmap width x height : %d x %d\n", hdr.pixmap_width,
- hdr.pixmap_height);
- printf("Bits per pixel : %d \n", hdr.bits_per_pixel);
- printf("Bitmap X offset : %d \n", hdr.xoffset);
- printf("Byte order MSB/LSB First : %d \n", hdr.byte_order);
- printf("Bit order MSB/LSB First : %d \n", hdr.bitmap_bit_order);
- printf("Bitmap unit : %d \n", hdr.bitmap_unit);
- printf("Bytes per scanline : %d \n", hdr.bytes_per_line);
- printf("Bitmap scanline pad : %d \n", hdr.bitmap_pad);
- printf("Class of colourmap : %d \n", hdr.visual_class);
- printf("Z red mask : %d \n", hdr.red_mask);
- printf("Z green mask : %d \n", hdr.green_mask);
- printf("Z blue mask : %d \n", hdr.blue_mask);
- printf("Log2 of distinct colour values : %d \n", hdr.bits_per_rgb);
- printf("Number of entries in colourmap : %d \n", hdr.colourmap_entries);
- printf("Number of colour structures : %d \n", hdr.ncolours);
- printf("Window width x height : %d x %d\n", hdr.window_width,
- hdr.window_height);
- printf("Window position upper left X,Y : %d x %d\n", hdr.window_x,
- hdr.window_y);
- printf("Window border width : %d \n", hdr.window_bdrwidth);
-
- if(argc>1 && strcmp(argv[1],"-c")==0)
- {
- printf("\n");
-
- /* skip additional info in header */
-
- for(i=sizeof(xwd_header); i<hdr.header_size; i++)
- c = fgetc(file);
-
- printf("%-10s : %8s %5s %5s %5s %5s\n",
- "Colour Map","Pixel","Red","Green","Blue","Flags");
-
- /* read colour map */
-
- for(i=0; i<hdr.ncolours; i++)
- {
- read_struct(BE, (BYTE*)&xcol, xwd_colour_descr, file);
-
- printf("%10d : %08X %04X %04X %04X %02X\n",i,
- xcol.pixel,
- xcol.red,
- xcol.green,
- xcol.blue,
- xcol.flags);
- }
- }
-
- fclose(file);
-
- return(0);
- }
-