- consolidated the two averageColor instances.

This commit is contained in:
Christoph Oelckers 2017-06-07 22:42:19 +02:00
commit 8b19ae98ea
3 changed files with 26 additions and 72 deletions

View file

@ -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)