NVIDIA Iray API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::IImage Class Referenceabstract

This interface represents a pixel image file. More...

Inheritance diagram for mi::IImage:
Inheritance graph
[legend]

Public Member Functions

virtual Sint32  reset_file (const char *filename)=0
  Resets the underlying file to a new file given by filename. More...
 
virtual const char *  get_filename () const =0
  Returns the resolved file name of the file containing the image. More...
 
virtual const char *  get_original_filename () const =0
  Returns the unresolved file as passed to reset_file(). More...
 
virtual bool  set_from_canvas (const neuraylib::ICanvas *canvas)=0
  Sets the pixels of this image based on the passed canvas (without sharing). More...
 
virtual bool  set_from_canvas (neuraylib::ICanvas *canvas, bool shared=false)=0
  Sets the pixels of this image based on the passed canvas (possibly sharing the pixel data). More...
 
virtual const neuraylib::ICanvas get_canvas (Uint32 level=0) const =0
  Returns a canvas with the pixel data of the image. More...
 
virtual const char *  get_type () const =0
  Returns the pixel type of the image. More...
 
virtual Uint32  get_levels () const =0
  Returns the number of levels in the mipmap pyramid. More...
 
virtual Uint32  resolution_x (Uint32 level=0) const =0
  Returns the horizontal resolution of the image. More...
 
virtual Uint32  resolution_y (Uint32 level=0) const =0
  Returns the vertical resolution of the image. More...
 
virtual Uint32  resolution_z (Uint32 level=0) const =0
  Returns the number of layers of the 3D image. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0xca59b977, 0x30ee, 0x4172, 0x91, 0x53, 0xb7, 0x70, 0x2c, 0x6b, 0x3a, 0x76, IScene_element >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
IScene_element
Self
  Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
  Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xca59b977, 0x30ee, 0x4172, 0x91, 0x53, 0xb7, 0x70, 0x2c, 0x6b, 0x3a, 0x76, IScene_element >
static bool  compare_iid (const Uuid &iid)
  Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed Description

This interface represents a pixel image file.

It supports different pixel types, 2D and 3D image data, and mipmap levels. Its main usage is in textures, see the mi::ITexture class.

The image coordinate system has its origin in the lower left corner in the case of 2D image data.

Editing an image

Note that editing an existing image has unusual semantics that differ from all other DB elements. Usually, when editing a database element, an identical copy of the database element is created (the existing one cannot be used because it might be needed for other transactions, other scopes, or in case the transaction is aborted). For images, this implies a copy of all the pixel data which is very expensive.

There are only two mutable methods on this interface, reset_file() and set_from_canvas(); all other methods are const. Both methods eventually replace the entire pixel data anyway. Therefore, when an image is edited, the pixel data is not copied, but replaced by a dummy image of size 1x1. This approach saves the unneeded, but expensive copy of the original pixel data. When afterwards one of two methods above is called, the image uses the correct pixel data again.

Note that this also affects the results from methods like resolution_x(), etc. (if you want to know the resolution of an existing image without changing it, you should access the image, not edit it). Furthermore, you might end up with the dummy image if you do not call reset_file() or set_from_canvas() (or if these methods fail).

Member Function Documentation

virtual const neuraylib::ICanvas* mi::IImage::get_canvas ( Uint32  level = 0) const
pure virtual

Returns a canvas with the pixel data of the image.

Note that it is not possible to manipulate the pixel data.

Parameters
level The desired mipmap level. Level 0 is the highest resolution.
Returns
A canvas pointing to the pixel data of the image, or NULL in case of failure.
virtual const char* mi::IImage::get_filename ( ) const
pure virtual

Returns the resolved file name of the file containing the image.

The method returns NULL if there is no file associated with the image, e.g., after default construction, calls to set_from_canvas(), or failures to resolve the file name passed to reset_file().

See Also
get_original_filename()
virtual Uint32 mi::IImage::get_levels ( ) const
pure virtual

Returns the number of levels in the mipmap pyramid.

virtual const char* mi::IImage::get_original_filename ( ) const
pure virtual

Returns the unresolved file as passed to reset_file().

The method returns NULL after default construction or calls to set_from_canvas().

See Also
get_filename()
virtual const char* mi::IImage::get_type ( ) const
pure virtual

Returns the pixel type of the image.

See Types for a list of supported pixel types.

virtual Sint32 mi::IImage::reset_file ( const char *  filename)
pure virtual

Resets the underlying file to a new file given by filename.

Note that support for a given image format requires an image plugin capable of handling that format.

Returns
  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: Failure to use the given file (e.g., the file does not exist, unknown format, etc.).
virtual Uint32 mi::IImage::resolution_x ( Uint32  level = 0) const
pure virtual

Returns the horizontal resolution of the image.

Parameters
level The desired mipmap level. Level 0 is the highest resolution.
virtual Uint32 mi::IImage::resolution_y ( Uint32  level = 0) const
pure virtual

Returns the vertical resolution of the image.

Parameters
level The desired mipmap level. Level 0 is the highest resolution.
virtual Uint32 mi::IImage::resolution_z ( Uint32  level = 0) const
pure virtual

Returns the number of layers of the 3D image.

Parameters
level The desired mipmap level. Level 0 is the highest resolution.
virtual bool mi::IImage::set_from_canvas ( const neuraylib::ICanvas canvas)
pure virtual

Sets the pixels of this image based on the passed canvas (without sharing).

Parameters
canvas The pixel data to be used by this image. Note that the pixel data is copied, not shared. If sharing is intended use mi::IImage::set_from_canvas(mi::neuraylib::ICanvas*,bool) instead.
Returns
true if the pixel data of this image has been set correctly, and false otherwise.
virtual bool mi::IImage::set_from_canvas ( neuraylib::ICanvas canvas,
bool  shared = false 
)
pure virtual

Sets the pixels of this image based on the passed canvas (possibly sharing the pixel data).

Parameters
canvas The pixel data to be used by this image.
shared If false (the default), the pixel data is copied from canvas and the method does the same as mi::IImage::set_from_canvas(const mi::neuraylib::ICanvas*). If set to true, the image uses the canvas directly (doing reference counting on the canvas pointer). You must not modify the canvas content after this call.
Returns
true if the pixel data of this image has been set correctly, and false otherwise.