|
wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
|
The MCAL alpha-map codec. More...
#include <wowlib/formats/adt/codec.hpp>
Public Member Functions | |
| AlphaMapCodec (AlphaFormat format) noexcept | |
| std::vector< std::uint8_t > | decode (std::span< const std::byte > src, bool compressed, bool fixEdges) const |
| Decode one layer's on-disk alpha bytes to the 4096-texel edit surface. | |
| void | encode (std::span< const std::uint8_t > map, bool compressed, std::vector< std::byte > &out) const |
| Encode a 4096-texel edit surface to its on-disk alpha bytes, appended to out. | |
Protected Member Functions | |
| void | decode4Bit (std::span< const std::byte > src, std::vector< std::uint8_t > &out) const |
| Decode a 2048-byte 4-bit map to 4096 texels (nibble * 0x11, LSB first). | |
| void | decode8Bit (std::span< const std::byte > src, std::vector< std::uint8_t > &out) const |
| Decode a 4096-byte 8-bit map (a straight copy). | |
| void | decodeRle (std::span< const std::byte > src, std::vector< std::uint8_t > &out) const |
| Decode a Blizzard RLE map (8-bit) to 4096 texels. | |
| void | encode4Bit (std::span< const std::uint8_t > map, std::vector< std::byte > &out) const |
| Encode 4096 texels to a 2048-byte 4-bit map (texel >> 4). | |
| void | encode8Bit (std::span< const std::uint8_t > map, std::vector< std::byte > &out) const |
| Encode 4096 texels to a 4096-byte 8-bit map (a straight copy). | |
| void | encodeRle (std::span< const std::uint8_t > map, std::vector< std::byte > &out) const |
| RLE-encode 4096 texels one row at a time (runs cannot span rows). | |
The MCAL alpha-map codec.
Constructed with the tile's on-disk bit depth (its state); decode()/encode() move a single layer between its on-disk bytes and the 4096-texel edit surface, choosing the encoding from that depth and the per-layer compression flag.
|
inlineexplicitnoexcept |
|
inlinenodiscard |
Decode one layer's on-disk alpha bytes to the 4096-texel edit surface.
| src | the layer's on-disk alpha bytes. |
| compressed | whether the layer is RLE-compressed (MCLY flag 0x200); overrides the bit depth when set. |
| fixEdges | whether to repair the 63x63 "unfixed" form (MCNK flag do_not_fix_alpha clear). |
Definition at line 73 of file codec.hpp.
References wowlib::formats::adt::detail::TerrainMapCodec::_fixLastRowCol(), decode4Bit(), decode8Bit(), decodeRle(), and wowlib::formats::adt::Highres8Bit.
Referenced by wowlib::formats::adt::detail::AlphaCodec::read().
|
inlineprotected |
Decode a 2048-byte 4-bit map to 4096 texels (nibble * 0x11, LSB first).
| src | the on-disk 4-bit bytes. |
| out | the decoded surface, resized to 4096. |
Definition at line 97 of file codec.hpp.
References wowlib::formats::adt::detail::Alpha4BitBytes, and wowlib::formats::adt::detail::AlphaTexels.
Referenced by decode().
|
inlineprotected |
Decode a 4096-byte 8-bit map (a straight copy).
| src | the on-disk 8-bit bytes. |
| out | the decoded surface, resized to 4096. |
Definition at line 109 of file codec.hpp.
References wowlib::formats::adt::detail::AlphaTexels.
Referenced by decode().
|
inlineprotected |
Decode a Blizzard RLE map (8-bit) to 4096 texels.
Tolerates the known corrupt chunks that unpack past 4096 by stopping at the boundary.
| src | the on-disk RLE bytes. |
| out | the decoded surface, resized to 4096. |
Definition at line 118 of file codec.hpp.
References wowlib::formats::adt::detail::AlphaTexels.
Referenced by decode().
|
inline |
Encode a 4096-texel edit surface to its on-disk alpha bytes, appended to out.
wowlib always holds and re-emits the fixed 64x64 form.
| map | the 4096-texel edit surface. |
| compressed | whether to RLE-compress (MCLY flag 0x200). |
| out | the destination byte buffer, appended to. |
Definition at line 87 of file codec.hpp.
References encode4Bit(), encode8Bit(), encodeRle(), and wowlib::formats::adt::Highres8Bit.
Referenced by wowlib::formats::adt::detail::AlphaCodec::prepare().
|
inlineprotected |
Encode 4096 texels to a 2048-byte 4-bit map (texel >> 4).
| map | the 4096-texel surface. |
| out | the destination buffer, appended to. |
Definition at line 143 of file codec.hpp.
References wowlib::formats::adt::detail::Alpha4BitBytes.
Referenced by encode().
|
inlineprotected |
|
inlineprotected |
RLE-encode 4096 texels one row at a time (runs cannot span rows).
A greedy encoder: fill runs of >= 3 equal bytes, copy otherwise. This does NOT reproduce Blizzard's exact byte stream (their encoder differs), which is why ADT round-trip is semantic, not byte-identical.
| map | the 4096-texel surface. |
| out | the destination buffer, appended to. |
Definition at line 164 of file codec.hpp.
References wowlib::formats::adt::detail::AlphaDim.
Referenced by encode().