diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-19 18:45:43 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-01-19 18:45:43 +0100 |
| commit | 62b0678ebcbeda157a0f338b2dec02ad685b8dc4 (patch) | |
| tree | 7599ec54acac9e516b1c4220ec9022e9d9726817 /src | |
| parent | 7b3f9960ba5f92abeb6fbc8fd33eacf000940d27 (diff) | |
add usage
Diffstat (limited to 'src')
| -rw-r--r-- | src/pnmcurve.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/pnmcurve.c b/src/pnmcurve.c index 7f22ba5..49adad2 100644 --- a/src/pnmcurve.c +++ b/src/pnmcurve.c @@ -23,6 +23,19 @@ buildCurve(const char *ctrl_points, int resolution, int maxval); #define GREEN 0x2 #define BLUE 0x4 +static void +usage() { + fprintf(stderr, + "usage: pnmcurve [-rgb] -c <curve>\n" + " -r apply curve to red channel.\n" + " -g apply curve to green channel.\n" + " -b apply curve to blue channel.\n" + " -c <curve> curve to apply. <curve> must be\n" + " of the form x1:y1,x2,y2,x3,y3 where xi,yi are\n" + " control points of a cubic spline curve.\n" + " xi,yi must be in the range [0.0,1.0].\n"); +} + int main(int argc, char **argv) { int c, i; @@ -51,6 +64,11 @@ main(int argc, char **argv) { } } + if (!curve) { + usage(); + exit(1); + } + if (readPnmHeader(stdin, &in_pnm) != 0) { fprintf(stderr, "failed to read PNM file\n"); exit(1); @@ -61,21 +79,19 @@ main(int argc, char **argv) { exit(1); } - if (curve) { - if (channels == 0) channels = RED | GREEN | BLUE; + if (channels == 0) channels = RED | GREEN | BLUE; - table = buildCurve(curve, in_pnm.maxval + 1, in_pnm.maxval); + table = buildCurve(curve, in_pnm.maxval + 1, in_pnm.maxval); - if (!table) { - fprintf(stderr, "could not build table.\n"); - exit(1); - } - - gTable[0] = channels & RED ? table : NULL; - gTable[1] = channels & GREEN ? table : NULL; - gTable[2] = channels & BLUE ? table : NULL; + if (!table) { + fprintf(stderr, "could not build table.\n"); + exit(1); } + gTable[0] = channels & RED ? table : NULL; + gTable[1] = channels & GREEN ? table : NULL; + gTable[2] = channels & BLUE ? table : NULL; + writePnmHeader(stdout, &in_pnm); pam_transform(stdin, stdout, &in_pnm, gTable); |
