Further compression and png work.
This commit is contained in:
parent
318b481ccc
commit
9c8faa534b
34 changed files with 1164 additions and 203 deletions
|
@ -1,6 +1,13 @@
|
|||
#include "PngWriter.h"
|
||||
|
||||
#include "PngElements.h"
|
||||
#include "Image.h"
|
||||
#include "File.h"
|
||||
#include "BufferBitStream.h"
|
||||
#include "OutputBitStream.h"
|
||||
#include "ImageBitStream.h"
|
||||
|
||||
#include "Lz77Encoder.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -9,6 +16,11 @@ PngWriter::PngWriter()
|
|||
|
||||
}
|
||||
|
||||
PngWriter::~PngWriter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<PngWriter> PngWriter::Create()
|
||||
{
|
||||
return std::make_unique<PngWriter>();
|
||||
|
@ -19,8 +31,40 @@ void PngWriter::setPath(const Path& path)
|
|||
mPath = path;
|
||||
}
|
||||
|
||||
void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image) const
|
||||
void PngWriter::writeSignature()
|
||||
{
|
||||
mOutStream->writeByte(Png::getHighBitCheck());
|
||||
for (auto byte : Png::getSignature())
|
||||
{
|
||||
mOutStream->writeByte(byte);
|
||||
}
|
||||
}
|
||||
|
||||
void PngWriter::writeHeader()
|
||||
{
|
||||
writeSignature();
|
||||
}
|
||||
|
||||
void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image)
|
||||
{
|
||||
if (!mPath.empty())
|
||||
{
|
||||
mWorkingFile = std::make_unique<File>(mPath);
|
||||
mWorkingFile->Open(true);
|
||||
mOutStream = std::make_unique<OutputBitStream>(mWorkingFile->GetOutHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutStream = std::make_unique<BufferBitStream>();
|
||||
}
|
||||
|
||||
mWorkingImage = image.get();
|
||||
mInStream = std::make_unique<ImageBitStream>(image.get());
|
||||
|
||||
writeHeader();
|
||||
|
||||
|
||||
|
||||
//mImpl->write(image);
|
||||
//auto fp = fopen(mPath.c_str(), "wb");
|
||||
|
||||
|
@ -76,4 +120,9 @@ void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image) const
|
|||
|
||||
//fclose(fp);
|
||||
//return;
|
||||
|
||||
if (mWorkingFile)
|
||||
{
|
||||
mWorkingFile->Close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue