#pragma once

#include <string>
#include <memory>
#include <vector>

#include "File.h"

class Image;

class PngReader
{
public:
    ~PngReader();
    void setPath(const std::string& path);

    std::unique_ptr<Image> read();

private:

    struct IHDRChunk
    {
    	unsigned width{0};
    	unsigned height{0};
    	char bitDepth{0};
    	char colorType{0};
    	char compressionMethod{0};
    	char filterMethod{0};
    	char interlaceMethod{0};
    };

    bool readChunk();
    void parseHeader();
    void logHeader();

    bool checkSignature();

    unsigned mCurrentOffset{0};

    IHDRChunk mIHDRChunk;

    std::unique_ptr<Image> mWorkingImage;
    std::unique_ptr<File> mFile;
    std::string mPath;
};
