Skip to content

Commit 3d4f248

Browse files
Round values after renormalization when generating mipmaps.
1 parent 7864ac8 commit 3d4f248

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/io/image.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,9 +4575,9 @@ void Image::renormalize_uint8(uint8_t *p_rgb) {
45754575
n += Vector3(1, 1, 1);
45764576
n *= 0.5;
45774577
n *= 255;
4578-
p_rgb[0] = CLAMP(int(n.x), 0, 255);
4579-
p_rgb[1] = CLAMP(int(n.y), 0, 255);
4580-
p_rgb[2] = CLAMP(int(n.z), 0, 255);
4578+
p_rgb[0] = CLAMP(int(Math::round(n.x)), 0, 255);
4579+
p_rgb[1] = CLAMP(int(Math::round(n.y)), 0, 255);
4580+
p_rgb[2] = CLAMP(int(Math::round(n.z)), 0, 255);
45814581
}
45824582

45834583
void Image::renormalize_float(float *p_rgb) {
@@ -4604,9 +4604,9 @@ void Image::renormalize_uint16(uint16_t *p_rgb) {
46044604
n += Vector3(1, 1, 1);
46054605
n *= 0.5;
46064606
n *= 65535;
4607-
p_rgb[0] = CLAMP(int(n.x), 0, 65535);
4608-
p_rgb[1] = CLAMP(int(n.y), 0, 65535);
4609-
p_rgb[2] = CLAMP(int(n.z), 0, 65535);
4607+
p_rgb[0] = CLAMP(int(Math::round(n.x)), 0, 65535);
4608+
p_rgb[1] = CLAMP(int(Math::round(n.y)), 0, 65535);
4609+
p_rgb[2] = CLAMP(int(Math::round(n.z)), 0, 65535);
46104610
}
46114611

46124612
Image::Image(const uint8_t *p_mem_png_jpg, int p_len) {

0 commit comments

Comments
 (0)