Blame converter/ppm/ppmtoppm.c
|
Packit |
78deda |
/*----------------------------------------------------------------------------
|
|
Packit |
78deda |
ppmtoppm
|
|
Packit |
78deda |
------------------------------------------------------------------------------
|
|
Packit |
78deda |
Part of the Netpbm package.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
Copy PPM image from Standard Input to Standard Output
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
By Bryan Henderson, San Jose CA 2002.09.07
|
|
Packit |
78deda |
|
|
Packit |
78deda |
Contributed to the public domain by its author 2002.09.07
|
|
Packit |
78deda |
-----------------------------------------------------------------------------*/
|
|
Packit |
78deda |
|
|
Packit |
78deda |
#include "ppm.h"
|
|
Packit |
78deda |
|
|
Packit |
78deda |
int
|
|
Packit |
78deda |
main(int argc, char *argv[]) {
|
|
Packit |
78deda |
int format;
|
|
Packit |
78deda |
int rows, cols;
|
|
Packit |
78deda |
pixval maxval;
|
|
Packit |
78deda |
int row;
|
|
Packit |
78deda |
pixel* pixelrow;
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ppm_init(&argc, argv);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
if (argc-1 != 0)
|
|
Packit |
78deda |
pm_error("Program takes no arguments. Input is from Standard Input");
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ppm_readppminit(stdin, &cols, &rows, &maxval, &format);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ppm_writeppminit(stdout, cols, rows, maxval, 0);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
pixelrow = ppm_allocrow(cols);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
for (row = 0; row < rows; row++) {
|
|
Packit |
78deda |
ppm_readppmrow(stdin, pixelrow, cols, maxval, format);
|
|
Packit |
78deda |
ppm_writeppmrow(stdout, pixelrow, cols, maxval, 0);
|
|
Packit |
78deda |
}
|
|
Packit |
78deda |
ppm_freerow(pixelrow);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
pm_close(stdin);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
exit(0);
|
|
Packit |
78deda |
}
|