6#ifndef MATERIALX_IMAGEHANDLER_H
7#define MATERIALX_IMAGEHANDLER_H
19MATERIALX_NAMESPACE_BEGIN
21extern MX_RENDER_API
const string IMAGE_PROPERTY_SEPARATOR;
22extern MX_RENDER_API
const string UADDRESS_MODE_SUFFIX;
23extern MX_RENDER_API
const string VADDRESS_MODE_SUFFIX;
24extern MX_RENDER_API
const string FILTER_TYPE_SUFFIX;
25extern MX_RENDER_API
const string DEFAULT_COLOR_SUFFIX;
38using ImageLoaderMap = std::unordered_map<string, std::vector<ImageLoaderPtr>>;
84 bool enableMipmaps =
true;
88 Color4 defaultColor = { 0.0f, 0.0f, 0.0f, 1.0f };
117 static const string EXR_EXTENSION;
118 static const string GIF_EXTENSION;
119 static const string HDR_EXTENSION;
120 static const string JPG_EXTENSION;
121 static const string JPEG_EXTENSION;
122 static const string PIC_EXTENSION;
123 static const string PNG_EXTENSION;
124 static const string PSD_EXTENSION;
125 static const string TGA_EXTENSION;
126 static const string TIF_EXTENSION;
127 static const string TIFF_EXTENSION;
128 static const string TXT_EXTENSION;
129 static const string TX_EXTENSION;
130 static const string TXR_EXTENSION;
146 bool verticalFlip =
false);
223 _resolver = resolver;
243 releaseRenderResources();
265 void cacheImage(
const string& filePath,
ImagePtr image);
279MATERIALX_NAMESPACE_END
The top-level Document class.
shared_ptr< const Document > ConstDocumentPtr
A shared pointer to a const Document.
Definition: Document.h:24
shared_ptr< StringResolver > StringResolverPtr
A shared pointer to a StringResolver.
Definition: Element.h:66
Cross-platform support for file and search paths.
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
Definition: Image.h:26
std::vector< ImagePtr > ImageVec
A vetor of images.
Definition: Image.h:32
std::unordered_map< string, ImagePtr > ImageMap
A map from strings to images.
Definition: Image.h:29
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
std::shared_ptr< ImageLoader > ImageLoaderPtr
Shared pointer to an ImageLoader.
Definition: ImageHandler.h:35
std::shared_ptr< ImageHandler > ImageHandlerPtr
Shared pointer to an ImageHandler.
Definition: ImageHandler.h:32
std::unordered_map< string, std::vector< ImageLoaderPtr > > ImageLoaderMap
Map from strings to vectors of image loaders.
Definition: ImageHandler.h:38
std::set< string > StringSet
A set of strings.
Definition: Library.h:59
Macros for declaring imported and exported symbols.
A four-component color value.
Definition: Types.h:364
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:27
A sequence of file paths, which may be queried to find the first instance of a given filename on the ...
Definition: File.h:219
Base image handler class.
Definition: ImageHandler.h:164
ImagePtr acquireImage(const FilePath &filePath, const Color4 &defaultColor=Color4(0.0f))
Acquire an image from the cache or file system.
virtual bool createRenderResources(ImagePtr image, bool generateMipMaps, bool useAsRenderTarget=false)
Create rendering resources for the given image.
virtual bool unbindImage(ImagePtr image)
Unbind an image, making it no longer active for rendering.
void clearImageCache()
Clear the contents of the image cache, first releasing any render resources associated with cached im...
Definition: ImageHandler.h:241
ImageVec getReferencedImages(ConstDocumentPtr doc)
Acquire all images referenced by the given document, and return the images in a vector.
const FileSearchPath & getSearchPath() const
Return the image search path.
Definition: ImageHandler.h:215
StringResolverPtr getFilenameResolver() const
Return the filename resolver for images.
Definition: ImageHandler.h:227
virtual bool bindImage(ImagePtr image, const ImageSamplingProperties &samplingProperties)
Bind an image for rendering.
void setSearchPath(const FileSearchPath &path)
Set the search path to be used for finding images on the file system.
Definition: ImageHandler.h:209
void addLoader(ImageLoaderPtr loader)
Add another image loader to the handler, which will be invoked if existing loaders cannot load a give...
void unbindImages()
Unbind all images that are currently stored in the cache.
virtual void releaseRenderResources(ImagePtr image=nullptr)
Release rendering resources for the given image, or for all cached images if no image pointer is spec...
ImagePtr getZeroImage() const
Return a fallback image with zeroes in all channels.
Definition: ImageHandler.h:248
StringSet supportedExtensions()
Get a list of extensions supported by the handler.
void setFilenameResolver(StringResolverPtr resolver)
Set the filename resolver for images.
Definition: ImageHandler.h:221
bool saveImage(const FilePath &filePath, ConstImagePtr image, bool verticalFlip=false)
Save image to disk.
Abstract base class for file-system image loaders.
Definition: ImageHandler.h:108
const StringSet & supportedExtensions() const
Returns a list of supported extensions.
Definition: ImageHandler.h:134
virtual bool saveImage(const FilePath &filePath, ConstImagePtr image, bool verticalFlip=false)
Save an image to the file system.
virtual ImagePtr loadImage(const FilePath &filePath)
Load an image from the file system.
static const string BMP_EXTENSION
Standard image file extensions.
Definition: ImageHandler.h:116
Interface to describe sampling properties for images.
Definition: ImageHandler.h:43
FilterType
Filter type options.
Definition: ImageHandler.h:73
AddressMode
Address mode options.
Definition: ImageHandler.h:57
FilterType filterType
Filter type.
Definition: ImageHandler.h:81
void setProperties(const string &fileNameUniform, const VariableBlock &uniformBlock)
Set the properties based on data in a uniform block.
Color4 defaultColor
Default color.
Definition: ImageHandler.h:88
AddressMode uaddressMode
Address mode in U.
Definition: ImageHandler.h:66
bool enableMipmaps
Enable mipmaps.
Definition: ImageHandler.h:84
AddressMode vaddressMode
Address mode in V.
Definition: ImageHandler.h:68
A block of variables in a shader stage.
Definition: ShaderStage.h:61
Class used for hashing ImageSamplingProperties in an unordered_map.
Definition: ImageHandler.h:94