From c7fba85393d0fc26560bffd8cf119ab2ae1172ec Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Mon, 23 Jun 2025 20:35:36 +0200 Subject: [PATCH] fixing image set pixel --- runtime/Sources/Renderer/Image.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/Sources/Renderer/Image.cpp b/runtime/Sources/Renderer/Image.cpp index ee3ade6..0aa37b2 100644 --- a/runtime/Sources/Renderer/Image.cpp +++ b/runtime/Sources/Renderer/Image.cpp @@ -218,7 +218,7 @@ namespace mlx void Texture::SetPixel(int x, int y, mlx_color color) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > m_width || static_cast(y) > m_height) + if(x < 0 || y < 0 || static_cast(x) >= m_width || static_cast(y) >= m_height) return; if(!m_staging_buffer.has_value()) OpenCPUBuffer(); @@ -232,7 +232,7 @@ namespace mlx void Texture::SetRegion(int x, int y, int w, int h, mlx_color* pixels) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > m_width || static_cast(y) > m_height) + if(x < 0 || y < 0 || static_cast(x) >= m_width || static_cast(y) >= m_height) return; if(w < 0 || h < 0) return; @@ -258,7 +258,7 @@ namespace mlx void Texture::SetLinearRegion(int x, int y, std::size_t len, mlx_color* pixels) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > m_width || static_cast(y) > m_height) + if(x < 0 || y < 0 || static_cast(x) >= m_width || static_cast(y) >= m_height) return; if(!m_staging_buffer.has_value()) OpenCPUBuffer(); @@ -282,7 +282,7 @@ namespace mlx mlx_color Texture::GetPixel(int x, int y) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > m_width || static_cast(y) > m_height) + if(x < 0 || y < 0 || static_cast(x) >= m_width || static_cast(y) >= m_height) return { .rgba = 0x00000000 }; if(!m_staging_buffer.has_value()) OpenCPUBuffer(); @@ -295,7 +295,7 @@ namespace mlx void Texture::GetRegion(int x, int y, int w, int h, mlx_color* dst) noexcept { MLX_PROFILE_FUNCTION(); - if(x < 0 || y < 0 || static_cast(x) > m_width || static_cast(y) > m_height) + if(x < 0 || y < 0 || static_cast(x) >= m_width || static_cast(y) >= m_height) return; if(!m_staging_buffer.has_value()) OpenCPUBuffer();