/*---------- actual image processing ----------*/
-static int cols, rows, informat;
+static int cols, rows, informat, row, col;
static pixval maxval;
static FILE *encodingfile;
static void badformat(const char *m) {
- fprintf(stderr,"bad format: %s\n", m);
+ fprintf(stderr,"bad format (row=%d,col=%d): %s\n", row,col, m);
exit(12);
}
}
static void process(void) {
- int row, col, i;
+ int i;
ppm_readppminit(encodingfile, &cols, &rows, &maxval, &informat);
if (maxval != 255) badformat("wrong maxval");
unsigned char rgbi[3], rgbo[3];
double rgbod[3];
- if (fread(rgbi,1,3,encodingfile)!=-3) {
+ if (fread(rgbi,1,3,encodingfile)!=3) {
if (ferror(encodingfile)) { perror("reading"); exit(12); }
else badformat("truncated file");
}
angle_to_colour(rgbdirn, angle);
ix= !movfeatpos ?
- (segnum < fixed_a ? fixed[segnum] : fixed[0]) :
+ (segnum < fixed_a ? fixed[segnum] : 0) :
(segnum < moveable_a && movfeatpos < moveable[segnum].lookup_a
- ? moveable[segnum].lookup[movfeatpos] : fixed[0]);
+ ? moveable[segnum].lookup[movfeatpos] : 0);
r= &idinfo[ix];
for (i=0; i<3; i++)
rgbo[i]= rgbod[i] * 255.0;
- if (fwrite(rgbi,1,3,stdout)!=3) { perror("writing"); exit(12); }
+ if (fwrite(rgbo,1,3,stdout)!=3) { perror("writing"); exit(12); }
}
}