Image Class Reference

Abstract image class supporting a standard 32-bit Rgba pixel format, as well as an extended, 128- or 256-bit floating-point RgbaHDR pixel format for high dynamic range images. More...

#include <Image.h>

Inheritance diagram for Image:

HDRImage RgbaImage

List of all members.

Saving / Loading

virtual bool save (const std::string &filename) const
 Attempts to save this image out to the given file, inferring the desired file format by the filename's extension.
static Imageload (const std::string &filename)
 Attempts to load an image from the given file, inferring the image file format by the filename's extension.

Public Member Functions

Constructors
 Image (unsigned width=640, unsigned height=480)
virtual ~Image ()
Data Accessors / Mutators
virtual bool isHDR () const =0
template<typename T>
getPixel (unsigned row, unsigned col) const
template<typename T>
void setPixel (unsigned row, unsigned col, const T &val)
 Sets the pixel in the given row and column to the pixel value in the desired template format (either Rgba32 or RgbaHDR).
virtual real_t getLuminance (unsigned row, unsigned col) const =0
Size accessors
unsigned getWidth () const
unsigned getHeight () const
unsigned getSize () const
Large Mutators
virtual void setSize (unsigned width, unsigned height)=0
 Sets the dimensions of this image, most likely allocating a new underlying buffer and erasing its previous contents.
template<typename T>
void setData (const T *data)
 Sets the underlying data - data should be the size of the image.
template<typename T>
void setData (const T *data, unsigned width, unsigned height)
 Sets the underlying data and image dimensions, where the given data should be preallocated to the desired size of the image.
Miscellaneous
virtual Imageclone () const =0
virtual void copyData (const Image *image)=0
 Overwrites this image's data with the given image which is assumed to have the same dimensions as this image (and may have been created from this image by, for example, the clone function).

Protected Member Functions

virtual Rgba32 _getPixelRgba32 (unsigned row, unsigned col) const =0
virtual RgbaHDR _getPixelRgbaHDR (unsigned row, unsigned col) const =0
virtual void _setPixel (unsigned row, unsigned col, const Rgba32 &val)=0
virtual void _setPixel (unsigned row, unsigned col, const RgbaHDR &val)=0
virtual void _setData (const Rgba32 *data)=0
virtual void _setData (const RgbaHDR *data)=0

Protected Attributes

unsigned m_width
unsigned m_height
unsigned m_size


Detailed Description

Abstract image class supporting a standard 32-bit Rgba pixel format, as well as an extended, 128- or 256-bit floating-point RgbaHDR pixel format for high dynamic range images.

Author:
Travis Fischer (fisch0920@gmail.com)
Date:
Fall 2008
Note:
In addition to Qt's normal image loading / saving, represented by the following table, this class also supports loading / saving of images in HDR, OpenEXR, and PFM image formats.
Default / built-in image formats supported by Qt:

Format Description Qt Support ------ ------------------------------------------- -------------- BMP Windows Bitmap Read / Write GIF Graphic Interchange Format (optional) Read JPG Joint Photographic Experts Group Read / Write JPEG Joint Photographic Experts Group Read / Write PNG Portable Network Graphics Read / Write PBM Portable Bitmap Read PGM Portable Graymap Read PPM Portable Pixmap Read / Write TIFF Tagged Image File Format Read / Write XBM X11 Bitmap Read / Write XPM X11 Pixmap Read / Write

Extra High Dynamic Range image formats supported by Milton:

Format Description Support ------ ------------------------------------------- ----------- HDR Also known as RGBE (Radiance, by Greg Ward) Read / Write EXR ILM's OpenEXR Format Read / Write* PFM Portable Float Map Format Read / Write

Note:
OpenEXR is only supported on platforms / builds with ILM's OpenEXR libraries which do not come bundled with Milton.

Definition at line 51 of file Image.h.


Constructor & Destructor Documentation

Image::Image ( unsigned  width = 640,
unsigned  height = 480 
) [inline]

Definition at line 49 of file Image.inl.

virtual Image::~Image (  )  [inline, virtual]

Definition at line 57 of file Image.h.


Member Function Documentation

Image * Image::load ( const std::string &  filename  )  [static]

Attempts to load an image from the given file, inferring the image file format by the filename's extension.

Note:
If the actual file loaded is RgbaHDR and the requested image format is RgbaImage, the loaded HDRImage image will be converted to an RgbaImage before returning. Similarly, if the image was stored in an Rgba32 format (PNG, JPEG, etc.), and the requested image format is HDRImage, the loaded RgbaImage will be converted to an HDRImage before returning.
Returns:
a new image of the desired type upon success or NULL upon failur

Definition at line 54 of file Image.cpp.

bool Image::save ( const std::string &  filename  )  const [virtual]

Attempts to save this image out to the given file, inferring the desired file format by the filename's extension.

Returns:
whether or not file was successfully saved

Definition at line 91 of file Image.cpp.

virtual bool Image::isHDR (  )  const [pure virtual]

Returns:
whether or not the underlying data for this image is stored in a floating-point HDR format
Note:
that some operations will be more of less efficient when performed on an HDR image versus a standard 32-bit Rgba image, and knowing whether or not an image is in HDR format can facilitate efficient usage (cutting down on the number of implicit conversions between HDR and non-HDR pixel formats that must be performed)

Implemented in HDRImage, and RgbaImage.

template<typename T>
T Image::getPixel ( unsigned  row,
unsigned  col 
) const [inline]

Returns:
the pixel in the given row and column in the desired template format (either Rgba32 or RgbaHDR)
Note:
if this image is an HDR image and an Rgba32 is requested, an implicit conversion is performed (and vice-versa if this image is non-HDR and the caller requests an RgbaHDR)

Definition at line 54 of file Image.inl.

template<typename T>
void Image::setPixel ( unsigned  row,
unsigned  col,
const T &  val 
) [inline]

Sets the pixel in the given row and column to the pixel value in the desired template format (either Rgba32 or RgbaHDR).

Note:
if this image is an HDR image and an Rgba32 value is given, an implicit conversion is performed (and vice-versa if this image is non-HDR and the caller gives an RgbaHDR)

Definition at line 64 of file Image.inl.

virtual real_t Image::getLuminance ( unsigned  row,
unsigned  col 
) const [pure virtual]

Returns:
the luminance of the pixel at the given row and column which is guaranteed to lie in [0, 1]

Implemented in HDRImage, and RgbaImage.

unsigned Image::getWidth (  )  const [inline]

Returns:
the image width

Definition at line 70 of file Image.inl.

unsigned Image::getHeight (  )  const [inline]

Returns:
the image height

Definition at line 74 of file Image.inl.

unsigned Image::getSize (  )  const [inline]

Returns:
width * height

Definition at line 78 of file Image.inl.

virtual void Image::setSize ( unsigned  width,
unsigned  height 
) [pure virtual]

Sets the dimensions of this image, most likely allocating a new underlying buffer and erasing its previous contents.

Implemented in HDRImage, and RgbaImage.

template<typename T>
void Image::setData ( const T *  data  )  [inline]

Sets the underlying data - data should be the size of the image.

Note:
copies the given data into the underlying buffer, leaving the given data unmodified

if this image is an HDR image and Rgba32 data is given, an implicit conversion is performed (and vice-versa if this image is non-HDR and the caller gives RgbaHDR data)

Definition at line 83 of file Image.inl.

template<typename T>
void Image::setData ( const T *  data,
unsigned  width,
unsigned  height 
) [inline]

Sets the underlying data and image dimensions, where the given data should be preallocated to the desired size of the image.

Note:
copies the given data into a new underlying buffer, leaving the given data unmodified

if this image is an HDR image and Rgba32 data is given, an implicit conversion is performed (and vice-versa if this image is non-HDR and the caller gives RgbaHDR data)

Definition at line 88 of file Image.inl.

virtual Image* Image::clone (  )  const [pure virtual]

Returns:
a copy of this Image and its underlying data

Implemented in HDRImage, and RgbaImage.

virtual void Image::copyData ( const Image image  )  [pure virtual]

Overwrites this image's data with the given image which is assumed to have the same dimensions as this image (and may have been created from this image by, for example, the clone function).

Implemented in HDRImage, and RgbaImage.

virtual Rgba32 Image::_getPixelRgba32 ( unsigned  row,
unsigned  col 
) const [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.

virtual RgbaHDR Image::_getPixelRgbaHDR ( unsigned  row,
unsigned  col 
) const [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.

virtual void Image::_setPixel ( unsigned  row,
unsigned  col,
const Rgba32 val 
) [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.

virtual void Image::_setPixel ( unsigned  row,
unsigned  col,
const RgbaHDR val 
) [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.

virtual void Image::_setData ( const Rgba32 data  )  [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.

virtual void Image::_setData ( const RgbaHDR data  )  [protected, pure virtual]

Implemented in HDRImage, and RgbaImage.


Member Data Documentation

unsigned Image::m_width [protected]

Definition at line 223 of file Image.h.

unsigned Image::m_height [protected]

Definition at line 224 of file Image.h.

unsigned Image::m_size [protected]

Definition at line 225 of file Image.h.


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

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6