FIFE
|
The SDL implementation of the Image
base class.
More...
#include <sdlimage.h>
Public Member Functions | |
SDLImage (IResourceLoader *loader=0) | |
SDLImage (const std::string &name, IResourceLoader *loader=0) | |
SDLImage (SDL_Surface *surface) | |
SDLImage (const std::string &name, SDL_Surface *surface) | |
SDLImage (const uint8_t *data, uint32_t width, uint32_t height) | |
SDLImage (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~SDLImage () |
virtual void | invalidate () |
Invalidates the Image causing it to be reset or re-loaded. More... | |
virtual void | setSurface (SDL_Surface *surface) |
This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL). More... | |
virtual void | render (const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0) |
Renders itself to the current render target (main screen or attached destination image) at the rectangle rect. More... | |
virtual size_t | getSize () |
virtual void | useSharedImage (const ImagePtr &shared, const Rect ®ion) |
After this call all image data will be taken from the given image and its subregion. More... | |
virtual void | forceLoadInternal () |
Forces to load the image into internal memory of GPU. More... | |
virtual void | load () |
virtual void | free () |
![]() | |
Image (IResourceLoader *loader=0) | |
Constructor. More... | |
Image (const std::string &name, IResourceLoader *loader=0) | |
Image (SDL_Surface *surface) | |
Constructor. More... | |
Image (const std::string &name, SDL_Surface *surface) | |
Image (const uint8_t *data, uint32_t width, uint32_t height) | |
Constructor. More... | |
Image (const std::string &name, const uint8_t *data, uint32_t width, uint32_t height) | |
virtual | ~Image () |
Destructor. More... | |
virtual void | renderZ (const Rect &rect, float vertexZ, uint8_t alpha=255, bool forceNewBatch=false, uint8_t const *rgb=0) |
SDL_Surface * | detachSurface () |
Removes underlying SDL_Surface from the image (if exists) and returns this. More... | |
SDL_Surface * | getSurface () |
const SDL_Surface * | getSurface () const |
void | saveImage (const std::string &filename) |
Saves the image using given filename. More... | |
uint32_t | getWidth () const |
uint32_t | getHeight () const |
const Rect & | getArea () const |
void | setXShift (int32_t xshift) |
int32_t | getXShift () const |
void | setYShift (int32_t yshift) |
int32_t | getYShift () const |
void | getPixelRGBA (int32_t x, int32_t y, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a) |
bool | isSharedImage () const |
Returns true if this image shares data with another one. More... | |
const Rect & | getSubImageRect () const |
Returns area of the image it occupies in the shared image. More... | |
virtual void | copySubimage (uint32_t xoffset, uint32_t yoffset, const ImagePtr &img) |
Copies given image into this one with respect to given offsets. More... | |
![]() | |
IResource (const std::string &name, IResourceLoader *loader=0) | |
virtual | ~IResource () |
virtual const std::string & | getName () |
ResourceHandle | getHandle () |
virtual ResourceState | getState () |
virtual void | setState (const ResourceState &state) |
Private Member Functions | |
void | finalize () |
SDL_Surface * | optimize (SDL_Surface *surface) |
SDL Alpha Optimizer This tries to convert an image with a fake alpha channel to an RGB image when the channel can be reasonably be replaced by an colorkey. More... | |
void | resetSdlimage () |
void | validateShared () |
Private Attributes | |
Uint8 | m_last_alpha |
bool | m_finalized |
SDL_Color | m_colorkey |
SDL_Surface * | m_zoom_surface |
float | m_scale_x |
float | m_scale_y |
ImagePtr | m_atlas_img |
std::string | m_atlas_name |
Additional Inherited Members | |
![]() | |
enum | ResourceState { RES_INVALID = 0, RES_NOT_LOADED, RES_LOADED } |
![]() | |
static void | saveAsPng (const std::string &filename, const SDL_Surface &surface) |
Saves the SDL_Surface to png format. More... | |
static bool | putPixel (SDL_Surface *surface, int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
![]() | |
void | reset (SDL_Surface *surface) |
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). More... | |
![]() | |
SDL_Surface * | m_surface |
int32_t | m_xshift |
int32_t | m_yshift |
bool | m_shared |
Rect | m_subimagerect |
![]() | |
std::string | m_name |
IResourceLoader * | m_loader |
ResourceState | m_state |
The SDL implementation of the Image
base class.
Definition at line 40 of file sdlimage.h.
FIFE::SDLImage::SDLImage | ( | IResourceLoader * | loader = 0 | ) |
Definition at line 47 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
IResourceLoader * | loader = 0 |
||
) |
Definition at line 52 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | SDL_Surface * | surface | ) |
Definition at line 57 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
SDL_Surface * | surface | ||
) |
Definition at line 62 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const uint8_t * | data, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 67 of file sdlimage.cpp.
References resetSdlimage().
FIFE::SDLImage::SDLImage | ( | const std::string & | name, |
const uint8_t * | data, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 72 of file sdlimage.cpp.
References resetSdlimage().
|
virtual |
Definition at line 86 of file sdlimage.cpp.
References m_zoom_surface.
|
private |
Definition at line 412 of file sdlimage.cpp.
References FIFE::DynamicSingleton< RenderBackend >::instance(), FIFE::RenderBackend::isAlphaOptimizerEnabled(), load(), m_colorkey, m_finalized, FIFE::IResource::m_state, FIFE::Image::m_surface, optimize(), and FIFE::IResource::RES_NOT_LOADED.
Referenced by render().
|
virtual |
Forces to load the image into internal memory of GPU.
Implements FIFE::Image.
Definition at line 694 of file sdlimage.cpp.
References validateShared().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 723 of file sdlimage.cpp.
References FIFE::IResource::m_state, FIFE::IResource::RES_NOT_LOADED, and setSurface().
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 660 of file sdlimage.cpp.
References FIFE::Image::m_surface, and m_zoom_surface.
|
inlinevirtual |
Invalidates the Image causing it to be reset or re-loaded.
Implements FIFE::Image.
Definition at line 50 of file sdlimage.h.
|
virtual |
Reimplemented from FIFE::Image.
Definition at line 709 of file sdlimage.cpp.
References FIFE::ImageManager::create(), FIFE::ImageManager::exists(), FIFE::DynamicSingleton< ImageManager >::instance(), FIFE::Image::load(), m_atlas_img, m_atlas_name, FIFE::Image::m_subimagerect, and useSharedImage().
Referenced by finalize(), and validateShared().
|
private |
SDL Alpha Optimizer This tries to convert an image with a fake alpha channel to an RGB image when the channel can be reasonably be replaced by an colorkey.
Definition at line 453 of file sdlimage.cpp.
References FIFE::_log, FL_DBG, FIFE::DynamicSingleton< RenderBackend >::instance(), and m_colorkey.
Referenced by finalize().
|
virtual |
Renders itself to the current render target (main screen or attached destination image) at the rectangle rect.
Convenience function
rect | The position and clipping where to draw this image to. |
alpha | The alpha value, with which to draw self. |
rgb | The color value of overlay if any. |
Implements FIFE::Image.
Definition at line 335 of file sdlimage.cpp.
References FIFE::RectType< T >::bottom(), finalize(), FIFE::RenderBackend::getRenderTargetSurface(), FIFE::getZoomedSurface(), FIFE::RectType< T >::h, FIFE::DynamicSingleton< RenderBackend >::instance(), m_last_alpha, m_scale_x, m_scale_y, FIFE::Image::m_surface, m_zoom_surface, FIFE::nearlyEqual(), FIFE::RectType< T >::right(), FIFE::SDL_BlitSurfaceWithAlpha(), validateShared(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
|
private |
Definition at line 77 of file sdlimage.cpp.
References FIFE::RenderBackend::getColorKey(), FIFE::DynamicSingleton< RenderBackend >::instance(), m_colorkey, m_finalized, m_last_alpha, m_scale_x, m_scale_y, and m_zoom_surface.
Referenced by SDLImage(), and setSurface().
|
virtual |
This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL).
surface | the SDL_Surface to use for this image |
Implements FIFE::Image.
Definition at line 92 of file sdlimage.cpp.
References m_zoom_surface, FIFE::Image::reset(), and resetSdlimage().
Referenced by free(), and useSharedImage().
After this call all image data will be taken from the given image and its subregion.
Implements FIFE::Image.
Definition at line 672 of file sdlimage.cpp.
References FIFE::IResource::getName(), FIFE::IResource::getState(), FIFE::Image::getSurface(), FIFE::RectType< T >::h, FIFE::Image::load(), m_atlas_img, m_atlas_name, FIFE::Image::m_shared, FIFE::Image::m_subimagerect, FIFE::IResource::RES_LOADED, FIFE::IResource::setState(), setSurface(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by load().
|
private |
Definition at line 698 of file sdlimage.cpp.
References FIFE::IResource::getState(), load(), m_atlas_img, m_atlas_name, and FIFE::IResource::RES_NOT_LOADED.
Referenced by forceLoadInternal(), and render().
|
private |
Definition at line 83 of file sdlimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 85 of file sdlimage.h.
Referenced by load(), useSharedImage(), and validateShared().
|
private |
Definition at line 77 of file sdlimage.h.
Referenced by finalize(), optimize(), and resetSdlimage().
|
private |
Definition at line 76 of file sdlimage.h.
Referenced by finalize(), and resetSdlimage().
|
private |
Definition at line 74 of file sdlimage.h.
Referenced by render(), and resetSdlimage().
|
private |
Definition at line 80 of file sdlimage.h.
Referenced by render(), and resetSdlimage().
|
private |
Definition at line 81 of file sdlimage.h.
Referenced by render(), and resetSdlimage().
|
private |
Definition at line 79 of file sdlimage.h.
Referenced by getSize(), render(), resetSdlimage(), setSurface(), and ~SDLImage().