2021-12-26 20:19:38 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
2021-12-26 20:19:38 +00:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
2008-06-13 14:57:47 +00:00
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-04-05 16:18:42 +00:00
|
|
|
*
|
2012-12-19 22:15:43 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2006-04-02 14:20:45 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-19 22:15:43 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-04-05 16:18:42 +00:00
|
|
|
*
|
2012-12-19 22:15:43 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
*/
|
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
|
|
|
|
2012-01-16 16:12:14 +00:00
|
|
|
#include "graphics/pixelformat.h"
|
|
|
|
|
2012-03-27 03:12:00 +00:00
|
|
|
#include "common/endian.h"
|
2012-04-04 23:11:05 +00:00
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
2012-03-27 03:12:00 +00:00
|
|
|
|
2011-09-07 21:08:59 +00:00
|
|
|
#include "engines/grim/pool.h"
|
2005-01-01 12:27:57 +00:00
|
|
|
|
2012-01-24 17:20:33 +00:00
|
|
|
namespace Graphics {
|
2021-11-27 19:14:44 +00:00
|
|
|
struct Surface;
|
2012-01-24 17:20:33 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 03:12:00 +00:00
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
|
|
|
}
|
|
|
|
|
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:
|
2012-02-02 17:34:53 +00:00
|
|
|
BitmapData(const Common::String &fname);
|
2021-11-27 19:14:44 +00:00
|
|
|
BitmapData(const Graphics::Surface &buf, int w, int h, const char *fname);
|
2011-05-09 17:20:47 +00:00
|
|
|
BitmapData();
|
|
|
|
~BitmapData();
|
2011-09-07 21:08:59 +00:00
|
|
|
|
2012-02-02 17:34:53 +00:00
|
|
|
void freeData();
|
|
|
|
|
|
|
|
void load();
|
|
|
|
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Loads an EMI TILE-bitmap.
|
|
|
|
*
|
2013-07-09 19:12:55 +00:00
|
|
|
* @param data the data for the TILE.
|
|
|
|
* @param len the length of the data.
|
2011-08-27 03:27:46 +00:00
|
|
|
*/
|
2012-02-02 17:34:53 +00:00
|
|
|
bool loadTile(Common::SeekableReadStream *data);
|
|
|
|
bool loadGrimBm(Common::SeekableReadStream *data);
|
|
|
|
bool loadTGA(Common::SeekableReadStream *data);
|
2011-05-09 17:20:47 +00:00
|
|
|
|
2012-02-02 17:34:53 +00:00
|
|
|
static BitmapData *getBitmapData(const Common::String &fname);
|
2011-05-09 17:20:47 +00:00
|
|
|
static Common::HashMap<Common::String, BitmapData *> *_bitmaps;
|
|
|
|
|
2021-11-27 19:14:44 +00:00
|
|
|
const Graphics::Surface &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.
|
|
|
|
*
|
2013-07-09 19:12:55 +00:00
|
|
|
* @param format the format to convert to.
|
2011-08-27 03:27:46 +00:00
|
|
|
*/
|
2012-01-24 17:20:33 +00:00
|
|
|
void convertToColorFormat(const Graphics::PixelFormat &format);
|
2012-01-16 16:12:14 +00:00
|
|
|
|
2012-01-24 18:02:50 +00:00
|
|
|
/**
|
|
|
|
* Convert a bitmap to another color-format.
|
|
|
|
*
|
2013-07-09 19:12:55 +00:00
|
|
|
* @param format the format to convert to.
|
2012-01-24 18:02:50 +00:00
|
|
|
*/
|
|
|
|
void convertToColorFormat(int num, const Graphics::PixelFormat &format);
|
|
|
|
|
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;
|
2012-02-02 17:34:53 +00:00
|
|
|
bool _loaded;
|
|
|
|
bool _keepData;
|
2011-05-09 17:20:47 +00:00
|
|
|
|
|
|
|
int _refCount;
|
2011-05-12 09:08:45 +00:00
|
|
|
|
2012-11-18 17:17:21 +00:00
|
|
|
float *_texc;
|
|
|
|
|
|
|
|
struct Vert {
|
|
|
|
uint32 _texid;
|
|
|
|
uint32 _pos;
|
|
|
|
uint32 _verts;
|
|
|
|
};
|
2012-11-26 00:57:07 +00:00
|
|
|
struct Layer {
|
2012-11-18 17:17:21 +00:00
|
|
|
uint32 _offset;
|
|
|
|
uint32 _numImages;
|
|
|
|
};
|
|
|
|
Vert *_verts;
|
2012-11-26 00:57:07 +00:00
|
|
|
Layer *_layers;
|
2012-11-18 17:17:21 +00:00
|
|
|
uint32 _numCoords;
|
|
|
|
uint32 _numVerts;
|
2012-11-26 00:57:07 +00:00
|
|
|
uint32 _numLayers;
|
2012-11-18 17:17:21 +00:00
|
|
|
|
2012-02-13 18:20:20 +00:00
|
|
|
// private:
|
2021-11-27 19:14:44 +00:00
|
|
|
Graphics::Surface *_data;
|
2013-07-14 13:37:38 +00:00
|
|
|
void *_userData;
|
2011-05-09 17:20:47 +00:00
|
|
|
};
|
|
|
|
|
2012-04-05 22:20:30 +00:00
|
|
|
class Bitmap : public PoolObject<Bitmap> {
|
2003-08-15 18:00:22 +00:00
|
|
|
public:
|
2011-08-27 03:27:46 +00:00
|
|
|
/**
|
|
|
|
* Construct a bitmap from the given data.
|
|
|
|
*
|
2013-07-09 19:12:55 +00:00
|
|
|
* @oaram filename the filename of the bitmap
|
|
|
|
* @param data the actual data to construct from
|
|
|
|
* @param len the length of the data
|
2011-08-27 03:27:46 +00:00
|
|
|
*/
|
2012-02-02 17:34:53 +00:00
|
|
|
Bitmap(const Common::String &filename);
|
2021-11-27 19:14:44 +00:00
|
|
|
Bitmap(const Graphics::Surface &buf, int width, int height, const char *filename);
|
2011-03-21 16:18:04 +00:00
|
|
|
Bitmap();
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2012-04-05 22:20:30 +00:00
|
|
|
static int32 getStaticTag() { return MKTAG('V', 'B', 'U', 'F'); }
|
|
|
|
|
2012-02-02 17:34:53 +00:00
|
|
|
static Bitmap *create(const Common::String &filename);
|
|
|
|
|
2011-05-22 04:02:20 +00:00
|
|
|
const Common::String &getFilename() const { return _data->_fname; }
|
2009-06-26 16:13:11 +00:00
|
|
|
|
2012-02-02 17:34:53 +00:00
|
|
|
void draw();
|
|
|
|
void draw(int x, int y);
|
2003-08-15 18:00:22 +00:00
|
|
|
|
EMI: Draw background layers at intervals
Previously, we split the background layers into everything
before SO 15 and after, and drew like that. However, this caused
the pink ship in shi.setb to not be drawn.
This patch draws the layers of the background at intervals of ten.
So if a set has six layers, layer 5 is the background and 4,3,2,1,0
are rendered at sortorder 40,30,20,10,0.
2013-06-29 12:36:17 +00:00
|
|
|
void drawLayer(uint32 layer);
|
2012-11-21 21:32:46 +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
|
|
|
*
|
2013-07-09 19:12:55 +00:00
|
|
|
* @param n the image to be selected
|
2011-08-27 03:27:46 +00:00
|
|
|
*/
|
2011-09-18 16:46:20 +00:00
|
|
|
void setActiveImage(int n);
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2012-02-12 16:06:23 +00:00
|
|
|
int getNumImages() const;
|
2015-05-16 08:32:36 +00:00
|
|
|
int getNumLayers() const;
|
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; }
|
2003-08-15 18:00:22 +00:00
|
|
|
|
2021-11-27 19:14:44 +00:00
|
|
|
const Graphics::Surface &getData(int num) const { return _data->getImageData(num); }
|
|
|
|
const Graphics::Surface &getData() const { return getData(_currImage); }
|
2016-07-17 09:21:21 +00:00
|
|
|
BitmapData *getBitmapData() const { return _data; }
|
2011-05-09 17:20:47 +00:00
|
|
|
void *getTexIds() const { return _data->_texIds; }
|
|
|
|
int getNumTex() const { return _data->_numTex; }
|
2012-01-24 18:02:50 +00:00
|
|
|
const Graphics::PixelFormat &getPixelFormat(int num) const;
|
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
|
|
|
|
2012-11-18 17:17:21 +00:00
|
|
|
//private:
|
2011-09-07 21:08:59 +00:00
|
|
|
void freeData();
|
|
|
|
|
2011-05-09 17:20:47 +00:00
|
|
|
BitmapData *_data;
|
2012-01-16 16:12:14 +00:00
|
|
|
/**
|
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;
|
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
|