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);
@ -98,7 +100,7 @@ size_t Color::MinChannelRGB() {
size_t Color::MaxChannelRGB() {
if (r >= g && r >= b) return 0;
if (g >= b && g >=r) return 1;
if (g >= b && g >= r) return 1;
return 2;
}
@ -107,12 +109,10 @@ Color Color::Min(const Color &A, const Color &B) { return Color(std::min(A[0], B
Color Color::Max(const Color &a, const Color &b) { return Color(std::max(a[0], b[0]), std::max(a[1], b[1]), std::max(a[2], b[2]), std::max(a[3], b[3])); }
Color::operator Vector4() const { return Vector4(r, g, b, a); }
Color::operator Vector4Int() const { return Vector4Int(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;