OpenXcom
1.0
Open-source clone of the original X-Com
|
Container of a set of surfaces. More...
#include <SurfaceSet.h>
Public Member Functions | |
SurfaceSet (int width, int height) | |
Crates a surface set with frames of the specified size. More... | |
SurfaceSet (const SurfaceSet &other) | |
Creates a surface set from an existing one. More... | |
~SurfaceSet () | |
Cleans up the surface set. More... | |
void | loadPck (const std::string &pck, const std::string &tab="") |
Loads an X-Com set of PCK/TAB image files. More... | |
void | loadDat (const std::string &filename) |
Loads an X-Com DAT image file. More... | |
Surface * | getFrame (int i) |
Gets a particular frame from the set. More... | |
Surface * | addFrame (int i) |
Creates a new surface and returns a pointer to it. More... | |
int | getWidth () const |
Gets the width of all frames. More... | |
int | getHeight () const |
Gets the height of all frames. More... | |
size_t | getTotalFrames () const |
Gets the total frames in the set. More... | |
void | setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256) |
Sets the surface set's palette. More... | |
Container of a set of surfaces.
Used to manage single images that contain series of frames inside, like animated sprites, making them easier to access without constant cropping.
OpenXcom::SurfaceSet::SurfaceSet | ( | int | width, |
int | height | ||
) |
OpenXcom::SurfaceSet::SurfaceSet | ( | const SurfaceSet & | other | ) |
Creates a surface set from an existing one.
Performs a deep copy of an existing surface set.
other | Surface set to copy from. |
OpenXcom::SurfaceSet::~SurfaceSet | ( | ) |
Cleans up the surface set.
Deletes the images from memory.
Surface * OpenXcom::SurfaceSet::addFrame | ( | int | i | ) |
Creates a new surface and returns a pointer to it.
Creates and returns a particular frame in the surface set.
i | Frame number in the set. |
Surface * OpenXcom::SurfaceSet::getFrame | ( | int | i | ) |
Gets a particular frame from the set.
Returns a particular frame from the surface set.
i | Frame number in the set. |
int OpenXcom::SurfaceSet::getHeight | ( | ) | const |
Gets the height of all frames.
Returns the full height of a frame in the set.
size_t OpenXcom::SurfaceSet::getTotalFrames | ( | ) | const |
Gets the total frames in the set.
Returns the total amount of frames currently stored in the set.
int OpenXcom::SurfaceSet::getWidth | ( | ) | const |
Gets the width of all frames.
Returns the full width of a frame in the set.
void OpenXcom::SurfaceSet::loadDat | ( | const std::string & | filename | ) |
Loads an X-Com DAT image file.
Loads the contents of an X-Com DAT image file into the surface.
Unlike the PCK, a DAT file is an uncompressed image with no offsets so these have to be figured out manually, usually by splitting the image into equal portions.
filename | Filename of the DAT image. |
void OpenXcom::SurfaceSet::loadPck | ( | const std::string & | pck, |
const std::string & | tab = "" |
||
) |
Loads an X-Com set of PCK/TAB image files.
Loads the contents of an X-Com set of PCK/TAB image files into the surface.
The PCK file contains an RLE compressed image, while the TAB file contains the offsets to each frame in the image.
pck | Filename of the PCK image. |
tab | Filename of the TAB offsets. |
void OpenXcom::SurfaceSet::setPalette | ( | SDL_Color * | colors, |
int | firstcolor = 0 , |
||
int | ncolors = 256 |
||
) |
Sets the surface set's palette.
Replaces a certain amount of colors in all of the frames.
colors | Pointer to the set of colors. |
firstcolor | Offset of the first color to replace. |
ncolors | Amount of colors to replace. |