diff options
Diffstat (limited to 'converter/other/pnmtoddif.c')
-rw-r--r-- | converter/other/pnmtoddif.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c index 65152865..962487f2 100644 --- a/converter/other/pnmtoddif.c +++ b/converter/other/pnmtoddif.c @@ -558,17 +558,20 @@ int main(int argc, char *argv[]) break; case PGM_TYPE: { - gray *pixels; - - pixels = (gray *) data; + gray *pixels = pgm_allocrow(cols); for (i = 0; i < rows; i++) { + p = data; pgm_readpgmrow(ifd, pixels, cols, maxval, format); + for (j = 0; j < cols; j++) { + *p++ = (unsigned char) pixels[j]; + } if (fwrite(data,1,ip.bytes_per_line,ofd) != ip.bytes_per_line) { perror("Writing image data\n"); exit(1); } } + pgm_freerow(pixels); } break; case PPM_TYPE: |