xoreos
0.0.5
|
Loader for CBGT, BioWare's Compressed BackGround Tiles, an image format found in Sonic, used as area background images. More...
#include <cbgt.h>
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 () |
ImageDecoder & | operator= (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 MipMap & | getMipMap (size_t mipMap, size_t layer=0) const |
Return a mip map. More... | |
void | decompress () |
Manually decompress the texture image data. More... | |
const TXI & | getTXI () 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::DeallocatorArray > | Palettes |
typedef std::vector< size_t > | PaletteIndices |
typedef Common::PtrVector< Common::SeekableReadStream > | Cells |
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< MipMap > | MipMaps |
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 |
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.
|
private |
|
private |
|
private |
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().
|
private |
Definition at line 204 of file cbgt.cpp.
References Graphics::CBGT::ReadContext::cells, Graphics::CBGT::ReadContext::maxPaletteIndex, Graphics::CBGT::ReadContext::paletteIndices, and Graphics::CBGT::ReadContext::palettes.
Referenced by load().
Definition at line 214 of file cbgt.cpp.
References Graphics::ImageDecoder::_dataType, Graphics::ImageDecoder::_format, Graphics::ImageDecoder::_formatRaw, Graphics::ImageDecoder::_mipMaps, Graphics::kPixelDataType8, Graphics::kPixelFormatBGRA, and Graphics::kPixelFormatRGBA8.
Referenced by drawImage().
|
private |
Definition at line 228 of file cbgt.cpp.
References Graphics::ImageDecoder::_mipMaps, Graphics::CBGT::ReadContext::cells, createImage(), Graphics::CBGT::ReadContext::height, Graphics::CBGT::ReadContext::paletteIndices, Graphics::CBGT::ReadContext::palettes, Common::ReadStream::readByte(), and Graphics::CBGT::ReadContext::width.
Referenced by load().
|
private |
Definition at line 62 of file cbgt.cpp.
References checkConsistency(), drawImage(), readCells(), readPaletteIndices(), and readPalettes().
Referenced by CBGT().
|
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().
|
private |
Definition at line 108 of file cbgt.cpp.
References Common::StackException::add(), Common::UString::c_str(), Aurora::TwoDAFile::getColumnCount(), Aurora::TwoDAFile::getRow(), Aurora::TwoDAFile::getRowCount(), Aurora::TwoDARow::getString(), Graphics::CBGT::ReadContext::height, Graphics::CBGT::ReadContext::maxPaletteIndex, Graphics::CBGT::ReadContext::paletteIndices, Graphics::CBGT::ReadContext::twoda, and Graphics::CBGT::ReadContext::width.
Referenced by load().
|
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().