Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: third_party/libpng/contrib/libtests/fakepng.c

Issue 2033063003: Check libpng directly into third_party/ (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: public.bzl Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libpng/contrib/libtests/fakepng.c
diff --git a/third_party/libpng/contrib/libtests/fakepng.c b/third_party/libpng/contrib/libtests/fakepng.c
new file mode 100644
index 0000000000000000000000000000000000000000..6512c1401049bed7b1f2ab3aff163e7dd3ef53d2
--- /dev/null
+++ b/third_party/libpng/contrib/libtests/fakepng.c
@@ -0,0 +1,65 @@
+/* Fake a PNG - just write it out directly.
+ *
+ * COPYRIGHT: Written by John Cunningham Bowler, 2014.
+ * To the extent possible under law, the author has waived all copyright and
+ * related or neighboring rights to this work. This work is published from:
+ * United States.
+ *
+ */
+
+#include <stdio.h>
+#include <zlib.h> /* for crc32 */
+
+void
+put_uLong(uLong val)
+{
+ putchar(val >> 24);
+ putchar(val >> 16);
+ putchar(val >> 8);
+ putchar(val >> 0);
+}
+
+void
+put_chunk(const unsigned char *chunk, uInt length)
+{
+ uLong crc;
+
+ put_uLong(length-4); /* Exclude the tag */
+
+ fwrite(chunk, length, 1, stdout);
+
+ crc = crc32(0, Z_NULL, 0);
+ put_uLong(crc32(crc, chunk, length));
+}
+
+const unsigned char signature[] =
+{
+ 137, 80, 78, 71, 13, 10, 26, 10
+};
+
+const unsigned char IHDR[] =
+{
+ 73, 72, 68, 82, /* IHDR */
+ 0, 0, 0, 1, /* width */
+ 0, 0, 0, 1, /* height */
+ 1, /* bit depth */
+ 0, /* color type: greyscale */
+ 0, /* compression method */
+ 0, /* filter method */
+ 0 /* interlace method: none */
+};
+
+const unsigned char unknown[] =
+{
+ 'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
+};
+
+int
+main(void)
+{
+ fwrite(signature, sizeof signature, 1, stdout);
+ put_chunk(IHDR, sizeof IHDR);
+
+ for (;;)
+ put_chunk(unknown, sizeof unknown);
+}

Powered by Google App Engine
This is Rietveld 408576698