/******************************************************************* Program: a2ppm.c Eric Weeks 8-1-96 6-18-95: a2ps.c started from mat2las.c; designed for (perhaps) CA's added in -xy options 8-01-96: a2ppm.c started from a2ps.c http://www.physics.emory.edu/~weeks/ *******************************************************************/ #include char *prgname; main(argc,argv) int argc; char **argv; { int i,j,c,count; double atof(),blah; int hres,vres,invert; unsigned char pixel; FILE *fp, *fopen(); extern int optind; extern char *optarg; invert = 0; count = 0; while ((c = getopt(argc, argv, "hi")) != EOF) switch (c) { case 'h': fprintf(stderr,"Usage: a2ppm [options] [<] [file] > file.ppm\n"); fprintf(stderr," -h : this help message\n"); fprintf(stderr," -i : invert colors [default:no]\n"); exit(1); break; case 'i': invert = 1; break; } argc -= (optind-1) ; argv += (optind-1) ; fp = (argc > 1) ? fopen(*++argv, "r") : stdin; fscanf(fp,"%ld %ld",&hres,&vres); /* Write the necessary starting junk */ printf("P5\n#Created by a2ppm, written by Eric R. Weeks\n"); printf("%d %d\n255\n",hres,vres); /* Now, read in the rest of the file, converting each character to hexadecimal and punching to std. output. */ for(j=0;j.3) { fprintf(stderr,"%5.1f percent of picture is black,\nyou might want to consider using -i option!\n\nUse 'cancel' command to stop laserwriter output.\n",blah*100.0); } }