- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# MPxImageFile Class Reference
OpenMaya - API module for common classes | Proxy classes

Search for all occurrences

## Detailed Description

Image manipulation.

This class provides methods for reading file images stored on disk.

The MPxImageFile class can be used to implement support for new image file formats in Maya. The implementation is able to support both fixed and floating point image formats.

MPxImageFile allows custom image formats to be recognized by Maya and any plug-ins that use Maya's API for accessing images. However be aware that some third party plugins, such as mental ray, bypass Maya's API and use their own internal facilities for accessing images, which means that they will not recognize MPxImageFile-based image formats. In the case of mental ray, it provides its own API which can be used to provide it with support for the image format.

Examples:

  ddsFloatReader.cpp, OpenEXR.cpp, simpleImageFile.cpp, and tiffFloatReader.cpp.

`#include <MPxImageFile.h>`

List of all members.

## Public Member Functions
| MPxImageFile ()
| The default class constructor.
virtual | ~MPxImageFile ()
| Class destructor.
virtual MStatus | open (MString pathname, MImageFileInfo *info)
| Attempt to open the specified file as an image and extract the image characteristics.
virtual MStatus | load (MImage &image, unsigned int imageNumber)
| Load the previously opened image file into an MImage.
virtual MStatus | glLoad (const MImageFileInfo &info, unsigned int imageNumber)
| Load the previously opened image file as an OpenGL texture.
virtual MStatus | close ()
| Close the image file.

## Constructor & Destructor Documentation

MPxImageFile | ( |  | ) |

The default class constructor.

Initialize the image.

~MPxImageFile | ( |  | ) | `[virtual]`

Class destructor.

Automatically releases the associated image array.

## Member Function Documentation

MStatus open | ( | MString | pathname,
|  | MImageFileInfo * | info
| ) |  | `[virtual]`

Search for all occurrences

Attempt to open the specified file as an image and extract the image characteristics.

It is important that this function only return success if the image is definitely supported by this implementation.

Parameters:

  [in] | pathname | the image file to open
  [in] | info | an optional pointer to the image info structure to fill in. If this pointer is non-NULL, the implementation of this method should parse the image header to populate the information structure.

Returns:
  - MS::kSuccess if the image is supported by this implementation
  - MS::kFailure otherwise

Examples:
  ddsFloatReader.cpp, OpenEXR.cpp, simpleImageFile.cpp, and tiffFloatReader.cpp.

MStatus load | ( | MImage & | image,
|  | unsigned int | imageNumber
| ) |  | `[virtual]`

Search for all occurrences

Load the previously opened image file into an MImage.

Parameters:

  [in] | image | the image to load the currently open file into
  [in] | imageNumber | the index of image to load (for files containing multiple images)

Returns:
  - MS::kFailure if the image cannot be loaded (e.g. it is corrupt)
  - MS::kSuccess otherwise

Examples:
  ddsFloatReader.cpp, OpenEXR.cpp, simpleImageFile.cpp, and tiffFloatReader.cpp.

MStatus glLoad | ( | const MImageFileInfo & | info,
|  | unsigned int | imageNumber
| ) |  | `[virtual]`

Search for all occurrences

Load the previously opened image file as an OpenGL texture.

The OpenGL texture will already have been bound by the caller of this method (i.e. do not call glBind again inside your implementation of this method - just use glTexImage2D or equivalent to load the texture). The type of texture that has been bound is specified in the information structure provided. It is important that your implementation verifies this type before loading any data, as loading an incompatible type may lead to instability. By overriding this method, you can implement non-2D texture support (such as cube maps), non-byte texture support (such as float and half), and compressed hardware texture support (such as DXT). You are free to use any available OpenGL extensions you want to load in the texture. While standard Maya shaders will only be able to use standard 2D textures, plugin hardware shaders can access non-2D textures loaded via this method. If your plugin set mipmaps to true at file open time, it is responsible for loading or generating the mipmap information inside this method.

Parameters:

  [in] | info | a description of hardware texture to load.
  [in] | imageNumber | the index of image to load (for files containing multiple images)

Returns:
  - MS::kFailure if the image cannot be loaded (e.g. it is corrupt)
  - MS::kSuccess otherwise

Examples:
  simpleImageFile.cpp.

MStatus close | ( |  | ) | `[virtual]`

Search for all occurrences

Close the image file.

Returns:
  - MS::kSuccess if the image was closed
  - MS::kFailure otherwise

Examples:
  ddsFloatReader.cpp, and tiffFloatReader.cpp.

MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile
MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile MPxImageFile