diff options
| author | Dylan <boss@tehbox.org> | 2026-04-02 11:58:24 +1300 |
|---|---|---|
| committer | Dylan <boss@tehbox.org> | 2026-04-02 11:58:24 +1300 |
| commit | e9a32a966d49ab798a4c6f24471669fc03adb395 (patch) | |
| tree | 6373120682604c489816df391c45f17841a838b6 /test/main.cpp | |
| parent | 93a78ac64327b53f53952b625c7ce8a11bcc8651 (diff) | |
| download | tehimage-e9a32a966d49ab798a4c6f24471669fc03adb395.tar.gz tehimage-e9a32a966d49ab798a4c6f24471669fc03adb395.zip | |
feat: Added basic zlib compression
Currently not incredibly well implemented, but it can handle fixed
codes
Diffstat (limited to 'test/main.cpp')
| -rw-r--r-- | test/main.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/main.cpp b/test/main.cpp index d4c2e64..8dc9de5 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,7 +1,9 @@ +#include <bitset> #include <reader.h> #include <debug.h> #include <PNGImage.h> #include <BMPImage.h> +#include <HashTable.h> #include <zlib.h> #include <cstdint> #include <cstring> @@ -16,6 +18,40 @@ int main(int argc, char* argv[]) cout << "usage: " << argv[0] << " <in file> <out file>" << endl; return 1; } + + TehImage::ZLib encoder; + TehImage::ZLib decoder; + + const int inSize = 1000; + uint8_t in[inSize]; + for(int i = 0; i < 10; i++) + { + for(int j = 0; j < 100; j++) + { + in[i*100+j] = i; + } + } + + const int encodedSize = 1024; + uint8_t encoded[encodedSize]; + + int compressedSize = encoder.encodeData(in, inSize, encoded, encodedSize); + + // for(int i = 0; i < compressedSize; i++) + // { + // cout << std::bitset<8>(encoded[i]) << endl; + // } + + uint8_t out[inSize]; + int decodedSize = decoder.decodeData(encoded, encodedSize, out, inSize); + cout << ((memcmp(in, out, inSize) == 0)?"Pass":"Fail") << ", Size: " << compressedSize << endl; + + // for(int i = 0; i < inSize; i++) + // { + // cout << 0 + in[i] << " " << 0 + out[i] << endl; + // } + + return 0; std::string infile = argv[1]; std::string outfile = argv[2]; |
