diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-24 23:42:48 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-25 00:12:36 +0200 |
commit | bbfa8faf5337ebdff60ef2106074417aa628eca1 (patch) | |
tree | 99604a6bc9a99f1c68232cfff84f01192991f1a9 /src/openvic-simulation/utility/BMP.hpp | |
parent | 3714db86f7c52674e044566096f389660a67a039 (diff) |
Adding terrain image/type loading
Diffstat (limited to 'src/openvic-simulation/utility/BMP.hpp')
-rw-r--r-- | src/openvic-simulation/utility/BMP.hpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/openvic-simulation/utility/BMP.hpp b/src/openvic-simulation/utility/BMP.hpp index f04b41a..c08ac99 100644 --- a/src/openvic-simulation/utility/BMP.hpp +++ b/src/openvic-simulation/utility/BMP.hpp @@ -1,11 +1,14 @@ #pragma once -#include <cstdio> +#include <filesystem> +#include <fstream> #include <vector> #include "openvic-simulation/types/Colour.hpp" namespace OpenVic { + namespace fs = std::filesystem; + class BMP { #pragma pack(push) #pragma pack(1) @@ -29,10 +32,11 @@ namespace OpenVic { } header; #pragma pack(pop) - FILE* file = nullptr; - bool header_validated = false; + std::ifstream file; + bool header_validated = false, palette_read = false, pixel_data_read = false; uint32_t palette_size = 0; std::vector<colour_t> palette; + std::vector<uint8_t> pixel_data; public: static constexpr uint32_t PALETTE_COLOUR_SIZE = sizeof(colour_t); @@ -40,12 +44,17 @@ namespace OpenVic { BMP() = default; ~BMP(); - bool open(char const* filepath); + bool open(fs::path const& filepath); bool read_header(); bool read_palette(); + bool read_pixel_data(); void close(); void reset(); + int32_t get_width() const; + int32_t get_height() const; + uint16_t get_bits_per_pixel() const; std::vector<colour_t> const& get_palette() const; + std::vector<uint8_t> const& get_pixel_data() const; }; } |