From a7e7db1fe93f38216fb038e230d8d02d29ff6a38 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 10 May 2018 15:45:29 +0300 Subject: [PATCH] - fixed calculation of glow color Width and pitch were mixed up for RGB format texture, pixel data were read outside of designated buffer https://forum.zdoom.org/viewtopic.php?t=60538 --- src/textures/texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 997ac3708..50ba4d1bd 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -1136,10 +1136,10 @@ void FTexture::GetGlowColor(float *data) if (bGlowing && GlowColor == 0) { int w = Width, h = Height; - auto buffer = new uint8_t[w * h]; + auto buffer = new uint8_t[w * h * 4]; if (buffer) { - FillBuffer(buffer, w, h, TEX_RGB); + FillBuffer(buffer, w * 4, h, TEX_RGB); GlowColor = averageColor((uint32_t *)buffer, w*h, 153); delete[] buffer; }