MaterialX 1.38.9
Loading...
Searching...
No Matches
Image Class Reference

Class representing an image in system memory. More...

#include <Image.h>

Public Types

enum class  BaseType {
  UINT8 , INT8 , UINT16 , INT16 ,
  HALF , FLOAT
}
 

Public Member Functions

Property Accessors
unsigned int getWidth () const
 Return the width of the image.
 
unsigned int getHeight () const
 Return the height of the image.
 
unsigned int getChannelCount () const
 Return the channel count of the image.
 
BaseType getBaseType () const
 Return the base type of the image.
 
unsigned int getBaseStride () const
 Return the stride of our base type in bytes.
 
unsigned int getRowStride () const
 Return the stride of an image row in bytes.
 
unsigned int getMaxMipCount () const
 Return the maximum number of mipmaps for this image.
 
Texel Accessors
void setTexelColor (unsigned int x, unsigned int y, const Color4 &color)
 Set the texel color at the given coordinates. More...
 
Color4 getTexelColor (unsigned int x, unsigned int y) const
 Return the texel color at the given coordinates. More...
 
Image Analysis
Color4 getAverageColor ()
 Compute the average color of the image.
 
bool isUniformColor (Color4 *uniformColor=nullptr)
 Return true if all texels of this image are identical in color. More...
 
Image Processing
void setUniformColor (const Color4 &color)
 Set all texels of this image to a uniform color.
 
void applyMatrixTransform (const Matrix33 &mat)
 Apply the given matrix transform to all texels of this image.
 
void applyGammaTransform (float gamma)
 Apply the given gamma transform to all texels of this image.
 
ImagePtr copy (unsigned int channelCount, BaseType baseType) const
 Create a copy of this image with the given channel count and base type.
 
ImagePtr applyBoxBlur ()
 Apply a 3x3 box blur to this image, returning a new blurred image.
 
ImagePtr applyGaussianBlur ()
 Apply a 7x7 Gaussian blur to this image, returning a new blurred image.
 
ImagePair splitByLuminance (float luminance)
 Split this image by the given luminance threshold, returning the resulting underflow and overflow images.
 
void writeTable (const FilePath &filePath, unsigned int channel)
 Save a channel of this image to disk as a text table, in a format that can be used for curve and surface fitting.
 
Resource Buffers
void setResourceBuffer (void *buffer)
 Set the resource buffer for this image.
 
void * getResourceBuffer () const
 Return the resource buffer for this image.
 
void createResourceBuffer ()
 Allocate a resource buffer for this image that matches its properties.
 
void releaseResourceBuffer ()
 Release the resource buffer for this image.
 
void setResourceBufferDeallocator (ImageBufferDeallocator deallocator)
 Set the resource buffer deallocator for this image.
 
ImageBufferDeallocator getResourceBufferDeallocator () const
 Return the resource buffer deallocator for this image.
 
Resource IDs
void setResourceId (unsigned int id)
 Set the resource ID for this image.
 
unsigned int getResourceId () const
 Return the resource ID for this image.
 

Static Public Member Functions

static ImagePtr create (unsigned int width, unsigned int height, unsigned int channelCount, BaseType baseType=BaseType::UINT8)
 Create an empty image with the given properties.
 

Protected Member Functions

 Image (unsigned int width, unsigned int height, unsigned int channelCount, BaseType baseType)
 

Protected Attributes

unsigned int _width
 
unsigned int _height
 
unsigned int _channelCount
 
BaseType _baseType
 
void * _resourceBuffer
 
ImageBufferDeallocator _resourceBufferDeallocator
 
unsigned int _resourceId = 0
 

Detailed Description

Class representing an image in system memory.

Member Function Documentation

◆ getTexelColor()

Color4 getTexelColor ( unsigned int  x,
unsigned int  y 
) const

Return the texel color at the given coordinates.

If the coordinates or image resource buffer are invalid, then an exception is thrown.

◆ isUniformColor()

bool isUniformColor ( Color4 uniformColor = nullptr)

Return true if all texels of this image are identical in color.

Parameters
uniformColorReturn the uniform color of the image, if any.

◆ setTexelColor()

void setTexelColor ( unsigned int  x,
unsigned int  y,
const Color4 color 
)

Set the texel color at the given coordinates.

If the coordinates or image resource buffer are invalid, then an exception is thrown.


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