FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
Base Class for Images. More...
#include <image.h>
Public Member Functions | |
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 | invalidate ()=0 |
Invalidates the Image causing it to be reset or re-loaded. More... | |
virtual void | render (const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)=0 |
Renders itself to the current render target (main screen or attached destination image) at the rectangle rect. More... | |
virtual void | render (const Rect &rect, const ImagePtr &overlay, uint8_t alpha=255, uint8_t const *rgb=0) |
virtual void | renderZ (const Rect &rect, float vertexZ, uint8_t alpha=255, uint8_t const *rgb=0) |
virtual void | renderZ (const Rect &rect, float vertexZ, const ImagePtr &overlay, uint8_t alpha=255, uint8_t const *rgb=0) |
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 |
virtual void | setSurface (SDL_Surface *surface)=0 |
This frees the current suface and replaces it with the surface passed in the parameter (which can be NULL). More... | |
void | saveImage (const std::string &filename) |
Saves the image using given filename. More... | |
uint32_t | getWidth () const |
uint32_t | getHeight () 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) |
virtual size_t | getSize () |
virtual void | load () |
virtual void | free () |
virtual void | useSharedImage (const ImagePtr &shared, const Rect ®ion)=0 |
After this call all image data will be taken from the given image and its subregion. More... | |
virtual void | forceLoadInternal ()=0 |
Forces to load the image into internal memory of GPU. More... | |
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... | |
Public Member Functions inherited from FIFE::IResource | |
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) |
Static Public Member Functions | |
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) |
Protected Member Functions | |
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... | |
Protected Attributes | |
SDL_Surface * | m_surface |
int32_t | m_xshift |
int32_t | m_yshift |
bool | m_shared |
Rect | m_subimagerect |
Protected Attributes inherited from FIFE::IResource | |
std::string | m_name |
IResourceLoader * | m_loader |
ResourceState | m_state |
Private Member Functions | |
std::string | createUniqueImageName () |
Additional Inherited Members | |
Public Types inherited from FIFE::IResource | |
enum | ResourceState { RES_INVALID = 0, RES_NOT_LOADED, RES_LOADED } |
FIFE::Image::Image | ( | IResourceLoader * | loader = 0 | ) |
FIFE::Image::Image | ( | const std::string & | name, |
IResourceLoader * | loader = 0 |
||
) |
FIFE::Image::Image | ( | SDL_Surface * | surface | ) |
FIFE::Image::Image | ( | const std::string & | name, |
SDL_Surface * | surface | ||
) |
FIFE::Image::Image | ( | const uint8_t * | data, |
uint32_t | width, | ||
uint32_t | height | ||
) |
Constructor.
data | Pointer to the imagedata (needs to be in RGBA, 8 bits per channel). |
width | Width of the image. |
height | Height of the image. |
Definition at line 76 of file image.cpp.
References FIFE::AMASK, FIFE::BMASK, FIFE::GMASK, reset(), and FIFE::RMASK.
FIFE::Image::Image | ( | const std::string & | name, |
const uint8_t * | data, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Definition at line 93 of file image.cpp.
References FIFE::AMASK, FIFE::BMASK, FIFE::GMASK, reset(), and FIFE::RMASK.
|
virtual |
|
virtual |
Copies given image into this one with respect to given offsets.
Reimplemented in FIFE::GLImage.
Definition at line 315 of file image.cpp.
References FIFE::AMASK, FIFE::BMASK, getHeight(), getSubImageRect(), getWidth(), FIFE::GMASK, FIFE::RectType< T >::h, isSharedImage(), m_surface, FIFE::RMASK, FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), FIFE::GLImage::copySubimage(), getSubImageRect(), and FIFE::Cursor::setNativeImageCursor().
|
private |
SDL_Surface * FIFE::Image::detachSurface | ( | ) |
Removes underlying SDL_Surface from the image (if exists) and returns this.
Definition at line 145 of file image.cpp.
References m_surface.
Referenced by FIFE::InstanceRenderer::getMultiColorOverlay(), and renderZ().
|
pure virtual |
Forces to load the image into internal memory of GPU.
Implemented in FIFE::GLImage, and FIFE::SDLImage.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::Camera::getMatchingInstances(), FIFE::InstanceRenderer::getMultiColorOverlay(), and getYShift().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::GLImage, and FIFE::SDLImage.
Definition at line 135 of file image.cpp.
References FIFE::IResource::m_state, m_xshift, m_yshift, FIFE::IResource::RES_NOT_LOADED, and reset().
Referenced by FIFE::LibRocketRenderInterface::freeTextures(), and getYShift().
Rect FIFE::Image::getArea | ( | ) | const |
Definition at line 176 of file image.cpp.
References getHeight(), and getWidth().
Referenced by FIFE::RenderBackendSDL::attachRenderTarget(), FIFE::RenderBackendOpenGL::attachRenderTarget(), getSurface(), and FIFE::SDLImage::render().
uint32_t FIFE::Image::getHeight | ( | ) | const |
Definition at line 160 of file image.cpp.
References FIFE::RectType< T >::h, m_shared, m_subimagerect, and m_surface.
Referenced by fcn::ClickLabel::adjustSize(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::GLImage::copySubimage(), copySubimage(), FIFE::RenderBackendOpenGL::detachRenderTarget(), FIFE::Cursor::draw(), fcn::ClickLabel::draw(), FIFE::GuiFont::drawMultiLineString(), FIFE::GLImage::generateGLSharedTexture(), getArea(), FIFE::GuiImage::getHeight(), FIFE::Camera::getMatchingInstances(), FIFE::InstanceRenderer::getMultiColorOverlay(), getSurface(), FIFE::FloatingTextRenderer::render(), FIFE::CoordinateRenderer::render(), FIFE::CellRenderer::render(), FIFE::LightRendererImageInfo::render(), FIFE::LightRendererAnimationInfo::render(), FIFE::OffRendererImageInfo::render(), FIFE::GenericRendererImageInfo::render(), FIFE::OffRendererAnimationInfo::render(), FIFE::GenericRendererAnimationInfo::render(), FIFE::OffRendererTextInfo::render(), FIFE::GenericRendererTextInfo::render(), FIFE::Camera::renderOverlay(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
void FIFE::Image::getPixelRGBA | ( | int32_t | x, |
int32_t | y, | ||
uint8_t * | r, | ||
uint8_t * | g, | ||
uint8_t * | b, | ||
uint8_t * | a | ||
) |
Definition at line 181 of file image.cpp.
References isSharedImage(), m_subimagerect, m_surface, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::Camera::getMatchingInstances(), FIFE::InstanceRenderer::getMultiColorOverlay(), and getYShift().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::SDLImage.
Definition at line 169 of file image.cpp.
References m_shared, and m_surface.
Referenced by getYShift().
|
inline |
Returns area of the image it occupies in the shared image.
Definition at line 152 of file image.h.
References copySubimage(), and m_subimagerect.
Referenced by copySubimage(), and FIFE::SDLImage::render().
|
inline |
Definition at line 96 of file image.h.
References m_surface.
Referenced by FIFE::RenderBackendSDL::attachRenderTarget(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::GLImage::copySubimage(), FIFE::Cursor::setNativeImageCursor(), FIFE::SubImageFont::SubImageFont(), and FIFE::SDLImage::useSharedImage().
|
inline |
Definition at line 97 of file image.h.
References getArea(), getHeight(), getWidth(), m_surface, putPixel(), saveAsPng(), saveImage(), and setSurface().
uint32_t FIFE::Image::getWidth | ( | ) | const |
Definition at line 151 of file image.cpp.
References m_shared, m_subimagerect, m_surface, and FIFE::RectType< T >::w.
Referenced by fcn::ClickLabel::adjustSize(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::GLImage::copySubimage(), copySubimage(), FIFE::RenderBackendOpenGL::detachRenderTarget(), FIFE::Cursor::draw(), fcn::ClickLabel::draw(), FIFE::GuiFont::drawMultiLineString(), FIFE::GLImage::generateGLSharedTexture(), getArea(), FIFE::Camera::getMatchingInstances(), FIFE::InstanceRenderer::getMultiColorOverlay(), getSurface(), FIFE::GuiImage::getWidth(), FIFE::LibRocketRenderInterface::LoadTexture(), FIFE::FloatingTextRenderer::render(), FIFE::CoordinateRenderer::render(), FIFE::CellRenderer::render(), FIFE::LightRendererImageInfo::render(), FIFE::LightRendererAnimationInfo::render(), FIFE::OffRendererImageInfo::render(), FIFE::GenericRendererImageInfo::render(), FIFE::OffRendererAnimationInfo::render(), FIFE::GenericRendererAnimationInfo::render(), FIFE::OffRendererTextInfo::render(), FIFE::GenericRendererTextInfo::render(), FIFE::Camera::renderOverlay(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
|
inline |
Definition at line 122 of file image.h.
References m_xshift.
Referenced by FIFE::Cursor::draw(), FIFE::ImageLoader::load(), FIFE::Cursor::setNativeImageCursor(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
|
inline |
Definition at line 128 of file image.h.
References forceLoadInternal(), free(), getPixelRGBA(), getSize(), load(), m_yshift, and useSharedImage().
Referenced by FIFE::Cursor::draw(), FIFE::ImageLoader::load(), FIFE::Cursor::setNativeImageCursor(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
|
pure virtual |
Invalidates the Image causing it to be reset or re-loaded.
Implemented in FIFE::GLImage, and FIFE::SDLImage.
|
inline |
Returns true if this image shares data with another one.
Definition at line 148 of file image.h.
References m_shared.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), copySubimage(), FIFE::Camera::getMatchingInstances(), FIFE::InstanceRenderer::getMultiColorOverlay(), getPixelRGBA(), FIFE::ImageLoader::load(), and FIFE::Cursor::setNativeImageCursor().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::GLImage, and FIFE::SDLImage.
Definition at line 124 of file image.cpp.
References FIFE::ImageLoader::load(), FIFE::IResourceLoader::load(), FIFE::IResource::m_loader, FIFE::IResource::m_state, and FIFE::IResource::RES_LOADED.
Referenced by FIFE::Animation::getFrame(), FIFE::Animation::getFrameByTimestamp(), getYShift(), FIFE::SDLImage::load(), FIFE::GLImage::load(), FIFE::ImageManager::load(), FIFE::Cursor::setNativeImageCursor(), and FIFE::SDLImage::useSharedImage().
|
static |
Definition at line 364 of file image.cpp.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), FIFE::InstanceRenderer::getMultiColorOverlay(), and getSurface().
|
pure 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. |
Implemented in FIFE::GLImage, and FIFE::SDLImage.
Referenced by FIFE::Cursor::draw(), FIFE::OpenGLGuiGraphics::drawImage(), FIFE::SdlGuiGraphics::drawImage(), FIFE::GuiFont::drawMultiLineString(), FIFE::GuiFont::drawString(), FIFE::FloatingTextRenderer::render(), FIFE::CoordinateRenderer::render(), FIFE::LightRendererImageInfo::render(), FIFE::CellRenderer::render(), FIFE::LightRendererAnimationInfo::render(), FIFE::OffRendererImageInfo::render(), FIFE::GenericRendererImageInfo::render(), FIFE::OffRendererAnimationInfo::render(), FIFE::GenericRendererAnimationInfo::render(), FIFE::LightRendererResizeInfo::render(), FIFE::OffRendererTextInfo::render(), FIFE::GenericRendererTextInfo::render(), FIFE::OffRendererResizeInfo::render(), FIFE::GenericRendererResizeInfo::render(), FIFE::InstanceRenderer::renderAlreadySorted(), FIFE::InstanceRenderer::renderOverlay(), and FIFE::Camera::renderOverlay().
|
inlinevirtual |
Reimplemented in FIFE::GLImage.
|
inlinevirtual |
Reimplemented in FIFE::GLImage.
Definition at line 86 of file image.h.
Referenced by FIFE::InstanceRenderer::renderOverlay(), and FIFE::InstanceRenderer::renderUnsorted().
|
inlinevirtual |
Reimplemented in FIFE::GLImage.
|
inlinevirtual |
Definition at line 89 of file image.h.
References detachSurface().
|
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).
surface | the SDL_Surface to use for this image |
Definition at line 110 of file image.cpp.
References m_shared, m_surface, m_xshift, and m_yshift.
Referenced by free(), Image(), FIFE::SDLImage::setSurface(), FIFE::GLImage::setSurface(), and ~Image().
|
static |
Saves the SDL_Surface to png format.
Definition at line 231 of file image.cpp.
Referenced by FIFE::RenderBackendSDL::captureScreen(), FIFE::RenderBackendOpenGL::captureScreen(), getSurface(), and saveImage().
void FIFE::Image::saveImage | ( | const std::string & | filename | ) |
Saves the image using given filename.
Definition at line 227 of file image.cpp.
References m_surface, and saveAsPng().
Referenced by getSurface().
|
pure 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 |
Implemented in FIFE::GLImage, and FIFE::SDLImage.
Referenced by FIFE::InstanceRenderer::getMultiColorOverlay(), getSurface(), and FIFE::ImageLoader::load().
|
inline |
Definition at line 119 of file image.h.
References m_xshift.
Referenced by FIFE::ImageLoader::load(), FIFE::ObjectLoader::load(), and FIFE::AnimationLoader::loadAnimation().
|
inline |
Definition at line 125 of file image.h.
References m_yshift.
Referenced by FIFE::ImageLoader::load(), FIFE::ObjectLoader::load(), and FIFE::AnimationLoader::loadAnimation().
|
pure virtual |
After this call all image data will be taken from the given image and its subregion.
Implemented in FIFE::GLImage, and FIFE::SDLImage.
Referenced by getYShift(), FIFE::GuiImageLoader::load(), FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::loadAtlas().
|
protected |
Definition at line 175 of file image.h.
Referenced by FIFE::GLImage::cleanup(), FIFE::GLImage::forceLoadInternal(), FIFE::GLImage::generateGLTexture(), getHeight(), FIFE::SDLImage::getSize(), getSize(), getWidth(), FIFE::SDLImage::invalidate(), isSharedImage(), FIFE::GLImage::load(), FIFE::SDLImage::render(), FIFE::GLImage::render(), FIFE::GLImage::renderZ(), reset(), FIFE::SDLImage::setTexture(), FIFE::SDLImage::useSharedImage(), and FIFE::GLImage::useSharedImage().
|
protected |
Definition at line 177 of file image.h.
Referenced by getHeight(), getPixelRGBA(), getSubImageRect(), getWidth(), FIFE::SDLImage::load(), FIFE::GLImage::load(), FIFE::SDLImage::useSharedImage(), FIFE::GLImage::useSharedImage(), and FIFE::GLImage::validateShared().
|
protected |
Definition at line 160 of file image.h.
Referenced by copySubimage(), detachSurface(), FIFE::GLImage::generateGLTexture(), getHeight(), getPixelRGBA(), FIFE::SDLImage::getSize(), getSize(), getSurface(), getWidth(), FIFE::GLImage::GLImage(), FIFE::GLImage::load(), FIFE::SDLImage::render(), FIFE::GLImage::render(), FIFE::GLImage::renderZ(), reset(), saveImage(), FIFE::GLImage::useSharedImage(), and FIFE::GLImage::validateShared().
|
protected |
Definition at line 162 of file image.h.
Referenced by FIFE::SDLImage::free(), FIFE::GLImage::free(), free(), getXShift(), reset(), and setXShift().
|
protected |
Definition at line 164 of file image.h.
Referenced by FIFE::SDLImage::free(), FIFE::GLImage::free(), free(), getYShift(), reset(), and setYShift().