aboutsummaryrefslogtreecommitdiff
path: root/test/main.cpp
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-05-06 13:39:47 +1200
committerDylan <boss@tehbox.org>2026-05-06 13:39:47 +1200
commitd60976a70e68e1cd312b0e56fe6fbe6c7428cbaa (patch)
tree00bc987a6d935ca26e4d4c2d61ad70d7aa3c2f4c /test/main.cpp
parenta75bdd0e167140eeb4afb091c9dedd84474c8531 (diff)
downloadtehimage-d60976a70e68e1cd312b0e56fe6fbe6c7428cbaa.tar.gz
tehimage-d60976a70e68e1cd312b0e56fe6fbe6c7428cbaa.zip
feat: Started on PNG writing implementation
Currently writes IHDR and IEND chunks correctly CRC implementation is borrowed from the specification Writer class now also has a buffer for the CRC calculation
Diffstat (limited to 'test/main.cpp')
-rw-r--r--test/main.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/main.cpp b/test/main.cpp
index 6e521f3..5a2525b 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -12,6 +12,36 @@ using std::cout, std::endl;
int main(int argc, char* argv[])
{
+ // uint8_t poly = 0b10011;
+ // uint32_t data = 0b11010110110000;
+ // uint32_t ones = 0b11111;
+ // char dashes[15];
+ // memset(dashes, '-', 14);
+ // dashes[14] = 0;
+ // for(int i = 9; i >= 0; i--)
+ // {
+ // uint32_t shiftedPoly = poly << i;
+ // cout << std::bitset<14>(data) << endl << std::bitset<14>(shiftedPoly) << endl << dashes << endl;
+ // bool greater = false;
+ // for(int j = 4; j >= 0; j++)
+ // {
+ // if(data & (0b1 << (j+i)))
+ // {
+ // greater = true;
+ // break;
+ // }
+ // else if (shiftedPoly & (0b1 << (j+i)))
+ // break;
+ // }
+ // if(greater)
+ // data ^= shiftedPoly;
+ // }
+
+ // cout << std::bitset<5>(data) << endl;
+
+ // return 0;
+
+
if(argc < 3)
{
cout << "usage: " << argv[0] << " <in file> <out file>" << endl;
@@ -57,7 +87,9 @@ int main(int argc, char* argv[])
TehImage::BMPImage bmp;
bmp.readFromFile(infile);
- bmp.writeToFile(outfile);
+
+ TehImage::PNGImage png(bmp);
+ png.writeToFile(outfile);
// TehImage::PNGImage png;