FIFE
|
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 | 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 |
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... | |
![]() | |
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 |
![]() | |
std::string | m_name |
IResourceLoader * | m_loader |
ResourceState | m_state |
Private Member Functions | |
std::string | createUniqueImageName () |
Additional Inherited Members | |
![]() | |
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::GLeImage, and FIFE::GLImage.
Definition at line 310 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::bindOutline(), FIFE::GLImage::copySubimage(), and FIFE::GLeImage::copySubimage().
|
private |
SDL_Surface * FIFE::Image::detachSurface | ( | ) |
|
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(), FIFE::RenderBackendOpenGLe::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), and FIFE::Camera::getMatchingInstances().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::GLeImage, FIFE::GLImage, and FIFE::SDLImage.
Definition at line 135 of file image.cpp.
References FIFE::IResource::m_state, FIFE::IResource::RES_NOT_LOADED, and reset().
const Rect & FIFE::Image::getArea | ( | ) | const |
Definition at line 171 of file image.cpp.
References getHeight(), and getWidth().
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::RenderBackendSDL::attachRenderTarget(), and FIFE::RenderBackendOpenGLe::attachRenderTarget().
uint32_t FIFE::Image::getHeight | ( | ) | const |
Definition at line 155 of file image.cpp.
References FIFE::RectType< T >::h, m_shared, m_subimagerect, and m_surface.
Referenced by FIFE::CellRenderer::addConcealImageToMap(), FIFE::CellRenderer::addMaskImageToMap(), gcn::ClickLabel::adjustSize(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::RenderBackendOpenGLe::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::GLImage::copySubimage(), FIFE::GLeImage::copySubimage(), copySubimage(), FIFE::RenderBackendOpenGL::detachRenderTarget(), FIFE::RenderBackendOpenGLe::detachRenderTarget(), FIFE::Cursor::draw(), FIFE::GuiFont::drawMultiLineString(), FIFE::GLImage::generateGLSharedTexture(), FIFE::GLeImage::generateGLSharedTexture(), getArea(), FIFE::GuiImage::getHeight(), FIFE::Camera::getMatchingInstances(), 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 176 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(), and FIFE::Camera::getMatchingInstances().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::SDLImage.
|
inline |
Returns area of the image it occupies in the shared image.
Definition at line 147 of file image.h.
References m_subimagerect.
Referenced by copySubimage().
|
inline |
Definition at line 91 of file image.h.
References m_surface.
Referenced by FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::RenderBackendOpenGLe::attachRenderTarget(), FIFE::RenderBackendSDL::attachRenderTarget(), FIFE::GLImage::copySubimage(), FIFE::GLeImage::copySubimage(), FIFE::SubImageFont::SubImageFont(), and FIFE::SDLImage::useSharedImage().
|
inline |
uint32_t FIFE::Image::getWidth | ( | ) | const |
Definition at line 146 of file image.cpp.
References m_shared, m_subimagerect, m_surface, and FIFE::RectType< T >::w.
Referenced by FIFE::CellRenderer::addConcealImageToMap(), FIFE::CellRenderer::addMaskImageToMap(), gcn::ClickLabel::adjustSize(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::RenderBackendOpenGLe::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), FIFE::GLImage::copySubimage(), FIFE::GLeImage::copySubimage(), copySubimage(), FIFE::RenderBackendOpenGL::detachRenderTarget(), FIFE::RenderBackendOpenGLe::detachRenderTarget(), FIFE::Cursor::draw(), FIFE::GuiFont::drawMultiLineString(), FIFE::GLImage::generateGLSharedTexture(), FIFE::GLeImage::generateGLSharedTexture(), getArea(), FIFE::Camera::getMatchingInstances(), FIFE::GuiImage::getWidth(), 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 117 of file image.h.
References m_xshift.
Referenced by FIFE::Cursor::draw(), FIFE::ImageLoader::load(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
|
inline |
Definition at line 123 of file image.h.
References m_yshift.
Referenced by FIFE::Cursor::draw(), FIFE::ImageLoader::load(), FIFE::LayerCache::updatePosition(), and FIFE::LayerCache::updateVisual().
|
pure virtual |
Invalidates the Image causing it to be reset or re-loaded.
Implemented in FIFE::GLImage, FIFE::GLeImage, and FIFE::SDLImage.
|
inline |
Returns true if this image shares data with another one.
Definition at line 143 of file image.h.
References m_shared.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), copySubimage(), FIFE::Camera::getMatchingInstances(), getPixelRGBA(), and FIFE::ImageLoader::load().
|
virtual |
Implements FIFE::IResource.
Reimplemented in FIFE::GLeImage, 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(), FIFE::SDLImage::load(), FIFE::GLImage::load(), FIFE::GLeImage::load(), FIFE::ImageManager::load(), and FIFE::SDLImage::useSharedImage().
|
static |
Definition at line 346 of file image.cpp.
Referenced by FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindOutline(), and FIFE::RenderBackendSDL::putPixel().
|
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, FIFE::GLeImage, and FIFE::SDLImage.
Referenced by FIFE::Cursor::draw(), FIFE::SdlGuiGraphics::drawImage(), FIFE::OpenGLGuiGraphics::drawImage(), FIFE::OpenGLeGuiGraphics::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::Camera::renderOverlay(), and FIFE::Camera::renderStaticLayer().
|
inlinevirtual |
Reimplemented in FIFE::GLeImage.
Definition at line 84 of file image.h.
Referenced by FIFE::InstanceRenderer::renderUnsorted().
|
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(), FIFE::GLeImage::setSurface(), and ~Image().
|
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().
void FIFE::Image::saveImage | ( | const std::string & | filename | ) |
Saves the image using given filename.
Definition at line 222 of file image.cpp.
References m_surface, and saveAsPng().
|
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, FIFE::GLeImage, and FIFE::SDLImage.
Referenced by FIFE::ImageLoader::load().
|
inline |
Definition at line 114 of file image.h.
References m_xshift.
Referenced by FIFE::ImageLoader::load(), FIFE::AnimationLoader::load(), FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
inline |
Definition at line 120 of file image.h.
References m_yshift.
Referenced by FIFE::ImageLoader::load(), FIFE::AnimationLoader::load(), FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::parseObject().
|
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.
Referenced by FIFE::ObjectLoader::load(), and FIFE::AtlasLoader::load().
|
protected |
Definition at line 170 of file image.h.
Referenced by FIFE::GLImage::cleanup(), FIFE::GLeImage::cleanup(), FIFE::GLImage::forceLoadInternal(), FIFE::GLeImage::forceLoadInternal(), FIFE::GLImage::generateGLTexture(), FIFE::GLeImage::generateGLTexture(), getHeight(), getSize(), getWidth(), isSharedImage(), FIFE::GLImage::load(), FIFE::GLeImage::load(), FIFE::GLImage::render(), FIFE::GLeImage::renderCheck(), reset(), FIFE::SDLImage::useSharedImage(), FIFE::GLImage::useSharedImage(), and FIFE::GLeImage::useSharedImage().
|
protected |
Definition at line 172 of file image.h.
Referenced by getHeight(), getPixelRGBA(), getSubImageRect(), getWidth(), FIFE::SDLImage::load(), FIFE::GLImage::load(), FIFE::GLeImage::load(), FIFE::SDLImage::useSharedImage(), FIFE::GLImage::useSharedImage(), FIFE::GLeImage::useSharedImage(), FIFE::GLImage::validateShared(), and FIFE::GLeImage::validateShared().
|
protected |
Definition at line 155 of file image.h.
Referenced by copySubimage(), detachSurface(), FIFE::SDLImage::finalize(), FIFE::GLImage::generateGLTexture(), FIFE::GLeImage::generateGLTexture(), getHeight(), getPixelRGBA(), FIFE::SDLImage::getSize(), getSize(), getSurface(), getWidth(), FIFE::GLeImage::GLeImage(), FIFE::GLImage::GLImage(), FIFE::GLImage::load(), FIFE::GLeImage::load(), FIFE::SDLImage::render(), FIFE::GLImage::render(), FIFE::GLeImage::renderCheck(), reset(), saveImage(), FIFE::GLImage::useSharedImage(), FIFE::GLeImage::useSharedImage(), FIFE::GLImage::validateShared(), and FIFE::GLeImage::validateShared().
|
protected |
Definition at line 157 of file image.h.
Referenced by getXShift(), reset(), and setXShift().
|
protected |
Definition at line 159 of file image.h.
Referenced by getYShift(), reset(), and setYShift().