ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

bitmap.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_BITMAP_H
00024 #define GRIM_BITMAP_H
00025 
00026 #include "graphics/pixelformat.h"
00027 
00028 #include "common/endian.h"
00029 #include "common/hashmap.h"
00030 #include "common/hash-str.h"
00031 
00032 #include "engines/grim/pool.h"
00033 
00034 namespace Graphics {
00035 class PixelBuffer;
00036 }
00037 
00038 namespace Common {
00039 class SeekableReadStream;
00040 }
00041 
00042 namespace Grim {
00043 
00051 class BitmapData {
00052 public:
00053     BitmapData(const Common::String &fname);
00054     BitmapData(const Graphics::PixelBuffer &buf, int w, int h, const char *fname);
00055     BitmapData();
00056     ~BitmapData();
00057 
00058     void freeData();
00059 
00060     void load();
00061 
00068     bool loadTile(Common::SeekableReadStream *data);
00069     bool loadGrimBm(Common::SeekableReadStream *data);
00070     bool loadTGA(Common::SeekableReadStream *data);
00071 
00072     static BitmapData *getBitmapData(const Common::String &fname);
00073     static Common::HashMap<Common::String, BitmapData *> *_bitmaps;
00074 
00075     const Graphics::PixelBuffer &getImageData(int num) const;
00076 
00082     void convertToColorFormat(const Graphics::PixelFormat &format);
00083 
00089     void convertToColorFormat(int num, const Graphics::PixelFormat &format);
00090 
00091     Common::String _fname;
00092     int _numImages;
00093     int _width, _height, _x, _y;
00094     int _format;
00095     int _numTex;
00096     int _bpp;
00097     int _colorFormat;
00098     void *_texIds;
00099     bool _hasTransparency;
00100     bool _loaded;
00101     bool _keepData;
00102 
00103     int _refCount;
00104 
00105     float *_texc;
00106 
00107     struct Vert {
00108         uint32 _texid;
00109         uint32 _pos;
00110         uint32 _verts;
00111     };
00112     struct Layer {
00113         uint32 _offset;
00114         uint32 _numImages;
00115     };
00116     Vert *_verts;
00117     Layer *_layers;
00118     uint32 _numCoords;
00119     uint32 _numVerts;
00120     uint32 _numLayers;
00121 
00122 // private:
00123     Graphics::PixelBuffer *_data;
00124     void *_userData;
00125 };
00126 
00127 class Bitmap : public PoolObject<Bitmap> {
00128 public:
00136     Bitmap(const Common::String &filename);
00137     Bitmap(const Graphics::PixelBuffer &buf, int width, int height, const char *filename);
00138     Bitmap();
00139 
00140     static int32 getStaticTag() { return MKTAG('V', 'B', 'U', 'F'); }
00141 
00142     static Bitmap *create(const Common::String &filename);
00143 
00144     const Common::String &getFilename() const { return _data->_fname; }
00145 
00146     void draw();
00147     void draw(int x, int y);
00148 
00149     void drawLayer(uint32 layer);
00150 
00156     void setActiveImage(int n);
00157 
00158     int getNumImages() const;
00159     int getNumLayers() const;
00160     int getActiveImage() const { return _currImage; }
00161     bool getHasTransparency() const { return _data->_hasTransparency; }
00162     int getFormat() const { return _data->_format; }
00163     int getWidth() const { return _data->_width; }
00164     int getHeight() const { return _data->_height; }
00165 
00166     const Graphics::PixelBuffer &getData(int num) const { return _data->getImageData(num); }
00167     const Graphics::PixelBuffer &getData() const { return getData(_currImage); }
00168     BitmapData *getBitmapData() const { return _data; }
00169     void *getTexIds() const { return _data->_texIds; }
00170     int getNumTex() const { return _data->_numTex; }
00171     const Graphics::PixelFormat &getPixelFormat(int num) const;
00172 
00173     void saveState(SaveGame *state) const;
00174     void restoreState(SaveGame *state);
00175 
00176     virtual ~Bitmap();
00177 
00178 //private:
00179     void freeData();
00180 
00181     BitmapData *_data;
00186     int _currImage;
00187 };
00188 
00189 } // end of namespace Grim
00190 
00191 #endif


Generated on Sat Feb 16 2019 05:00:46 for ResidualVM by doxygen 1.7.1
curved edge   curved edge