Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

SFImage Class Reference

Inheritance diagram for SFImage:

FieldValue List of all members.

Public Methods

 SFImage () throw ()
 SFImage (size_t w, size_t h, size_t nc, const unsigned char *pixels=0) throw (std::bad_alloc)
 Create an SFImage.

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

virtual ~SFImage () throw ()
 Destructor.

SFImage & operator= (const SFImage &rhs) throw (std::bad_alloc)
 Assignment.

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

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

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

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

void set (size_t width, size_t height, size_t components, const unsigned char *pixels) throw (std::bad_alloc)
 Set the image.

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

virtual FieldValueassign (const FieldValue &value) throw (std::bad_cast, std::bad_alloc)
 Virtual assignment.

virtual Type type () const throw ()
 Get the FieldValue::Type associated with this class.


Private Methods

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


Private Attributes

size_t d_w
size_t d_h
size_t d_nc
unsigned char * d_pixels

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

SFImage   throw ()
 

Construct the default SFImage.

SFImage size_t    width,
size_t    height,
size_t    components,
const unsigned char *    pixels = 0
throw (std::bad_alloc)
 

Create an SFImage.

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:
width width in pixels
height height in pixels
components number of components/pixel (see above)
pixels the caller owns the bytes, so this ctr makes a copy
Exceptions:
std::bad_alloc if memory allocation fails.

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.

~SFImage   throw () [virtual]
 

Destructor.


Member Function Documentation

FieldValue & assign const FieldValue   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.

Implements FieldValue.

std::auto_ptr< FieldValue > 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 FieldValue.

size_t getComponents   const throw ()
 

Get the number of components.

Returns:
the number of components

size_t getHeight   const throw ()
 

Get the image height.

Returns:
the image height

const unsigned char * getPixels   const throw ()
 

Get the pixel data.

Returns:
a pointer to the array of pixel data.

size_t getWidth   const throw ()
 

Get the image width.

Returns:
the image width

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 print std::ostream &    out const [private, virtual]
 

Print to an output stream.

Parameters:
out an output stream.

Implements FieldValue.

void set size_t    width,
size_t    height,
size_t    components,
const unsigned char *    pixels
throw (std::bad_alloc)
 

Set the image.

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

FieldValue::Type type   const throw () [virtual]
 

Get the FieldValue::Type associated with this class.

Returns:
FieldValue::sfimage.

Implements FieldValue.