From cfc61f4fa5a5b2236439ec1ebe416f23e31d8092 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 11 Jun 2020 14:53:23 +0200 Subject: Soo many features added weeee so much efficiencyyyy --- .repos/farbfeld/ff2pam.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .repos/farbfeld/ff2pam.c (limited to '.repos/farbfeld/ff2pam.c') diff --git a/.repos/farbfeld/ff2pam.c b/.repos/farbfeld/ff2pam.c new file mode 100644 index 0000000..fca5c6f --- /dev/null +++ b/.repos/farbfeld/ff2pam.c @@ -0,0 +1,55 @@ +/* See LICENSE file for copyright and license details. */ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" + +static void +usage(void) +{ + die("usage: %s", argv0); +} + +int +main(int argc, char *argv[]) +{ + size_t rowlen; + uint32_t width, height, i; + uint16_t *row; + + /* arguments */ + argv0 = argv[0], argc--, argv++; + + if (argc) { + usage(); + } + + /* prepare */ + ff_read_header(&width, &height); + row = ereallocarray(NULL, width, (sizeof("RGBA") - 1) * sizeof(uint16_t)); + rowlen = width * (sizeof("RGBA") - 1); + + /* write data */ + printf("P7\n" + "WIDTH %" PRIu32 "\n" + "HEIGHT %" PRIu32 "\n" + "DEPTH 4\n" /* number of channels */ + "MAXVAL 65535\n" + "TUPLTYPE RGB_ALPHA\n" + "ENDHDR\n", + width, height); + + for (i = 0; i < height; i++) { + efread(row, sizeof(uint16_t), rowlen, stdin); + efwrite(row, sizeof(uint16_t), rowlen, stdout); + } + + return fshut(stdout, ""); +} -- cgit v1.2.3