From 15dc5e7dbc3d2971b68432cdd8d5f256326e61e6 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 6 Jul 2025 01:03:04 +0200 Subject: [PATCH] Parsing a png works now --- file_reader | 2 +- library.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/file_reader b/file_reader index 1b00548..ff45377 160000 --- a/file_reader +++ b/file_reader @@ -1 +1 @@ -Subproject commit 1b005488a2932156a5a5165820e93c04c39f6e55 +Subproject commit ff45377ffe6580049c1e125c478fe03d46cedec3 diff --git a/library.cpp b/library.cpp index 6f4a909..3589b69 100644 --- a/library.cpp +++ b/library.cpp @@ -39,6 +39,8 @@ char * read_png(const std::string &file_path) while (true) { buffer chunk_type{0}; + chunk_type.allocated = 0; + chunk_type.data = nullptr; chunk_type.size = 4; auto chunk_head = std::make_tuple((unsigned int)0, chunk_type); auto ret = reader.read_from_tuple(chunk_head); @@ -48,11 +50,9 @@ char * read_png(const std::string &file_path) buffer data_body{0}; data_body.size = std::get<0>(chunk_head); auto data = std::make_tuple(data_body, chunk_type); - ret = reader.read_from_tuple(data); - if (ret.second == READ_INCOMPLETE || ret.second == READ_FILE_ENDED) - throw std::runtime_error("Incomplete chunk"); + auto ree = reader.read_from_tuple(data); + std::println("Size received {}", ree.first); if (strcmp("IHDR", std::get<1>(chunk_head).data) == 0) meta = parse_metadata(std::get<0>(data)); - break; } }