home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * TGA bitmap information *
- * *
- * Version 1.00 (17-Jun-1993) *
- * 2.00 (05-Aug-1993) *
- * 2.50 (22-Aug-1993) *
- * *
- * (C) 1993 DEEJ Technology PLC *
- * *
- ************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include "io.h"
- #include "tga.h"
-
- int main(int argc, char** argv)
- {
- int i;
- int r,g,b;
- FILE *file;
- tga_hdr_str hdr;
-
- 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(LE, (BYTE*)&hdr, tga_hdr_descr, file);
-
- printf("ID Length : %d\n",hdr.IDLength);
- printf("Map Type : %d\n",hdr.MapType);
- printf("Image Type : %d\n",hdr.ImageType);
- printf("Map Info Orgin : %d\n",hdr.MapInfoOrgin);
- printf("Map Info Length : %d\n",hdr.MapInfoLength);
- printf("Map Info Width : %d\n",hdr.MapInfoWidth);
- printf("Image x,y start : %d,%d\n",hdr.ImageInfoX,hdr.ImageInfoY);
- printf("Image x,y length : %d,%d\n",hdr.ImageInfoDX,hdr.ImageInfoDY);
- printf("Image depth (BPP): %d\n",hdr.ImageInfoDepth);
- printf("Image attributes : %d\n",hdr.ImageInfoAttrib);
-
- if(argc>1 && strcmp(argv[1],"-c")==0)
- {
- printf("\n");
- if(hdr.MapInfoOrgin==0 &&
- hdr.MapInfoLength<=256 &&
- hdr.MapInfoWidth==24)
- {
- printf("Palette red,green,blue\n");
-
- for(i=0; i<(int)hdr.MapInfoLength; i++)
- {
- b = fgetc(file);
- g = fgetc(file);
- r = fgetc(file);
-
- printf("%5d : %3d %3d %3d\n",
- i, r, g, b);
- }
- }
- else
- {
- printf("Cannot handle this type of colour map\n");
- }
- }
-
- fclose(file);
-
- return(0);
- }
-