From 4674ec0e4b833ab0d0365225ba99228df14abe87 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 13 Jan 2017 09:05:08 +0100 Subject: Rename to blind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-set-luma.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/blind-set-luma.c (limited to 'src/blind-set-luma.c') diff --git a/src/blind-set-luma.c b/src/blind-set-luma.c new file mode 100644 index 0000000..4500645 --- /dev/null +++ b/src/blind-set-luma.c @@ -0,0 +1,47 @@ +/* See LICENSE file for copyright and license details. */ +#include "stream.h" +#include "util.h" + +#include +#include +#include +#include + +USAGE("luma-stream") + +static void +process_xyza(struct stream *colour, struct stream *luma, size_t n) +{ + size_t i; + double a; + for (i = 0; i < n; i += colour->pixel_size) { + a = ((double *)(luma->buf + i))[1]; + a *= ((double *)(luma->buf + i))[3]; + ((double *)(colour->buf + i))[1] *= a; + } +} + +int +main(int argc, char *argv[]) +{ + struct stream colour, luma; + void (*process)(struct stream *colour, struct stream *luma, size_t n); + + ENOFLAGS(argc != 1); + + colour.file = ""; + colour.fd = STDIN_FILENO; + einit_stream(&colour); + + luma.file = argv[0]; + luma.fd = eopen(luma.file, O_RDONLY); + einit_stream(&luma); + + if (!strcmp(colour.pixfmt, "xyza")) + process = process_xyza; + else + eprintf("pixel format %s is not supported, try xyza\n", colour.pixfmt); + + process_two_streams(&colour, &luma, STDOUT_FILENO, "", process); + return 0; +} -- cgit v1.2.3-70-g09d2