From 37980568fc614968f1c1f55f3ef4e0dd17f968eb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 14 Jan 2017 04:59:20 +0100 Subject: Fix blind-transpose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-transpose.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/blind-transpose.c b/src/blind-transpose.c index 0c32d81..7bc124d 100644 --- a/src/blind-transpose.c +++ b/src/blind-transpose.c @@ -14,28 +14,33 @@ main(int argc, char *argv[]) { struct stream stream; char *buf, *image; - size_t n, imgw, imgh, x, y, i, b; + size_t n, imgw, srcw, srch, ps, x, y, i, b, dx; ENOFLAGS(argc); stream.file = ""; stream.fd = STDIN_FILENO; einit_stream(&stream); + imgw = srch = stream.height; + stream.height = srcw = stream.width; + stream.width = imgw; fprint_stream_head(stdout, &stream); efflush(stdout, ""); echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, ""); - n = stream.width * stream.height * stream.pixel_size; + n = stream.width * stream.height * (ps = stream.pixel_size); buf = emalloc(n); image = emalloc(n); - imgw = stream.width * (imgh = stream.height * stream.pixel_size); + srch *= ps; + srcw *= dx = imgw * ps; + imgw *= ps; memcpy(buf, stream.buf, stream.ptr); while (eread_frame(&stream, buf, n)) { - for (b = y = 0; y < imgh; y += stream.pixel_size) - for (x = 0; x < imgw; x += imgh) - for (i = 0; i < stream.pixel_size; i++) - image[x + y + i] = buf[b++]; + for (b = y = 0; y < srch; y += ps) + for (x = 0; x < srcw; x += dx) + for (i = 0; i < ps; i++, b++) + image[y + x + i] = buf[b]; ewriteall(STDOUT_FILENO, image, n, ""); } -- cgit v1.2.3-70-g09d2