1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef PNGREADER_H
- #define PNGREADER_H
- #include <png.h>
- #include "utils/Color.h"
- class PNGReader final {
- const char* path;
- int width;
- int height;
- int channels;
- int bitDepth;
- int rowBytes;
- FILE* file;
- png_structp read;
- png_infop info;
- ColorChannel** rowPointers;
- public:
- PNGReader(const char* path);
- ~PNGReader();
- PNGReader(const PNGReader& other) = delete;
- PNGReader(PNGReader&& other) = delete;
- PNGReader& operator=(const PNGReader& other) = delete;
- PNGReader& operator=(PNGReader&& other) = delete;
- int getWidth() const;
- int getHeight() const;
- int getChannels() const;
- int getBufferSize() const;
- bool hasError() const;
- template<int N>
- bool readData(Color<N>* buffer) {
- if(channels != N) {
- return true;
- }
- return readData(reinterpret_cast<ColorChannel*> (buffer));
- }
- private:
- bool readData(ColorChannel* buffer);
- bool checkSignature();
- };
- #endif
|