OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::SurfaceSet Class Reference

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...
 
SurfacegetFrame (int i)
 Gets a particular frame from the set. More...
 
SurfaceaddFrame (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenXcom::SurfaceSet::SurfaceSet ( int  width,
int  height 
)

Crates a surface set with frames of the specified size.

Sets up a new empty surface set for frames of the specified size.

Parameters
widthFrame width in pixels.
heightFrame height in pixels.
OpenXcom::SurfaceSet::SurfaceSet ( const SurfaceSet other)

Creates a surface set from an existing one.

Performs a deep copy of an existing surface set.

Parameters
otherSurface set to copy from.
OpenXcom::SurfaceSet::~SurfaceSet ( )

Cleans up the surface set.

Deletes the images from memory.

Member Function Documentation

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.

Parameters
iFrame number in the set.
Returns
Pointer to the respective surface.
Surface * OpenXcom::SurfaceSet::getFrame ( int  i)

Gets a particular frame from the set.

Returns a particular frame from the surface set.

Parameters
iFrame number in the set.
Returns
Pointer to the respective surface.
int OpenXcom::SurfaceSet::getHeight ( ) const

Gets the height of all frames.

Returns the full height of a frame in the set.

Returns
Height in pixels.
size_t OpenXcom::SurfaceSet::getTotalFrames ( ) const

Gets the total frames in the set.

Returns the total amount of frames currently stored in the set.

Returns
Number of frames.
int OpenXcom::SurfaceSet::getWidth ( ) const

Gets the width of all frames.

Returns the full width of a frame in the set.

Returns
Width in pixels.
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.

Parameters
filenameFilename of the DAT image.
See also
http://www.ufopaedia.org/index.php?title=Image_Formats#SCR_.26_DAT
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.

Parameters
pckFilename of the PCK image.
tabFilename of the TAB offsets.
See also
http://www.ufopaedia.org/index.php?title=Image_Formats#PCK
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.

Parameters
colorsPointer to the set of colors.
firstcolorOffset of the first color to replace.
ncolorsAmount of colors to replace.

The documentation for this class was generated from the following files: