aboutsummaryrefslogtreecommitdiff
path: root/.repos/farbfeld/ff2png.c
diff options
context:
space:
mode:
authorMarvin Borner2022-05-31 14:17:19 +0200
committerMarvin Borner2022-05-31 14:17:19 +0200
commitb8be82d9113dd0fec9021aa573039cc64dbd849a (patch)
tree0694d21e5ba03e843dc6f03d1c5b1ed033123875 /.repos/farbfeld/ff2png.c
parent272cc6e941d798d7270fcf74a98f592ef06e14ac (diff)
Clean
Diffstat (limited to '.repos/farbfeld/ff2png.c')
-rw-r--r--.repos/farbfeld/ff2png.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/.repos/farbfeld/ff2png.c b/.repos/farbfeld/ff2png.c
deleted file mode 100644
index 193b375..0000000
--- a/.repos/farbfeld/ff2png.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <png.h>
-
-#include "util.h"
-
-static void
-png_err(png_struct *pngs, const char *msg)
-{
- (void)pngs;
- die("libpng: %s", msg);
-}
-
-static void
-png_setup_writer(png_struct **s, png_info **i, uint32_t w, uint32_t h)
-{
- *s = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_err, NULL);
- *i = png_create_info_struct(*s);
-
- if (!*s || !*i) {
- die("Failed to initialize libpng");
- }
-
- png_init_io(*s, stdout);
- png_set_IHDR(*s, *i, w, h, 16, PNG_COLOR_TYPE_RGB_ALPHA,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
- PNG_FILTER_TYPE_BASE);
- png_write_info(*s, *i);
-}
-
-static void
-usage(void)
-{
- die("usage: %s", argv0);
-}
-
-int
-main(int argc, char *argv[])
-{
- png_struct *pngs;
- png_info *pngi;
- size_t rowlen;
- uint32_t width, height, i;
- uint16_t *row;
-
- /* arguments */
- argv0 = argv[0], argc--, argv++;
-
- if (argc) {
- usage();
- }
-
- /* prepare */
- ff_read_header(&width, &height);
- png_setup_writer(&pngs, &pngi, width, height);
- row = ereallocarray(NULL, width, (sizeof("RGBA") - 1) * sizeof(uint16_t));
- rowlen = width * (sizeof("RGBA") - 1);
-
- /* write data */
- for (i = 0; i < height; ++i) {
- efread(row, sizeof(uint16_t), rowlen, stdin);
- png_write_row(pngs, (uint8_t *)row);
- }
-
- /* clean up */
- png_write_end(pngs, NULL);
- png_destroy_write_struct(&pngs, NULL);
-
- return fshut(stdout, "<stdout>");
-}