diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 76477c738..b671edbf7 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -167,50 +167,6 @@ void gl_GenerateGlobalBrightmapFromColormap() } } -//=========================================================================== -// -// averageColor -// input is RGBA8 pixel format. -// The resulting RGB color can be scaled uniformly so that the highest -// component becomes one. -// -//=========================================================================== -static PalEntry averageColor(const uint32_t *data, int size, int maxout) -{ - int i; - unsigned int r, g, b; - - - - // First clear them. - r = g = b = 0; - if (size==0) - { - return PalEntry(255,255,255); - } - for(i = 0; i < size; i++) - { - r += BPART(data[i]); - g += GPART(data[i]); - b += RPART(data[i]); - } - - r = r/size; - g = g/size; - b = b/size; - - int maxv=MAX(MAX(r,g),b); - - if(maxv && maxout) - { - r = Scale(r, maxout, maxv); - g = Scale(g, maxout, maxv); - b = Scale(b, maxout, maxv); - } - return PalEntry(255,r,g,b); -} - - //========================================================================== // diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 2d7cc9486..162d0ca43 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -848,40 +848,37 @@ void FTexture::SetScaledSize(int fitwidth, int fitheight) // //=========================================================================== -namespace +PalEntry FTexture::averageColor(const uint32_t *data, int size, int maxout) { - PalEntry averageColor(const uint32_t *data, int size, int maxout) + int i; + unsigned int r, g, b; + + // First clear them. + r = g = b = 0; + if (size == 0) { - int i; - unsigned int r, g, b; - - // First clear them. - r = g = b = 0; - if (size == 0) - { - return PalEntry(255, 255, 255); - } - for (i = 0; i < size; i++) - { - b += BPART(data[i]); - g += GPART(data[i]); - r += RPART(data[i]); - } - - r = r / size; - g = g / size; - b = b / size; - - int maxv = MAX(MAX(r, g), b); - - if (maxv && maxout) - { - r = Scale(r, maxout, maxv); - g = Scale(g, maxout, maxv); - b = Scale(b, maxout, maxv); - } - return PalEntry(255, r, g, b); + return PalEntry(255, 255, 255); } + for (i = 0; i < size; i++) + { + b += BPART(data[i]); + g += GPART(data[i]); + r += RPART(data[i]); + } + + r = r / size; + g = g / size; + b = b / size; + + int maxv = MAX(MAX(r, g), b); + + if (maxv && maxout) + { + r = ::Scale(r, maxout, maxv); + g = ::Scale(g, maxout, maxv); + b = ::Scale(b, maxout, maxv); + } + return PalEntry(255, r, g, b); } PalEntry FTexture::GetSkyCapColor(bool bottom) diff --git a/src/textures/textures.h b/src/textures/textures.h index 3c93b35df..1c5a1ddf8 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -307,6 +307,7 @@ public: void SetScaledSize(int fitwidth, int fitheight); PalEntry GetSkyCapColor(bool bottom); + static PalEntry averageColor(const uint32_t *data, int size, int maxout); virtual void HackHack (int newheight); // called by FMultipatchTexture to discover corrupt patches.