Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
WorldStone::DC6 Class Reference

Decoder for the DC6 image format. More...

#include <dc6.h>

Classes

struct  FrameHeader
 
struct  Header
 

Public Types

enum  Flags { IsSerialized = 1 << 0, IsLoadedInHW = 1 << 1, Is24Bits = 1 << 2 }
 

Public Member Functions

bool initDecoder (StreamPtr &&streamPtr)
 Start decoding the stream and preparing data. More...
 
void reset ()
 Resets the decoder and frees resources.
 
const HeadergetHeader () const
 
const std::vector< FrameHeader > & getFrameHeaders () const
 
std::vector< uint8_t > decompressFrame (size_t frameNumber) const
 Decompress the given frame. More...
 
bool decompressFrameIn (size_t frameNumber, uint8_t *data) const
 Same as decompressFrame but will output the data in a given buffer.
 
void exportToPPM (const char *ppmFilenameBase, const Palette &palette) const
 

Protected Member Functions

bool extractHeaders ()
 

Protected Attributes

StreamPtr stream = nullptr
 
Header header
 
std::vector< uint32_t > framePointers
 
std::vector< FrameHeaderframeHeaders
 

Detailed Description

Decoder for the DC6 image format.

The DC6 (Diablo Cel 6) format is a compressed sprite image format. It can store multiple directions and frames in a single file. A palette is used to generate the colors, but the file itself doesn't have any information about the palette to use, it is up to the user to know which one to use.

See Also
WorldStone::Palette

This format is mostly used for menu, items but also for some monsters (eg:Mephisto) This is an update of diablo 1 Cel format

Layout of a DC6 file:

Name Type Size in bytes Offsets
header DC6::Header 24 0x00
framePointers uint32_t[dirs][framesPerDir] 4 * header.directions * header.framesPerDir 0x18
frameHeader[0] DC6::FrameHeader 32 framePointers[0]
frameData[0] uint8_t[frameHeader.length] frameHeader[0].length ^
skipColor[0] uint8_t[3] 3 ^
... other frames ...
frameHeader[totalFrames-1] DC6::FrameHeader 32 framePointers[nbFrames-1]
frameData[totalFrames-1] uint8_t[frameHeader.length] frameHeader[nbFrames-1].length ^
skipColor[totalFrames-1] uint8_t[3] 3 ^

Definition at line 39 of file dc6.h.

Member Enumeration Documentation

Enumerator
IsSerialized 

Always set for files.

IsLoadedInHW 

Used by the game to know if the file was loaded in the renderer.

Is24Bits 

Used internally by the game for 24 to 8 bits per color conversion.

Definition at line 42 of file dc6.h.

Member Function Documentation

std::vector< uint8_t > WorldStone::DC6::decompressFrame ( size_t  frameNumber) const

Decompress the given frame.

Parameters
frameNumberThe frame number in the file
Returns
A valid vector to the data on success, empty one on failure

Definition at line 56 of file dc6.cpp.

bool WorldStone::DC6::initDecoder ( StreamPtr &&  streamPtr)

Start decoding the stream and preparing data.

Returns
true on success

Prepares the decoder to read the frames using decompressFrame. Basically calls extractHeaders(), so that you can call getHeader() and getFrameHeaders().

Definition at line 17 of file dc6.cpp.


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