xoreos  0.0.5
ncgr.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
26 #ifndef GRAPHICS_IMAGES_NCGR_H
27 #define GRAPHICS_IMAGES_NCGR_H
28 
29 #include <vector>
30 
31 #include "src/common/scopedptr.h"
32 
33 #include "src/aurora/nitrofile.h"
34 
36 
37 namespace Graphics {
38 
58 class NCGR : public ImageDecoder, public Aurora::NitroFile {
59 public:
61  NCGR(const std::vector<Common::SeekableReadStream *> &ncgrs, uint32 width, uint32 height,
63  ~NCGR();
64 
65 private:
66  struct NCGRFile {
69 
72 
76 
79 
80  NCGRFile();
81  ~NCGRFile();
82  };
83 
84  struct ReadContext {
87 
89 
90  std::vector<NCGRFile> ncgrs;
91  };
92 
93 
94  void load(const std::vector<Common::SeekableReadStream *> &ncgrs, uint32 width, uint32 height,
96 
97  void load (NCGRFile &ctx);
98  void readHeader(NCGRFile &ctx);
99  void readChar (NCGRFile &ctx);
100 
101  void calculateGrid(ReadContext &ctx, uint32 &imageWidth, uint32 &imageHeight);
102  void draw(ReadContext &ctx);
103 };
104 
105 } // End of namespace Graphics
106 
107 #endif // GRAPHICS_IMAGES_NCGR_H
Generic image decoder interface.
uint32 offsetX
X offset in pixels into the final image.
Definition: ncgr.h:77
This is a wrapper around SeekableSubReadStream, but it adds non-endian read methods whose endianness ...
Definition: readstream.h:383
uint32 width
Width of the NCGR grid, in NCGR.
Definition: ncgr.h:85
Common::ScopedArray< const byte > pal
Definition: ncgr.h:88
void calculateGrid(ReadContext &ctx, uint32 &imageWidth, uint32 &imageHeight)
Definition: ncgr.cpp:225
uint8_t uint8
Definition: types.h:200
Image decoder for Nintendo&#39;s tile-based graphics format.
Definition: ncgr.h:58
void load(const std::vector< Common::SeekableReadStream *> &ncgrs, uint32 width, uint32 height, Common::SeekableReadStream &nclr)
Definition: ncgr.cpp:96
A simple scoped smart pointer template.
Common::SeekableSubReadStreamEndian * ncgr
Definition: ncgr.h:67
uint32 width
Width in pixels of this NCGR.
Definition: ncgr.h:73
Common::SeekableReadStream * image
Definition: ncgr.h:68
uint32 offsetY
Y offset in pixels into the final image.
Definition: ncgr.h:78
void readHeader(NCGRFile &ctx)
Definition: ncgr.cpp:131
NCGR(Common::SeekableReadStream &ncgr, Common::SeekableReadStream &nclr)
Definition: ncgr.cpp:84
uint8 depth
Color depth in bits.
Definition: ncgr.h:75
uint32 offsetCHAR
Offset to the CHAR section within the NCGR file.
Definition: ncgr.h:71
void readChar(NCGRFile &ctx)
Definition: ncgr.cpp:160
uint32 height
Height of the NCGR grid, in NCGR.
Definition: ncgr.h:86
uint32_t uint32
Definition: types.h:204
Base class for Nitro (Nintendo DS) files.
A generic interface for image decoders.
Definition: decoder.h:48
uint32 height
Height in pixels of this NCGR.
Definition: ncgr.h:74
Interface for a seekable & readable data stream.
Definition: readstream.h:265
std::vector< NCGRFile > ncgrs
Definition: ncgr.h:90
void draw(ReadContext &ctx)
Definition: ncgr.cpp:247