diff --git a/PVRTCEncoder/src/Pixel.cpp b/PVRTCEncoder/src/Pixel.cpp index 8db81f6..d8504a3 100644 --- a/PVRTCEncoder/src/Pixel.cpp +++ b/PVRTCEncoder/src/Pixel.cpp @@ -163,5 +163,19 @@ namespace PVRTCC { return r; } + bool Pixel::operator==(const Pixel &other) const { + uint8 depths[4]; + other.GetBitDepth(depths); + + bool ok = true; + for(int i = 0; i < 4; i++) { + ok = ok && m_BitDepth[i] == depths[i]; + + uint8 mask = (1 << depths[i]) - 1; + const uint8 c = other.Component(i) & mask; + ok = ok && (c == (Component(i) & mask)); + } + return ok; + } } // namespace PVRTCC diff --git a/PVRTCEncoder/src/Pixel.h b/PVRTCEncoder/src/Pixel.h index 7c3a488..692eed3 100644 --- a/PVRTCEncoder/src/Pixel.h +++ b/PVRTCEncoder/src/Pixel.h @@ -111,6 +111,9 @@ class Pixel { // up in the most-significant byte. uint32 PackRGBA() const; + // Tests for equality by comparing the values and the bit depths. + bool operator==(const Pixel &) const; + private: union { struct {