diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-11 09:11:51 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-11 09:11:51 +0100 |
| commit | b7a82c980fe7e0c1f9029b55be97422428d65d5a (patch) | |
| tree | 67bedc856eb1f72a2daa8ef8347b904269b06df5 /src/vu-colour-srgb.c | |
| parent | vu-crop: add -t (diff) | |
| download | blind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.gz blind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.bz2 blind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.xz | |
Clean up code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/vu-colour-srgb.c')
| -rw-r--r-- | src/vu-colour-srgb.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/vu-colour-srgb.c b/src/vu-colour-srgb.c index 164c6ae..53fb784 100644 --- a/src/vu-colour-srgb.c +++ b/src/vu-colour-srgb.c @@ -1,25 +1,18 @@ /* See LICENSE file for copyright and license details. */ -#include "arg.h" #include "util.h" -static void -usage(void) -{ - eprintf("usage: %s [-d depth] [-l] red green blue\n", argv0); -} +USAGE("[-d depth] [-l] red green blue") int main(int argc, char *argv[]) { unsigned long long int max; double red, green, blue, X, Y, Z; - int depth = 8; - int linear = 0; + int depth = 8, linear = 0; ARGBEGIN { case 'd': - if (toi(EARGF(usage()), 1, 64, &depth)) - eprintf("argument of -d must be an integer in [1, 64]\n"); + depth = etoi_flag('d', EARG(), 1, 64); break; case 'l': linear = 1; @@ -31,18 +24,11 @@ main(int argc, char *argv[]) if (argc != 3) usage(); - if (tolf(argv[0], &red)) - eprintf("the X value must be a floating-point value\n"); - if (tolf(argv[1], &green)) - eprintf("the Y value must be a floating-point value\n"); - if (tolf(argv[2], &blue)) - eprintf("the Z value must be a floating-point value\n"); - - max = 1ULL << (depth - 1); - max |= max - 1; - red /= max; - green /= max; - blue /= max; + max = 1ULL << (depth - 1); + max |= max - 1; + red = etolf_arg("the red value", argv[0]) / max; + green = etolf_arg("the green value", argv[1]) / max; + blue = etolf_arg("the blue value", argv[2]) / max; if (!linear) { red = srgb_decode(red); green = srgb_decode(green); @@ -51,7 +37,7 @@ main(int argc, char *argv[]) srgb_to_ciexyz(red, green, blue, &X, &Y, &Z); printf("%lf %lf %lf\n", X, Y, Z); - efshut(stdout, "<stdout>"); + efshut(stdout, "<stdout>"); return 0; } |
