aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-colour-srgb.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-13 09:05:08 +0100
committerMattias Andrée <maandree@kth.se>2017-01-13 09:05:08 +0100
commit4674ec0e4b833ab0d0365225ba99228df14abe87 (patch)
tree1b89fe1559fc9a2422e20048700e694a72d17751 /src/blind-colour-srgb.c
parentvu-from-video: fix Y'UV encoding + add vu-to-video (diff)
downloadblind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.gz
blind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.bz2
blind-4674ec0e4b833ab0d0365225ba99228df14abe87.tar.xz
Rename to blind
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-colour-srgb.c')
-rw-r--r--src/blind-colour-srgb.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/blind-colour-srgb.c b/src/blind-colour-srgb.c
new file mode 100644
index 0000000..53fb784
--- /dev/null
+++ b/src/blind-colour-srgb.c
@@ -0,0 +1,43 @@
+/* See LICENSE file for copyright and license details. */
+#include "util.h"
+
+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, linear = 0;
+
+ ARGBEGIN {
+ case 'd':
+ depth = etoi_flag('d', EARG(), 1, 64);
+ break;
+ case 'l':
+ linear = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 3)
+ usage();
+
+ 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);
+ blue = srgb_decode(blue);
+ }
+
+ srgb_to_ciexyz(red, green, blue, &X, &Y, &Z);
+ printf("%lf %lf %lf\n", X, Y, Z);
+
+ efshut(stdout, "<stdout>");
+ return 0;
+}