summaryrefslogtreecommitdiff
path: root/tests/imageutils-lodepng.cc
diff options
context:
space:
mode:
authorBrad Pitcher <bradpitcher@gmail.com>2011-11-01 17:15:35 (GMT)
committerBrad Pitcher <bradpitcher@gmail.com>2011-11-01 17:15:35 (GMT)
commite2caf3726d68ff1fef63113519049abffc0563af (patch)
tree6558c6f03ccc21e7138d23861f80e8d97b09e60e /tests/imageutils-lodepng.cc
parent7541854212d6c1223e015faf55a6ca0657a1c184 (diff)
parentcb56f700b1b0f4ae589da62a5fd1d4e368deb604 (diff)
merge master
Diffstat (limited to 'tests/imageutils-lodepng.cc')
-rw-r--r--tests/imageutils-lodepng.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/imageutils-lodepng.cc b/tests/imageutils-lodepng.cc
new file mode 100644
index 0000000..8460d9e
--- /dev/null
+++ b/tests/imageutils-lodepng.cc
@@ -0,0 +1,24 @@
+#include "lodepng.h"
+#include <stdio.h>
+
+bool write_png(const char *filename, unsigned char *pixels, int width, int height)
+{
+ //encoder.settings.zlibsettings.windowSize = 2048;
+ //LodePNG_Text_add(&encoder.infoPng.text, "Comment", "Created with LodePNG");
+
+ size_t dataout_size = -1;
+ unsigned char *dataout = (unsigned char *)malloc(width*height*4);
+ LodePNG_encode(&dataout, &dataout_size, pixels, width, height, LCT_RGBA, 8);
+ //LodePNG_saveFile(dataout, dataout_size, "blah2.png");
+
+ FILE *f = fopen(filename, "wb");
+ if (!f) {
+ free(dataout);
+ return false;
+ }
+
+ fwrite(dataout, 1, dataout_size, f);
+ fclose(f);
+ free(dataout);
+ return true;
+}
contact: Jan Huwald // Impressum