From eb2646b61337a434f6bbe67f439a4a7bf25dd216 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 13 Jul 2021 06:32:38 -0400 Subject: [PATCH] - change previous /0 fix: as suggested here: https://github.com/coelckers/gzdoom/commit/cb8ae0b5602a980c95ed8055c68bea5b61db3298#commitcomment-53414064 --- src/common/fonts/v_font.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index d353887c6..750bb5d95 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -673,10 +673,6 @@ void V_ApplyLuminosityTranslation(int translation, uint8_t* pixel, int size) int lum_range = (lum_max - lum_min + 1); PalEntry* remap = paletteptr + colorrange * 256; - // why was this ever allowed to divide by zero? - if (!lum_max) - lum_max++; - for (int i = 0; i < size; i++, pixel += 4) { // we must also process the transparent pixels here to ensure proper filtering on the characters' edges. @@ -685,13 +681,13 @@ void V_ApplyLuminosityTranslation(int translation, uint8_t* pixel, int size) int index = clamp(lumadjust, 0, 255); PalEntry newcol = remap[index]; // extend the range if we find colors outside what initial analysis provided. - if (gray < lum_min) + if (gray < lum_min && lum_min != 0) { newcol.r = newcol.r * gray / lum_min; newcol.g = newcol.g * gray / lum_min; newcol.b = newcol.b * gray / lum_min; } - else if (gray > lum_max) + else if (gray > lum_max && lum_max != 0) { newcol.r = clamp(newcol.r * gray / lum_max, 0, 255); newcol.g = clamp(newcol.g * gray / lum_max, 0, 255);