FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Friends | List of all members
FotoSHOCKcore::ImageBuffer< PixelFormat > Class Template Reference

Class storing the image. More...

#include <ImageBuffer.hpp>

Inheritance diagram for FotoSHOCKcore::ImageBuffer< PixelFormat >:
FotoSHOCKcore::ImageBufferBase

Public Types

typedef ImageBufferIterator
< PixelFormat > 
Iterator
 Iterator used for data traversal in the ImageBuffer. More...
 

Public Member Functions

 ImageBuffer (unsigned int width, unsigned int height, PixelData pixelData, unsigned int tileExtent, bool allocateTiles=true)
 A constructor. More...
 
 ImageBuffer (const ImageBuffer< PixelFormat > &other)
 A copy constructor. More...
 
virtual ~ImageBuffer ()
 A destructor. More...
 
ImageBuffer< PixelFormat > & operator= (const ImageBuffer< PixelFormat > &other)
 An assignment operator. More...
 
void setStamp (long stamp)
 Set stamp for all Tiles. More...
 
Tile< PixelFormat > * getTile (unsigned int horizontal, unsigned int vertical)
 Get the given Tile. More...
 
Tile< PixelFormat > * getTileFromPos (unsigned int x, unsigned int y)
 Get a Tile storing the pixel at the given position in the image. More...
 
Iterator upperLeft ()
 Return ImageBufferIterator for the upper left corner of the ImageBuffer. More...
 
Iterator lowerRight ()
 Return ImageBufferIterator for the lower right corner of the ImageBuffer. More...
 
Iterator getIterator (unsigned int x, unsigned int y)
 Return ImageBufferIterator at the given position in the ImageBuffer. More...
 
- Public Member Functions inherited from FotoSHOCKcore::ImageBufferBase
const PixelDatagetPixelData () const
 Get the format of pixels in the buffer. More...
 
const unsigned int getWidth () const
 Get the width of the ImageBuffer in pixels. More...
 
const unsigned int getHeight () const
 Get the height of the ImageBuffer in pixels. More...
 
const unsigned int getTileExtent () const
 Get the size of a side of underlying Tiles in pixels. More...
 
const unsigned int getNumOfTilesHoriz () const
 Get the number of tiles in a grid in the horizontal dimension. More...
 
const unsigned int getNumOfTilesVert () const
 Get the number of tiles in a grid in the vertical dimension. More...
 
const long newStamp ()
 Get a new stamp for use with Tile::setStamp() function. More...
 

Friends

class ImageBufferIterator< PixelFormat >
 

Additional Inherited Members

- Protected Member Functions inherited from FotoSHOCKcore::ImageBufferBase
 ImageBufferBase ()
 Protected constructor. More...
 
- Protected Attributes inherited from FotoSHOCKcore::ImageBufferBase
PixelData m_pixelData
 
unsigned int m_width
 
unsigned int m_height
 
unsigned int m_tileExtent
 
unsigned int m_numOfTilesHorizontal
 
unsigned int m_numOfTilesVertical
 
long m_stamp
 

Detailed Description

template<ValueType::Enum PixelFormat>
class FotoSHOCKcore::ImageBuffer< PixelFormat >

Class storing the image.

The ImageBuffer encapsulates the access to image pixels. The image is divided into set of independent tiles (see Tile class). Pixels can be accessed using ImageBuffer::Iterator or by accessing tiles directly (faster).

Examples:
graph/example.cpp.

Member Typedef Documentation

template<ValueType::Enum PixelFormat>
typedef ImageBufferIterator<PixelFormat> FotoSHOCKcore::ImageBuffer< PixelFormat >::Iterator

Iterator used for data traversal in the ImageBuffer.

The iterator iterates over lines in the buffer.

Constructor & Destructor Documentation

template<ValueType::Enum PixelFormat>
FotoSHOCKcore::ImageBuffer< PixelFormat >::ImageBuffer ( unsigned int  width,
unsigned int  height,
PixelData  pixelData,
unsigned int  tileExtent,
bool  allocateTiles = true 
)

A constructor.

Constructs the ImageBuffer with specified attributes.

Parameters
widthwidth of the buffer in pixels
heightheight of the buffer in pixels
pixelDataPixelData structure describing the format of a pixel
tileExtentsize in pixels of a side of a Tile. The tileExtent mush be power of two.
allocateTilesif set to true (default) the tiles necessary to store image data are constructed along with the buffer
template<ValueType::Enum PixelFormat>
FotoSHOCKcore::ImageBuffer< PixelFormat >::ImageBuffer ( const ImageBuffer< PixelFormat > &  other)

A copy constructor.

Performs a deep copy.

Parameters
otherthe ImageBuffer to copy
template<ValueType::Enum PixelFormat>
FotoSHOCKcore::ImageBuffer< PixelFormat >::~ImageBuffer ( )
virtual

A destructor.

Frees any allocated memory

Member Function Documentation

template<ValueType::Enum PixelFormat>
ImageBuffer< PixelFormat >::Iterator FotoSHOCKcore::ImageBuffer< PixelFormat >::getIterator ( unsigned int  x,
unsigned int  y 
)

Return ImageBufferIterator at the given position in the ImageBuffer.

Parameters
xx coordinate
yy coordinate
Returns
iterator at the [x, y] coordinate
template<ValueType::Enum PixelFormat>
Tile< PixelFormat > * FotoSHOCKcore::ImageBuffer< PixelFormat >::getTile ( unsigned int  horizontal,
unsigned int  vertical 
)

Get the given Tile.

Get the pointer to a Tile. If the Tile doesn't exist yet, it's created. The numbering starts from 0.

Parameters
horizontalhorizontal position of a tile in the tile grid
verticalvertical position in a tile grid
Returns
pointer to a Tile
template<ValueType::Enum PixelFormat>
Tile< PixelFormat > * FotoSHOCKcore::ImageBuffer< PixelFormat >::getTileFromPos ( unsigned int  x,
unsigned int  y 
)

Get a Tile storing the pixel at the given position in the image.

Get the pointer to a Tile at the given position. If the Tile doesn't exist yet, it's created.

Parameters
xx coordinate
yy cordinate
Returns
pointer to a Tile
template<ValueType::Enum PixelFormat>
ImageBuffer< PixelFormat >::Iterator FotoSHOCKcore::ImageBuffer< PixelFormat >::lowerRight ( )

Return ImageBufferIterator for the lower right corner of the ImageBuffer.

Returns
iterator to the lower right corner
template<ValueType::Enum PixelFormat>
ImageBuffer< PixelFormat > & FotoSHOCKcore::ImageBuffer< PixelFormat >::operator= ( const ImageBuffer< PixelFormat > &  other)

An assignment operator.

Performs a deep copy of the data.

Parameters
otherthe source buffer
Returns
reference to the current ImageBuffer
template<ValueType::Enum PixelFormat>
void FotoSHOCKcore::ImageBuffer< PixelFormat >::setStamp ( long  stamp)

Set stamp for all Tiles.

A stamp is used to help operations identify whether they have alrey run on a specific buffer.

The stamp used should be obtained by calling the ImageBufferBase::newStamp() function.

Parameters
stampa stamp
template<ValueType::Enum PixelFormat>
ImageBuffer< PixelFormat >::Iterator FotoSHOCKcore::ImageBuffer< PixelFormat >::upperLeft ( )

Return ImageBufferIterator for the upper left corner of the ImageBuffer.

Returns
Iterator to the upper left corner

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