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,10 @@
|
|||
#include "PngReader.h"
|
||||
|
||||
#include "BinaryStream.h"
|
||||
#include "BitStream.h"
|
||||
#include "BufferBitStream.h"
|
||||
|
||||
#include "ZlibEncoder.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -84,12 +88,11 @@ void PngReader::readIDATChunk(unsigned length)
|
|||
{
|
||||
if (mAwaitingDataBlock)
|
||||
{
|
||||
mImageData.setCompressionMethod(mFile->readNextByte());
|
||||
mImageData.setExtraFlags(mFile->readNextByte());
|
||||
mImageData.setDataSize(length-2);
|
||||
mEncoder->setCompressionMethod(mFile->readNextByte());
|
||||
mEncoder->setExtraFlags(mFile->readNextByte());
|
||||
for(unsigned idx=0; idx<length-2; idx++)
|
||||
{
|
||||
mImageData.setByte(idx, mFile->readNextByte());
|
||||
mInputStream->writeByte(mFile->readNextByte());
|
||||
}
|
||||
mAwaitingDataBlock = false;
|
||||
}
|
||||
|
@ -97,7 +100,7 @@ void PngReader::readIDATChunk(unsigned length)
|
|||
{
|
||||
for(unsigned idx=0; idx<length; idx++)
|
||||
{
|
||||
mImageData.setByte(idx, mFile->readNextByte());
|
||||
mInputStream->writeByte(mFile->readNextByte());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,10 +138,14 @@ std::unique_ptr<Image<unsigned char> > PngReader::read()
|
|||
return image;
|
||||
}
|
||||
|
||||
mInputStream = std::make_unique<BufferBitStream>();
|
||||
mOutputStream = std::make_unique<BufferBitStream>();
|
||||
mEncoder = std::make_unique<ZlibEncoder>(mInputStream.get(), mOutputStream.get());
|
||||
|
||||
while(readChunk())
|
||||
{
|
||||
|
||||
}
|
||||
mImageData.processData();
|
||||
mEncoder->decode();
|
||||
return std::move(image);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue