From 55f1e16c434e181f93c641dd0774ead8d81c68b9 Mon Sep 17 00:00:00 2001 From: rrrlasse Date: Thu, 28 Nov 2024 06:44:01 +0100 Subject: [PATCH] Added required cast Avoid needing NOMINMAX to be defined --- ConsoleGraphics/RenderSurface.h | 9 +++++---- ConsoleGraphics/bitmap_image.hpp | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ConsoleGraphics/RenderSurface.h b/ConsoleGraphics/RenderSurface.h index 5bae2d7..92e21de 100644 --- a/ConsoleGraphics/RenderSurface.h +++ b/ConsoleGraphics/RenderSurface.h @@ -9,7 +9,7 @@ namespace cg { public: inline RenderSurface(Vec2u size); - inline RenderSurface(size_t width, size_t height); + inline RenderSurface(int width, int height); [[nodiscard]] inline auto getSize() const noexcept -> Vec2u; @@ -44,9 +44,10 @@ namespace cg RenderSurface(size.x, size.y) {} - inline RenderSurface::RenderSurface(size_t width, size_t height) : - m_surfaceSize{ width, height }, - m_surface{ width * height, makeCharInfo(' ', Color::Black, Color::Gray) } + inline RenderSurface::RenderSurface(int width, int height) : + m_surfaceSize{ static_cast(width), + static_cast(height) }, + m_surface{ static_cast(width * height), makeCharInfo(' ', Color::Black, Color::Gray) } {} inline auto RenderSurface::getSize() const noexcept -> Vec2u diff --git a/ConsoleGraphics/bitmap_image.hpp b/ConsoleGraphics/bitmap_image.hpp index e7c7220..5b82d72 100644 --- a/ConsoleGraphics/bitmap_image.hpp +++ b/ConsoleGraphics/bitmap_image.hpp @@ -1244,7 +1244,7 @@ class bitmap_image case red_plane : return 0; case green_plane : return 1; case blue_plane : return 2; - default : return std::numeric_limits::max(); + default : return (std::numeric_limits::max)(); } } @@ -1254,11 +1254,11 @@ class bitmap_image case red_plane : return 2; case green_plane : return 1; case blue_plane : return 0; - default : return std::numeric_limits::max(); + default : return (std::numeric_limits::max)(); } } - default : return std::numeric_limits::max(); + default : return (std::numeric_limits::max)(); } } @@ -2941,7 +2941,7 @@ inline rgb_t find_nearest_color(const rgb_t& c, const Iterator begin, const Iter if (0 == std::distance(begin,end)) return c; - double min_d = std::numeric_limits::max(); + double min_d = (std::numeric_limits::max)(); rgb_t result = *begin; for (Iterator itr = begin; itr != end; ++itr) @@ -2981,7 +2981,7 @@ inline double find_nearest_wave_length(const rgb_t& c, const double increment = const double max_wave_length = 800.0; //800nm double min_wave_length = 0.0; - double min_d = std::numeric_limits::max(); + double min_d = (std::numeric_limits::max)(); for (double i = 0.0; i < max_wave_length; i += increment) {