home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Tex
/
Dvi
/
shdvi10b.zoo
/
src
/
imginfo.c
< prev
Wrap
C/C++ Source or Header
|
1990-07-16
|
4KB
|
145 lines
/*
* IMGinfo program.
*
* Displays statistics about GEM IMG-files.
*
* This program is freely redistributable. You may modify and use this
* program to your heart's content, so long as you send modifications
* to Robert Stabl. It can be included in any distribution, commercial
* or otherwise, so long as the banner string defined in the constant
* HEADER is not modified (except for the version number) and this banner
* is printed on programs invocation, or can be printed on programs
* invocation with the -? option.
*
* For further information read the README file.
*
* 15.01.89 (C) copyright Robert Stabl.
*
* 15.07.90 v1.01 few changes for release (rbs)
*/
#define VERSION "1.01"
#define HEADER "IMGinfo - Version %s \275 1989/90 Robert Stabl\n"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tos.h>
int imgversion;
int headlength;
int nrplanes;
int patlen;
int pixelwidth;
int pixelheight;
int scpixwidth;
int sclinenr;
int scbytewidth;
double cmwidth1;
double cmheigh1;
double cmwidth3;
double cmheigh3;
double inwidth1;
double inheigh1;
double inwidth3;
double inheigh3;
static void usage(void)
{
fprintf(stderr, HEADER, VERSION);
fprintf(stderr, "usage: IMGinfo imgfile ...\n");
}
unsigned int ReadInt(FILE *fp)
{
register unsigned int x = 0;
x = fgetc(fp);
x <<= 8;
x |= fgetc(fp);
return(x);
}
void ReadHeader(FILE *fp)
{
int i;
imgversion = (int)ReadInt(fp);
headlength = (int)ReadInt(fp);
nrplanes = (int)ReadInt(fp);
patlen = (int)ReadInt(fp);
pixelwidth = (int)ReadInt(fp);
pixelheight = (int)ReadInt(fp);
scpixwidth = (int)ReadInt(fp);
sclinenr = (int)ReadInt(fp);
if (headlength >8)
{
fprintf(stderr, "Headlength (%d) too long",headlength);
for (i=8; i<= headlength; i++)
{
fgetc(fp);
}
}
cmwidth1 = (double)(((double)scpixwidth / 100) * 2.54);
cmheigh1 = (double)(((double)sclinenr / 100) * 2.54);
cmwidth3 = (double)(((double)scpixwidth / 300) * 2.54);
cmheigh3 = (double)(((double)sclinenr / 300) * 2.54);
inwidth1 = (double)(((double)scpixwidth / 100));
inheigh1 = (double)(((double)sclinenr / 100));
inwidth3 = (double)(((double)scpixwidth / 300));
inheigh3 = (double)(((double)sclinenr / 300));
}
void PrintHeader(void)
{
fprintf(stdout," measure in pixels:\n");
fprintf(stdout," width: %6d height: %6d\n\n",
scpixwidth, sclinenr);
fprintf(stdout," measure in cm:\n");
fprintf(stdout," 300 dpi -- width: %6.3Lf height: %6.3Lf\n",
cmwidth3, cmheigh3);
fprintf(stdout," 100 dpi -- width: %6.3Lf height: %6.3Lf\n\n",
cmwidth1, cmheigh1);
fprintf(stdout," measure in inch:\n");
fprintf(stdout," 300 dpi -- width: %6.3Lf height: %6.3Lf\n",
inwidth3, inheigh3);
fprintf(stdout," 100 dpi -- width: %6.3Lf height: %6.3Lf\n\n",
inwidth1, inheigh1);
fprintf(stdout," IMG statistics:\n");
fprintf(stdout," version number : %d\n",imgversion);
fprintf(stdout," number of planes : %d\n",nrplanes);
fprintf(stdout," width of 1 pixel : %d\n",pixelwidth);
fprintf(stdout," height of 1 pixel : %d\n",pixelheight);
}
main(int argc, char *argv[])
{
FILE *imgfile;
int i;
if (argc < 2)
{
usage();
return(1);
}
fprintf(stdout, HEADER, VERSION);
for (i=1; i<argc; i++)
{
imgfile = fopen(argv[i],"rb");
if (imgfile == NULL)
{
fprintf(stderr, "Can't open IMG file %s\n", argv[i]);
continue;
}
ReadHeader(imgfile);
fprintf(stdout, "Statistics for IMG file %s:\n", argv[i]);
PrintHeader();
fclose(imgfile);
}
return(0);
}