diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-11 11:25:02 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-11 11:25:02 +0100 |
commit | 6d2d5307a6b358f3528f53cc6a8c9b2acd50f397 (patch) | |
tree | 72bbada59c7c2188e7bdfbe7e7b372097cc9ef38 /src/scrotty.c | |
parent | soon, convert will not be used (diff) | |
download | scrotty-6d2d5307a6b358f3528f53cc6a8c9b2acd50f397.tar.gz scrotty-6d2d5307a6b358f3528f53cc6a8c9b2acd50f397.tar.bz2 scrotty-6d2d5307a6b358f3528f53cc6a8c9b2acd50f397.tar.xz |
use libpng, ... now we just have to make it faster
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/scrotty.c')
-rw-r--r-- | src/scrotty.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/scrotty.c b/src/scrotty.c index da69cc9..9837a26 100644 --- a/src/scrotty.c +++ b/src/scrotty.c @@ -21,6 +21,7 @@ #include "kern.h" #include "info.h" #include "pnm.h" +#include "png.h" #include "pattern.h" #include <getopt.h> @@ -188,6 +189,7 @@ save (const char *fbpath, const char *imgpath, long width, long height, int raw) if (raw) goto no_convert; + /* Create a pipe that for sending data into the conversion process program. */ if (pipe (pipe_rw) < 0) goto fail; @@ -203,17 +205,18 @@ save (const char *fbpath, const char *imgpath, long width, long height, int raw) { /* Close the write-end of the pipe. */ close (pipe_rw[1]); - /* Turn the read-end of the pipe into stdin. */ - if (pipe_rw[0] != STDIN_FILENO) - { - close (STDIN_FILENO); - if (dup2 (pipe_rw[0], STDIN_FILENO) == -1) - goto child_fail; - close (pipe_rw[0]); - } - /* Exec. `convert` to convert the PNM-image we create to a compressed image. */ - execlp ("convert", "convert", DEVDIR "/stdin", imgpath, NULL); + /* Open file descriptor for the output image. */ + fd = open(imgpath, O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (fd == -1) + goto child_fail; + + /* Convert the PNM-image we create to a compressed image, namely in PNG. */ + if (convert (pipe_rw[0], fd) < 0) + goto child_fail; + + _exit(0); child_fail: perror(execname); _exit(1); |