Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

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

# openvrml::image Class Reference
[Base Types]

List of all members.

## Detailed Description

Pixmap data.

The first pixel in the array is the lower left pixel and the last is the upper right pixel. Pixel values are limited to 256 levels of intensity. The elements of array are bytes, with one byte per pixel component. Thus the number of elements in the array is `x` * &p y * `comp`.

A one-component image specifies one-byte greyscale values. A two-component image specifies the intensity in the first byte and the alpha opacity in the second byte. A three-component image specifies the red component in the first byte, followed by the green and blue components. Four-component images specify the alpha opacity byte after red/green/blue.

## Public Member Functions
| image () throw ()
| Construct.
| image (size_t x, size_t y, size_t comp) throw (std::bad_alloc)
| Construct.
| image (size_t x, size_t y, size_t comp, const std::vector< unsigned char > &array) throw (std::bad_alloc)
| Construct.
template<typename InputIterator>
| image (size_t x, size_t y, size_t comp, InputIterator array_begin, InputIterator array_end) throw (std::bad_alloc)
| Construct.
size_t | x () const throw ()
| Pixels in the x-dimension.
void | x (size_t value) throw (std::bad_alloc)
| Set the pixels in the x-dimension.
size_t | y () const throw ()
| Pixels in the y-dimension.
void | y (size_t value) throw (std::bad_alloc)
| Set the pixels in the y-dimension.
void | resize (size_t x, size_t y) throw (std::bad_alloc)
| Resize the x- and y-dimensions.
size_t | comp () const throw ()
| Number of components.
void | comp (size_t value) throw (std::bad_alloc)
| Set the number of components.
const std::vector< unsigned char > & | array () const throw ()
| Pixel value array.
void | array (const std::vector< unsigned char > &value) throw ()
| Set the pixel value array.
template<typename InputIterator>
void | array (InputIterator begin, InputIterator end) throw ()
| Set the pixel value array.
int32 | pixel (size_t index) const throw ()
| Pixel value.
void | pixel (size_t index, int32 value) throw ()
| Set a pixel value.
int32 | pixel (size_t x, size_t y) const throw ()
| Pixel value.
void | pixel (size_t x, size_t y, int32 value) throw ()
| Set a pixel value.
## Private Attributes
size_t | x_
| Pixels in the x-dimension.
size_t | y_
| Pixels in the y-dimension.
size_t | comp_
| Number of components.
std::vector< unsigned char > | array_
| Pixel data.
## Related Functions
(Note that these are not member functions.)
bool | operator== (const image &lhs, const image &rhs) throw()
| Compare for equality.
bool | operator!= (const image &lhs, const image &rhs) throw()
| Compare for inequality.
std::ostream & | operator<< (std::ostream &out, const image &img)
| Stream output.

## Constructor & Destructor Documentation

openvrml::image::image | ( |  | ) | throw ()

| Construct.

openvrml::image::image | ( | size_t | x,
|  | size_t | y,
|  | size_t | comp
| ) | throw (std::bad_alloc)

  | Construct. Parameters:
  | x | pixels in the x-direction.
  | y | pixels in the y-direction.
  | comp | number of components.

openvrml::image::image | ( | size_t | x,
|  | size_t | y,
|  | size_t | comp,
|  | const std::vector< unsigned char > & | array
| ) | throw (std::bad_alloc)

  | Construct. Precondition: `array.size()` <= `x` * `y` & `comp`. Parameters:
  | x | pixels in the x-direction.
  | y | pixels in the y-direction.
  | comp | number of components.
  | array | pixel data.

template<typename InputIterator>
openvrml::image::image | ( | size_t | x,
|  | size_t | y,
|  | size_t | comp,
|  | InputIterator | array_begin,
|  | InputIterator | array_end
| ) | throw (std::bad_alloc)

  | Construct. Precondition: std::distance(`array_begin`, `array_end`) <= `x` * `y` * `comp`. Parameters:
  | x | pixels in the x-direction.
  | y | pixels in the y-direction.
  | comp | number of components.
  | array_begin | pixel data begin iterator.
  | array_end | pixel data end iterator.
  Exceptions:
  | std::bad_alloc | if memory allocation fails.

## Member Function Documentation

size_t openvrml::image::x | ( |  | ) | const throw ()`[inline]`

| Pixels in the x-dimension. Returns: the number of pixels in the x-dimension.

void openvrml::image::x | ( | size_t | value | ) | throw (std::bad_alloc)

  | Set the pixels in the x-dimension. Parameters:
  | value | new value for the x-dimension.
  Exceptions:
  | std::bad_alloc | if memory allocation fails.

size_t openvrml::image::y | ( |  | ) | const throw ()`[inline]`

| Pixels in the y-dimension. Returns: the number of pixels in the y-dimension.

void openvrml::image::y | ( | size_t | value | ) | throw (std::bad_alloc)

  | Set the pixels in the y-dimension. Parameters:
  | value | new value for the x-dimension.
  Exceptions:
  | std::bad_alloc | if memory allocation fails.

void openvrml::image::resize | ( | size_t | x,
|  | size_t | y
| ) | throw (std::bad_alloc)

  | Resize the x- and y-dimensions. Parameters:
  | x | x-dimension.
  | y | y-dimension.
  Exceptions:
  | std::bad_alloc | if memory allocation fails.

size_t openvrml::image::comp | ( |  | ) | const throw ()`[inline]`

| Number of components. Returns: the number of components.

void openvrml::image::comp | ( | size_t | value | ) | throw (std::bad_alloc)

  | Set the number of components. Precondition: `value` <= 4 Parameters:
  | value | number of components.

const std::vector< unsigned char > & openvrml::image::array | ( |  | ) | const throw ()`[inline]`

| Pixel value array. Returns: the array of pixel values.

void openvrml::image::array | ( | const std::vector< unsigned char > & | value | ) | throw ()`[inline]`

  | Set the pixel value array. Precondition: `value.size()` <= (x() * y() * comp()) Parameters:
  | value | pixel value array.

template<typename InputIterator>
void openvrml::image::array | ( | InputIterator | begin,
|  | InputIterator | end
| ) | throw ()

  | Set the pixel value array. Precondition: std::distance(`begin`, `end`) <= (x() * y() * comp()) Parameters:
  | begin | input iterator to the beginning of a sequence.
  | end | input iterator to the end of the sequence (one past the last element).

int32 openvrml::image::pixel | ( | size_t | index | ) | const throw ()`[inline]`

  | Pixel value. Precondition: `index` < x() * y() Parameters:
  | index | pixel value index.
Returns: the pixel value at `index`.

void openvrml::image::pixel | ( | size_t | index,
|  | int32 | value
| ) | throw ()`[inline]`

  | Set a pixel value. Precondition: `index` < x() * y() Parameters:
  | index | pixel value index.
  | value | pixel value.

int32 openvrml::image::pixel | ( | size_t | x,
|  | size_t | y
| ) | const throw ()`[inline]`

  | Pixel value. Precondition: `x` < x(), `y` < y() Parameters:
  | x | pixel value x- (column) index.
  | y | pixel value y- (row) index.
Returns: the pixel value at (`x`, `y`).

void openvrml::image::pixel | ( | size_t | x,
|  | size_t | y,
|  | int32 | value
| ) | throw ()`[inline]`

  | Set a pixel value. Precondition: `x` < x(), `y` < y() Parameters:
  | x | pixel value x- (column) index.
  | y | pixel value y- (row) index.
  | value | pixel value.

## Friends And Related Function Documentation

bool operator== | ( | const image & | lhs,
|  | const image & | rhs
| ) | throw()`[related]`

  | Compare for equality. Parameters:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: `true` if `lhs` and `rhs` are equal; `false` otherwise.

bool operator!= | ( | const image & | lhs,
|  | const image & | rhs
| ) | throw()`[related]`

  | Compare for inequality. Parameters:
  | lhs | left-hand operand.
  | rhs | right-hand operand.
Returns: `true` if `lhs` and `rhs` are not equal; `false` otherwise.

std::ostream & operator<< | ( | std::ostream & | out,
|  | const image & | img
| ) | `[related]`

  | Stream output. Parameters:
  | out | output stream.
  | img | image.

## Member Data Documentation

size_t openvrml::image::x_`[private]`

| Pixels in the x-dimension.

size_t openvrml::image::y_`[private]`

| Pixels in the y-dimension.

size_t openvrml::image::comp_`[private]`

| Number of components.

std::vector< int32 > openvrml::image::array_`[private]`

| Pixel data.