H3DUtil::Image Class Reference

Virtual base class for all images containing virtual functions that all Image classes must define. More...

#include <H3DUtil/Image.h>

Inheritance diagram for H3DUtil::Image:

Inheritance graph

List of all members.

Public Types

enum  PixelType
 Type that defines what format each pixel in the image is on. More...
enum  PixelComponentType
 Type of each component in the pixel.

Public Member Functions

 Image ()
 Constructor.
virtual unsigned int width ()=0
 Returns the width of the image in pixels.
virtual unsigned int height ()=0
 Returns the height of the image in pixels.
virtual unsigned int depth ()=0
 Returns the depth of the image in pixels.
virtual unsigned int bitsPerPixel ()=0
 Returns the number of bits used for each pixel in the image.
virtual PixelType pixelType ()=0
 Returns the PixelType of the image.
virtual PixelComponentType pixelComponentType ()=0
 Returns the PixelComponentType of the image.
virtual Vec3f pixelSize ()
 Returns the size of the pixel in x, y and z direction in metres.
virtual void * getImageData ()=0
 Returns a pointer to the raw image data.
void getSample (void *value, H3DFloat x=0, H3DFloat y=0, H3DFloat z=0)
 Sample the image at a given normalized position(texture coordinate), i.e.
H3DUtil::RGBA getSample (H3DFloat x=0, H3DFloat y=0, H3DFloat z=0)
 Sample the image at a given normalized position(texture coordinate), i.e.
void setPixel (const H3DUtil::RGBA &value, int x=0, int y=0, int z=0)
 Set the pixel at a given position given an RGBA struct.
H3DUtil::RGBA getPixel (int x=0, int y=0, int z=0)
 Get the pixel at a given position as an RGBA struct.
void RGBAToImageValue (const H3DUtil::RGBA &rgba, void *value)
 Convert a RGBA value to a value of the same type as the image data.
H3DUtil::RGBA imageValueToRGBA (void *value)
 Convert an image value to an RGBA value.
virtual void getElement (void *value, int x=0, int y=0, int z=0)
 Get the value of a pixel/voxel.
virtual void setElement (void *value, int x=0, int y=0, int z=0)
 Set the value of a pixel/voxel.
virtual int byteAlignment ()
 Gets the byte alignment for the start of each pixel row in memory.


Detailed Description

Virtual base class for all images containing virtual functions that all Image classes must define.

For functions that load images check ImageLoaderFunctions.h


Member Enumeration Documentation

Type that defines what format each pixel in the image is on.


Member Function Documentation

virtual int H3DUtil::Image::byteAlignment (  )  [inline, virtual]

Gets the byte alignment for the start of each pixel row in memory.

Valid values are 1, 2, 4 and 8.

virtual void H3DUtil::Image::getElement ( void *  value,
int  x = 0,
int  y = 0,
int  z = 0 
) [inline, virtual]

Get the value of a pixel/voxel.

The size of data written in value as output depends on the type of the image.

Parameters:
value Where to put the return value.
x The position in x(width) to sample.
y The position in y(height) to sample.
z The position in z(depth) to sample.

Referenced by getPixel().

virtual void* H3DUtil::Image::getImageData (  )  [pure virtual]

Returns a pointer to the raw image data.

The ownership of the pointer is held by the Image class, if any memory allocations are made for the pointer the Image class is responsible for deallocating that memory.

Implemented in H3DUtil::FreeImageImage, and H3DUtil::PixelImage.

Referenced by H3DUtil::PixelImage::PixelImage().

H3DUtil::RGBA Image::getPixel ( int  x = 0,
int  y = 0,
int  z = 0 
)

Get the pixel at a given position as an RGBA struct.

If an LUMINANCE image, the value is copied to RGB channels and alpha set to 1.

Parameters:
x The position in x(width).
y The position in y(height).
z The position in z(depth).

References bitsPerPixel(), getElement(), and imageValueToRGBA().

Referenced by getSample().

H3DUtil::RGBA H3DUtil::Image::getSample ( H3DFloat  x = 0,
H3DFloat  y = 0,
H3DFloat  z = 0 
) [inline]

Sample the image at a given normalized position(texture coordinate), i.e.

coordinates between 0 and 1. Pixel data will be trilinearly interpolated to calculate the result.

Parameters:
x The position in x(width) to sample(0-1).
y The position in y(height) to sample(0-1).
z The position in z(depth) to sample(0-1).

void Image::getSample ( void *  value,
H3DFloat  x = 0,
H3DFloat  y = 0,
H3DFloat  z = 0 
)

Sample the image at a given normalized position(texture coordinate), i.e.

coordinates between 0 and 1. Pixel data will be trilinearly interpolated to calculate the result.

Parameters:
value Where to put the return value.
x The position in x(width) to sample(0-1).
y The position in y(height) to sample(0-1).
z The position in z(depth) to sample(0-1).

References depth(), getPixel(), H3DUtil::H3DCeil(), H3DUtil::H3DFloor(), height(), RGBAToImageValue(), and width().

Referenced by H3DUtil::PixelImage::PixelImage().

virtual Vec3f H3DUtil::Image::pixelSize (  )  [inline, virtual]

Returns the size of the pixel in x, y and z direction in metres.

By default all pixels have the size Vec3f( 1, 1, 1 ).

Reimplemented in H3DUtil::PixelImage.

Referenced by H3DUtil::PixelImage::PixelImage().

virtual void H3DUtil::Image::setElement ( void *  value,
int  x = 0,
int  y = 0,
int  z = 0 
) [inline, virtual]

Set the value of a pixel/voxel.

The size of data read from value depends on the type of the image.

Referenced by setPixel().

void Image::setPixel ( const H3DUtil::RGBA value,
int  x = 0,
int  y = 0,
int  z = 0 
)

Set the pixel at a given position given an RGBA struct.

If an LUMINANCE image, the R component is used as value.

Parameters:
value The value to set the pixel to. One or more components may be used, this depends on the type of image.
x The position in x(width).
y The position in y(height).
z The position in z(depth).

References bitsPerPixel(), RGBAToImageValue(), and setElement().


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

Generated on Fri Nov 7 10:23:44 2008 for H3DUtil by  doxygen 1.5.7