unlimited-storage

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 15f9bf9a7e30b67f7fb91f2c470f3fcccd14e880
parent 524192288a32ee69b28143d1d7e67eb09b4b2609
Author: Andrew Laack <andrew@laack.co>
Date:   Thu, 10 Jul 2025 23:37:22 -0500

Started working on implementing a better system for encoding the filename and chunk information into the visible data instead of metadata.

Diffstat:
Msrc/chunk.cpp | 32++++++++++++++++++++++++--------
Msrc/encode.cpp | 4++--
2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/chunk.cpp b/src/chunk.cpp @@ -140,6 +140,13 @@ void Chunk::writeVideo(std::string filename){ std::cout << "NOT IMPLEMENTED" << std::endl; } + + +// - chunk number 4 bytes +// - characters 4 bytes +// - fnamelen 4 bytes +// - filename fnamelen + void Chunk::writeImage(std::string filename, uint chunkNumber, std::string originalFilename, uint x, uint y){ Chunk chunk = this->chunk; @@ -152,16 +159,25 @@ void Chunk::writeImage(std::string filename, uint chunkNumber, std::string origi } std::string header = "P1\n"; - std::string comment = "# "; - comment.append(originalFilename); - // we assume no spaces in original filename - comment.append(" "); - comment.append(std::to_string(chunkNumber)); - comment += " "; - comment += std::to_string(data.size()); - comment.append("\n"); + std::string comment = "# Encoded with Andrew's awesome .tga encoder.\n"; + + std::string chunkNumberEncoded = std::bitset<8*4>(chunkNumber).to_string(); + std::string charactersEncoded = std::bitset<8*4>(data.size()).to_string(); std::string dims = std::to_string(x); + + std::string filenameEncoded = ""; + + // ascii encoding + // todo: + // create function for this. + + for (std::size_t i = 0; i < filename.size(); ++i) + { + filenameEncoded += std::bitset<8>(filename.c_str()[i]).to_string(); + } + std::cout << filenameEncoded << std::endl; + dims += " "; dims += std::to_string(y); dims += ("\n"); diff --git a/src/encode.cpp b/src/encode.cpp @@ -17,12 +17,12 @@ int main(int argc, char* argv[]){ Chunk outChunk = Chunk(bytes); outChunk.writeImage(destination, 1, source, 1920, 1080); std::cout << "BEFORE: " << std::endl; - outChunk.print(); + // outChunk.print(); std::cout << std::endl; Chunk readChunk = Chunk(destination); std::cout << "AFTER: " << std::endl; - readChunk.print(); + // readChunk.print(); std::cout << std::endl; return 0;