60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "PngHeader.h"
|
|
#include "Image.h"
|
|
#include "DeflateElements.h"
|
|
#include "PlatformImageWriter.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <filesystem>
|
|
|
|
using Path = std::filesystem::path;
|
|
|
|
class BitStream;
|
|
class BufferBitStream;
|
|
class File;
|
|
|
|
class PngWriter
|
|
{
|
|
public:
|
|
PngWriter();
|
|
~PngWriter();
|
|
|
|
static std::unique_ptr<PngWriter> Create();
|
|
|
|
void setCompressionMethod(Deflate::CompressionMethod method);
|
|
|
|
void setPath(const Path& path);
|
|
|
|
void setPngInfo(const PngInfo& info);
|
|
|
|
void write(const std::unique_ptr<Image>& image);
|
|
void write(Image* image);
|
|
|
|
private:
|
|
void writeSignature();
|
|
void writeHeader();
|
|
|
|
void writeDataChunks(const BufferBitStream& buffer);
|
|
|
|
void writeEndChunk();
|
|
|
|
//void writeIDatChunk();
|
|
|
|
Path mPath;
|
|
Image* mWorkingImage{nullptr};
|
|
std::unique_ptr<BitStream> mInStream;
|
|
std::unique_ptr<BitStream> mOutStream;
|
|
std::unique_ptr<File> mWorkingFile;
|
|
|
|
unsigned mPngInfoUserSet{false};
|
|
PngInfo mPngInfo;
|
|
PngHeader mPngHeader;
|
|
|
|
Deflate::CompressionMethod mCompressionMethod{Deflate::CompressionMethod::DYNAMIC_HUFFMAN};
|
|
|
|
std::unique_ptr<PlatformImageWriter> mPlatformWriter;
|
|
};
|
|
|
|
using PngWriterPtr = std::unique_ptr<PngWriter>;
|