From bcac04b4316d64063e743e7a49195173a0c175a0 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 24 Sep 2017 01:26:08 +0200 Subject: Add -% to blind-to-text, blind-colour-srgb, and blind-colour-ciexyz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-to-text.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/blind-to-text.c') diff --git a/src/blind-to-text.c b/src/blind-to-text.c index befa3c7..b4f977c 100644 --- a/src/blind-to-text.c +++ b/src/blind-to-text.c @@ -3,7 +3,9 @@ #define INCLUDE_UINT16 #include "common.h" -USAGE("") +USAGE("[-% format]") + +const char *fmt = NULL; #define FILE "blind-to-text.c" #include "define-functions.h" @@ -14,10 +16,19 @@ main(int argc, char *argv[]) struct stream stream; void (*process)(struct stream *stream, size_t n); - UNOFLAGS(argc); + ARGBEGIN { + case '%': + fmt = UARGF(); + break; + default: + usage(); + } ARGEND; - eopen_stream(&stream, NULL); + if (argc) + usage(); + eopen_stream(&stream, NULL); + fmt = select_print_format("%! %! %! %!\n", stream.encoding, fmt); SELECT_PROCESS_FUNCTION(&stream); printf("%zu %zu %zu %s\n", stream.frames, stream.width, stream.height, stream.pixfmt); process_stream(&stream, process); @@ -32,12 +43,10 @@ PROCESS(struct stream *stream, size_t n) { size_t i; TYPE *p = (TYPE *)(stream->buf); - for (i = 0, n /= stream->chan_size; i < n; i++) -#ifdef INTEGER_TYPE - printf("%"PRINT_TYPE"%c", (PRINT_CAST)(p[i]), (i + 1) % stream->n_chan ? ' ' : '\n'); -#else - printf("%.25"PRINT_TYPE"%c", (PRINT_CAST)(p[i]), (i + 1) % stream->n_chan ? ' ' : '\n'); -#endif + for (i = 0, n /= stream->chan_size; i < n; i += 4) { + printf(fmt, (PRINT_CAST)(p[i + 0]), (PRINT_CAST)(p[i + 1]), + (PRINT_CAST)(p[i + 2]), (PRINT_CAST)(p[i + 3])); + } } #endif -- cgit v1.2.3-70-g09d2