(wrong string) ée

From: <git_AT_suckless.org>
Date: Mon, 9 Jan 2017 19:43:54 +0100 (CET)

commit 3d80d7237d18bdbf53e327a576b52b35b36af3ad
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Mon Jan 9 05:23:27 2017 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Mon Jan 9 19:42:39 2017 +0100

    Add ff2pam(1): convert farbfeld to 16-bit RGBA Portable Arbitrary Map
    
    Laslo: Minor changes
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/Makefile b/Makefile
index 2177d25..72a5e3c 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -2,7 +2,7 @@
 # See LICENSE file for copyright and license details
 include config.mk
 
-BIN = png2ff ff2png jpg2ff ff2jpg ff2ppm
+BIN = png2ff ff2png jpg2ff ff2jpg ff2pam ff2ppm
 SCRIPTS = 2ff
 SRC = ${BIN:=.c}
 HDR = arg.h
diff --git a/ff2pam.1 b/ff2pam.1
new file mode 100644
index 0000000..1153c5a
--- /dev/null
+++ b/ff2pam.1
_AT_@ -0,0 +1,41 @@
+.Dd 2017-01-09
+.Dt FF2PAM 1
+.Os suckless.org
+.Sh NAME
+.Nm ff2pam
+.Nd convert farbfeld to PAM
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+.Nm
+reads a
+.Xr farbfeld 5
+image from stdin, converts it to a 16-bit RGBA PAM and writes the result
+to stdout.
+.Pp
+In case of an error
+.Nm
+writes a diagnostic message to stderr.
+.Sh EXIT STATUS
+.Bl -tag -width Ds
+.It 0
+Image processed successfully.
+.It 1
+An error occurred.
+.El
+.Sh EXAMPLES
+$
+.Nm
+< image.ff > image.pam
+.Pp
+$ bunzip2 < image.ff.bz2 |
+.Nm
+> image.pam
+.Sh SEE ALSO
+.Xr 2ff 1 ,
+.Xr bunzip2 1 ,
+.Xr bzip2 1 ,
+.Xr png2ff 1 ,
+.Xr farbfeld 5
+.Sh AUTHORS
+.An Mattias Andrée Aq Mt maandree_AT_kth.se
diff --git a/ff2pam.c b/ff2pam.c
new file mode 100644
index 0000000..93bd26c
--- /dev/null
+++ b/ff2pam.c
_AT_@ -0,0 +1,74 @@
+/* See LICENSE file for copyright and license details. */
+#include <arpa/inet.h>
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static char *argv0;
+
+int
+main(int argc, char *argv[])
+{
+ uint32_t hdr[4], width, height;
+ char buf[BUFSIZ];
+ size_t n, t;
+
+ argv0 = argv[0], argc--, argv++;
+
+ if (argc) {
+ fprintf(stderr, "usage: %s\n", argv0);
+ return 1;
+ }
+
+ /* header */
+ if (fread(hdr, sizeof(*hdr), 4, stdin) != 4) {
+ fprintf(stderr, "%s: file too short\n", argv0);
+ return 1;
+ }
+ if (memcmp("farbfeld", hdr, sizeof("farbfeld") - 1)) {
+ fprintf(stderr, "%s: invalid magic value\n", argv0);
+ return 1;
+ }
+ width = ntohl(hdr[2]);
+ height = ntohl(hdr[3]);
+
+ /* write header */
+ printf("P7\n"
+ "WIDTH %" PRIu32 "\n"
+ "HEIGHT %" PRIu32 "\n"
+ "DEPTH 4\n" /* number of channels */
+ "MAXVAL 65535\n"
+ "TUPLTYPE RGB_ALPHA\n"
+ "ENDHDR\n",
+ width, height);
+
+ /* write image */
+ t = (size_t)width * (size_t)height * sizeof(uint16_t) * (sizeof("RGBA") - 1);
+ for (; (n = fread(buf, 1, sizeof(buf) <= t ? sizeof(buf) : t, stdin)); ) {
+ t -= n;
+ fwrite(buf, 1, n, stdout);
+
+ if (feof(stdin)) {
+ break;
+ }
+ if (ferror(stdin)) {
+ fprintf(stderr, "%s: read: %s\n", argv0, strerror(errno));
+ return 1;
+ }
+ if (ferror(stdout)) {
+ fprintf(stderr, "%s: write: %s\n", argv0, strerror(errno));
+ return 1;
+ }
+ }
+
+ if (t > 0) {
+ fprintf(stderr, "%s: file too short\n", argv0);
+ return 1;
+ }
+
+ return 0;
+}
Received on Mon Jan 09 2017 - 19:43:54 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 09 2017 - 19:48:15 CET