Fix errors in last commit

This commit is contained in:
Andrew Cassidy 2021-03-02 18:32:47 -08:00
parent 4eb8c397f9
commit 0924e43dc2
4 changed files with 10 additions and 6 deletions

View File

@ -158,7 +158,7 @@ template <size_t M, size_t N> class ColorBlockView : public BlockView<Color, M,
total++;
}
if (total > 0) metrics.avg = (metrics.sum + Vector4Int(total / 2)) / total; // half-total added for better rounding
if (total > 0) metrics.avg = (metrics.sums + Vector4Int(total / 2)) / total; // half-total added for better rounding
return metrics;
}

View File

@ -30,6 +30,8 @@ Color::Color() { SetRGBA(0, 0, 0, 0xFF); }
Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { SetRGBA(r, g, b, a); }
Color::Color(Vector4Int v) { SetRGBA(v[0], v[1], v[2], v[3]); }
uint16_t Color::Pack565Unscaled(uint8_t r, uint8_t g, uint8_t b) {
assert5bit(r);
assert6bit(g);
@ -110,9 +112,7 @@ Color::operator Vector4() const { return Vector4(r, g, b, a); }
Color::operator Vector4Int() const { return Vector4Int(r, g, b, a); }
Vector4Int operator-(const Color &lhs, const Color &rhs) {
Vector4Int result;
for (unsigned i = 0; i < 4; i++) {
result[i] = (int)lhs[i] - rhs[i];
}
for (unsigned i = 0; i < 4; i++) { result[i] = (int)lhs[i] - rhs[i]; }
return result;
}

View File

@ -39,6 +39,8 @@ class Color {
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF);
Color(Vector4Int v);
static uint16_t Pack565Unscaled(uint8_t r, uint8_t g, uint8_t b);
static uint16_t Pack565(uint8_t r, uint8_t g, uint8_t b);

View File

@ -29,6 +29,8 @@ namespace rgbcx {
class Vector4Int {
public:
Vector4Int() : Vector4Int(0) {}
Vector4Int(int x, int y, int z = 0, int w = 0) {
_c[0] = x;
_c[1] = y;