aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/utility/BMP.hpp
diff options
context:
space:
mode:
author CptAlanSmith <123112708+CptAlanSmith@users.noreply.github.com>2023-09-25 23:21:59 +0200
committer GitHub <noreply@github.com>2023-09-25 23:21:59 +0200
commit63e462fceff981f79bcbae53e8d90fc59733e8c2 (patch)
tree403b586b3bc3f69f42a2362a273e77415ebf1d22 /src/openvic-simulation/utility/BMP.hpp
parent127ca294056817bc5814ef5516b29a67ff3fa3bb (diff)
parent932b43953d623557236a31b30899b706307260ed (diff)
Merge pull request #33 from OpenVicProject/terrain-types
Terrain types
Diffstat (limited to 'src/openvic-simulation/utility/BMP.hpp')
-rw-r--r--src/openvic-simulation/utility/BMP.hpp17
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;
};
}