From 80d5c4be4818f3a0ccf28c93aaf1f04b29a6f5b9 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 17 Jan 2015 09:16:48 -0800 Subject: [PATCH] fix bug introduced when doing hdr cleanup --- stb_image_write.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stb_image_write.h b/stb_image_write.h index 726e3fe..d40386f 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -222,9 +222,9 @@ void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) } else { float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; - rgbe[0] = (unsigned char)(linear[0] * maxcomp); - rgbe[1] = (unsigned char)(linear[1] * maxcomp); - rgbe[2] = (unsigned char)(linear[2] * maxcomp); + rgbe[0] = (unsigned char)(linear[0] * normalize); + rgbe[1] = (unsigned char)(linear[1] * normalize); + rgbe[2] = (unsigned char)(linear[2] * normalize); rgbe[3] = (unsigned char)(exponent + 128); } }