2009-05-26 14:13:08 +00:00
|
|
|
/* Residual - A 3D game interpreter
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
|
|
|
* Residual is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2009-05-26 09:39:42 +00:00
|
|
|
#ifndef GRIM_BITMAP_H
|
|
|
|
#define GRIM_BITMAP_H
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-09-07 21:08:59 +00:00
|
|
|
#include "engines/grim/pool.h"
|
2005-01-01 12:27:57 +00:00
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
namespace Grim {
|
|
|
|
|
2011-09-07 21:08:59 +00:00
|
|
|
/**
|
2011-08-27 03:27:46 +00:00
|
|
|
* This BitmapData class keeps the actual bitmap data and can be shared
|
|
|
|
* between Bitmap instances, by using getBitmapData.
|
|
|
|
* Bitmap still keeps the data that can change between the instances
|
|
|
|
* i.e. _x, _y and _currImage.
|
|
|
|
* They are automatically deleted if they are not used by any bitmap anymore.
|
|
|
|
*/
|
2011-05-09 17:20:47 +00:00
|
|
|
class BitmapData {
|
|
|
|
public:
|
2011-12-17 17:32:31 +00:00
|
|
|
BitmapData(const Common::String &fname, Common::SeekableReadStream *data);
|
2011-05-09 17:20:47 +00:00
|
|
|
BitmapData(const char *data, int w, int h, int bpp, const char *fname);
|
|
|
|
BitmapData();
|
|
|
|
~BitmapData();
|
2011-09-07 21:08:59 +00:00
|
|
|
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Loads an EMI TILE-bitmap.
|
|
|
|
*
|
|
|
|
* @param data the data for the TILE.
|
|
|
|
* @param len the length of the data.
|
|
|
|
*/
|
2011-12-17 17:32:31 +00:00
|
|
|
bool loadTile(const Common::String &fname, Common::SeekableReadStream *data);
|
|
|
|
bool loadGrimBm(const Common::String &fname, Common::SeekableReadStream *data);
|
2011-05-09 17:20:47 +00:00
|
|
|
|
2011-12-17 17:32:31 +00:00
|
|
|
static BitmapData *getBitmapData(const Common::String &fname, Common::SeekableReadStream *data);
|
2011-05-09 17:20:47 +00:00
|
|
|
static Common::HashMap<Common::String, BitmapData *> *_bitmaps;
|
|
|
|
|
2011-05-12 09:08:45 +00:00
|
|
|
char *getImageData(int num) const;
|
2011-09-07 21:08:59 +00:00
|
|
|
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Convert a bitmap to another color-format.
|
|
|
|
*
|
|
|
|
* @param num the bitmap to convert.
|
|
|
|
* @param format the format to convert to.
|
|
|
|
* @see colorFormat
|
|
|
|
*/
|
2011-05-15 22:14:46 +00:00
|
|
|
void convertToColorFormat(int num, int format);
|
2011-05-12 09:08:45 +00:00
|
|
|
|
2011-05-09 17:20:47 +00:00
|
|
|
Common::String _fname;
|
|
|
|
int _numImages;
|
|
|
|
int _width, _height, _x, _y;
|
|
|
|
int _format;
|
|
|
|
int _numTex;
|
|
|
|
int _bpp;
|
2011-05-15 22:14:46 +00:00
|
|
|
int _colorFormat;
|
2011-05-09 17:20:47 +00:00
|
|
|
void *_texIds;
|
|
|
|
bool _hasTransparency;
|
|
|
|
char _filename[32];
|
|
|
|
|
|
|
|
int _refCount;
|
2011-05-12 09:08:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
char **_data;
|
2011-05-09 17:20:47 +00:00
|
|
|
};
|
|
|
|
|
2011-09-07 21:08:59 +00:00
|
|
|
class Bitmap : public PoolObject<Bitmap, MKTAG('V', 'B', 'U', 'F')> {
|
2003-08-15 18:00:22 +00:00
|
|
|
public:
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Construct a bitmap from the given data.
|
|
|
|
*
|
|
|
|
* @oaram filename the filename of the bitmap
|
|
|
|
* @param data the actual data to construct from
|
|
|
|
* @param len the length of the data
|
|
|
|
*/
|
2011-12-17 17:32:31 +00:00
|
|
|
Bitmap(const Common::String &filename, Common::SeekableReadStream *data);
|
2011-04-30 19:50:18 +00:00
|
|
|
Bitmap(const char *data, int width, int height, int bpp, const char *filename);
|
2011-03-21 16:18:04 +00:00
|
|
|
Bitmap();
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-05-22 04:02:20 +00:00
|
|
|
const Common::String &getFilename() const { return _data->_fname; }
|
2009-06-26 16:13:11 +00:00
|
|
|
|
2004-02-24 08:20:45 +00:00
|
|
|
void draw() const;
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Set which image in an animated bitmap to use
|
2011-09-07 21:08:59 +00:00
|
|
|
*
|
2011-08-27 03:27:46 +00:00
|
|
|
* @param n the image to be selected
|
|
|
|
*/
|
2011-09-18 16:46:20 +00:00
|
|
|
void setActiveImage(int n);
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-05-09 17:20:47 +00:00
|
|
|
int getNumImages() const { return _data->_numImages; }
|
2011-09-18 16:46:20 +00:00
|
|
|
int getActiveImage() const { return _currImage; }
|
2011-05-09 17:20:47 +00:00
|
|
|
bool getHasTransparency() const { return _data->_hasTransparency; }
|
|
|
|
int getFormat() const { return _data->_format; }
|
|
|
|
int getWidth() const { return _data->_width; }
|
|
|
|
int getHeight() const { return _data->_height; }
|
2011-05-05 08:49:53 +00:00
|
|
|
int getX() const { return _x; }
|
|
|
|
int getY() const { return _y; }
|
2009-10-17 12:48:23 +00:00
|
|
|
void setX(int xPos) { _x = xPos; }
|
|
|
|
void setY(int yPos) { _y = yPos; }
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-05-12 09:08:45 +00:00
|
|
|
char *getData(int num) const { return _data->getImageData(num); }
|
|
|
|
char *getData() const { return getData(_currImage); }
|
2011-05-09 17:20:47 +00:00
|
|
|
void *getTexIds() const { return _data->_texIds; }
|
|
|
|
int getNumTex() const { return _data->_numTex; }
|
2003-08-30 17:58:33 +00:00
|
|
|
|
2011-09-07 21:08:59 +00:00
|
|
|
void saveState(SaveGame *state) const;
|
|
|
|
void restoreState(SaveGame *state);
|
|
|
|
|
2011-03-20 21:16:27 +00:00
|
|
|
virtual ~Bitmap();
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2011-05-09 17:20:47 +00:00
|
|
|
private:
|
2011-09-07 21:08:59 +00:00
|
|
|
void freeData();
|
|
|
|
|
2011-05-09 17:20:47 +00:00
|
|
|
BitmapData *_data;
|
2011-10-28 19:31:05 +00:00
|
|
|
/**
|
|
|
|
* Specifies a one-based index to the current image in BitmapData.
|
|
|
|
* _currImage==0 means a null image is chosen.
|
|
|
|
*/
|
2011-05-09 17:20:47 +00:00
|
|
|
int _currImage;
|
|
|
|
int _x, _y;
|
2003-08-15 18:00:22 +00:00
|
|
|
};
|
|
|
|
|
2009-05-25 06:49:57 +00:00
|
|
|
} // end of namespace Grim
|
|
|
|
|
2003-08-15 18:00:22 +00:00
|
|
|
#endif
|