Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Attributes | List of all members
om::images::base::Image Class Reference

A class that stores packed pixel data for images with an arbitrary number of dimensions. More...

#include <omImage.h>

Public Member Functions

 Image ()
 Create an empty image with UNDEFINED pixel format. More...
 
 Image (const PixelFormat &newPixelFormat, Size width)
 Create a 1D image object with the specified pixel format and width. More...
 
 Image (const PixelFormat &newPixelFormat, Size width, Size height)
 Create a 2D image object with the specified pixel format, width and height. More...
 
 Image (const PixelFormat &newPixelFormat, Size width, Size height, Size depth)
 Create a 3D image object with the specified pixel format, width, height and depth. More...
 
 Image (const PixelFormat &newPixelFormat, const Size *sizes, Size numDimensions)
 Create an image object with the specified pixel format and an arbitrary number of dimensions. More...
 
 Image (const Image &image)
 Construct a copy of another image, copying its internal format and pixel data. More...
 
 ~Image ()
 Destroy an image and release its internal pixel data. More...
 
Imageoperator= (const Image &other)
 Assign the state of another image to this one. More...
 
Size getDimensionCount () const
 Return the number of dimensions in this image, usually 1, 2, or 3. More...
 
const SizegetSizes () const
 Return a pointer to an array containing the size along each dimension of this image. More...
 
Size getSize (Index dimension) const
 Return the size of the image along the specified dimension index. More...
 
Size getSize1D () const
 Return the size of the image assuming it is a 1D image. More...
 
Size2D getSize2D () const
 Return the size of the image assuming it is a 2D image. More...
 
Size3D getSize3D () const
 Return the size of the image assuming it is a 3D image. More...
 
Size getWidth () const
 Return the width of this image (size along dimension 0). More...
 
Size getHeight () const
 Return the height of this image (size along dimension 1). More...
 
Size getDepth () const
 Return the depth of this image (size along dimension 2). More...
 
void setSize (Size width)
 Reset the size of the image to be 1D with the given width. More...
 
void setSize (Size width, Size height)
 Reset the size of the image to be 2D with the given width and height. More...
 
void setSize (Size width, Size height, Size depth)
 Reset the size of the image to be 3D with the given width, height, and depth. More...
 
void setSize (const Size *sizes, Size numDimensions)
 Reset the size of the image to be an arbitrary number of dimensions. More...
 
Size getPixelCount () const
 Return the total number of pixels in the image. More...
 
Size getSizeInBytes () const
 Return the total size in bytes of the image's pixel data. More...
 
const PixelFormatgetPixelFormat () const
 Return an object that describes the pixel format of this image. More...
 
void setPixelFormat (const PixelFormat &newPixelFormat)
 Change the pixel format of this image. More...
 
UBytegetPixelData ()
 Return a pointer to the pixel data for this image. More...
 
const UBytegetPixelData () const
 Return a const pointer to the pixel data for this image. More...
 
Bool isAllocated () const
 Return whether or not this image has allocated any memory for pixel data. More...
 
Bool allocate ()
 Allocate memory for this image's pixel data and return if the memory was successfully allocated. More...
 
Bool deallocate ()
 Free memory for this image's pixel data and return if the memory was successfully freed. More...
 
Bool isValid () const
 Return whether or not this image has valid pixel data and format. More...
 
const ImageFormatgetFormat () const
 Return an object that describes the perferred encoded format of this image. More...
 
void setFormat (const ImageFormat &newFormat)
 Change the preferred encoded format of this image. More...
 
ImageFormatSettingsgetFormatSettings ()
 Return the settings for the preferred encoded format of this image. More...
 
const ImageFormatSettingsgetFormatSettings () const
 Return the settings for the preferred encoded format of this image. More...
 
void setFormatSettings (const ImageFormatSettings &newFormatSettings)
 Change the settings for the preferred encoded format of this image. More...
 
Bool hasEncodedData () const
 Return whether or not this image has any encoded data. More...
 
UBytegetEncodedData ()
 Return a pointer to the encoded data for this image. More...
 
const UBytegetEncodedData () const
 Return a pointer to the encoded data for this image. More...
 
Size getEncodedDataSize () const
 Return the size in bytes of the encoded data for this image. More...
 
Bool setEncodedDataSize (Size newEncodedDataSize)
 Set the size of the encoded data for this image. More...
 
Bool setEncodedData (const UByte *newEncodedData, Size newEncodedDataSize)
 Set the encoded data for this image. More...
 
Bool setEncodedData (const UByte *newEncodedData, Size newEncodedDataSize, const ImageFormat &format)
 Set the encoded data for this image. More...
 
void clearEncodedData ()
 Deallocate any previous encoded image data. More...
 

Static Public Attributes

static const om::resources::ResourceType RESOURCE_TYPE
 The resource type for an image. More...
 

Detailed Description

A class that stores packed pixel data for images with an arbitrary number of dimensions.

Constructor & Destructor Documentation

om::images::base::Image::Image ( )

Create an empty image with UNDEFINED pixel format.

om::images::base::Image::Image ( const PixelFormat newPixelFormat,
Size  width 
)

Create a 1D image object with the specified pixel format and width.

No pixel data is initially allocated for the image.

om::images::base::Image::Image ( const PixelFormat newPixelFormat,
Size  width,
Size  height 
)

Create a 2D image object with the specified pixel format, width and height.

No pixel data is initially allocated for the image.

om::images::base::Image::Image ( const PixelFormat newPixelFormat,
Size  width,
Size  height,
Size  depth 
)

Create a 3D image object with the specified pixel format, width, height and depth.

No pixel data is initially allocated for the image.

om::images::base::Image::Image ( const PixelFormat newPixelFormat,
const Size sizes,
Size  numDimensions 
)

Create an image object with the specified pixel format and an arbitrary number of dimensions.

The user specifies the number of dimensions in the image and a pointer to an array of sizes along each dimension.

No pixel data is initially allocated for the image.

om::images::base::Image::Image ( const Image image)

Construct a copy of another image, copying its internal format and pixel data.

om::images::base::Image::~Image ( )

Destroy an image and release its internal pixel data.

Member Function Documentation

Image& om::images::base::Image::operator= ( const Image other)

Assign the state of another image to this one.

Size om::images::base::Image::getDimensionCount ( ) const
inline

Return the number of dimensions in this image, usually 1, 2, or 3.

A 1D image is an array of pixels, a 2D image is a plane of pixels, a 3D image is a rectangular volume of voxels, etc.

const Size* om::images::base::Image::getSizes ( ) const
inline

Return a pointer to an array containing the size along each dimension of this image.

Size om::images::base::Image::getSize ( Index  dimension) const
inline

Return the size of the image along the specified dimension index.

Indices start from 0 and count to d-1 for a image with d dimensions. If the specified dimension index is out of bounds, 1 is returned.

Size om::images::base::Image::getSize1D ( ) const
inline

Return the size of the image assuming it is a 1D image.

Size2D om::images::base::Image::getSize2D ( ) const
inline

Return the size of the image assuming it is a 2D image.

Size3D om::images::base::Image::getSize3D ( ) const
inline

Return the size of the image assuming it is a 3D image.

Size om::images::base::Image::getWidth ( ) const
inline

Return the width of this image (size along dimension 0).

If the dimension is not valid for this image, 1 is returned.

Size om::images::base::Image::getHeight ( ) const
inline

Return the height of this image (size along dimension 1).

If the dimension is not valid for this image, 1 is returned.

Size om::images::base::Image::getDepth ( ) const
inline

Return the depth of this image (size along dimension 2).

If the dimension is not valid for this image, 1 is returned.

void om::images::base::Image::setSize ( Size  width)

Reset the size of the image to be 1D with the given width.

This call deallocates any previously allocated image pixel data if the image size changes.

void om::images::base::Image::setSize ( Size  width,
Size  height 
)

Reset the size of the image to be 2D with the given width and height.

This call deallocates any previously allocated image pixel data if the image size changes.

void om::images::base::Image::setSize ( Size  width,
Size  height,
Size  depth 
)

Reset the size of the image to be 3D with the given width, height, and depth.

This call deallocates any previously allocated image pixel data if the image size changes.

void om::images::base::Image::setSize ( const Size sizes,
Size  numDimensions 
)

Reset the size of the image to be an arbitrary number of dimensions.

The user specifies the number of dimensions in the image and a pointer to an array of sizes along each dimension.

This call deallocates any previously allocated image pixel data if the image size changes.

Size om::images::base::Image::getPixelCount ( ) const

Return the total number of pixels in the image.

Size om::images::base::Image::getSizeInBytes ( ) const
inline

Return the total size in bytes of the image's pixel data.

const PixelFormat& om::images::base::Image::getPixelFormat ( ) const
inline

Return an object that describes the pixel format of this image.

void om::images::base::Image::setPixelFormat ( const PixelFormat newPixelFormat)

Change the pixel format of this image.

This call deallocates any previously allocated image pixel data if the pixel format has a different size in bytes. Otherwise, the image pixel data is unchanged but is now reinterpreted using the new pixel format.

UByte* om::images::base::Image::getPixelData ( )
inline

Return a pointer to the pixel data for this image.

If the image is not allocated, the method returns a NULL pointer.

const UByte* om::images::base::Image::getPixelData ( ) const
inline

Return a const pointer to the pixel data for this image.

If the image is not allocated, the method returns a NULL pointer.

Bool om::images::base::Image::isAllocated ( ) const
inline

Return whether or not this image has allocated any memory for pixel data.

Bool om::images::base::Image::allocate ( )

Allocate memory for this image's pixel data and return if the memory was successfully allocated.

The resulting contents of the image are undefined if it was previously not allocated.

Bool om::images::base::Image::deallocate ( )

Free memory for this image's pixel data and return if the memory was successfully freed.

The image deallocates its internal pixel data but retains its size information and pixel format.

Bool om::images::base::Image::isValid ( ) const
inline

Return whether or not this image has valid pixel data and format.

const ImageFormat& om::images::base::Image::getFormat ( ) const
inline

Return an object that describes the perferred encoded format of this image.

void om::images::base::Image::setFormat ( const ImageFormat newFormat)

Change the preferred encoded format of this image.

This call deallocates the image's encoded data if it was allocated and the new format is not compatible with the previous encoded data format.

ImageFormatSettings& om::images::base::Image::getFormatSettings ( )
inline

Return the settings for the preferred encoded format of this image.

const ImageFormatSettings& om::images::base::Image::getFormatSettings ( ) const
inline

Return the settings for the preferred encoded format of this image.

void om::images::base::Image::setFormatSettings ( const ImageFormatSettings newFormatSettings)
inline

Change the settings for the preferred encoded format of this image.

Bool om::images::base::Image::hasEncodedData ( ) const
inline

Return whether or not this image has any encoded data.

UByte* om::images::base::Image::getEncodedData ( )
inline

Return a pointer to the encoded data for this image.

If the returned pointer is NULL, it indicates the start of memory containing the image's encoded data in its format.

const UByte* om::images::base::Image::getEncodedData ( ) const
inline

Return a pointer to the encoded data for this image.

If the returned pointer is NULL, it indicates the start of memory containing the image's encoded data in its format.

Size om::images::base::Image::getEncodedDataSize ( ) const
inline

Return the size in bytes of the encoded data for this image.

Bool om::images::base::Image::setEncodedDataSize ( Size  newEncodedDataSize)

Set the size of the encoded data for this image.

The image allocates internal space for the specified number of bytes of encoded image data. The contents of the encoded data are undefined.

Bool om::images::base::Image::setEncodedData ( const UByte newEncodedData,
Size  newEncodedDataSize 
)

Set the encoded data for this image.

The image copies the image data to internal memory and the current image format is used. The method returns whether or not the operation was successful.

Bool om::images::base::Image::setEncodedData ( const UByte newEncodedData,
Size  newEncodedDataSize,
const ImageFormat format 
)

Set the encoded data for this image.

The image copies the image data to internal memory and the image format is set to the specified format. The method returns whether or not the operation was successful.

void om::images::base::Image::clearEncodedData ( )

Deallocate any previous encoded image data.

This method is used to discard a previously encoded version of an image so that will be re-encoded when it is next saved. This method should be called whenever an image's pixel data is edited.

Member Data Documentation

const om::resources::ResourceType om::images::base::Image::RESOURCE_TYPE
static

The resource type for an image.


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