All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageHandler Class Reference

#include <ImageHandler.h>

+ Inheritance diagram for ImageHandler:

Public Member Functions

virtual ~ImageHandler ()
void addLoader (ImageLoaderPtr loader)
StringSet supportedExtensions ()
 Get a list of extensions supported by the handler. More...
bool saveImage (const FilePath &filePath, ConstImagePtr image, bool verticalFlip=false)
ImagePtr acquireImage (const FilePath &filePath)
virtual bool bindImage (ImagePtr image, const ImageSamplingProperties &samplingProperties)
virtual bool unbindImage (ImagePtr image)
void unbindImages ()
 Unbind all images that are currently stored in the cache. More...
void setSearchPath (const FileSearchPath &path)
 Set the search path to be used for finding images on the file system. More...
const FileSearchPathgetSearchPath () const
 Return the image search path. More...
void setFilenameResolver (StringResolverPtr resolver)
 Set the filename resolver for images. More...
StringResolverPtr getFilenameResolver () const
 Return the filename resolver for images. More...
virtual bool createRenderResources (ImagePtr image, bool generateMipMaps)
 Create rendering resources for the given image. More...
virtual void releaseRenderResources (ImagePtr image=nullptr)
void clearImageCache ()
ImagePtr getZeroImage () const
 Return a fallback image with zeroes in all channels. More...
ImagePtr getInvalidImage () const
ImageVec getReferencedImages (DocumentPtr doc)

Static Public Member Functions

static ImageHandlerPtr create (ImageLoaderPtr imageLoader)

Protected Member Functions

 ImageHandler (ImageLoaderPtr imageLoader)
ImagePtr loadImage (const FilePath &filePath)
void cacheImage (const string &filePath, ImagePtr image)
ImagePtr getCachedImage (const FilePath &filePath)

Protected Attributes

ImageLoaderMap _imageLoaders
ImageMap _imageCache
FileSearchPath _searchPath
StringResolverPtr _resolver
ImagePtr _zeroImage
ImagePtr _invalidImage

Detailed Description

Base image handler class. Keeps track of images which are loaded from disk via supplied ImageLoader. Derived classes are responsible for determinining how to perform the logic for "binding" of these resources for a given target (such as a given shading language).

Definition at line 147 of file ImageHandler.h.

Constructor & Destructor Documentation

virtual ImageHandler::~ImageHandler ( )

Definition at line 154 of file ImageHandler.h.

ImageHandler::ImageHandler ( ImageLoaderPtr  imageLoader)

Member Function Documentation

ImagePtr ImageHandler::acquireImage ( const FilePath filePath)

Acquire an image from the cache or file system. If the image is not found in the cache, then each image loader will be applied in turn.

filePathFile path of the image.
On success, a shared pointer to the acquired image.
void ImageHandler::addLoader ( ImageLoaderPtr  loader)

Add another image loader to the handler, which will be invoked if existing loaders cannot load a given image.

virtual bool ImageHandler::bindImage ( ImagePtr  image,
const ImageSamplingProperties samplingProperties 

Bind an image for rendering.

imageThe image to bind.
samplingPropertiesSampling properties for the image.

Reimplemented in GLTextureHandler.

void ImageHandler::cacheImage ( const string filePath,
ImagePtr  image 
void ImageHandler::clearImageCache ( )

Clear the contents of the image cache, first releasing any render resources associated with cached images.

Definition at line 222 of file ImageHandler.h.

static ImageHandlerPtr ImageHandler::create ( ImageLoaderPtr  imageLoader)

Definition at line 150 of file ImageHandler.h.

virtual bool ImageHandler::createRenderResources ( ImagePtr  image,
bool  generateMipMaps 

Create rendering resources for the given image.

Reimplemented in GLTextureHandler.

ImagePtr ImageHandler::getCachedImage ( const FilePath filePath)
StringResolverPtr ImageHandler::getFilenameResolver ( ) const

Return the filename resolver for images.

Definition at line 208 of file ImageHandler.h.

ImagePtr ImageHandler::getInvalidImage ( ) const

Return the sentinel invalid image, representing images that cannot be loaded and should be replaced with their declared default value.

Definition at line 236 of file ImageHandler.h.

ImageVec ImageHandler::getReferencedImages ( DocumentPtr  doc)

Acquire all images referenced by the given document, and return the images in a vector.

const FileSearchPath& ImageHandler::getSearchPath ( ) const

Return the image search path.

Definition at line 196 of file ImageHandler.h.

ImagePtr ImageHandler::getZeroImage ( ) const

Return a fallback image with zeroes in all channels.

Definition at line 229 of file ImageHandler.h.

ImagePtr ImageHandler::loadImage ( const FilePath filePath)
virtual void ImageHandler::releaseRenderResources ( ImagePtr  image = nullptr)

Release rendering resources for the given image, or for all cached images if no image pointer is specified.

Reimplemented in GLTextureHandler.

bool ImageHandler::saveImage ( const FilePath filePath,
ConstImagePtr  image,
bool  verticalFlip = false 

Save image to disk. This method must be implemented by derived classes. The first image loader which supports the file name extension will be used.

filePathFile path to be written
imageThe image to be saved
verticalFlipWhether the image should be flipped in Y during save
if save succeeded
void ImageHandler::setFilenameResolver ( StringResolverPtr  resolver)

Set the filename resolver for images.

Definition at line 202 of file ImageHandler.h.

void ImageHandler::setSearchPath ( const FileSearchPath path)

Set the search path to be used for finding images on the file system.

Definition at line 190 of file ImageHandler.h.

StringSet ImageHandler::supportedExtensions ( )

Get a list of extensions supported by the handler.

virtual bool ImageHandler::unbindImage ( ImagePtr  image)

Unbind an image, making it no longer active for rendering.

imageThe image to unbind.

Reimplemented in GLTextureHandler.

void ImageHandler::unbindImages ( )

Unbind all images that are currently stored in the cache.

Member Data Documentation

ImageMap ImageHandler::_imageCache

Definition at line 261 of file ImageHandler.h.

ImageLoaderMap ImageHandler::_imageLoaders

Definition at line 260 of file ImageHandler.h.

ImagePtr ImageHandler::_invalidImage

Definition at line 265 of file ImageHandler.h.

StringResolverPtr ImageHandler::_resolver

Definition at line 263 of file ImageHandler.h.

FileSearchPath ImageHandler::_searchPath

Definition at line 262 of file ImageHandler.h.

ImagePtr ImageHandler::_zeroImage

Definition at line 264 of file ImageHandler.h.

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