OpenMaya.MImage Class Reference

Class Description

Manipulate color data.
+ Inheritance diagram for OpenMaya.MImage:

Public Member Functions

__init__ ()
 
create ()
 
depth ()
 
depthMap ()
 
filter ()
 
floatPixels ()
 
getDepthMapRange ()
 
getDepthMapSize ()
 
getSize ()
 
haveDepth ()
 
isRGBA ()
 
pixelType ()
 
pixels ()
 
readDepthMap ()
 
readFromFile ()
 
readFromTextureNode ()
 
release ()
 
resize ()
 
setDepthMap ()
 
setFloatPixels ()
 
setPixels ()
 
setRGBA ()
 
verticalFlip ()
 
writeToFile ()
 
writeToFileWithDepth ()
 

Static Public Member Functions

filterExists ()
 

Static Public Attributes

int kByte = 1
 
int kFloat = 2
 
int kHeightFieldBumpFormat = 1
 
int kNoFormat = 0
 
int kNormalMapBumpFormat = 2
 
int kUnknown = 0
 
int kUnknownFormat = 3
 

Constructor & Destructor Documentation

OpenMaya.MImage.__init__ ( )
x.__init__(...) initializes x; see help(type(x)) for signature

Member Function Documentation

OpenMaya.MImage.create ( )
create(width, height, channels=4, type=kByte) -> self

Create a new MImage object. Allocates memory for an RGBA array of pixels
of the given size. If an object was already in memory, it is released first.

* width (unsigned int) - the desired image's width in pixels.
* height (unsigned int) - the desired image's height in pixels.
* channels (unsigned int) - the desired number of channels per pixel.
* type (int) - the desired pixel format (kByte or kFloat, see MImage.pixelType() description for details.)
OpenMaya.MImage.depth ( )
depth() -> int

Get the color depth (in bytes) of the currently opened image.
OpenMaya.MImage.depthMap ( )
depthMap() -> long

Returns a long containing a C++ 'float' pointer which points to the depth data.
OpenMaya.MImage.filter ( )
filter(sourceFormat, targetFormat, scale=1.0, offset=1.0) -> self

Modify the content of the image by applying a filter.
The dimension of the image remains the same; only the RGBA components get affected.

* sourceFormat (MImageFilterFormat) - the format of the source image.
* targetFormat (MImageFilterFormat) - the format of the resulting image.* scale (float) - vary depending on the source/target format.
* offset (float) - vary depending on the source/target format.

The scale argument for this filter can vary from -256.0 to 256.0, although typical values range from 1.0 to 10.0.
The offset argument is currently ignored and should be left to the default value of 0.0.
OpenMaya.MImage.filterExists ( )
static
filterExists(sourceFormat, targetFormat) -> bool

Return whether or not a given source format can be directly converted to a given target format.

* sourceFormat (MImageFilterFormat) - the format of the source image.
* targetFormat (MImageFilterFormat) - the format of the resulting image.
OpenMaya.MImage.floatPixels ( )
floatPixels() -> long

Returns a long containing a C++ 'float' pointer which points to the pixel data.
This data is uncompressed and tightly packed, of size (width * height * depth * sizeof( float)) bytes.
OpenMaya.MImage.getDepthMapRange ( )
getDepthMapRange() -> [minValue, maxValue]

Compute the minimum and maximum depth values (range) for any stored depth buffer.
OpenMaya.MImage.getDepthMapSize ( )
getDepthMapSize() -> [width, height]

Returns the size of the depth map buffer.
OpenMaya.MImage.getSize ( )
getSize() -> [width, height]

Get the width and height of the currently opened image.
OpenMaya.MImage.haveDepth ( )
haveDepth() -> bool

Returns True if this instance of MImage contains a depth map.
OpenMaya.MImage.isRGBA ( )
isRGBA() -> bool

Query flag which indicates whether the pixel information is in RGBA sequence or BGRA sequence.
If no pixel data exists, then False will be returned.
OpenMaya.MImage.pixels ( )
pixels() -> long

Returns a long containing a C++ 'unsigned char' pointer which points to the pixel data.
This data is uncompressed and tightly packed, of size (width * height * depth) bytes.
For the moment, pixels are always stored in a RGBA (depth=4 bytes) pixel format.
OpenMaya.MImage.pixelType ( )
pixelType() -> int

Get the current pixel format of the image:  kUnknown    Format not known or invalid.
  kByte       One byte per channel, ranging from 0 to 255.
  kFloat      One float per channel, ranging from 0.0 to 1.0.
OpenMaya.MImage.readDepthMap ( )
readDepthMap(pathname) -> self

Reads the depth map from the specified file and place the result into the depth map array of this MImage instance.
OpenMaya.MImage.readFromFile ( )
readFromFile(pathname, type=kByte) -> self

Attempt to identify and open the specified image file.

* pathname (string) - the full path of the image file that should be opened.
* type (MPixelType) - the desired pixel format. kUnknown attempts to load the native pixel type.
OpenMaya.MImage.readFromTextureNode ( )
readFromTextureNode(fileTextureObject, type=kByte) -> self

Attempt to read the content of the given file texture node.


* fileTextureObject (MObject) - an object that refers to the file texture node that should be read.
* type (MPixelType) - the desired pixel format. kUnknown attempts to load the native pixel type.
OpenMaya.MImage.release ( )
release() -> self

Release the current image. If there is no current image, the call is ignored.
OpenMaya.MImage.resize ( )
resize(width, height, preserveAspectRatio=True) -> self

Resize the currently opened image to the specified dimension, or to the closest
width/height that is preserves the original aspect ratio.* width (unsigned int) - the desired image's width in pixels.
* height (unsigned int) - the desired image's height in pixels.
* preserveAspectRatio (bool) - specifies whether the aspect ratio should be preserved or not.
         If this flag is set, the given width and height are interpreted as the maximum dimensions allowable.
OpenMaya.MImage.setDepthMap ( )
setDepthMap(depth, width, heigth) -> self

Specifies the depth map resolution and data.

* depth (float*) - float buffer that contains depth values.
* width (unsigned int) - the width of the depth buffer.
* height (unsigned int) - the height of the depth buffer.

* depth (MFloatArray) - float array that contains depth values.
* width (unsigned int) - the width of the depth buffer.
* height (unsigned int) - the height of the depth buffer.
OpenMaya.MImage.setFloatPixels ( )
setFloatPixels(pixels, width, height, channels=4) -> self

Copy the uncompressed pixels array passed in into the MImage.
This array is tightly packed, of size (width * height * depth) bytes.
For the moment, pixels are always stored in a RGBA (depth=4 bytes) pixel format.

* pixels (float*) - the variable containing a block of pixels.
* width (unsigned int) - the variable that will be set to the image's width in pixels.
* height (unsigned int) - the variable that will be set to the image's height in pixels.
* channels (unsigned int) - the number of channels per pixel.
OpenMaya.MImage.setPixels ( )
setPixels(pixels, width, height) -> self

Copy the uncompressed pixels array passed in into the MImage.
This array is tightly packed, of size (width * height * depth) bytes.
For the moment, pixels are always stored in a RGBA (depth=4 bytes) pixel format.

* pixels (unsigned char*) - the variable containing a block of pixels.
* width (unsigned int) - the variable that will be set to the image's width in pixels.
* height (unsigned int) - the variable that will be set to the image's height in pixels.
OpenMaya.MImage.setRGBA ( )
setRGBA(bool) -> self

Sets a flag to indicate that pixel information is in RGBA sequence or BGRA sequence.
Pixel data must have been allocated before this call is made.
OpenMaya.MImage.verticalFlip ( )
verticalFlip() -> bool

Flips the image vertically.
OpenMaya.MImage.writeToFile ( )
writeToFile(pathname, outputFormat=iff) -> self

Save the content of this image in a file. By default, the file is saved in IFF format.
Optionally, the file can also be converted in a variety of image formats.
OpenMaya.MImage.writeToFileWithDepth ( )
writeToFileWithDepth(pathname, outputFormat=iff, writeDepth=False) -> self

Save the content of this image in a file. By default, the file is saved in IFF format.
Optionally, the file can also be converted in a variety of image formats.
If the writeDepth parameter is True then any depth information stored in MImage will be written to file.