xoreos  0.0.5
Classes | Public Member Functions | Private Types | Private Member Functions | List of all members
Graphics::CBGT Class Reference

Loader for CBGT, BioWare's Compressed BackGround Tiles, an image format found in Sonic, used as area background images. More...

#include <cbgt.h>

Inheritance diagram for Graphics::CBGT:
Inheritance graph
[legend]
Collaboration diagram for Graphics::CBGT:
Collaboration graph
[legend]

Classes

struct  ReadContext
 

Public Member Functions

 CBGT (Common::SeekableReadStream &cbgt, Common::SeekableReadStream &pal, Common::SeekableReadStream &twoda)
 
 ~CBGT ()
 
- Public Member Functions inherited from Graphics::ImageDecoder
 ImageDecoder ()
 
 ImageDecoder (const ImageDecoder &image)
 
virtual ~ImageDecoder ()
 
ImageDecoderoperator= (const ImageDecoder &image)
 
bool isCompressed () const
 Is the image data compressed? More...
 
bool hasAlpha () const
 Does the image data have alpha? . More...
 
PixelFormat getFormat () const
 Return the image data's general format. More...
 
PixelFormatRaw getFormatRaw () const
 Return the image data's raw format. More...
 
PixelDataType getDataType () const
 Return the image data pixel's type. More...
 
size_t getMipMapCount () const
 Return the number of mip maps contained in the image. More...
 
size_t getLayerCount () const
 Return the number of layers contained in the image. More...
 
bool isCubeMap () const
 Is this image a cube map? More...
 
const MipMapgetMipMap (size_t mipMap, size_t layer=0) const
 Return a mip map. More...
 
void decompress ()
 Manually decompress the texture image data. More...
 
const TXIgetTXI () const
 Return the texture information TXI, which may be embedded in the image. More...
 
bool dumpTGA (const Common::UString &fileName) const
 Dump the image into a TGA. More...
 

Private Types

typedef Common::PtrVector< byte, Common::DeallocatorArrayPalettes
 
typedef std::vector< size_t > PaletteIndices
 
typedef Common::PtrVector< Common::SeekableReadStreamCells
 

Private Member Functions

void load (ReadContext &ctx)
 
void readPalettes (ReadContext &ctx)
 
void readPaletteIndices (ReadContext &ctx)
 
void readCells (ReadContext &ctx)
 
void checkConsistency (ReadContext &ctx)
 
void createImage (uint32 width, uint32 height)
 
void drawImage (ReadContext &ctx)
 

Additional Inherited Members

- Protected Types inherited from Graphics::ImageDecoder
typedef Common::PtrVector< MipMapMipMaps
 
- Static Protected Member Functions inherited from Graphics::ImageDecoder
static void decompress (MipMap &out, const MipMap &in, PixelFormatRaw format)
 
- Protected Attributes inherited from Graphics::ImageDecoder
bool _compressed
 
bool _hasAlpha
 
PixelFormat _format
 
PixelFormatRaw _formatRaw
 
PixelDataType _dataType
 
size_t _layerCount
 Number of layers in this image. More...
 
bool _isCubeMap
 Is this image a cube map? A cube map always needs to have 6 layers! More...
 
MipMaps _mipMaps
 
TXI _txi
 

Detailed Description

Loader for CBGT, BioWare's Compressed BackGround Tiles, an image format found in Sonic, used as area background images.

A CBGT is similar to a collection of NCGR files: cells of 64x64 pixels, divided in tiles of 8x8 pixels. Each cell is compressed using Nintendo's 0x10 LZSS algorithm, though. Moreover, PAL files with the same name as the CBGT file contain the palette data, and 2DA files with the same name yet again contain the mapping of palette indices onto cells.

The width and height of the final image is not stored within the CBGT file, but the palette mapping 2DA does contain the number cells in X and Y direction, since it stores the palette indices in a two-dimensional array of those dimensions. Therefore, multi- plying the number of columns and rows in said 2DA by 64 yields the width and height, respectively, of the final image.

Definition at line 57 of file cbgt.h.

Member Typedef Documentation

◆ Cells

Definition at line 66 of file cbgt.h.

◆ PaletteIndices

typedef std::vector<size_t> Graphics::CBGT::PaletteIndices
private

Definition at line 65 of file cbgt.h.

◆ Palettes

Definition at line 64 of file cbgt.h.

Constructor & Destructor Documentation

◆ CBGT()

Graphics::CBGT::CBGT ( Common::SeekableReadStream cbgt,
Common::SeekableReadStream pal,
Common::SeekableReadStream twoda 
)

Definition at line 46 of file cbgt.cpp.

References Common::StackException::add(), and load().

Here is the call graph for this function:

◆ ~CBGT()

Graphics::CBGT::~CBGT ( )

Definition at line 59 of file cbgt.cpp.

Member Function Documentation

◆ checkConsistency()

void Graphics::CBGT::checkConsistency ( ReadContext ctx)
private

◆ createImage()

void Graphics::CBGT::createImage ( uint32  width,
uint32  height 
)
private

◆ drawImage()

void Graphics::CBGT::drawImage ( ReadContext ctx)
private

◆ load()

void Graphics::CBGT::load ( ReadContext ctx)
private

Definition at line 62 of file cbgt.cpp.

References checkConsistency(), drawImage(), readCells(), readPaletteIndices(), and readPalettes().

Referenced by CBGT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readCells()

void Graphics::CBGT::readCells ( ReadContext ctx)
private

Definition at line 164 of file cbgt.cpp.

References Common::StackException::add(), Graphics::CBGT::ReadContext::cbgt, Graphics::CBGT::ReadContext::cells, Aurora::Small::decompress(), Common::SeekableReadStream::pos(), Common::ReadStream::readUint16LE(), and Common::SeekableReadStream::seek().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readPaletteIndices()

void Graphics::CBGT::readPaletteIndices ( ReadContext ctx)
private

◆ readPalettes()

void Graphics::CBGT::readPalettes ( ReadContext ctx)
private

Definition at line 72 of file cbgt.cpp.

References Common::StackException::add(), Graphics::CBGT::ReadContext::pal, Graphics::CBGT::ReadContext::palettes, Common::ReadStream::readUint16LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::size().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

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