aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-to-text.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-05-07 16:11:31 +0200
committerMattias Andrée <maandree@kth.se>2017-05-07 16:11:31 +0200
commit4df594b3f48679f594e6f738981cb3baca8a42d9 (patch)
tree6d25bcd5ce62af2537687eff9cce67fa197ec65d /src/blind-to-text.c
parentBump version to 1.1 (diff)
downloadblind-4df594b3f48679f594e6f738981cb3baca8a42d9.tar.gz
blind-4df594b3f48679f594e6f738981cb3baca8a42d9.tar.bz2
blind-4df594b3f48679f594e6f738981cb3baca8a42d9.tar.xz
Add support for floats
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-to-text.c')
-rw-r--r--src/blind-to-text.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/blind-to-text.c b/src/blind-to-text.c
index 7fefbfc..59ab8c3 100644
--- a/src/blind-to-text.c
+++ b/src/blind-to-text.c
@@ -8,17 +8,19 @@
USAGE("")
-static void
-process_xyza(struct stream *stream, size_t n)
-{
- size_t i;
- for (i = 0; i < n; i += stream->pixel_size)
- printf("%lf %lf %lf %lf\n",
- ((double *)(stream->buf + i))[0],
- ((double *)(stream->buf + i))[1],
- ((double *)(stream->buf + i))[2],
- ((double *)(stream->buf + i))[3]);
-}
+#define PROCESS(TYPE, CAST, FMT)\
+ do {\
+ size_t i;\
+ for (i = 0; i < n; i += stream->pixel_size)\
+ printf("%"FMT" %"FMT" %"FMT" %"FMT"\n",\
+ (CAST)(((TYPE *)(stream->buf + i))[0]),\
+ (CAST)(((TYPE *)(stream->buf + i))[1]),\
+ (CAST)(((TYPE *)(stream->buf + i))[2]),\
+ (CAST)(((TYPE *)(stream->buf + i))[3]));\
+ } while (0)
+
+static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, double, "lf");}
+static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, double, "lf");}
int
main(int argc, char *argv[])
@@ -32,6 +34,8 @@ main(int argc, char *argv[])
if (!strcmp(stream.pixfmt, "xyza"))
process = process_xyza;
+ else if (!strcmp(stream.pixfmt, "xyza f"))
+ process = process_xyzaf;
else
eprintf("pixel format %s is not supported, try xyza\n", stream.pixfmt);