Clean up some tests.
This commit is contained in:
parent
b17ba8b3a7
commit
c102ebb6da
64 changed files with 615 additions and 541 deletions
|
@ -25,14 +25,14 @@ void PngReader::setPath(const Path& path)
|
|||
bool PngReader::checkSignature()
|
||||
{
|
||||
const int highBitCheck = 0x89;
|
||||
const auto firstPos = mFile->GetInHandle()->get();
|
||||
const auto firstPos = mFile->getInHandle()->get();
|
||||
if (firstPos != highBitCheck)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string fileType;
|
||||
BinaryStream::getNextString(mFile->GetInHandle(), fileType, 3);
|
||||
BinaryStream::getNextString(mFile->getInHandle(), fileType, 3);
|
||||
if (fileType != "PNG")
|
||||
{
|
||||
return false;
|
||||
|
@ -41,7 +41,7 @@ bool PngReader::checkSignature()
|
|||
std::vector<char> sequence{13, 10, 26, 10};
|
||||
for (auto c : sequence)
|
||||
{
|
||||
if (mFile->GetInHandle()->get() != c)
|
||||
if (mFile->getInHandle()->get() != c)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ bool PngReader::checkSignature()
|
|||
|
||||
bool PngReader::readChunk()
|
||||
{
|
||||
unsigned length = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
unsigned length = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
|
||||
std::string chunkType;
|
||||
BinaryStream::getNextString(mFile->GetInHandle(), chunkType, 4);
|
||||
BinaryStream::getNextString(mFile->getInHandle(), chunkType, 4);
|
||||
|
||||
//std::cout << "Got chunk with type: " << chunkType << " and length: " << length << std::endl;
|
||||
bool lastChunk = false;
|
||||
|
@ -72,7 +72,7 @@ bool PngReader::readChunk()
|
|||
{
|
||||
decodeData();
|
||||
}
|
||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
}
|
||||
else if(chunkType == "IDAT")
|
||||
{
|
||||
|
@ -91,31 +91,31 @@ bool PngReader::readChunk()
|
|||
|
||||
for(unsigned idx=0;idx<length;idx++)
|
||||
{
|
||||
mFile->GetInHandle()->get();
|
||||
mFile->getInHandle()->get();
|
||||
}
|
||||
|
||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
unsigned crcCheck = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
}
|
||||
return !lastChunk;
|
||||
}
|
||||
|
||||
bool PngReader::readHeaderChunk()
|
||||
{
|
||||
auto width = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
auto height = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
auto bitDepth = mFile->GetInHandle()->get();
|
||||
auto width = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
auto height = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
auto bitDepth = mFile->getInHandle()->get();
|
||||
|
||||
mHeader.setImageData(width, height, bitDepth);
|
||||
|
||||
PngInfo info;
|
||||
info.mColorType = static_cast<PngInfo::ColorType>(mFile->GetInHandle()->get());
|
||||
info.mCompressionMethod = static_cast<PngInfo::CompressionMethod>(mFile->GetInHandle()->get());
|
||||
info.mFilterMethod = static_cast<PngInfo::FilterMethod>(mFile->GetInHandle()->get());
|
||||
info.mInterlaceMethod = static_cast<PngInfo::InterlaceMethod>(mFile->GetInHandle()->get());
|
||||
info.mColorType = static_cast<PngInfo::ColorType>(mFile->getInHandle()->get());
|
||||
info.mCompressionMethod = static_cast<PngInfo::CompressionMethod>(mFile->getInHandle()->get());
|
||||
info.mFilterMethod = static_cast<PngInfo::FilterMethod>(mFile->getInHandle()->get());
|
||||
info.mInterlaceMethod = static_cast<PngInfo::InterlaceMethod>(mFile->getInHandle()->get());
|
||||
mHeader.setPngInfo(info);
|
||||
mHeader.updateData();
|
||||
|
||||
uint32_t file_crc = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
uint32_t file_crc = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
auto crc_calc = mHeader.getCrc();
|
||||
|
||||
//std::cout << mHeader.toString() << "*************\n";
|
||||
|
@ -147,7 +147,7 @@ bool PngReader::readIDATChunk(unsigned length)
|
|||
}
|
||||
mInputStream->clearChecksumCalculator();
|
||||
|
||||
uint32_t file_crc = *BinaryStream::getNextDWord(mFile->GetInHandle());
|
||||
uint32_t file_crc = *BinaryStream::getNextDWord(mFile->getInHandle());
|
||||
auto crc_calc = crc_check->getChecksum();
|
||||
|
||||
if (file_crc != crc_calc)
|
||||
|
@ -166,7 +166,7 @@ std::unique_ptr<Image<unsigned char> > PngReader::read()
|
|||
auto image = std::make_unique<Image<unsigned char> >(5, 5);
|
||||
|
||||
mFile = std::make_unique<File>(mPath);
|
||||
mFile->Open(true);
|
||||
mFile->open(File::AccessMode::Read);
|
||||
|
||||
if (!checkSignature())
|
||||
{
|
||||
|
|
|
@ -161,9 +161,8 @@ void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image)
|
|||
if (!mPath.empty())
|
||||
{
|
||||
mWorkingFile = std::make_unique<File>(mPath);
|
||||
mWorkingFile->SetAccessMode(File::AccessMode::Write);
|
||||
mWorkingFile->Open(true);
|
||||
mOutStream = std::make_unique<OutputBitStream>(mWorkingFile->GetOutHandle());
|
||||
mWorkingFile->open(File::AccessMode::Write);
|
||||
mOutStream = std::make_unique<OutputBitStream>(mWorkingFile->getOutHandle());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -218,6 +217,6 @@ void PngWriter::write(const std::unique_ptr<Image<unsigned char> >& image)
|
|||
|
||||
if (mWorkingFile)
|
||||
{
|
||||
mWorkingFile->Close();
|
||||
mWorkingFile->close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue