--- ray/src/px/ra_t8.c 1989/02/02 10:49:37 1.1 +++ ray/src/px/ra_t8.c 1990/01/18 23:58:24 1.4 @@ -19,6 +19,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include "targa.h" +#ifndef BSD +#define bcopy(s,d,n) (void)memcpy(d,s,n) +extern char *memcpy(); +#endif /* descriptor for a picture file or frame buffer */ typedef struct { char *name; /* file name */ @@ -122,7 +126,7 @@ char *argv[]; /* put header */ printargs(argc, argv, stdout); putchar('\n'); - printf("-Y %d +X %d\n", ymax, xmax); + fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); /* convert file */ tg2ra(&head); } else { @@ -227,7 +231,7 @@ register FILE *fp; if (ip != NULL) if (nidbytes) - fread(ip, nidbytes, 1, fp); + fread((char *)ip, nidbytes, 1, fp); else *ip = '\0'; else if (nidbytes) @@ -280,7 +284,7 @@ register struct hdStruct *h; return(NULL); /* discard header */ getheader(p->fp, NULL); - if (fscanf(p->fp, "-Y %d +X %d\n", &ymax, &xmax) != 2) + if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) quiterr("bad picture size"); p->nexty = 0; p->bytes_line = 0; /* variable length lines */ @@ -320,8 +324,8 @@ struct hdStruct *hp; register int i, j; /* get color table */ - if ((hp->CMapBits==24 ? fread(map.c3, sizeof(map.c3), 1, stdin) : - fread(map.c4, sizeof(map.c4), 1, stdin)) != 1) + if ((hp->CMapBits==24 ? fread((char *)map.c3,sizeof(map.c3),1,stdin) : + fread((char *)map.c4,sizeof(map.c4),1,stdin)) != 1) quiterr("error reading color table"); /* convert table */ for (i = hp->mapOrig; i < hp->mapOrig+hp->mapLength; i++) @@ -358,11 +362,9 @@ picreadline3(y, l3) /* read in 3-byte scanline */ int y; register rgbpixel *l3; { - register BYTE *l4; - register int shift, c; - int i; + register int i; - if (inpic->nexty != y) { /* find scanline */ + if (inpic->nexty != y) { /* find scanline */ if (inpic->bytes_line == 0) { if (inpic->pos.y[y] == 0) { while (inpic->nexty < y) { @@ -380,28 +382,11 @@ register rgbpixel *l3; quiterr("read error in picreadline3"); inpic->nexty = y+1; /* convert scanline */ - for (l4=inline[0], i=xmax; i--; l4+=4, l3++) { - shift = l4[EXP] - COLXS; - if (shift >= 8) { - l3->r = l3->g = l3->b = 255; - } else if (shift <= -8) { - l3->r = l3->g = l3->b = 0; - } else if (shift > 0) { - c = l4[RED] << shift; - l3->r = c > 255 ? 255 : c; - c = l4[GRN] << shift; - l3->g = c > 255 ? 255 : c; - c = l4[BLU] << shift; - l3->b = c > 255 ? 255 : c; - } else if (shift < 0) { - l3->r = l4[RED] >> -shift; - l3->g = l4[GRN] >> -shift; - l3->b = l4[BLU] >> -shift; - } else { - l3->r = l4[RED]; - l3->g = l4[GRN]; - l3->b = l4[BLU]; - } + normcolrs(inline, xmax); + for (i = 0; i < xmax; i++) { + l3[i].r = inline[i][RED]; + l3[i].g = inline[i][GRN]; + l3[i].b = inline[i][BLU]; } } @@ -410,7 +395,7 @@ picwriteline(y, l) /* save output scanline */ int y; pixel *l; { - bcopy(l, &tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel)); + bcopy((char *)l, (char *)&tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel)); } @@ -420,7 +405,7 @@ pixel *d; FILE *fp; { if (h->dataType == IM_CMAP) { /* uncompressed */ - if (fwrite(d, h->x*sizeof(pixel), h->y, fp) != h->y) + if (fwrite((char *)d,h->x*sizeof(pixel),h->y,fp) != h->y) quiterr("error writing targa file"); return; } @@ -437,7 +422,7 @@ FILE *fp; register pixel *dp; if (h->dataType == IM_CMAP) { /* uncompressed */ - if (fread(data, h->x*sizeof(pixel), h->y, fp) != h->y) + if (fread((char *)data,h->x*sizeof(pixel),h->y,fp) != h->y) goto readerr; return; }