home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * sun raster information *
- * *
- * Version 2.00 (16-Nov-1993) *
- * *
- * (C) 1989/1993 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "ras.h"
-
- int main(int argc, char** argv)
- {
- int i,j;
- rasterfile ras;
- FILE *file;
- uchar cmap[256][3];
- char *ras_types[] =
- {
- "RT_OLD",
- "RT_STANDARD",
- "RT_BYTE_ENCODED",
- "RT_FORMAT_RGB",
- "RT_FORMAT_TIFF",
- "RT_FORMAT_IFF"
- };
- char *ras_maptypes[] =
- {
- "RMT_NONE",
- "RMT_EQUAL_RGB",
- "RMT_RAW"
- };
-
- 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*)&ras, rasterfile_descr, file);
-
- printf("Magic word : 0x%08X (0x%08X)\n", ras.ras_magic, RAS_MAGIC);
- printf("Width : %d \n", ras.ras_width);
- printf("Height : %d \n", ras.ras_height);
- printf("Depth : %d \n", ras.ras_depth);
- printf("Length : %d \n", ras.ras_length);
- printf("Type : %s (%d)\n", ras.ras_type > RT_FORMAT_IFF ?
- "Unknown" : ras_types[ras.ras_type],
- ras.ras_type);
- printf("Map type : %s (%d)\n", ras.ras_maptype > RMT_RAW ?
- "Unknown" : ras_maptypes[ras.ras_maptype],
- ras.ras_maptype);
- printf("Map length : %d (%d)\n", ras.ras_maplength,ras.ras_maplength/3);
-
-
- if(argc>1 && strcmp(argv[1],"-c")==0)
- {
- printf("\n");
-
- if(ras.ras_maptype != RMT_EQUAL_RGB)
- {
- printf("Only RMT_EQUAL_RGB maps can be displayed\n");
- return(0);
- }
- if((ras.ras_maplength/3) > 256)
- {
- printf("Colour map is > 256 entries\n");
- return(0);
- }
-
- printf("%-10s : %s\n", "Colour Map","Red Green Blue");
-
- /* read colour map */
-
- for(j=0; j<3; j++)
- {
- for(i=0; i<ras.ras_maplength/3; i++)
- {
- cmap[i][j] = fgetc(file);
- }
- }
-
- for(i=0; i<ras.ras_maplength/3; i++)
- {
- printf("%10d : %02X %02X %02X\n",i,
- cmap[i][0],
- cmap[i][1],
- cmap[i][2]);
- }
- }
-
- fclose(file);
-
- return(0);
- }
-