summaryrefslogtreecommitdiff
path: root/libpng_wrapper.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libpng_wrapper.hpp')
-rw-r--r--libpng_wrapper.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/libpng_wrapper.hpp b/libpng_wrapper.hpp
new file mode 100644
index 0000000..cf95dff
--- /dev/null
+++ b/libpng_wrapper.hpp
@@ -0,0 +1,42 @@
+#ifndef PNGWRAP_H
+#define PNGWRAP_H
+
+#include <string>
+#include <array>
+#include <png.h>
+
+#define PNG_FILE_ERROR 0
+#define PNG_LIBPNG_ERROR 1
+
+struct rgb {
+ png_byte r;
+ png_byte g;
+ png_byte b;
+};
+
+
+class png {
+ protected:
+ const int DEFAULT_BIT_DEPTH = 8;
+ const int DEFAULT_COLOR_TYPE = PNG_COLOR_TYPE_RGB;
+ const bool DEFAULT_INTERLACE = false;
+ const int DEFAULT_TRANSFORMS = PNG_TRANSFORM_IDENTITY;
+ FILE *output_fp;
+ png_structp png_ptr;
+ png_infop png_info_ptr;
+ png_byte **row_pointers;
+
+ public:
+ //the user doesn't have a lot of control over png output settings.
+ //Will expand class to allow so if it's found nessesary.
+ ~png();
+ png(std::string filename, uint32_t width, uint32_t height);
+ void save();
+
+ void set_pixel(uint32_t x, uint32_t y, png_byte r, png_byte g, png_byte b);
+
+ uint32_t width();
+ uint32_t height();
+};
+
+#endif