--- ray/src/px/protate.c 1989/02/02 10:49:27 1.1 +++ ray/src/px/protate.c 1990/06/26 09:09:35 1.5 @@ -45,18 +45,16 @@ char *argv[]; exit(1); } /* copy header */ - while (fgets(buf, sizeof(buf), fin) != NULL && buf[0] != '\n') - fputs(buf, stdout); + copyheader(fin, stdout); /* add new header info. */ printf("%s\n\n", progname); /* get picture size */ - if (fgets(buf, sizeof(buf), fin) == NULL || - sscanf(buf, "-Y %d +X %d\n", &yres, &xres) != 2) { + if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) { fprintf(stderr, "%s: bad picture size\n", progname); exit(1); } /* write new picture size */ - printf("-Y %d +X %d\n", xres, yres); + fputresolu(YMAJOR|YDECR, yres, xres, stdout); /* compute buffer capacity */ nrows = sizeof(buf)/sizeof(COLR)/yres; rotate(fin); /* rotate the image */ @@ -67,11 +65,11 @@ char *argv[]; rotate(fp) /* rotate picture */ FILE *fp; { - register COLR *inline; + register COLR *inln; register int xoff, inx, iny; long start, ftell(); - if ((inline = (COLR *)malloc(xres*sizeof(COLR))) == NULL) { + if ((inln = (COLR *)malloc(xres*sizeof(COLR))) == NULL) { fprintf(stderr, "%s: out of memory\n", progname); exit(1); } @@ -82,12 +80,13 @@ FILE *fp; exit(1); } for (iny = yres-1; iny >= 0; iny--) { - if (freadcolrs(inline, xres, fp) < 0) { + if (freadcolrs(inln, xres, fp) < 0) { fprintf(stderr, "%s: read error\n", progname); exit(1); } for (inx = 0; inx < nrows && xoff+inx < xres; inx++) - bcopy(inline[xoff+inx], scanbar[inx*yres+iny], + bcopy((char *)inln[xoff+inx], + (char *)scanbar[inx*yres+iny], sizeof(COLR)); } for (inx = 0; inx < nrows && xoff+inx < xres; inx++) @@ -96,5 +95,5 @@ FILE *fp; exit(1); } } - free((char *)inline); + free((char *)inln); }