Add RGBA pixel constructor

This commit is contained in:
Pavel Krajcevski 2013-09-19 15:11:27 -04:00
parent 9f4fa671d9
commit 1d58ea2385
2 changed files with 14 additions and 3 deletions

View file

@ -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<uint8 *>(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<uint8 *>(0),
uint8 bitOffset = 0) {
FromBits(bits, channelDepth, bitOffset);
}

View file

@ -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);