ScummVM API documentation
bitmap.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_BITMAP_H
23 #define GRIM_BITMAP_H
24 
25 #include "graphics/pixelformat.h"
26 
27 #include "common/endian.h"
28 #include "common/hashmap.h"
29 #include "common/hash-str.h"
30 
31 #include "engines/grim/pool.h"
32 
33 namespace Graphics {
34 struct Surface;
35 }
36 
37 namespace Common {
38 class SeekableReadStream;
39 }
40 
41 namespace Grim {
42 
50 class BitmapData {
51 public:
52  BitmapData(const Common::String &fname);
53  BitmapData(const Graphics::Surface &buf, int w, int h, const char *fname);
54  BitmapData();
55  ~BitmapData();
56 
57  void freeData();
58 
59  void load();
60 
67  bool loadTile(Common::SeekableReadStream *data);
68  bool loadGrimBm(Common::SeekableReadStream *data);
69  bool loadTGA(Common::SeekableReadStream *data);
70 
71  static BitmapData *getBitmapData(const Common::String &fname);
73 
74  const Graphics::Surface &getImageData(int num) const;
75 
81  void convertToColorFormat(const Graphics::PixelFormat &format);
82 
88  void convertToColorFormat(int num, const Graphics::PixelFormat &format);
89 
90  Common::String _fname;
91  int _numImages;
92  int _width, _height, _x, _y;
93  int _format;
94  int _numTex;
95  int _bpp;
96  void *_texIds;
97  bool _hasTransparency;
98  bool _loaded;
99  bool _keepData;
100 
101  int _refCount;
102 
103  float *_texc;
104 
105  struct Vert {
106  uint32 _texid;
107  uint32 _pos;
108  uint32 _verts;
109  };
110  struct Layer {
111  uint32 _offset;
112  uint32 _numImages;
113  };
114  Vert *_verts;
115  Layer *_layers;
116  uint32 _numCoords;
117  uint32 _numVerts;
118  uint32 _numLayers;
119 
120 //private:
121  Graphics::Surface *_data;
122  void *_userData;
123 };
124 
125 class Bitmap : public PoolObject<Bitmap> {
126 public:
134  Bitmap(const Common::String &filename);
135  Bitmap(const Graphics::Surface &buf, int width, int height, const char *filename);
136  Bitmap();
137 
138  static int32 getStaticTag() { return MKTAG('V', 'B', 'U', 'F'); }
139 
140  static Bitmap *create(const Common::String &filename);
141 
142  const Common::String &getFilename() const { return _data->_fname; }
143 
144  void draw();
145  void draw(int x, int y);
146 
147  void drawLayer(uint32 layer);
148 
154  void setActiveImage(int n);
155 
156  int getNumImages() const;
157  int getNumLayers() const;
158  int getActiveImage() const { return _currImage; }
159  bool getHasTransparency() const { return _data->_hasTransparency; }
160  int getFormat() const { return _data->_format; }
161  int getWidth() const { return _data->_width; }
162  int getHeight() const { return _data->_height; }
163 
164  const Graphics::Surface &getData(int num) const { return _data->getImageData(num); }
165  const Graphics::Surface &getData() const { return getData(_currImage); }
166  BitmapData *getBitmapData() const { return _data; }
167  void *getTexIds() const { return _data->_texIds; }
168  int getNumTex() const { return _data->_numTex; }
169  const Graphics::PixelFormat &getPixelFormat(int num) const;
170 
171  void saveState(SaveGame *state) const;
172  void restoreState(SaveGame *state);
173 
174  virtual ~Bitmap();
175 
176 //private:
177  void freeData();
178 
179  BitmapData *_data;
185 };
186 
187 } // end of namespace Grim
188 
189 #endif
Definition: str.h:59
Definition: surface.h:67
Definition: pixelformat.h:138
Definition: bitmap.h:105
Definition: savegame.h:33
Definition: stream.h:745
Definition: actor.h:33
Definition: bitmap.h:125
Definition: hashmap.h:85
Definition: bitmap.h:50
Definition: algorithm.h:29
Definition: formatinfo.h:28
int _currImage
Definition: bitmap.h:184
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: pool.h:42
Definition: bitmap.h:110