aboutsummaryrefslogtreecommitdiffstats
path: root/src/vu-crop.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-11 21:48:59 +0100
committerMattias Andrée <maandree@kth.se>2017-01-11 21:48:59 +0100
commit763a16e7e60fdb2bd189a7e1f84d2432065478bc (patch)
tree5b125083679713f1246987901c1fadf729e6a0df /src/vu-crop.c
parentReuse code (diff)
downloadblind-763a16e7e60fdb2bd189a7e1f84d2432065478bc.tar.gz
blind-763a16e7e60fdb2bd189a7e1f84d2432065478bc.tar.bz2
blind-763a16e7e60fdb2bd189a7e1f84d2432065478bc.tar.xz
Reuse code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/vu-crop.c')
-rw-r--r--src/vu-crop.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/vu-crop.c b/src/vu-crop.c
index 7be2e74..68b1724 100644
--- a/src/vu-crop.c
+++ b/src/vu-crop.c
@@ -16,7 +16,6 @@ main(int argc, char *argv[])
char *buf, *image, *p;
size_t width = 0, height = 0, left = 0, top = 0;
size_t off, yoff = 0, x, y, irown, orown, ptr, n, m;
- ssize_t r;
int tile = 0;
ARGBEGIN {
@@ -65,21 +64,9 @@ main(int argc, char *argv[])
off = (orown - (left % orown)) % orown;
yoff = (height - (top % height)) % height;
}
- memcpy(buf, stream.buf, ptr = stream.ptr);
- for (;;) {
- for (; ptr < n; ptr += (size_t)r) {
- r = read(stream.fd, buf + ptr, n - ptr);
- if (r < 0) {
- eprintf("read %s:", stream.file);
- } else if (r == 0) {
- if (!ptr)
- break;
- eprintf("%s: incomplete frame", stream.file);
- }
- }
- if (!ptr)
- break;
+ memcpy(buf, stream.buf, ptr = stream.ptr);
+ while (eread_frame(&stream, buf, n)) {
if (!tile) {
for (y = 0; y < height; y++)
memcpy(image + y * orown, buf + y * irown + off, orown);
@@ -90,7 +77,6 @@ main(int argc, char *argv[])
image[ptr++] = p[(x + off) % orown];
}
}
-
ewriteall(STDOUT_FILENO, image, m, "<stdout>");
}