diff --git a/general.hpp b/general.hpp index 3731171..b0bf033 100644 --- a/general.hpp +++ b/general.hpp @@ -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