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

Image decoder for Nintendo's tile-based graphics format. More...

#include <ncgr.h>

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

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 ()
 
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 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< MipMapMipMaps
 
- 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::SeekableSubReadStreamEndianopen (Common::SeekableReadStream &stream)
 Treat this stream as a Nitro file and return an endian'd stream according to its BOM. More...
 
static Common::SeekableSubReadStreamEndianopen (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
 

Detailed Description

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.

Definition at line 58 of file ncgr.h.

Constructor & Destructor Documentation

◆ NCGR() [1/2]

Graphics::NCGR::NCGR ( Common::SeekableReadStream ncgr,
Common::SeekableReadStream nclr 
)

Definition at line 84 of file ncgr.cpp.

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

Here is the call graph for this function:

◆ NCGR() [2/2]

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().

Here is the call graph for this function:

◆ ~NCGR()

Graphics::NCGR::~NCGR ( )

Definition at line 123 of file ncgr.cpp.

Member Function Documentation

◆ calculateGrid()

void Graphics::NCGR::calculateGrid ( ReadContext ctx,
uint32 imageWidth,
uint32 imageHeight 
)
private

◆ draw()

void Graphics::NCGR::draw ( ReadContext ctx)
private

◆ load() [1/2]

void Graphics::NCGR::load ( const std::vector< Common::SeekableReadStream *> &  ncgrs,
uint32  width,
uint32  height,
Common::SeekableReadStream nclr 
)
private

◆ load() [2/2]

void Graphics::NCGR::load ( NCGRFile ctx)
private

Definition at line 126 of file ncgr.cpp.

References readChar(), and readHeader().

Here is the call graph for this function:

◆ readChar()

void Graphics::NCGR::readChar ( NCGRFile ctx)
private

◆ readHeader()

void Graphics::NCGR::readHeader ( NCGRFile ctx)
private

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