Non compressing png writer is ok.
This commit is contained in:
parent
33369b1775
commit
e4f9393ee7
18 changed files with 196 additions and 23 deletions
|
@ -1,7 +1,11 @@
|
|||
#include "File.h"
|
||||
|
||||
#include "FileLogger.h"
|
||||
#include "ByteUtils.h"
|
||||
|
||||
#include <streambuf>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
File::File(std::filesystem::path path)
|
||||
: mFullPath(path),
|
||||
|
@ -22,6 +26,30 @@ void File::SetAccessMode(AccessMode mode)
|
|||
mAccessMode = mode;
|
||||
}
|
||||
|
||||
std::string File::dumpBinary()
|
||||
{
|
||||
mAccessMode = AccessMode::Read;
|
||||
Open();
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "Count | Binary | Decimal | ASCII \n";
|
||||
unsigned count = 0;
|
||||
while(mInHandle->peek() != EOF)
|
||||
{
|
||||
const unsigned char val = static_cast<unsigned char>(mInHandle->get());
|
||||
const unsigned char ascii_val = std::isalpha(val) ? val : '.';
|
||||
sstr << count << " | " << ByteUtils::toString(val) << " | " << static_cast<int>(val) << " | " << ascii_val << '\n';
|
||||
if (count < 0 && count % 10 == 0)
|
||||
{
|
||||
sstr << "\n";
|
||||
}
|
||||
count++;
|
||||
}
|
||||
const auto out = sstr.str();
|
||||
Close();
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ifstream* File::GetInHandle() const
|
||||
{
|
||||
return mInHandle.get();
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
|
||||
std::optional<unsigned char> readNextByte();
|
||||
|
||||
std::string dumpBinary();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -30,11 +30,10 @@ void BitStream::write(uint32_t data)
|
|||
|
||||
void BitStream::writeWord(uint16_t data)
|
||||
{
|
||||
unsigned num_bytes = sizeof(uint16_t);
|
||||
for(unsigned idx=0; idx<num_bytes;idx++)
|
||||
{
|
||||
writeByte(ByteUtils::getByteN(data, idx));
|
||||
}
|
||||
const auto byte0 = data >> 8;
|
||||
const auto byte1 = (data << 8) >> 8;
|
||||
writeByte(byte0);
|
||||
writeByte(byte1);
|
||||
}
|
||||
|
||||
int BitStream::getCurrentByteOffset() const
|
||||
|
|
|
@ -57,8 +57,6 @@ public:
|
|||
mChecksumCalculator = nullptr;
|
||||
}
|
||||
|
||||
//unsigned getSize() = 0;
|
||||
|
||||
protected:
|
||||
int mByteOffset{-1};
|
||||
unsigned mBitOffset{0};
|
||||
|
|
|
@ -11,7 +11,14 @@ std::vector<unsigned char> BufferBitStream::peekNextNBytes(unsigned n) const
|
|||
{
|
||||
std::vector<unsigned char> ret (n, 0);
|
||||
unsigned count = 0;
|
||||
for(unsigned idx=mByteOffset; idx<mByteOffset + n; idx++)
|
||||
|
||||
int start = mByteOffset;
|
||||
if (start<0)
|
||||
{
|
||||
start = 0;
|
||||
}
|
||||
|
||||
for(unsigned idx=start; idx<start + n; idx++)
|
||||
{
|
||||
if (idx == mBuffer.size())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue