Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

openvrml::sfimage Class Reference
[Field Values]

Inheritance diagram for openvrml::sfimage:

Inheritance graph
[legend]
Collaboration diagram for openvrml::sfimage:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 sfimage () throw ()
 sfimage (size_t x, size_t y, size_t comp, const unsigned char *array=0) throw (std::bad_alloc)
 Construct.

 sfimage (const sfimage &) throw (std::bad_alloc)
 Copy constructor.

virtual ~sfimage () throw ()
 Destroy.

sfimageoperator= (const sfimage &sfimage) throw (std::bad_alloc)
 Assignment.

size_t x () const throw ()
 Get the image width.

size_t y () const throw ()
 Get the image height.

size_t comp () const throw ()
 Get the number of components.

const unsigned char * array () const throw ()
 Get the pixel data.

void set (size_t x, size_t y, size_t comp, const unsigned char *array) throw (std::bad_alloc)
 Set the image.

virtual std::auto_ptr< field_valueclone () const throw (std::bad_alloc)
 Virtual copy constructor.

virtual field_valueassign (const field_value &value) throw (std::bad_cast, std::bad_alloc)
 Virtual assignment.

virtual type_id type () const throw ()
 Get the field_value::type_id associated with this class.


Private Member Functions

virtual void print (std::ostream &out) const
 Print to an output stream.


Private Attributes

size_t d_w
 Image width.

size_t d_h
 Image height.

size_t d_nc
 Number of components.

unsigned char * d_pixels
 Pixel data.


Detailed Description

A single uncompressed 2-dimensional pixel image. The first hexadecimal value is the lower left pixel and the last value is the upper right pixel.Pixel values are limited to 256 levels of intensity. A one-component image specifies one-byte greyscale values. A two-component image specifies the intensity in the first (high) byte and the alpha opacity in the second (low) byte. A three-component image specifies the red component in the first (high) byte, followed by the green and blue components. Four-component images specify the alpha opacity byte after red/green/blue.


Constructor & Destructor Documentation

openvrml::sfimage::sfimage  )  throw ()
 

Construct.

openvrml::sfimage::sfimage size_t  x,
size_t  y,
size_t  comp,
const unsigned char *  array = 0
throw (std::bad_alloc)
 

Construct.

Note that the pixels read from lower left to upper right, which is a reflection around the y-axis from the "normal" convention.

Note also that width and height are specified in pixels, and a pixel may be more than one byte wide. For example, an image with a width and height of 16, and nc==3, would have a pixel array w*h*nc = 16*16*3 = 768 bytes long. See the class intro above for the interpretation of different pixel depths.

Parameters:
x width in pixels
y height in pixels
comp number of components/pixel (see above)
array the caller owns the bytes, so this ctr makes a copy
Exceptions:
std::bad_alloc if memory allocation fails.

openvrml::sfimage::sfimage const sfimage sfimage  )  throw (std::bad_alloc)
 

Copy constructor.

Parameters:
sfimage the sfimage object to copy.
Exceptions:
std::bad_alloc if memory allocation fails.

Member Function Documentation

const unsigned char * openvrml::sfimage::array  )  const throw ()
 

Get the pixel data.

Returns:
a pointer to the array of pixel data.

field_value & openvrml::sfimage::assign const field_value value  )  throw (std::bad_cast, std::bad_alloc) [virtual]
 

Virtual assignment.

Parameters:
value the new value to give the object.
Returns:
a reference to the object.
Exceptions:
std::bad_cast if value is not an sfimage.
std::bad_alloc if memory allocation fails.

Implements openvrml::field_value.

std::auto_ptr< field_value > openvrml::sfimage::clone  )  const throw (std::bad_alloc) [virtual]
 

Virtual copy constructor.

Returns:
a pointer to a copy of the object.
Exceptions:
std::bad_alloc if memory allocation fails.

Implements openvrml::field_value.

size_t openvrml::sfimage::comp  )  const throw ()
 

Get the number of components.

Returns:
the number of components

sfimage & openvrml::sfimage::operator= const sfimage sfimage  )  throw (std::bad_alloc)
 

Assignment.

Parameters:
sfimage the sfimage value to assign to the object.
Exceptions:
std::bad_alloc if memory allocation fails.

void openvrml::sfimage::print std::ostream &  out  )  const [private, virtual]
 

Print to an output stream.

Parameters:
out an output stream.

Implements openvrml::field_value.

void openvrml::sfimage::set size_t  x,
size_t  y,
size_t  comp,
const unsigned char *  array
throw (std::bad_alloc)
 

Set the image.

Parameters:
x width in pixels
y height in pixels
comp number of components
array array of (width * height * components) bytes comprising the image data.

field_value::type_id openvrml::sfimage::type  )  const throw () [virtual]
 

Get the field_value::type_id associated with this class.

Returns:
field_value::sfimage.

Implements openvrml::field_value.

size_t openvrml::sfimage::x  )  const throw ()
 

Get the image width.

Returns:
the image width

size_t openvrml::sfimage::y  )  const throw ()
 

Get the image height.

Returns:
the image height