diff --git a/PVRTCEncoder/src/Pixel.h b/PVRTCEncoder/src/Pixel.h index 1953e09..f87d79d 100644 --- a/PVRTCEncoder/src/Pixel.h +++ b/PVRTCEncoder/src/Pixel.h @@ -63,9 +63,14 @@ class Pixel { for(int i = 0; i < 4; i++) m_BitDepth[i] = 8; } - explicit Pixel(const uint8 *bits, - const uint8 channelDepth[4] = static_cast(0), - uint8 bitOffset = 0) { + explicit Pixel(uint32 rgba) { + for(int i = 0; i < 4; i++) m_BitDepth[i] = 8; + UnpackRGBA(rgba); + } + + Pixel(const uint8 *bits, + const uint8 channelDepth[4] = static_cast(0), + uint8 bitOffset = 0) { FromBits(bits, channelDepth, bitOffset); } diff --git a/PVRTCEncoder/test/PixelTest.cpp b/PVRTCEncoder/test/PixelTest.cpp index b8b4d2a..5a2cc6e 100644 --- a/PVRTCEncoder/test/PixelTest.cpp +++ b/PVRTCEncoder/test/PixelTest.cpp @@ -206,6 +206,12 @@ TEST(Pixel, UnpackRGBA) { EXPECT_EQ(p.G(), 0xB3); EXPECT_EQ(p.R(), 0xFE); + p = PVRTCC::Pixel(rgba); + EXPECT_EQ(p.A(), 0x46); + EXPECT_EQ(p.B(), 0x19); + EXPECT_EQ(p.G(), 0xB3); + EXPECT_EQ(p.R(), 0xFE); + uint8 newBitDepth[4] = { 3, 5, 2, 1 }; // A R G B p.ChangeBitDepth(newBitDepth);