summaryrefslogtreecommitdiff
path: root/libpng_wrapper.hpp
blob: cf95dffb60986522352bba992d0bc6dd8337af9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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