diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-12 07:58:21 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-12 07:58:21 +0100 |
commit | 685e0abd14e20617e5821a35f0079632494e239f (patch) | |
tree | 46f95d09670d483935b34383f1466deb837cbe08 | |
parent | improve make files (diff) | |
download | scrotty-685e0abd14e20617e5821a35f0079632494e239f.tar.gz scrotty-685e0abd14e20617e5821a35f0079632494e239f.tar.bz2 scrotty-685e0abd14e20617e5821a35f0079632494e239f.tar.xz |
remove pnm support
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | doc/info/chap/invoking.texinfo | 17 | ||||
-rw-r--r-- | doc/man/scrotty.1 | 3 | ||||
-rw-r--r-- | doc/man/scrotty.sv.1 | 3 | ||||
-rw-r--r-- | po/sv.po | 2 | ||||
-rw-r--r-- | src/info.c | 1 | ||||
-rw-r--r-- | src/kern-linux.c | 45 | ||||
-rw-r--r-- | src/kern.h | 19 | ||||
-rw-r--r-- | src/png.c | 3 | ||||
-rw-r--r-- | src/png.h | 3 | ||||
-rw-r--r-- | src/pnm.c | 120 | ||||
-rw-r--r-- | src/pnm.h | 62 | ||||
-rw-r--r-- | src/scrotty.auto-completion | 3 | ||||
-rw-r--r-- | src/scrotty.c | 31 | ||||
-rw-r--r-- | src/scrotty.sv.auto-completion | 3 |
17 files changed, 18 insertions, 308 deletions
diff --git a/Makefile.in b/Makefile.in index c5d7196..efd0587 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,7 +60,7 @@ _VERSION = 2.0 _C_STD = c99 _PEDANTIC = yes _BIN = scrotty -_OBJ_scrotty = scrotty kern-linux info pattern pnm png +_OBJ_scrotty = scrotty kern-linux info pattern png _HEADER_DIRLEVELS = 1 _CPPFLAGS = -D'PACKAGE="$(PKGNAME)"' -D'PROGRAM_VERSION="$(_VERSION)"' _CPPFLAGS += $(shell pkg-config --cflags libpng) @@ -92,7 +92,7 @@ ___EVERYTHING_INFO = scrotty titlepage-data content hardcopy-copying \ appx/fdl appx/free-software-needs-free-documentation appx/gpl \ chap/invoking chap/overview chap/strftime \ reusable/macros reusable/paper reusable/titlepage -___EVERYTHING_H = common kern info pattern pnm png +___EVERYTHING_H = common kern info pattern png _EVERYTHING = $(foreach F,$(___EVERYTHING_INFO),doc/info/$(F).texinfo) \ $(foreach F,$(___EVERYTHING_H),src/$(F).h) \ $(__EVERYTHING_ALL_COMMON) DEPENDENCIES INSTALL NEWS $(__todo) doc/concept @@ -21,10 +21,6 @@ scrotty NEWS -*- outline -*- ** Improvements - The option --raw has been added. This option makes scrotty - store the images as a portable anymap format image rather - than as Portable Network Graphics image. - The ability to pass arguments to convert(1) has been removed. Utilise the --exec option instead! @@ -24,9 +24,6 @@ OPTIONS -c, --copyright Print copyright information. - -r, --raw - Save in PNM rather than in PNG. - -e, --exec CMD Command to run for each saved image. diff --git a/doc/info/chap/invoking.texinfo b/doc/info/chap/invoking.texinfo index bb4d8db..46d6e58 100644 --- a/doc/info/chap/invoking.texinfo +++ b/doc/info/chap/invoking.texinfo @@ -13,23 +13,6 @@ Print program name and version and exit. @item -c @itemx --copyright Print copyright information and exit. -@item -r -@itemx --raw -Save the images in portable anymap format -(@sc{PNM}), rather than in Portable Network -Graphics (@sc{PNG}). - -@sc{PNM} images are highly compressable with -@command{bzip2}. Compressed images are comparable -in size with @sc{PNG},@footnote{Usually a few -bytes in difference.} and can in fact be smaller. - -@sc{PNM} is a good alternative for anything -but storage. (Unless you compress them.) - -This option is also useful, in combination with -@option{--exec} if you want to save the image -in any other format. @item -e @itemx --exec CMD Run a command for each saved image. diff --git a/doc/man/scrotty.1 b/doc/man/scrotty.1 index aacb092..5cce851 100644 --- a/doc/man/scrotty.1 +++ b/doc/man/scrotty.1 @@ -33,9 +33,6 @@ Print program name and version. .B \-c ,\ \-\-copyright Print copyright information. .TP -.B \-r ,\ \-\-raw -Save in PNM rather than in PNG. -.TP .BR \-e ,\ \-\-exec \ \fICMD\fP Command to run for each saved image. .SH "SPECIAL STRINGS" diff --git a/doc/man/scrotty.sv.1 b/doc/man/scrotty.sv.1 index 0e294f6..b60ce87 100644 --- a/doc/man/scrotty.sv.1 +++ b/doc/man/scrotty.sv.1 @@ -34,9 +34,6 @@ Skriv ut programmets namn och version. .B \-c ,\ \-\-copyright Skriv ut upphovsrättsinformation. .TP -.B \-r ,\ \-\-raw -Spara som PNM-bild snarare än som PNG-bild. -.TP .BR \-e ,\ \-\-exec \ \fIKMD\fP Kommando att köra för varje sparad bild. .SH "SÄRSKILDA STRÄNGAR" @@ -64,7 +64,6 @@ msgid "" "\t-h, --help Print usage information.\n" "\t-v, --version Print program name and version.\n" "\t-c, --copyright Print copyright information.\n" -"\t-r, --raw Save in PNM rather than in PNG.\n" "\t-e, --exec CMD Command to run for each saved image.\n" "\n" "SPECIAL STRINGS\n" @@ -98,7 +97,6 @@ msgstr "" "\t-h, --help Skriv ut burksanvisningar.\n" "\t-v, --version Skriv ut programmets namn och version.\n" "\t-c, --copyright Skriv ut upphovsrättsinformation.\n" -"\t-r, --raw Spara som PNM-bild snarare än som PNG-bild.\n" "\t-e, --exec KMD Kommando att köra för varje sparad bild.\n" "\n" "SÄRSKILDA STRÄNGAR\n" @@ -36,7 +36,6 @@ print_help (void) "\t-h, --help Print usage information.\n" "\t-v, --version Print program name and version.\n" "\t-c, --copyright Print copyright information.\n" - "\t-r, --raw Save in PNM rather than in PNG.\n" "\t-e, --exec CMD Command to run for each saved image.\n" "\n" "SPECIAL STRINGS\n" diff --git a/src/kern-linux.c b/src/kern-linux.c index 7e31d1b..e6ca1a2 100644 --- a/src/kern-linux.c +++ b/src/kern-linux.c @@ -18,7 +18,6 @@ */ #include "common.h" #include "kern.h" -#include "pnm.h" #include "png.h" @@ -71,8 +70,7 @@ get_fbpath (int altpath, int fbno) * @param fbpath The path to the framebuffer device.. * @param width Output parameter for the width of the image. * @param height Output parameter for the height of the image. - * @parma data Additional data to pass to `convert_fb_to_pnm` - * and `convert_fb_to_png`. + * @parma data Additional data to pass to `convert_fb_to_png`. * @return Zero on success, -1 on error. */ int @@ -120,47 +118,6 @@ measure (int fbno, char *restrict fbpath, long *restrict width, /** - * Convert read data from a framebuffer to PNM pixel data. - * - * @param file The output image file. - * @param buf Buffer with read data. - * @param n The number of read characters. - * @param adjustment Set to zero if all bytes were converted - * (a whole number of pixels where available,) - * otherwise, set to the number of bytes a - * pixel is encoded. - * @param data Data from `measure`. - * @return Zero on success, -1 on error. - */ -int -convert_fb_to_pnm (FILE *restrict file, const char *restrict buf, size_t n, - size_t *restrict adjustment, void *restrict data) -{ - const uint32_t *restrict pixel; - int r, g, b; - size_t off; - - for (off = 0; off < n; off += 4) - { - /* A pixel in the framebuffer is formatted as `%{blue}%{green}%{red}%{x}` - in big-endian binary, or `%{x}%{red}%{green}%{blue}` in little-endian binary. */ - pixel = (const uint32_t *)(buf + off); - r = (*pixel >> 16) & 255; - g = (*pixel >> 8) & 255; - b = (*pixel >> 0) & 255; - - if (SAVE_PNM_PIXEL (file, r, g, b) < 0) - goto fail; - } - - *adjustment = (off != n ? 4 : 0); - return 0; - fail: - return -1; -} - - -/** * Convert read data from a framebuffer to PNG pixel data. * * @param file The output image file. @@ -58,30 +58,13 @@ char *get_fbpath (int altpath, int fbno); * @param fbpath The path to the framebuffer device.. * @param width Output parameter for the width of the image. * @param height Output parameter for the height of the image. - * @parma data Additional data to pass to `convert_fb_to_pnm` - * and `convert_fb_to_png`. + * @parma data Additional data to pass to `convert_fb_to_png`. * @return Zero on success, -1 on error. */ int measure (int fbno, char *restrict fbpath, long *restrict width, long *restrict height, void **restrict data); /** - * Convert read data from a framebuffer to PNM pixel data. - * - * @param file The output image file. - * @param buf Buffer with read data. - * @param n The number of read characters. - * @param adjustment Set to zero if all bytes were converted - * (a whole number of pixels where available,) - * otherwise, set to the number of bytes a - * pixel is encoded. - * @param data Data from `measure`. - * @return Zero on success, -1 on error. - */ -int convert_fb_to_pnm (FILE *restrict file, const char *restrict buf, size_t n, - size_t *restrict adjustment, void *restrict data); - -/** * Convert read data from a framebuffer to PNG pixel data. * * @param file The output image file. @@ -37,8 +37,7 @@ * @param width The width of the image. * @param height The height of the image. * @param imgfd The file descriptor connected to conversion process's stdin. - * @param data Additional data for `convert_fb_to_pnm` - * and `convert_fb_to_png`. + * @param data Additional data for `convert_fb_to_png`. * @return Zero on success, -1 on error. */ int @@ -58,8 +58,7 @@ * @param width The width of the image. * @param height The height of the image. * @param imgfd The file descriptor connected to conversion process's stdin. - * @param data Additional data for `convert_fb_to_pnm` - * and `convert_fb_to_png`. + * @param data Additional data for `convert_fb_to_png`. * @return Zero on success, -1 on error. */ int diff --git a/src/pnm.c b/src/pnm.c deleted file mode 100644 index 86fa738..0000000 --- a/src/pnm.c +++ /dev/null @@ -1,120 +0,0 @@ -/** - * scrotty — Screenshot program for Linux's TTY - * - * Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#include "common.h" -#include "pnm.h" -#include "kern.h" - - - -#define LIST_0_9(P) P"0\n", P"1\n", P"2\n", P"3\n", P"4\n", P"5\n", P"6\n", P"7\n", P"8\n", P"9\n" -/** - * [0, 255]-integer-to-text convertion lookup table for faster conversion from - * raw framebuffer data to the PNM format. The values have a whitespace at the - * end for even faster conversion. - * Lines should not be longer than 70 (although most programs will probably - * work even if there are longer lines), therefore the selected whitespace - * is LF (new line). - * - * ASCII has wider support than binary, and is create for version control, - * especifially with one datum per line. - */ -const char* inttable[] = - { - LIST_0_9(""), LIST_0_9("1"), LIST_0_9("2"), LIST_0_9("3"), LIST_0_9("4"), - LIST_0_9("5"), LIST_0_9("6"), LIST_0_9("7"), LIST_0_9("8"), LIST_0_9("9"), - - LIST_0_9("10"), LIST_0_9("11"), LIST_0_9("12"), LIST_0_9("13"), LIST_0_9("14"), - LIST_0_9("15"), LIST_0_9("16"), LIST_0_9("17"), LIST_0_9("18"), LIST_0_9("19"), - - LIST_0_9("20"), LIST_0_9("21"), LIST_0_9("22"), LIST_0_9("23"), LIST_0_9("24"), - "250\n", "251\n", "252\n", "253\n", "254\n", "255\n" - }; - - - -/** - * Create an PNM file. - * - * @param fbfd The file descriptor connected to framebuffer device. - * @param width The width of the image. - * @param height The height of the image. - * @param imgfd The file descriptor connected to conversion process's stdin. - * @param data Additional data for `convert_fb_to_pnm` - * and `convert_fb_to_png`. - * @return Zero on success, -1 on error. - */ -int -save_pnm (int fbfd, long width, long height, int imgfd, void *restrict data) -{ - char buf[8 << 10]; - FILE *file = NULL; - ssize_t got, off; - size_t adjustment; - int saved_errno; - - /* Create a FILE *, for writing, for the image file. */ - file = fdopen (imgfd, "w"); - if (file == NULL) - goto fail; - - /* The PNM image should begin with `P3\n%{width} %{height}\n%{colour max=255}\n`. - ('\n' and ' ' can be exchanged at will.) */ - if (fprintf (file, "P3\n%li %li\n255\n", width, height) < 0) - goto fail; - - /* Convert raw framebuffer data into a PNM image. */ - for (off = 0;;) - { - /* Read data from the framebuffer, we may have up to 3 bytes buffered. */ - got = read (fbfd, buf + off, sizeof (buf) - (size_t)off * sizeof (char)); - if (got < 0) - goto fail; - if (got == 0) - break; - got += off; - - /* Convert read pixels. */ - if (convert_fb_to_pnm (file, buf, (size_t)got, &adjustment, data) < 0) - goto fail; - - /* If we read a whole number of pixels, reset the buffer, otherwise, - move the unconverted bytes to the beginning of the buffer. */ - if (adjustment) - { - off -= (ssize_t)adjustment; - memcpy (buf, buf + off, (size_t)(got - off) * sizeof (char)); - off = got - off; - } - else - off = 0; - } - - /* Close file and return successfully. */ - fflush (file); - fclose (file); - return 0; - - fail: - saved_errno = errno; - if (file != NULL) - fclose (file); - errno = saved_errno; - return -1; -} - diff --git a/src/pnm.h b/src/pnm.h deleted file mode 100644 index f13972c..0000000 --- a/src/pnm.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * scrotty — Screenshot program for Linux's TTY - * - * Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.org) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -/** - * Store a pixel to a PNM image. - * - * A pixel in the PNM image is formatted as `%{red} %{green} %{blue} ` in text. - * - * @param F:FILE * The file whither the pixel shall be save. - * @param R:int The [0, 255]-value on the red subpixel. - * @param G:int The [0, 255]-value on the green subpixel. - * @param B:int The [0, 255]-value on the blue subpixel. - * @return Positive on success (not zero!), -1 on error. - */ -#define SAVE_PNM_PIXEL(F, R, G, B) \ - fprintf (F, "%s%s%s", inttable[R], inttable[G], inttable[B]) - - -/** - * [0, 255]-integer-to-text convertion lookup table for faster conversion from - * raw framebuffer data to the PNM format. The values have a whitespace at the - * end for even faster conversion. - * Lines should not be longer than 70 (although most programs will probably - * work even if there are longer lines), therefore the selected whitespace - * is LF (new line). - * - * ASCII is wider supported than binary, and is create for version control, - * especifially with one datum per line. - */ -extern const char* inttable[]; - - -/** - * Create an PNM file. - * - * @param fbfd The file descriptor connected to framebuffer device. - * @param width The width of the image. - * @param height The height of the image. - * @param imgfd The file descriptor connected to conversion process's stdin. - * @param data Additional data for `convert_fb_to_pnm` - * and `convert_fb_to_png`. - * @return Zero on success, -1 on error. - */ -int save_pnm (int fbfd, long width, long height, int imgfd, void *restrict data); - diff --git a/src/scrotty.auto-completion b/src/scrotty.auto-completion index 8e9e91f..83cb284 100644 --- a/src/scrotty.auto-completion +++ b/src/scrotty.auto-completion @@ -11,9 +11,6 @@ (unargumented (options -c --copyright) (complete --copyright) (desc 'Print copyright information.')) - (unargumented (options -r --raw) (complete --raw) - (desc 'Save in PNM rather than in PNG.')) - (argumented (options -e --exec) (complete --exec) (arg COMMAND) (files -0) (desc 'Command to run for each saved image.')) diff --git a/src/scrotty.c b/src/scrotty.c index 30c1dcc..e95b4e3 100644 --- a/src/scrotty.c +++ b/src/scrotty.c @@ -20,7 +20,6 @@ #include "common.h" #include "kern.h" #include "info.h" -#include "pnm.h" #include "png.h" #include "pattern.h" @@ -70,14 +69,12 @@ static int try_alt_fbpath = 0; * @param imgname The pathname of the output image. * @param width The width of the image. * @param height The height of the image. - * @param raw Save in PNM? - * @param data Additional data for `convert_fb_to_pnm` - * and `convert_fb_to_png`. + * @param data Additional data for `convert_fb_to_png`. * @return Zero on success, -1 on error. */ static int save (const char *fbpath, const char *imgpath, long width, - long height, int raw, void *restrict data) + long height, void *restrict data) { int imgfd = -1, fbfd = -1; int saved_errno; @@ -94,7 +91,7 @@ save (const char *fbpath, const char *imgpath, long width, FILE_FAILURE (fbpath); /* Save image. */ - if ((raw ? save_pnm : save_png) (fbfd, width, height, imgfd, data) < 0) + if (save_png (fbfd, width, height, imgfd, data) < 0) goto fail; close (fbfd); @@ -183,16 +180,15 @@ exec_image (char *flatten_args) * Take a screenshot of a framebuffer. * * @param fbno The number of the framebuffer. - * @param raw Save in PNM rather than in PNG?. * @param filepattern The pattern for the filename, `NULL` for default. * @param execpattern The pattern for the command to run to * process the image, `NULL` for none. * @return Zero on success, -1 on error, 1 if the framebuffer does not exist. */ static int -save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) +save_fb (int fbno, const char *filepattern, const char *execpattern) { - char imgpath_[sizeof ("fb.xyz.") + 2 * 3 * sizeof (int)]; + char imgpath_[sizeof ("fb.png.") + 2 * 3 * sizeof (int)]; char *imgpath = imgpath_; char *fbpath; /* Statically allocate string is returned. */ char *execargs = NULL; @@ -212,9 +208,9 @@ save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) /* Get output pathname. */ if (filepattern == NULL) { - sprintf (imgpath, "fb%i.%s", fbno, (raw ? "pnm" : "png")); + sprintf (imgpath, "fb%i.png", fbno); for (i = 2; access (imgpath, F_OK) == 0; i++) - sprintf (imgpath, "fb%i.%s.%i", fbno, (raw ? "pnm" : "png"), i); + sprintf (imgpath, "fb%i.png.%i", fbno, i); } else { @@ -224,7 +220,7 @@ save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) } /* Take a screenshot of the current framebuffer. */ - if (save (fbpath, imgpath, width, height, raw, data) < 0) + if (save (fbpath, imgpath, width, height, data) < 0) goto fail; fprintf (stderr, _("Saved framebuffer %i to %s.\n"), fbno, imgpath); @@ -257,14 +253,13 @@ save_fb (int fbno, int raw, const char *filepattern, const char *execpattern) /** * Take a screenshot of all framebuffers. * - * @param raw Save in PNM rather than in PNG?. * @param filepattern The pattern for the filename, `NULL` for default. * @param execpattern The pattern for the command to run to * process thes image, `NULL` for none. * @return Zero on success, -1 on error, 1 if no framebuffer exists. */ static -int save_fbs (int raw, const char *filepattern, const char *exec) +int save_fbs (const char *filepattern, const char *exec) { int r, fbno, found = 0; @@ -272,7 +267,7 @@ int save_fbs (int raw, const char *filepattern, const char *exec) /* Take a screenshot of each framebuffer. */ for (fbno = 0;; fbno++) { - r = save_fb (fbno, raw, filepattern, exec); + r = save_fb (fbno, filepattern, exec); if (r < 0) goto fail; else if (r == 0) @@ -326,7 +321,7 @@ main (int argc, char *argv[]) #define USAGE_ASSERT(ASSERTION, MSG) \ do { if (!(ASSERTION)) EXIT_USAGE (MSG); } while (0) - int r, raw = 0; + int r, all = 1, devno = 0; char *exec = NULL; char *filepattern = NULL; struct option long_options[] = @@ -334,7 +329,6 @@ main (int argc, char *argv[]) {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"copyright", no_argument, NULL, 'c'}, - {"raw", no_argument, NULL, 'r'}, {"exec", required_argument, NULL, 'e'}, {NULL, 0, NULL, 0 } }; @@ -355,7 +349,6 @@ main (int argc, char *argv[]) else if (r == 'h') return -(print_help ()); else if (r == 'v') return -(print_version ()); else if (r == 'c') return -(print_copyright ()); - else if (r == 'r') raw = 1; else if (r == 'e') { USAGE_ASSERT (exec == NULL, _("--exec is used twice.")); @@ -373,7 +366,7 @@ main (int argc, char *argv[]) } /* Take a screenshot of each framebuffer. */ - r = save_fbs (raw, filepattern, exec); + r = save_fbs (filepattern, exec); if (r < 0) goto fail; if (r > 0) diff --git a/src/scrotty.sv.auto-completion b/src/scrotty.sv.auto-completion index 24bd201..73e2c2a 100644 --- a/src/scrotty.sv.auto-completion +++ b/src/scrotty.sv.auto-completion @@ -11,9 +11,6 @@ (unargumented (options -c --copyright) (complete --copyright) (desc 'Skriv ut upphovsrättsinformation.')) - (unargumented (options -r --raw) (complete --raw) - (desc 'Spara som PNM-bild snarare än som PNG-bild.')) - (argumented (options -e --exec) (complete --exec) (arg KOMMANDO) (files -0) (desc 'Kör ett Kommando för varje sparad bild.')) |