From 93a78ac64327b53f53952b625c7ce8a11bcc8651 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 18 Mar 2026 16:28:27 +1300 Subject: feat: Added endianness option to reader The file reader class can now support either endianness to read in, and will convert to the native endianness --- src/reader.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/reader.h') diff --git a/src/reader.h b/src/reader.h index a4f913c..bb181e6 100644 --- a/src/reader.h +++ b/src/reader.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -8,12 +9,18 @@ namespace TehImage { - + enum FileEndianness + { + NO_CONVERT, + LITTLE, + BIG + }; + class Reader { public: //Bytes are big endian - Reader(std::string file); + Reader(std::string file, FileEndianness fileEndianness); ~Reader(); template @@ -31,8 +38,16 @@ namespace TehImage size_t pos; FILE* file; bool ready = false; + FileEndianness fileEndianness; void refreshBuffer(); + void convertEndian(uint8_t* out, size_t bytes); }; + // template + // T Reader::readData() + // { + // T num = 0; + // convertEndian((uint8_t*)&num, sizeof(T)); + // } } -- cgit v1.2.3