From bbfa8faf5337ebdff60ef2106074417aa628eca1 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Sun, 24 Sep 2023 22:42:48 +0100 Subject: Adding terrain image/type loading --- src/openvic-simulation/utility/BMP.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/openvic-simulation/utility/BMP.hpp') 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 +#include +#include #include #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 palette; + std::vector 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 const& get_palette() const; + std::vector const& get_pixel_data() const; }; } -- cgit v1.2.3-56-ga3b1