6#ifndef MATERIALX_IMAGE_H
7#define MATERIALX_IMAGE_H
30using ImageMap = std::unordered_map<string, ImagePtr>;
56 static ImagePtr create(
unsigned int width,
unsigned int height,
unsigned int channelCount, BaseType baseType = BaseType::UINT8)
58 return ImagePtr(
new Image(width, height, channelCount, baseType));
91 unsigned int getBaseStride()
const;
96 return _width * _channelCount * getBaseStride();
100 unsigned int getMaxMipCount()
const;
108 void setTexelColor(
unsigned int x,
unsigned int y,
const Color4& color);
112 Color4 getTexelColor(
unsigned int x,
unsigned int y)
const;
123 bool isUniformColor(
Color4* uniformColor =
nullptr);
130 void setUniformColor(
const Color4& color);
140 ImagePair splitByLuminance(
float luminance);
144 void writeTable(
const FilePath& filePath,
unsigned int channel);
153 _resourceBuffer = buffer;
159 return _resourceBuffer;
163 void createResourceBuffer();
166 void releaseResourceBuffer();
171 _resourceBufferDeallocator = deallocator;
177 return _resourceBufferDeallocator;
199 Image(
unsigned int width,
unsigned int height,
unsigned int channelCount, BaseType baseType);
203 unsigned int _height;
204 unsigned int _channelCount;
207 void* _resourceBuffer;
209 unsigned int _resourceId;
213MX_RENDER_API ImagePtr createUniformImage(
unsigned int width,
unsigned int height,
unsigned int channelCount, Image::BaseType baseType,
const Color4& color);
216MX_RENDER_API ImagePtr createImageStrip(
const vector<ImagePtr>& imageVec);
219MX_RENDER_API std::pair<unsigned int, unsigned int> getMaxDimensions(
const vector<ImagePtr>& imageVec);
Cross-platform support for file and search paths.
shared_ptr< const Image > ConstImagePtr
A shared pointer to a const image.
Definition: Image.h:27
std::function< void(void *)> ImageBufferDeallocator
A function to perform image buffer deallocation.
Definition: Image.h:39
std::vector< ImagePtr > ImageVec
A vetor of images.
Definition: Image.h:33
std::unordered_map< string, ImagePtr > ImageMap
A map from strings to images.
Definition: Image.h:30
std::pair< ImagePtr, ImagePtr > ImagePair
A pair of images.
Definition: Image.h:36
shared_ptr< Image > ImagePtr
A shared pointer to an image.
Definition: Image.h:24
Macros for declaring imported and exported symbols.
A four-component color value.
Definition: Types.h:389
A generic file path, supporting both syntactic and file system operations.
Definition: File.h:28
Class representing an image in system memory.
Definition: Image.h:44
void setResourceBufferDeallocator(ImageBufferDeallocator deallocator)
Set the resource buffer deallocator for this image.
Definition: Image.h:169
BaseType getBaseType() const
Return the base type of the image.
Definition: Image.h:85
unsigned int getHeight() const
Return the height of the image.
Definition: Image.h:73
unsigned int getChannelCount() const
Return the channel count of the image.
Definition: Image.h:79
unsigned int getResourceId() const
Return the resource ID for this image.
Definition: Image.h:191
void setResourceBuffer(void *buffer)
Set the resource buffer for this image.
Definition: Image.h:151
void setResourceId(unsigned int id)
Set the resource ID for this image.
Definition: Image.h:185
unsigned int getWidth() const
Return the width of the image.
Definition: Image.h:67
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:56
void * getResourceBuffer() const
Return the resource buffer for this image.
Definition: Image.h:157
unsigned int getRowStride() const
Return the stride of an image row in bytes.
Definition: Image.h:94
ImageBufferDeallocator getResourceBufferDeallocator() const
Return the resource buffer deallocator for this image.
Definition: Image.h:175