FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::Image Class Referenceabstract

#include <image.h>

Inheritance diagram for FIFE::Image:
Inheritance graph
Collaboration diagram for FIFE::Image:
Collaboration graph

Public Member Functions

 Image (IResourceLoader *loader=0)
 
 Image (SDL_Surface *surface)
 
 Image (const uint8_t *data, uint32_t width, uint32_t height)
 
virtual ~Image ()
 
virtual void invalidate ()=0
 
virtual void render (const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)=0
 
SDL_Surface * detachSurface ()
 
virtual void setSurface (SDL_Surface *surface)=0
 
void saveImage (const std::string &filename)
 
virtual void useSharedImage (const ImagePtr &shared, const Rect &region)=0
 
virtual void forceLoadInternal ()=0
 
bool isSharedImage () const
 
const RectgetSubImageRect () const
 
virtual void copySubimage (uint32_t xoffset, uint32_t yoffset, const ImagePtr &img)
 

Static Public Member Functions

static void saveAsPng (const std::string &filename, const SDL_Surface &surface)
 

Protected Member Functions

void reset (SDL_Surface *surface)
 

Detailed Description

Base Class for Images.

Definition at line 47 of file image.h.

Constructor & Destructor Documentation

FIFE::Image::Image ( IResourceLoader *  loader = 0)

Constructor.

Definition at line 41 of file image.cpp.

FIFE::Image::Image ( SDL_Surface *  surface)

Constructor.

Note
Takes ownership of the SDL Surface
Parameters
surfaceSDL Surface in RGBA format

Definition at line 57 of file image.cpp.

References reset().

FIFE::Image::Image ( const uint8_t *  data,
uint32_t  width,
uint32_t  height 
)

Constructor

Parameters
dataPointer to the imagedata (needs to be in RGBA, 8 bits per channel).
widthWidth of the image.
heightHeight of the image.

Definition at line 76 of file image.cpp.

References reset().

FIFE::Image::~Image ( )
virtual

Destructor.

Definition at line 120 of file image.cpp.

References reset().

Member Function Documentation

void FIFE::Image::copySubimage ( uint32_t  xoffset,
uint32_t  yoffset,
const ImagePtr img 
)
virtual

Copies given image into this one with respect to given offsets

Reimplemented in FIFE::GLeImage, and FIFE::GLImage.

Definition at line 310 of file image.cpp.

References getSubImageRect(), FIFE::RectType< T >::h, isSharedImage(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.

Referenced by FIFE::GLImage::copySubimage(), and FIFE::GLeImage::copySubimage().

Here is the caller graph for this function:

SDL_Surface * FIFE::Image::detachSurface ( )

Removes underlying SDL_Surface from the image (if exists) and returns this

Note
this effectively causes SDL_Surface not to be freed on destruction

Definition at line 140 of file image.cpp.

virtual void FIFE::Image::forceLoadInternal ( )
pure virtual

Forces to load the image into internal memory of GPU

Implemented in FIFE::GLeImage, FIFE::GLImage, and FIFE::SDLImage.

Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget(), and FIFE::RenderBackendOpenGLe::attachRenderTarget().

Here is the caller graph for this function:

const Rect& FIFE::Image::getSubImageRect ( ) const
inline

Returns area of the image it occupies in the shared image

Definition at line 147 of file image.h.

Referenced by copySubimage().

Here is the caller graph for this function:

virtual void FIFE::Image::invalidate ( )
pure virtual

Invalidates the Image causing it to be reset or re-loaded

Implemented in FIFE::GLImage, FIFE::GLeImage, and FIFE::SDLImage.

bool FIFE::Image::isSharedImage ( ) const
inline

Returns true if this image shares data with another one

Definition at line 143 of file image.h.

Referenced by copySubimage().

Here is the caller graph for this function:

virtual void FIFE::Image::render ( const Rect rect,
uint8_t  alpha = 255,
uint8_t const *  rgb = 0 
)
pure virtual

Renders itself to the current render target (main screen or attached destination image) at the rectangle rect. Convenience function

Parameters
rectThe position and clipping where to draw this image to.
alphaThe alpha value, with which to draw self.
rgbThe color value of overlay if any.

Implemented in FIFE::GLImage, FIFE::GLeImage, and FIFE::SDLImage.

Referenced by FIFE::Cursor::draw().

Here is the caller graph for this function:

void FIFE::Image::reset ( SDL_Surface *  surface)
protected

Resets the image to default values (including the x and y shift values), frees the current surface and sets the surface to the passed SDL_Surface (which can be NULL).

See also
IImage::setSurface(SDL_Surface* surface)
Parameters
surfacethe SDL_Surface to use for this image

Definition at line 110 of file image.cpp.

Referenced by Image(), FIFE::GLeImage::setSurface(), FIFE::GLImage::setSurface(), and ~Image().

Here is the caller graph for this function:

void FIFE::Image::saveAsPng ( const std::string &  filename,
const SDL_Surface &  surface 
)
static

Saves the SDL_Surface to png format

Definition at line 226 of file image.cpp.

Referenced by FIFE::RenderBackendOpenGL::captureScreen(), FIFE::RenderBackendSDL::captureScreen(), FIFE::RenderBackendOpenGLe::captureScreen(), and saveImage().

Here is the caller graph for this function:

void FIFE::Image::saveImage ( const std::string &  filename)

Saves the image using given filename.

Definition at line 222 of file image.cpp.

References saveAsPng().

virtual void FIFE::Image::setSurface ( SDL_Surface *  surface)
pure virtual

This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL).

See also
Image::reset(SDL_Surface* surface)
Parameters
surfacethe SDL_Surface to use for this image

Implemented in FIFE::GLImage, FIFE::GLeImage, and FIFE::SDLImage.

virtual void FIFE::Image::useSharedImage ( const ImagePtr shared,
const Rect region 
)
pure virtual

After this call all image data will be taken from the given image and its subregion

Implemented in FIFE::GLeImage, FIFE::GLImage, and FIFE::SDLImage.


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