Jazz2::AssetPacker::SpriteRepacker class

Re-lays out the hand-made sprite sheets that a platform would have to split.

The sheets the conversion produces never have a frame lying across a page line (see Compatibility::JJ2Anims::SheetPageSize), but the game's own content also carries sheets drawn by hand as a regular grid of cells, laid out however they were authored. A grid wider or taller than one page puts cells across the line, and a platform that splits the texture into pages draws those frames cut off at it - the water shield and Lori's end-of-level animation among them.

Such a sheet is rewritten into the tightly packed form the conversion uses: every frame trimmed to the pixels it actually covers and laid out by Compatibility::JJ2Anims::PackRectangles(). Each frame keeps its place within its cell, so it is drawn exactly where it was.

Only multi-frame grids larger than a page are touched. The smaller ones are left as they were authored, because some are sampled as a whole texture rather than frame by frame - the fire and lightning shields scroll across all of theirs - and rewriting them would change what they draw.

Public static functions

static auto TryRepack(Stream& input, MemoryStream& output, StringView name) -> bool
Rewrites a grid sheet larger than one page into a tightly packed one.
static auto TryConvertToLz4(Stream& input, MemoryStream& output, StringView name) -> bool
Rewrites a sprite sheet with its image content in LZ4.

Function documentation

static bool Jazz2::AssetPacker::SpriteRepacker::TryRepack(Stream& input, MemoryStream& output, StringView name)

Rewrites a grid sheet larger than one page into a tightly packed one.

Returns true when the sheet in input was rewritten into output. Otherwise nothing is written and the sheet is to be used as it is - it is not a sprite sheet, it is packed already, it fits into a page or it has a single frame. name is only used in messages.

static bool Jazz2::AssetPacker::SpriteRepacker::TryConvertToLz4(Stream& input, MemoryStream& output, StringView name)

Rewrites a sprite sheet with its image content in LZ4.

Returns true if output received the sheet, false if it was not recognized (or is LZ4 already) and has to be copied as it is

Used for the hand-made sheets of a target whose converted ones are written in LZ4 (see Compatibility::JJ2Anims::ImageCompression), so that the whole tree decodes one way. The header and the frame layout are copied as they are, only the flag and the image content change.