6#ifndef MATERIALX_IMAGE_H
7#define MATERIALX_IMAGE_H
18MATERIALX_NAMESPACE_BEGIN
29using ImageMap = std::unordered_map<string, ImagePtr>;
60 static ImagePtr create(
unsigned int width,
unsigned int height,
unsigned int channelCount, BaseType baseType = BaseType::UINT8)
62 return ImagePtr(
new Image(width, height, channelCount, baseType));
95 unsigned int getBaseStride()
const;
100 return _width * _channelCount * getBaseStride();
104 unsigned int getMaxMipCount()
const;
112 void setTexelColor(
unsigned int x,
unsigned int y,
const Color4& color);
116 Color4 getTexelColor(
unsigned int x,
unsigned int y)
const;
127 bool isUniformColor(
Color4* uniformColor =
nullptr);
134 void setUniformColor(
const Color4& color);
137 void applyMatrixTransform(
const Matrix33& mat);
140 void applyGammaTransform(
float gamma);
143 ImagePtr copy(
unsigned int channelCount, BaseType baseType)
const;
153 ImagePair splitByLuminance(
float luminance);
157 void writeTable(
const FilePath& filePath,
unsigned int channel);
166 _resourceBuffer = buffer;
172 return _resourceBuffer;
176 void createResourceBuffer();
179 void releaseResourceBuffer();
184 _resourceBufferDeallocator = deallocator;
190 return _resourceBufferDeallocator;
212 Image(
unsigned int width,
unsigned int height,
unsigned int channelCount, BaseType baseType);
216 unsigned int _height;
217 unsigned int _channelCount;
220 void* _resourceBuffer;
222 unsigned int _resourceId = 0;
226MX_RENDER_API
ImagePtr createUniformImage(
unsigned int width,
unsigned int height,
unsigned int channelCount, Image::BaseType baseType,
const Color4& color);
234MATERIALX_NAMESPACE_END
Cross-platform support for file and search paths.
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
Definition: Image.h:26
MX_RENDER_API ImagePtr createUniformImage(unsigned int width, unsigned int height, unsigned int channelCount, Image::BaseType baseType, const Color4 &color)
Create a uniform-color image with the given properties.
Definition: Image.cpp:22
MX_RENDER_API UnsignedIntPair getMaxDimensions(const vector< ImagePtr > &imageVec)
Compute the maximum width and height of all images in the given vector.
Definition: Image.cpp:77
std::pair< unsigned int, unsigned int > UnsignedIntPair
A pair of unsigned integers.
Definition: Image.h:41
std::function< void(void *)> ImageBufferDeallocator
A function to perform image buffer deallocation.
Definition: Image.h:38
std::vector< ImagePtr > ImageVec
A vetor of images.
Definition: Image.h:32
MX_RENDER_API ImagePtr createImageStrip(const vector< ImagePtr > &imageVec)
Create a horizontal image strip from a vector of images with identical resolutions and formats.
Definition: Image.cpp:30
std::unordered_map< string, ImagePtr > ImageMap
A map from strings to images.
Definition: Image.h:29
std::pair< ImagePtr, ImagePtr > ImagePair
A pair of images.
Definition: Image.h:35
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:23
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
Class representing an image in system memory.
Definition: Image.h:46
void setResourceBufferDeallocator(ImageBufferDeallocator deallocator)
Set the resource buffer deallocator for this image.
Definition: Image.h:182
BaseType getBaseType() const
Return the base type of the image.
Definition: Image.h:89
unsigned int getHeight() const
Return the height of the image.
Definition: Image.h:77
unsigned int getChannelCount() const
Return the channel count of the image.
Definition: Image.h:83
unsigned int getResourceId() const
Return the resource ID for this image.
Definition: Image.h:204
void setResourceBuffer(void *buffer)
Set the resource buffer for this image.
Definition: Image.h:164
void setResourceId(unsigned int id)
Set the resource ID for this image.
Definition: Image.h:198
unsigned int getWidth() const
Return the width of the image.
Definition: Image.h:71
static ImagePtr create(unsigned int width, unsigned int height, unsigned int channelCount, BaseType baseType=BaseType::UINT8)
Create an empty image with the given properties.
Definition: Image.h:60
void * getResourceBuffer() const
Return the resource buffer for this image.
Definition: Image.h:170
unsigned int getRowStride() const
Return the stride of an image row in bytes.
Definition: Image.h:98
ImageBufferDeallocator getResourceBufferDeallocator() const
Return the resource buffer deallocator for this image.
Definition: Image.h:188
A 3x3 matrix of floating-point values.
Definition: Types.h:586