diff --git a/src/Texture.cc b/src/Texture.cc index cdb34db0..1a57e2bc 100644 --- a/src/Texture.cc +++ b/src/Texture.cc @@ -18,6 +18,20 @@ namespace zenkit { std::uint16_t g : 6; std::uint16_t r : 5; }; + + struct a4r4g4b4 { + std::uint16_t b : 4; + std::uint16_t g : 4; + std::uint16_t r : 4; + std::uint16_t a : 4; + }; + + struct a1r5g5b5 { + std::uint16_t b : 5; + std::uint16_t g : 5; + std::uint16_t r : 5; + std::uint16_t a : 1; + }; #pragma pack(pop) /// \brief Calculates the size in bytes of a texture at the given mipmap level. @@ -149,6 +163,16 @@ namespace zenkit { break; } + case TextureFormat::A4R4G4B4: { + for (auto i = 0u; i < width * height; ++i) { + conv[i * 4 + 2] = ((bytes[i * 2 + 0] >> 0) & 0x0F) * 17; + conv[i * 4 + 1] = ((bytes[i * 2 + 0] >> 4) & 0x0F) * 17; + conv[i * 4 + 0] = ((bytes[i * 2 + 1] >> 0) & 0x0F) * 17; + conv[i * 4 + 3] = ((bytes[i * 2 + 1] >> 4) & 0x0F) * 17; + } + + break; + } default: throw ParserError {"texture", "cannot convert format to rgba: " + std::to_string(static_cast(src))};