mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- consolidated the two averageColor instances.
This commit is contained in:
parent
55df3a91ec
commit
8b19ae98ea
3 changed files with 29 additions and 75 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in a new issue