summaryrefslogtreecommitdiff
path: root/src/imageutils.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-26 00:36:55 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-26 00:36:55 (GMT)
commitc116a0849c7531ec4d0e59b6d61aaf6137dcd568 (patch)
tree39a8de4972d00aff8baaa05a51fda66d75fc6cdb /src/imageutils.cc
parente80d847e3d9249d22bf70f257df7b2130487b211 (diff)
undo experiment with object orientation
Diffstat (limited to 'src/imageutils.cc')
-rw-r--r--src/imageutils.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/imageutils.cc b/src/imageutils.cc
index 7ee14e9..eaab3b7 100644
--- a/src/imageutils.cc
+++ b/src/imageutils.cc
@@ -1,5 +1,6 @@
#include "imageutils.h"
#include <string.h>
+#include <fstream>
void flip_image(const unsigned char *src, unsigned char *dst, size_t pixelsize, size_t width, size_t height)
{
@@ -8,3 +9,16 @@ void flip_image(const unsigned char *src, unsigned char *dst, size_t pixelsize,
memmove(dst + (height - i - 1) * rowBytes, src + i * rowBytes, rowBytes);
}
}
+
+bool write_png(const char *filename, unsigned char *pixels, int width, int height) {
+ std::ofstream fstream( filename );
+ if (fstream.is_open()) {
+ write_png( fstream, pixels, width, height );
+ fstream.close();
+ return true;
+ } else {
+ std::cerr << "Can't open file " << filename << " for export.";
+ return false;
+ }
+}
+
contact: Jan Huwald // Impressum