From 3d4f248fdac05efbd8e817d37b3ed6257c493a3b Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Mon, 20 Oct 2025 13:15:24 +0300 Subject: [PATCH] Round values after renormalization when generating mipmaps. --- core/io/image.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/io/image.cpp b/core/io/image.cpp index 88a5fdb921e..dbdf5173a2c 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -4575,9 +4575,9 @@ void Image::renormalize_uint8(uint8_t *p_rgb) { n += Vector3(1, 1, 1); n *= 0.5; n *= 255; - p_rgb[0] = CLAMP(int(n.x), 0, 255); - p_rgb[1] = CLAMP(int(n.y), 0, 255); - p_rgb[2] = CLAMP(int(n.z), 0, 255); + p_rgb[0] = CLAMP(int(Math::round(n.x)), 0, 255); + p_rgb[1] = CLAMP(int(Math::round(n.y)), 0, 255); + p_rgb[2] = CLAMP(int(Math::round(n.z)), 0, 255); } void Image::renormalize_float(float *p_rgb) { @@ -4604,9 +4604,9 @@ void Image::renormalize_uint16(uint16_t *p_rgb) { n += Vector3(1, 1, 1); n *= 0.5; n *= 65535; - p_rgb[0] = CLAMP(int(n.x), 0, 65535); - p_rgb[1] = CLAMP(int(n.y), 0, 65535); - p_rgb[2] = CLAMP(int(n.z), 0, 65535); + p_rgb[0] = CLAMP(int(Math::round(n.x)), 0, 65535); + p_rgb[1] = CLAMP(int(Math::round(n.y)), 0, 65535); + p_rgb[2] = CLAMP(int(Math::round(n.z)), 0, 65535); } Image::Image(const uint8_t *p_mem_png_jpg, int p_len) {