6 #ifndef MATERIALX_IMAGE_H
7 #define MATERIALX_IMAGE_H
29 using ImageMap = std::unordered_map<string, ImagePtr>;
60 return ImagePtr(
new Image(width, height, channelCount, baseType));
93 unsigned int getBaseStride()
const;
98 return _width * _channelCount * getBaseStride();
102 unsigned int getMaxMipCount()
const;
110 void setTexelColor(
unsigned int x,
unsigned int y,
const Color4&
color);
114 Color4 getTexelColor(
unsigned int x,
unsigned int y)
const;
125 bool isUniformColor(
Color4* uniformColor =
nullptr);
135 void applyMatrixTransform(
const Matrix33& mat);
138 void applyGammaTransform(
float gamma);
141 ImagePtr copy(
unsigned int channelCount, BaseType baseType)
const;
151 ImagePair splitByLuminance(
float luminance);
155 void writeTable(
const FilePath& filePath,
unsigned int channel);
170 return _resourceBuffer;
174 void createResourceBuffer();
177 void releaseResourceBuffer();
182 _resourceBufferDeallocator = deallocator;
188 return _resourceBufferDeallocator;
210 Image(
unsigned int width,
unsigned int height,
unsigned int channelCount, BaseType baseType);
220 unsigned int _resourceId = 0;
unsigned int getWidth() const
Return the width of the image.
BaseType getBaseType() const
Return the base type of the image.
std::unordered_map< string, ImagePtr > ImageMap
A map from strings to images.
void setResourceBuffer(void *buffer)
Set the resource buffer for this image.
#define MATERIALX_NAMESPACE_BEGIN
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
unsigned int getRowStride() const
Return the stride of an image row in bytes.
ImageBufferDeallocator getResourceBufferDeallocator() const
Return the resource buffer deallocator for this image.
unsigned int _channelCount
std::vector< ImagePtr > ImageVec
A vetor of images.
unsigned int getChannelCount() const
Return the channel count of the image.
GLint GLsizei GLsizei height
std::function< void(void *)> ImageBufferDeallocator
A function to perform image buffer deallocation.
static ImagePtr create(unsigned int width, unsigned int height, unsigned int channelCount, BaseType baseType=BaseType::UINT8)
Create an empty image with the given properties.
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.
MX_RENDER_API ImagePtr createImageStrip(const vector< ImagePtr > &imageVec)
Create a horizontal image strip from a vector of images with identical resolutions and formats...
MX_RENDER_API UnsignedIntPair getMaxDimensions(const vector< ImagePtr > &imageVec)
Compute the maximum width and height of all images in the given vector.
std::pair< unsigned int, unsigned int > UnsignedIntPair
A pair of unsigned integers.
void setResourceBufferDeallocator(ImageBufferDeallocator deallocator)
Set the resource buffer deallocator for this image.
ImageBufferDeallocator _resourceBufferDeallocator
#define MATERIALX_NAMESPACE_END
shared_ptr< Image > ImagePtr
A shared pointer to an image.
unsigned int getHeight() const
Return the height of the image.
void * getResourceBuffer() const
Return the resource buffer for this image.
unsigned int getResourceId() const
Return the resource ID for this image.
void setResourceId(unsigned int id)
Set the resource ID for this image.
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
std::pair< ImagePtr, ImagePtr > ImagePair
A pair of images.