1 /* Fake a PNG - just write it out directly.
3 * COPYRIGHT: Written by John Cunningham Bowler, 2014.
4 * To the extent possible under law, the author has waived all copyright and
5 * related or neighboring rights to this work. This work is published from:
11 #include <zlib.h> /* for crc32 */
23 put_chunk(const unsigned char *chunk
, uInt length
)
27 put_uLong(length
-4); /* Exclude the tag */
29 fwrite(chunk
, length
, 1, stdout
);
31 crc
= crc32(0, Z_NULL
, 0);
32 put_uLong(crc32(crc
, chunk
, length
));
35 const unsigned char signature
[] =
37 137, 80, 78, 71, 13, 10, 26, 10
40 const unsigned char IHDR
[] =
42 73, 72, 68, 82, /* IHDR */
43 0, 0, 0, 1, /* width */
44 0, 0, 0, 1, /* height */
46 0, /* color type: greyscale */
47 0, /* compression method */
48 0, /* filter method */
49 0 /* interlace method: none */
52 const unsigned char unknown
[] =
54 'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
60 fwrite(signature
, sizeof signature
, 1, stdout
);
61 put_chunk(IHDR
, sizeof IHDR
);
64 put_chunk(unknown
, sizeof unknown
);