diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-14 04:40:03 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-14 04:40:03 +0100 |
| commit | a2dfbb3368ce0e998f774dd294383772651d1302 (patch) | |
| tree | 094dbc3206297d3b3b0d090daff426ce66ea45f7 /src/blind-to-image.c | |
| parent | Rename to blind (diff) | |
| download | blind-a2dfbb3368ce0e998f774dd294383772651d1302.tar.gz blind-a2dfbb3368ce0e998f774dd294383772651d1302.tar.bz2 blind-a2dfbb3368ce0e998f774dd294383772651d1302.tar.xz | |
Fix errors, blind-{to,from}-{video,image} works
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-to-image.c')
| -rw-r--r-- | src/blind-to-image.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/blind-to-image.c b/src/blind-to-image.c index 4b3d20c..761722a 100644 --- a/src/blind-to-image.c +++ b/src/blind-to-image.c @@ -46,14 +46,14 @@ write_pixel(double R, double G, double B, double A, int bytes, unsigned long lon colours[2] = srgb_encode(B) * max + 0.5; colours[3] = A * max + 0.5; - for (i = k = 0; i < 4; i++) { - for (j = 0; j < bytes; j++, k++) { - buf[k + bm - j] = (unsigned char)(colours[j]); - colours[j] >>= 8; + for (i = k = 0; i < 4; i++, k += bytes) { + for (j = 0; j < bytes; j++) { + buf[k + bm - j] = (unsigned char)(colours[i]); + colours[i] >>= 8; } } - ewriteall(STDOUT_FILENO, buf, (size_t)bytes * 4, "<stdout>"); + ewriteall(STDOUT_FILENO, buf, k, "<stdout>"); } static void @@ -75,7 +75,7 @@ process_xyza(struct stream *stream, size_t n, int bytes, unsigned long long int } } - srgb_to_ciexyz(X, Y, Z, &R, &G, &B); + ciexyz_to_srgb(X, Y, Z, &R, &G, &B); write_pixel(R, G, B, A, bytes, max); } } @@ -109,7 +109,7 @@ main(int argc, char *argv[]) max = 1ULL << (depth - 1); max |= max - 1; - for (bytes = 1; bytes * 8 < depth; bytes++); + bytes = (depth + 7) / 8; if (!strcmp(stream.pixfmt, "xyza")) process = process_xyza; |
