# Cinder

# cinder::ChannelT< T > Class Template Reference

`#include <Channel.h>`

List of all members.

## Classes
class | ConstIter
class | Iter
struct | Obj
## Public Member Functions
| ChannelT ()
| default constructor, creates an invalid ChannelT
| ChannelT (int32_t width, int32_t height)
| Allocates and owns a contiguous block of memory that is sizeof(T) * width * height.
| 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.
| ChannelT (ImageSourceRef imageSource)
| Creates a ChannelT by loading from an ImageSource imageSource.
| operator ImageSourceRef () const
ChannelT | 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.
ChannelT | 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.
int32_t | getWidth () const
| Returns the width of the Channel in pixels.
int32_t | getHeight () const
| Returns the height of the Channel in pixels.
Vec2i | getSize () const
| Returns the size of the Channel in pixels.
float | getAspectRatio () const
| Returns the Channel aspect ratio, which is its width / height.
Area | getBounds () const
| Returns the bounding Area of the Channel in pixels: [0,0]-(width,height).
int32_t | getRowBytes () const
| Returns the width of a row of the Channel measured in bytes, which is not necessarily getWidth() * getPixelInc().
uint8_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`.
bool | 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`
T * | getData ()
const T * | getData () const
T * | getData (const Vec2i &offset)
const T * | getData (const Vec2i &offset) const
T * | getData (int32_t x, int32_t y)
const T * | getData (int32_t x, int32_t y) const
T | getValue (Vec2i pos) const
| Convenience method for getting a single value. For performance-sensitive code consider Channel::Iter instead. Exhibits clamping behavior when outside Channel boundaries.
void | setValue (Vec2i pos, T v)
| Convenience method for setting a single value. For performance-sensitive code consider Channel::Iter instead. Exhibits clamping behavior when outside Channel boundaries.
void | copyFrom (const ChannelT< T > &srcChannel, const Area &srcArea, const Vec2i &relativeOffset=Vec2i::zero())
T | areaAverage (const Area &area) const
void | setDeallocator (void(*aDeallocatorFunc)(void *), void *aDeallocatorRefcon)
Iter | getIter ()
Iter | getIter (const Area &area)
ConstIter | getIter () const
ConstIter | getIter (const Area &area) const
## Protected Attributes
shared_ptr< Obj > | mObj
typedef shared_ptr< Obj > ::unspecified_bool_type | unspecified_bool_type
| Emulates shared_ptr-like behavior.
| operator unspecified_bool_type () const
| Emulates shared_ptr-like behavior.
void | reset ()
| Emulates shared_ptr-like behavior.

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

## Member Typedef Documentation

template<typename T>

typedef shared_ptr<Obj>::unspecified_bool_type cinder::ChannelT< T >::unspecified_bool_type

Emulates shared_ptr-like behavior.

## Constructor & Destructor Documentation

template<typename T>

cinder::ChannelT< T >::ChannelT | ( |  | ) |

default constructor, creates an invalid ChannelT

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 | ( | ImageSourceRef | imageSource | ) |

Creates a ChannelT by loading from an ImageSource imageSource.

## Member Function Documentation

template<typename T >

cinder::ChannelT< T >::operator ImageSourceRef | ( |  | ) | const

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>

Vec2i 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 | ( |  | ) |

template<typename T>

const T* cinder::ChannelT< T >::getData | ( |  | ) | const

template<typename T>

T* cinder::ChannelT< T >::getData | ( | const Vec2i & | offset | ) |

template<typename T>

const T* cinder::ChannelT< T >::getData | ( | const Vec2i & | offset | ) | const

template<typename T>

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

template<typename T>

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

template<typename T>

T cinder::ChannelT< T >::getValue | ( | Vec2i | pos | ) | const

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

template<typename T>

void cinder::ChannelT< T >::setValue | ( | Vec2i | pos,
|  | T | v |
| ) |  |  |

Convenience method for setting a single value. 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 Vec2i & | relativeOffset = `Vec2i::zero()` |
| ) |  |  |

template<typename T >

T cinder::ChannelT< T >::areaAverage | ( | const Area & | area | ) | const

template<typename T >

void cinder::ChannelT< T >::setDeallocator | ( | void(*)(void *) | aDeallocatorFunc,
|  | void * | aDeallocatorRefcon |
| ) |  |  |

template<typename T>

cinder::ChannelT< T >::operator unspecified_bool_type | ( |  | ) | const

Emulates shared_ptr-like behavior.

template<typename T>

void cinder::ChannelT< T >::reset | ( |  | ) |

Emulates shared_ptr-like behavior.

template<typename T>

Iter cinder::ChannelT< T >::getIter | ( |  | ) |

template<typename T>

Iter cinder::ChannelT< T >::getIter | ( | const Area & | area | ) |

template<typename T>

ConstIter cinder::ChannelT< T >::getIter | ( |  | ) | const

template<typename T>

ConstIter cinder::ChannelT< T >::getIter | ( | const Area & | area | ) | const

## Member Data Documentation

template<typename T>

shared_ptr<Obj> cinder::ChannelT< T >::mObj`[protected]`

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

- include/cinder/Channel.h
- src/cinder/Channel.cpp