wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::formats::adt::detail::AlphaMapCodec Class Reference

The MCAL alpha-map codec. More...

#include <wowlib/formats/adt/codec.hpp>

Inheritance diagram for wowlib::formats::adt::detail::AlphaMapCodec:

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).

Detailed Description

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.

Definition at line 60 of file codec.hpp.

Constructor & Destructor Documentation

◆ AlphaMapCodec()

wowlib::formats::adt::detail::AlphaMapCodec::AlphaMapCodec ( AlphaFormat format)
inlineexplicitnoexcept
Parameters
formatthe tile's on-disk alpha bit depth (from the WDT MPHD).

Definition at line 63 of file codec.hpp.

Member Function Documentation

◆ decode()

std::vector< std::uint8_t > wowlib::formats::adt::detail::AlphaMapCodec::decode ( std::span< const std::byte > src,
bool compressed,
bool fixEdges ) const
inlinenodiscard

Decode one layer's on-disk alpha bytes to the 4096-texel edit surface.

Parameters
srcthe layer's on-disk alpha bytes.
compressedwhether the layer is RLE-compressed (MCLY flag 0x200); overrides the bit depth when set.
fixEdgeswhether to repair the 63x63 "unfixed" form (MCNK flag do_not_fix_alpha clear).
Returns
the decoded 4096-texel map.

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().

◆ decode4Bit()

void wowlib::formats::adt::detail::AlphaMapCodec::decode4Bit ( std::span< const std::byte > src,
std::vector< std::uint8_t > & out ) const
inlineprotected

Decode a 2048-byte 4-bit map to 4096 texels (nibble * 0x11, LSB first).

Parameters
srcthe on-disk 4-bit bytes.
outthe 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().

◆ decode8Bit()

void wowlib::formats::adt::detail::AlphaMapCodec::decode8Bit ( std::span< const std::byte > src,
std::vector< std::uint8_t > & out ) const
inlineprotected

Decode a 4096-byte 8-bit map (a straight copy).

Parameters
srcthe on-disk 8-bit bytes.
outthe decoded surface, resized to 4096.

Definition at line 109 of file codec.hpp.

References wowlib::formats::adt::detail::AlphaTexels.

Referenced by decode().

◆ decodeRle()

void wowlib::formats::adt::detail::AlphaMapCodec::decodeRle ( std::span< const std::byte > src,
std::vector< std::uint8_t > & out ) const
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.

Parameters
srcthe on-disk RLE bytes.
outthe decoded surface, resized to 4096.

Definition at line 118 of file codec.hpp.

References wowlib::formats::adt::detail::AlphaTexels.

Referenced by decode().

◆ encode()

void wowlib::formats::adt::detail::AlphaMapCodec::encode ( std::span< const std::uint8_t > map,
bool compressed,
std::vector< std::byte > & out ) const
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.

Parameters
mapthe 4096-texel edit surface.
compressedwhether to RLE-compress (MCLY flag 0x200).
outthe 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().

◆ encode4Bit()

void wowlib::formats::adt::detail::AlphaMapCodec::encode4Bit ( std::span< const std::uint8_t > map,
std::vector< std::byte > & out ) const
inlineprotected

Encode 4096 texels to a 2048-byte 4-bit map (texel >> 4).

Parameters
mapthe 4096-texel surface.
outthe destination buffer, appended to.

Definition at line 143 of file codec.hpp.

References wowlib::formats::adt::detail::Alpha4BitBytes.

Referenced by encode().

◆ encode8Bit()

void wowlib::formats::adt::detail::AlphaMapCodec::encode8Bit ( std::span< const std::uint8_t > map,
std::vector< std::byte > & out ) const
inlineprotected

Encode 4096 texels to a 4096-byte 8-bit map (a straight copy).

Parameters
mapthe 4096-texel surface.
outthe destination buffer, appended to.

Definition at line 154 of file codec.hpp.

Referenced by encode().

◆ encodeRle()

void wowlib::formats::adt::detail::AlphaMapCodec::encodeRle ( std::span< const std::uint8_t > map,
std::vector< std::byte > & out ) const
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.

Parameters
mapthe 4096-texel surface.
outthe destination buffer, appended to.

Definition at line 164 of file codec.hpp.

References wowlib::formats::adt::detail::AlphaDim.

Referenced by encode().


The documentation for this class was generated from the following file: