xoreos
0.0.5
|
Image decoder for Nintendo's tile-based graphics format. More...
#include <ncgr.h>
Classes | |
struct | NCGRFile |
struct | ReadContext |
Public Member Functions | |
NCGR (Common::SeekableReadStream &ncgr, Common::SeekableReadStream &nclr) | |
NCGR (const std::vector< Common::SeekableReadStream *> &ncgrs, uint32 width, uint32 height, Common::SeekableReadStream &nclr) | |
~NCGR () | |
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 Member Functions | |
void | load (const std::vector< Common::SeekableReadStream *> &ncgrs, uint32 width, uint32 height, Common::SeekableReadStream &nclr) |
void | load (NCGRFile &ctx) |
void | readHeader (NCGRFile &ctx) |
void | readChar (NCGRFile &ctx) |
void | calculateGrid (ReadContext &ctx, uint32 &imageWidth, uint32 &imageHeight) |
void | draw (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) |
Static Protected Member Functions inherited from Aurora::NitroFile | |
static Common::SeekableSubReadStreamEndian * | open (Common::SeekableReadStream &stream) |
Treat this stream as a Nitro file and return an endian'd stream according to its BOM. More... | |
static Common::SeekableSubReadStreamEndian * | open (Common::SeekableReadStream *stream) |
Treat this stream as a Nitro file, take it over and return an endian'd stream according to its BOM. More... | |
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 |
Image decoder for Nintendo's tile-based graphics format.
2D graphics on the Nintendo DS is fundamentally tile-based. Specifically, the graphics data in NCGR is ordered in tiles of 8x8 pixels. We unwrap them, so this is transparent to the user of the NCGR class.
Moreover, an NCGR file can itself be a tile of a larger image. By specifying a vector of NCGR streams and the dimensions of the grid they span (in NCGR files, not pixels), the NCGR class can automatically stitch them together into a single big image.
If a pointer in the NCGR stream vector is 0, the cell in the grid will stay empty, filled with entry 0 of the palette.
Please note that, in accordance with other image decoder classes, NCGR will never take over any of the streams. The caller has to manage stream deletion itself.
Graphics::NCGR::NCGR | ( | Common::SeekableReadStream & | ncgr, |
Common::SeekableReadStream & | nclr | ||
) |
Definition at line 84 of file ncgr.cpp.
References Common::StackException::add(), and load().
Graphics::NCGR::NCGR | ( | const std::vector< Common::SeekableReadStream *> & | ncgrs, |
uint32 | width, | ||
uint32 | height, | ||
Common::SeekableReadStream & | nclr | ||
) |
Definition at line 73 of file ncgr.cpp.
References Common::StackException::add(), and load().
|
private |
Definition at line 225 of file ncgr.cpp.
References Graphics::NCGR::NCGRFile::height, Graphics::NCGR::ReadContext::height, MAX(), Graphics::NCGR::ReadContext::ncgrs, Graphics::NCGR::NCGRFile::offsetX, Graphics::NCGR::NCGRFile::offsetY, Graphics::NCGR::NCGRFile::width, and Graphics::NCGR::ReadContext::width.
Referenced by draw().
|
private |
Definition at line 247 of file ncgr.cpp.
References Graphics::ImageDecoder::_dataType, Graphics::ImageDecoder::_format, Graphics::ImageDecoder::_formatRaw, Graphics::ImageDecoder::_mipMaps, calculateGrid(), Graphics::kPixelDataType8, Graphics::kPixelFormatBGRA, Graphics::kPixelFormatRGBA8, Graphics::NCGR::ReadContext::ncgrs, and Graphics::NCGR::ReadContext::pal.
Referenced by load().
|
private |
Definition at line 96 of file ncgr.cpp.
References draw(), Graphics::NCGR::ReadContext::height, Graphics::NCLR::load(), Graphics::NCGR::ReadContext::ncgrs, Aurora::NitroFile::open(), Graphics::NCGR::ReadContext::pal, Common::ScopedPtrBase< T, Deallocator >::reset(), and Graphics::NCGR::ReadContext::width.
Referenced by NCGR().
|
private |
Definition at line 126 of file ncgr.cpp.
References readChar(), and readHeader().
|
private |
Definition at line 160 of file ncgr.cpp.
References Common::debugTag(), Graphics::NCGR::NCGRFile::depth, Graphics::NCGR::NCGRFile::height, Graphics::NCGR::NCGRFile::image, kCHARID, Graphics::NCGR::NCGRFile::ncgr, Graphics::NCGR::NCGRFile::offsetCHAR, Common::ReadStream::readByte(), Common::SeekableSubReadStreamEndian::readUint16(), Common::SeekableSubReadStreamEndian::readUint32(), Common::SeekableSubReadStream::seek(), Common::SeekableSubReadStream::size(), Common::SeekableReadStream::skip(), and Graphics::NCGR::NCGRFile::width.
Referenced by load().
|
private |
Definition at line 131 of file ncgr.cpp.
References Common::debugTag(), kNCGRID, Graphics::NCGR::NCGRFile::ncgr, Graphics::NCGR::NCGRFile::offsetCHAR, Common::ReadStream::readByte(), Common::SeekableSubReadStreamEndian::readUint16(), Common::SeekableSubReadStreamEndian::readUint32(), and Common::SeekableSubReadStream::size().
Referenced by load().