aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-to-text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/blind-to-text.c')
-rw-r--r--src/blind-to-text.c27
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