diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-09-24 01:26:08 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-09-24 01:31:31 +0200 |
| commit | bcac04b4316d64063e743e7a49195173a0c175a0 (patch) | |
| tree | fc29431d21d83e4496da31d32f4f441de41026be /src/blind-to-text.c | |
| parent | Fix colour distortion (diff) | |
| download | blind-bcac04b4316d64063e743e7a49195173a0c175a0.tar.gz blind-bcac04b4316d64063e743e7a49195173a0c175a0.tar.bz2 blind-bcac04b4316d64063e743e7a49195173a0c175a0.tar.xz | |
Add -% to blind-to-text, blind-colour-srgb, and blind-colour-ciexyz
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-to-text.c')
| -rw-r--r-- | src/blind-to-text.c | 27 |
1 files changed, 18 insertions, 9 deletions
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 |
