Fix average color computation

This commit is contained in:
Miloslav Číž 2018-09-30 14:40:27 +02:00
parent f5621ac8e1
commit fbd39cdcdf

View file

@ -463,6 +463,7 @@ unsigned char computeAverageColor(const unsigned char *texture, int16_t excludeC
uint32_t sumS = 0;
uint32_t sumV = 0;
uint32_t pixels = texture[0] * texture[1];
uint32_t count = 0;
for (uint16_t i = 0; i < pixels; ++i)
{
@ -476,9 +477,10 @@ unsigned char computeAverageColor(const unsigned char *texture, int16_t excludeC
sumH += h;
sumS += s;
sumV += v;
count++;
}
return encodeHSV(sumH / pixels,sumS / pixels, sumV / pixels);
return encodeHSV(sumH / count,sumS / count, sumV / count);
}
#endif