Clean up Image class.
This commit is contained in:
parent
4bb87de0e6
commit
0d3674faac
30 changed files with 330 additions and 135 deletions
|
@ -162,9 +162,9 @@ bool PngReader::readIDATChunk(unsigned length)
|
|||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Image<unsigned char> > PngReader::read()
|
||||
std::unique_ptr<Image> PngReader::read()
|
||||
{
|
||||
auto image = std::make_unique<Image<unsigned char> >(5, 5);
|
||||
auto image = std::make_unique<Image>(5, 5);
|
||||
|
||||
mFile = std::make_unique<File>(mPath);
|
||||
mFile->open(File::AccessMode::Read);
|
||||
|
@ -188,7 +188,6 @@ std::unique_ptr<Image<unsigned char> > PngReader::read()
|
|||
image->setHeight(mHeader.getHeight());
|
||||
image->setBitDepth(mHeader.getBitDepth());
|
||||
image->setNumChannels(mHeader.getPngInfo().getNumChannels());
|
||||
image->initialize();
|
||||
|
||||
auto image_bit_stream = std::make_unique<ImageBitStream>(image.get());
|
||||
PngFilter filter(mOutputStream.get(), image_bit_stream.get());
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
~PngReader();
|
||||
void setPath(const Path& path);
|
||||
|
||||
std::unique_ptr<Image<unsigned char> > read();
|
||||
std::unique_ptr<Image> read();
|
||||
private:
|
||||
bool readChunk();
|
||||
|
||||
|
@ -34,7 +34,7 @@ private:
|
|||
|
||||
PngHeader mHeader;
|
||||
|
||||
std::unique_ptr<Image<unsigned char> > mWorkingImage;
|
||||
std::unique_ptr<Image> mWorkingImage;
|
||||
std::unique_ptr<File> mFile;
|
||||
Path mPath;
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void PngWriter::writeDataChunks(const BufferBitStream& buffer)
|
|||
}
|
||||
}
|
||||
|
||||
void PngWriter::write(Image<unsigned char>* image)
|
||||
void PngWriter::write(Image* image)
|
||||
{
|
||||
if (!mPath.empty())
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ void PngWriter::write(Image<unsigned char>* image)
|
|||
}
|
||||
}
|
||||
|
||||
void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image)
|
||||
void PngWriter::write(const std::unique_ptr<Image>& image)
|
||||
{
|
||||
write(image.get());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "PngHeader.h"
|
||||
#include "Image.h"
|
||||
#include "DeflateElements.h"
|
||||
#include "PlatformImageWriter.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -28,8 +29,8 @@ public:
|
|||
|
||||
void setPngInfo(const PngInfo& info);
|
||||
|
||||
void write(const std::unique_ptr<Image<unsigned char> >& image);
|
||||
void write(Image<unsigned char>* image);
|
||||
void write(const std::unique_ptr<Image>& image);
|
||||
void write(Image* image);
|
||||
|
||||
private:
|
||||
void writeSignature();
|
||||
|
@ -42,7 +43,7 @@ private:
|
|||
//void writeIDatChunk();
|
||||
|
||||
Path mPath;
|
||||
Image<unsigned char>* mWorkingImage{nullptr};
|
||||
Image* mWorkingImage{nullptr};
|
||||
std::unique_ptr<BitStream> mInStream;
|
||||
std::unique_ptr<BitStream> mOutStream;
|
||||
std::unique_ptr<File> mWorkingFile;
|
||||
|
@ -52,6 +53,8 @@ private:
|
|||
PngHeader mPngHeader;
|
||||
|
||||
Deflate::CompressionMethod mCompressionMethod{Deflate::CompressionMethod::DYNAMIC_HUFFMAN};
|
||||
|
||||
std::unique_ptr<PlatformImageWriter> mPlatformWriter;
|
||||
};
|
||||
|
||||
using PngWriterPtr = std::unique_ptr<PngWriter>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue