From 72b92d5a9f472b714e098756bf9ce5957843d198 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sun, 24 Dec 2023 21:37:45 -0500 Subject: Add `BMP::palette_colour_t` as uint32_t Change `BMP::palette` to `std::vector` Change `BMP::PALETTE_COLOUR_SIZE` to use `sizeof(palette_colour_t)` Silence warning for `header.num_colours - 1 >> header.bits_per_pixel == 0` --- src/openvic-simulation/utility/BMP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/openvic-simulation/utility/BMP.cpp') diff --git a/src/openvic-simulation/utility/BMP.cpp b/src/openvic-simulation/utility/BMP.cpp index 83d26c4..4c220da 100644 --- a/src/openvic-simulation/utility/BMP.cpp +++ b/src/openvic-simulation/utility/BMP.cpp @@ -110,7 +110,7 @@ bool BMP::read_header() { palette_size = header.bits_per_pixel > PALETTE_BITS_PER_PIXEL_LIMIT ? 0 // Use header.num_colours if it's greater than 0 and at most 1 << header.bits_per_pixel - : (0 < header.num_colours && header.num_colours - 1 >> header.bits_per_pixel == 0 + : (0 < header.num_colours && (header.num_colours - 1) >> header.bits_per_pixel == 0 ? header.num_colours : 1 << header.bits_per_pixel); const uint32_t expected_offset = palette_size * PALETTE_COLOUR_SIZE + sizeof(header); @@ -182,7 +182,7 @@ uint16_t BMP::get_bits_per_pixel() const { return header.bits_per_pixel; } -std::vector const& BMP::get_palette() const { +std::vector const& BMP::get_palette() const { if (!palette_read) { Logger::warning("Trying to get BMP palette before loading"); } -- cgit v1.2.3-56-ga3b1