Cinder  0.9.1
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cinder::ChannelT< T > Class Template Reference

#include <Channel.h>

Classes

class  ConstIter
 
class  Iter
 

Public Member Functions

 ChannelT ()
 
 ChannelT (int32_t width, int32_t height)
 
 ChannelT (int32_t width, int32_t height, int32_t rowBytes, uint8_t increment, T *data)
 
 ChannelT (int32_t width, int32_t height, int32_t rowBytes, uint8_t increment, T *data, const std::shared_ptr< T > &dataStore)
 
 ChannelT (const ChannelT &rhs)
 
 ChannelT (ChannelT &&rhs)
 
 ChannelT (const ImageSourceRef &imageSource)
 
ChannelToperator= (const ChannelT &rhs)
 
ChannelToperator= (ChannelT &&rhs)
 
 operator ImageSourceRef () const
 
ChannelT clone (bool copyPixels=true) const
 
ChannelT clone (const Area &area, bool copyPixels=true) const
 
int32_t getWidth () const
 
int32_t getHeight () const
 
ivec2 getSize () const
 
float getAspectRatio () const
 
Area getBounds () const
 
int32_t getRowBytes () const
 
uint8_t getIncrement () const
 
bool isPlanar () const
 
T * getData ()
 
const T * getData () const
 
T * getData (const ivec2 &offset)
 
const T * getData (const ivec2 &offset) const
 
T * getData (int32_t x, int32_t y)
 
const T * getData (int32_t x, int32_t y) const
 
getValue (ivec2 pos) const
 
void setValue (ivec2 pos, T v)
 
void copyFrom (const ChannelT< T > &srcChannel, const Area &srcArea, const ivec2 &relativeOffset=ivec2())
 
areaAverage (const Area &area) const
 
std::shared_ptr< T > getDataStore () const
 
Iter getIter ()
 
Iter getIter (const Area &area)
 
ConstIter getIter () const
 
ConstIter getIter (const Area &area) const
 

Static Public Member Functions

static std::shared_ptr< ChannelT< T > > create (int32_t width, int32_t height)
 
static std::shared_ptr< ChannelT< T > > create (int32_t width, int32_t height, int32_t rowBytes, uint8_t increment, T *data)
 
static std::shared_ptr< ChannelT< T > > create (int32_t width, int32_t height, int32_t rowBytes, uint8_t increment, T *data, const std::shared_ptr< T > &dataStore)
 
static std::shared_ptr< ChannelT< T > > create (const ChannelT &rhs)
 
static std::shared_ptr< ChannelT< T > > create (const ImageSourceRef &imageSource)
 

Protected Attributes

int32_t mWidth
 
int32_t mHeight
 
int32_t mRowBytes
 
uint8_t mIncrement
 
T * mData
 
std::shared_ptr< T > mDataStore
 

Detailed Description

template<typename T>
class cinder::ChannelT< T >

A single channel of image data, either a color channel of a Surface or a grayscale image. Implicitly shared object.

Constructor & Destructor Documentation

template<typename T >
cinder::ChannelT< T >::ChannelT ( )

An null Channel.

template<typename T >
cinder::ChannelT< T >::ChannelT ( int32_t  width,
int32_t  height 
)

Allocates and owns a contiguous block of memory that is sizeof(T) * width * height.

template<typename T>
cinder::ChannelT< T >::ChannelT ( int32_t  width,
int32_t  height,
int32_t  rowBytes,
uint8_t  increment,
T *  data 
)

Does not allocate or own memory pointed to by data.

template<typename T>
cinder::ChannelT< T >::ChannelT ( int32_t  width,
int32_t  height,
int32_t  rowBytes,
uint8_t  increment,
T *  data,
const std::shared_ptr< T > &  dataStore 
)

Does not allocate memory pointed to by data but holds a reference to dataStore.

template<typename T>
cinder::ChannelT< T >::ChannelT ( const ChannelT< T > &  rhs)

Creates a clone of rhs. Data is always stored planar regardless of the increment of rhs.

template<typename T>
cinder::ChannelT< T >::ChannelT ( ChannelT< T > &&  rhs)

Move constructor. Receives data store of rhs.

template<typename T>
cinder::ChannelT< T >::ChannelT ( const ImageSourceRef imageSource)

Creates a ChannelT by loading from an ImageSource imageSource.

Member Function Documentation

template<typename T >
ChannelT< T > & cinder::ChannelT< T >::operator= ( const ChannelT< T > &  rhs)
template<typename T >
ChannelT< T > & cinder::ChannelT< T >::operator= ( ChannelT< T > &&  rhs)
template<typename T >
cinder::ChannelT< T >::operator ImageSourceRef ( ) const
template<typename T>
static std::shared_ptr<ChannelT<T> > cinder::ChannelT< T >::create ( int32_t  width,
int32_t  height 
)
static

Allocates and owns a contiguous block of memory that is sizeof(T) * width * height.

template<typename T>
static std::shared_ptr<ChannelT<T> > cinder::ChannelT< T >::create ( int32_t  width,
int32_t  height,
int32_t  rowBytes,
uint8_t  increment,
T *  data 
)
static

Does not allocate or own memory pointed to by data.

template<typename T>
static std::shared_ptr<ChannelT<T> > cinder::ChannelT< T >::create ( int32_t  width,
int32_t  height,
int32_t  rowBytes,
uint8_t  increment,
T *  data,
const std::shared_ptr< T > &  dataStore 
)
static

Does not allocate memory pointed to by data but holds a reference to dataStore.

template<typename T>
static std::shared_ptr<ChannelT<T> > cinder::ChannelT< T >::create ( const ChannelT< T > &  rhs)
static

Creates a clone of rhs. Data is always stored planar regardless of the increment of rhs.

template<typename T>
static std::shared_ptr<ChannelT<T> > cinder::ChannelT< T >::create ( const ImageSourceRef imageSource)
static

Creates a ChannelT by loading from an ImageSource imageSource.

template<typename T >
ChannelT< T > cinder::ChannelT< T >::clone ( bool  copyPixels = true) const

Returns a new Channel which is a duplicate. If copyPixels the pixel values are copied, otherwise the clone's pixels remain uninitialized.

template<typename T >
ChannelT< T > cinder::ChannelT< T >::clone ( const Area area,
bool  copyPixels = true 
) const

Returns a new Channel which is a duplicate of an Area area. If copyPixels the pixel values are copied, otherwise the clone's pixels remain uninitialized.

template<typename T>
int32_t cinder::ChannelT< T >::getWidth ( ) const

Returns the width of the Channel in pixels.

template<typename T>
int32_t cinder::ChannelT< T >::getHeight ( ) const

Returns the height of the Channel in pixels.

template<typename T>
ivec2 cinder::ChannelT< T >::getSize ( ) const

Returns the size of the Channel in pixels.

template<typename T>
float cinder::ChannelT< T >::getAspectRatio ( ) const

Returns the Channel aspect ratio, which is its width / height.

template<typename T>
Area cinder::ChannelT< T >::getBounds ( ) const

Returns the bounding Area of the Channel in pixels: [0,0]-(width,height)

template<typename T>
int32_t cinder::ChannelT< T >::getRowBytes ( ) const

Returns the width of a row of the Channel measured in bytes, which is not necessarily getWidth() * getPixelInc()

template<typename T>
uint8_t cinder::ChannelT< T >::getIncrement ( ) const

Returns the amount to increment a T* to increment by a pixel. For a planar channel this is 1, but for a Channel of a Surface this might be 3 or 4.

template<typename T>
bool cinder::ChannelT< T >::isPlanar ( ) const

Returns whether the Channel represents a tightly packed array of values. This will be false if the Channel is a member of a Surface. Analogous to getIncrement() == 1

template<typename T>
T* cinder::ChannelT< T >::getData ( )

Returns a pointer to the data of the Channel's first pixel. Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
const T* cinder::ChannelT< T >::getData ( ) const

Returns a const pointer to the data of the Channel's first pixel. Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
T* cinder::ChannelT< T >::getData ( const ivec2 &  offset)

Returns a pointer to the data of the Channel's pixel at offset. Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
const T* cinder::ChannelT< T >::getData ( const ivec2 &  offset) const

Returns a const pointer to the data of the Channel's pixel at offset. Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
T* cinder::ChannelT< T >::getData ( int32_t  x,
int32_t  y 
)

Returns a pointer to the data of the Channel's pixel at (x, y). Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
const T* cinder::ChannelT< T >::getData ( int32_t  x,
int32_t  y 
) const

Returns a const pointer to the data of the Channel's pixel at (x, y). Result is a uint8_t* for Channel8u and a float* for Channel32f.

template<typename T>
T cinder::ChannelT< T >::getValue ( ivec2  pos) const

Convenience method for getting a single value at pixel pos. For performance-sensitive code consider Channel::Iter instead. Exhibits clamping behavior when outside Channel boundaries.

template<typename T>
void cinder::ChannelT< T >::setValue ( ivec2  pos,
v 
)

Convenience method for setting a single value v at pixel pos. For performance-sensitive code consider Channel::Iter instead. Exhibits clamping behavior when outside Channel boundaries.

template<typename T>
void cinder::ChannelT< T >::copyFrom ( const ChannelT< T > &  srcChannel,
const Area srcArea,
const ivec2 &  relativeOffset = ivec2() 
)

Copies the Area srcArea of the Channel srcChannel to this Channel. The destination Area is srcArea offset by relativeOffset.

template<typename T >
T cinder::ChannelT< T >::areaAverage ( const Area area) const

Returns an averaged value for the Area defined by area.

template<typename T>
std::shared_ptr<T> cinder::ChannelT< T >::getDataStore ( ) const

Returns the shared_ptr used to store the Channel's data. In general prefer getData() instead.

template<typename T>
Iter cinder::ChannelT< T >::getIter ( )

Returns an Iter which iterates the entire Channel.

template<typename T>
Iter cinder::ChannelT< T >::getIter ( const Area area)

Returns an Iter which iterates the Area area.

template<typename T>
ConstIter cinder::ChannelT< T >::getIter ( ) const

Returns a ConstIter which iterates the entire Channel.

template<typename T>
ConstIter cinder::ChannelT< T >::getIter ( const Area area) const

Returns a ConstIter which iterates the Area area.

Member Data Documentation

template<typename T>
int32_t cinder::ChannelT< T >::mWidth
protected
template<typename T>
int32_t cinder::ChannelT< T >::mHeight
protected
template<typename T>
int32_t cinder::ChannelT< T >::mRowBytes
protected
template<typename T>
uint8_t cinder::ChannelT< T >::mIncrement
protected
template<typename T>
T* cinder::ChannelT< T >::mData
protected
template<typename T>
std::shared_ptr<T> cinder::ChannelT< T >::mDataStore
protected

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