diff options
| author | Dylan <boss@tehbox.org> | 2026-03-18 16:28:27 +1300 |
|---|---|---|
| committer | Dylan <boss@tehbox.org> | 2026-03-18 16:28:27 +1300 |
| commit | 93a78ac64327b53f53952b625c7ce8a11bcc8651 (patch) | |
| tree | df2bcea7256df8acdab5cb51edb0b59291b5b89c /src/reader.h | |
| parent | 8ca054ab8cf04e514df1570617b6a32ed83b9ea4 (diff) | |
| download | tehimage-93a78ac64327b53f53952b625c7ce8a11bcc8651.tar.gz tehimage-93a78ac64327b53f53952b625c7ce8a11bcc8651.zip | |
The file reader class can now support either endianness to read in,
and will convert to the native endianness
Diffstat (limited to 'src/reader.h')
| -rw-r--r-- | src/reader.h | 19 |
1 files changed, 17 insertions, 2 deletions
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 <cstddef> +#include <cstdint> #include <cstdio> #include <string> @@ -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 <typename T> @@ -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 <typename T> + // T Reader::readData() + // { + // T num = 0; + // convertEndian((uint8_t*)&num, sizeof(T)); + // } } |
