Further compression and png work.

This commit is contained in:
James Grogan 2022-11-23 15:41:33 +00:00
parent 318b481ccc
commit 9c8faa534b
34 changed files with 1164 additions and 203 deletions

View file

@ -12,6 +12,7 @@ list(APPEND TestFiles
audio/TestMidiReader.cpp
core/TestByteUtils.cpp
core/TestBinaryStream.cpp
core/TestBitStream.cpp
core/TestTomlReader.cpp
compiler/TestLexer.cpp
compiler/TestTemplatingEngine.cpp

View file

@ -1,5 +1,6 @@
#include <iostream>
#include "BufferBitStream.h"
#include "HuffmanEncoder.h"
#include "RunLengthEncoder.h"
#include "Lz77Encoder.h"
@ -42,10 +43,14 @@ void test_lz77_encoder()
std::string test_data = "sir sid eastman easily teases sea sick seals";
//std::string test_data = "sir sid eastman";
Lz77Encoder encoder;
auto encoded = encoder.encode(test_data);
BufferBitStream input_stream;
input_stream.setBuffer(StringUtils::toBytes(test_data));
std::cout << "Encoded: " << encoded << std::endl;
BufferBitStream output_stream;
Lz77Encoder encoder(&input_stream, &output_stream);
encoder.encode();
std::cout << "Encoded: " << StringUtils::toString(output_stream.getBuffer()) << std::endl;
//auto decoded = encoder.decode(encoded);

View file

@ -0,0 +1,30 @@
#include "ByteUtils.h"
#include "BufferBitStream.h"
#include <iostream>
int main()
{
std::vector<std::string> bytes{"11100101", "00110101", "00010001"};
BufferBitStream stream;
for(const auto& byte : bytes)
{
stream.writeByte(ByteUtils::getFromString(byte));
}
unsigned char buffer{0} ;
auto valid = stream.readNextNBits(3, buffer);
std::cout << "Slice0 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(3, buffer);
std::cout << "Slice1 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(5, buffer);
std::cout << "Slice2 is " << ByteUtils::toString(buffer) << std::endl;
valid = stream.readNextNBits(7, buffer);
std::cout << "Slice3 is " << ByteUtils::toString(buffer) << std::endl;
return 0;
}

View file

@ -1,11 +1,15 @@
#include "PngReader.h"
#include "BitStream.h"
#include "Image.h"
#include <iostream>
int main()
{
const auto path = "/home/jmsgrogan/Downloads/test.png";
//const auto path = "/home/jmsgrogan/Downloads/test.png";
const auto path = "/home/jmsgrogan/Downloads/index.png";
PngReader reader;
reader.setPath(path);

View file

@ -1,6 +1,8 @@
#include "Image.h"
#include "PngWriter.h"
#include "BitStream.h"
#include "ImagePrimitives.h"
#include <iostream>