--- ray/src/px/pvalue.c 2010/12/16 21:34:41 2.30 +++ ray/src/px/pvalue.c 2018/08/02 18:33:46 2.34 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pvalue.c,v 2.30 2010/12/16 21:34:41 greg Exp $"; +static const char RCSid[] = "$Id: pvalue.c,v 2.34 2018/08/02 18:33:46 greg Exp $"; #endif /* * pvalue.c - program to print pixel values. @@ -296,7 +296,7 @@ unkopt: } if (reverse) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) SET_FILE_BINARY(stdout); if (format != 'a' && format != 'i') SET_FILE_BINARY(fin); @@ -349,7 +349,7 @@ unkopt: fputsresolu(&picres, stdout); /* always put resolution */ valtopix(); } else { -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) SET_FILE_BINARY(fin); if (format != 'a' && format != 'i') SET_FILE_BINARY(stdout); @@ -389,7 +389,7 @@ checkhead( /* deal with line from header */ void *p ) { - char fmt[32]; + char fmt[MAXFMTLEN]; double d; COLOR ctmp; @@ -572,12 +572,12 @@ getcdouble( /* get a double color value from stream(s double vd[3]; if (fin2 == NULL) { - if (fread((char *)vd, sizeof(double), 3, fin) != 3) + if (getbinary(vd, sizeof(double), 3, fin) != 3) return(-1); } else { - if (fread((char *)vd, sizeof(double), 1, fin) != 1 || - fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 || - fread((char *)(vd+2), sizeof(double), 1, fin3) != 1) + if (getbinary(vd, sizeof(double), 1, fin) != 1 || + getbinary(vd+1, sizeof(double), 1, fin2) != 1 || + getbinary(vd+2, sizeof(double), 1, fin3) != 1) return(-1); } if (swapbytes) @@ -595,12 +595,12 @@ getcfloat( /* get a float color value from stream(s) float vf[3]; if (fin2 == NULL) { - if (fread((char *)vf, sizeof(float), 3, fin) != 3) + if (getbinary(vf, sizeof(float), 3, fin) != 3) return(-1); } else { - if (fread((char *)vf, sizeof(float), 1, fin) != 1 || - fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 || - fread((char *)(vf+2), sizeof(float), 1, fin3) != 1) + if (getbinary(vf, sizeof(float), 1, fin) != 1 || + getbinary(vf+1, sizeof(float), 1, fin2) != 1 || + getbinary(vf+2, sizeof(float), 1, fin3) != 1) return(-1); } if (swapbytes) @@ -637,15 +637,15 @@ getcbyte( /* get a byte color value from stream(s) */ COLOR col ) { - BYTE vb[3]; + uby8 vb[3]; if (fin2 == NULL) { - if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3) + if (getbinary(vb, sizeof(uby8), 3, fin) != 3) return(-1); } else { - if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 || - fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 || - fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1) + if (getbinary(vb, sizeof(uby8), 1, fin) != 1 || + getbinary(vb+1, sizeof(uby8), 1, fin2) != 1 || + getbinary(vb+2, sizeof(uby8), 1, fin3) != 1) return(-1); } setcolor(col, (vb[rord[RED]]+.5)/256., @@ -662,12 +662,12 @@ getcword( /* get a 16-bit color value from stream(s) uint16 vw[3]; if (fin2 == NULL) { - if (fread((char *)vw, sizeof(uint16), 3, fin) != 3) + if (getbinary(vw, sizeof(uint16), 3, fin) != 3) return(-1); } else { - if (fread((char *)vw, sizeof(uint16), 1, fin) != 1 || - fread((char *)(vw+1), sizeof(uint16), 1, fin2) != 1 || - fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1) + if (getbinary(vw, sizeof(uint16), 1, fin) != 1 || + getbinary(vw+1, sizeof(uint16), 1, fin2) != 1 || + getbinary(vw+2, sizeof(uint16), 1, fin3) != 1) return(-1); } if (swapbytes) @@ -699,7 +699,7 @@ getbdouble( /* get a double brightness value from fin { double vd; - if (fread((char *)&vd, sizeof(double), 1, fin) != 1) + if (getbinary(&vd, sizeof(double), 1, fin) != 1) return(-1); if (swapbytes) swap64((char *)&vd, 1); @@ -715,7 +715,7 @@ getbfloat( /* get a float brightness value from fin * { float vf; - if (fread((char *)&vf, sizeof(float), 1, fin) != 1) + if (getbinary(&vf, sizeof(float), 1, fin) != 1) return(-1); if (swapbytes) swap32((char *)&vf, 1); @@ -745,10 +745,10 @@ getbbyte( /* get a byte brightness value from fin */ COLOR col ) { - BYTE vb; + uby8 vb; double d; - if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1) + if (getbinary(&vb, sizeof(uby8), 1, fin) != 1) return(-1); d = (vb+.5)/256.; setcolor(col, d, d, d); @@ -764,7 +764,7 @@ getbword( /* get a 16-bit brightness value from fin * uint16 vw; double d; - if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1) + if (getbinary(&vw, sizeof(uint16), 1, fin) != 1) return(-1); if (swapbytes) swap16((char *)&vw, 1); @@ -800,7 +800,7 @@ putcfloat( /* put a float color to stdout */ vf[2] = colval(col,ord[2]); if (swapbytes) swap32((char *)vf, 3); - fwrite((char *)vf, sizeof(float), 3, stdout); + putbinary(vf, sizeof(float), 3, stdout); return(ferror(stdout) ? -1 : 0); } @@ -818,7 +818,7 @@ putcdouble( /* put a double color to stdout */ vd[2] = colval(col,ord[2]); if (swapbytes) swap64((char *)vd, 3); - fwrite((char *)vd, sizeof(double), 3, stdout); + putbinary(vd, sizeof(double), 3, stdout); return(ferror(stdout) ? -1 : 0); } @@ -844,7 +844,7 @@ putcbyte( /* put a byte color to stdout */ ) { long i; - BYTE vb[3]; + uby8 vb[3]; i = colval(col,ord[0])*256.; vb[0] = min(i,255); @@ -852,7 +852,7 @@ putcbyte( /* put a byte color to stdout */ vb[1] = min(i,255); i = colval(col,ord[2])*256.; vb[2] = min(i,255); - fwrite((char *)vb, sizeof(BYTE), 3, stdout); + putbinary(vb, sizeof(uby8), 3, stdout); return(ferror(stdout) ? -1 : 0); } @@ -874,7 +874,7 @@ putcword( /* put a 16-bit color to stdout */ vw[2] = min(i,65535); if (swapbytes) swap16((char *)vw, 3); - fwrite((char *)vw, sizeof(uint16), 3, stdout); + putbinary(vw, sizeof(uint16), 3, stdout); return(ferror(stdout) ? -1 : 0); } @@ -901,7 +901,7 @@ putbfloat( /* put a float brightness to stdout */ vf = (*mybright)(col); if (swapbytes) swap32((char *)&vf, 1); - fwrite((char *)&vf, sizeof(float), 1, stdout); + putbinary(&vf, sizeof(float), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -917,7 +917,7 @@ putbdouble( /* put a double brightness to stdout */ vd = (*mybright)(col); if (swapbytes) swap64((char *)&vd, 1); - fwrite((char *)&vd, sizeof(double), 1, stdout); + putbinary(&vd, sizeof(double), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -940,11 +940,11 @@ putbbyte( /* put a byte brightness to stdout */ ) { register int i; - BYTE vb; + uby8 vb; i = (*mybright)(col)*256.; vb = min(i,255); - fwrite((char *)&vb, sizeof(BYTE), 1, stdout); + putbinary(&vb, sizeof(uby8), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -962,7 +962,7 @@ putbword( /* put a 16-bit brightness to stdout */ vw = min(i,65535); if (swapbytes) swap16((char *)&vw, 1); - fwrite((char *)&vw, sizeof(uint16), 1, stdout); + putbinary(&vw, sizeof(uint16), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -989,7 +989,7 @@ putpfloat( /* put a float primary to stdout */ vf = colval(col,putprim); if (swapbytes) swap32((char *)&vf, 1); - fwrite((char *)&vf, sizeof(float), 1, stdout); + putbinary(&vf, sizeof(float), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -1005,7 +1005,7 @@ putpdouble( /* put a double primary to stdout */ vd = colval(col,putprim); if (swapbytes) swap64((char *)&vd, 1); - fwrite((char *)&vd, sizeof(double), 1, stdout); + putbinary(&vd, sizeof(double), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -1028,11 +1028,11 @@ putpbyte( /* put a byte primary to stdout */ ) { long i; - BYTE vb; + uby8 vb; i = colval(col,putprim)*256.; vb = min(i,255); - fwrite((char *)&vb, sizeof(BYTE), 1, stdout); + putbinary(&vb, sizeof(uby8), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -1050,7 +1050,7 @@ putpword( /* put a 16-bit primary to stdout */ vw = min(i,65535); if (swapbytes) swap16((char *)&vw, 1); - fwrite((char *)&vw, sizeof(uint16), 1, stdout); + putbinary(&vw, sizeof(uint16), 1, stdout); return(ferror(stdout) ? -1 : 0); } @@ -1154,10 +1154,10 @@ set_io(void) /* set put and get functions */ if (fin2 == NULL) goto namerr; if (fseek(fin2, - (long)sizeof(BYTE)*picres.xr*picres.yr, 1)) + (long)sizeof(uby8)*picres.xr*picres.yr, 1)) goto seekerr; if (fseek(fin3, - (long)sizeof(BYTE)*2*picres.xr*picres.yr, 1)) + (long)sizeof(uby8)*2*picres.xr*picres.yr, 1)) goto seekerr; } }