# Cinder

# cinder::SurfaceT< T > Class Template Reference

`#include <Surface.h>`

List of all members.

## Classes
class | ConstIter
class | Iter
## Public Member Functions
| SurfaceT ()
| SurfaceT (int32_t aWidth, int32_t aHeight, bool alpha, SurfaceChannelOrder aChannelOrder=SurfaceChannelOrder::UNSPECIFIED)
| SurfaceT (int32_t aWidth, int32_t aHeight, bool alpha, const SurfaceConstraints &constraints)
| SurfaceT (T *aData, int32_t aWidth, int32_t aHeight, int32_t aRowBytes, SurfaceChannelOrder aChannelOrder)
| SurfaceT (shared_ptr< class ImageSource > imageSource, const SurfaceConstraints &constraints=SurfaceConstraintsDefault(), boost::tribool alpha=boost::logic::indeterminate)
| operator ImageSourceRef () const
int32_t | getWidth () const
| Returns the width of the Surface in pixels.
int32_t | getHeight () const
| Returns the height of the Surface in pixels.
Vec2i | getSize () const
| Returns the size of the Surface in pixels.
float | getAspectRatio () const
| Returns the Surface aspect ratio, which is its width / height.
Area | getBounds () const
| Returns the bounding Area of the Surface in pixels: [0,0]-(width,height).
bool | hasAlpha () const
| Returns whether the Surface contains an alpha channel.
bool | isPremultiplied () const
| Returns whether the Surface color data is premultiplied by its alpha channel or not.
bool | setPremultiplied (bool premult=true) const
| Sets whether the Surface color data should be interpreted as being premultiplied by its alpha channel or not.
int32_t | getRowBytes () const
| Returns the width of a row of the Surface measured in bytes, which is not necessarily getWidth() * getPixelInc().
uint8_t | getPixelInc () const
| Returns the amount to increment a T* to increment by a pixel. Analogous to the number of channels, which is either 3 or 4.
SurfaceT | clone (bool copyPixels=true) const
| Returns a new Surface which is a duplicate. If copyPixels the pixel values are copied, otherwise the clone's pixels remain uninitialized.
SurfaceT | clone (const Area &area, bool copyPixels=true) const
| Returns a new Surface which is a duplicate of an Area area. If copyPixels the pixel values are copied, otherwise the clone's pixels remain uninitialized.
T * | getData ()
const T * | getData () const
T * | getData (const Vec2i &offset)
const T * | getData (const Vec2i &offset) const
T * | getDataRed (const Vec2i &offset)
const T * | getDataRed (const Vec2i &offset) const
T * | getDataGreen (const Vec2i &offset)
const T * | getDataGreen (const Vec2i &offset) const
T * | getDataBlue (const Vec2i &offset)
const T * | getDataBlue (const Vec2i &offset) const
T * | getDataAlpha (const Vec2i &offset)
const T * | getDataAlpha (const Vec2i &offset) const
void | setData (T *aData, int32_t aWidth, int32_t aHeight, int32_t aRowBytes)
void | setDeallocator (void(*aDeallocatorFunc)(void *), void *aDeallocatorRefcon)
const SurfaceChannelOrder & | getChannelOrder () const
uint8_t | getRedOffset () const
uint8_t | getGreenOffset () const
uint8_t | getBlueOffset () const
uint8_t | getAlphaOffset () const
void | setChannelOrder (const SurfaceChannelOrder &aChannelOrder)
ChannelT< T > * | getChannel (uint8_t ChannelT)
ChannelT< T > * | getChannelRed ()
ChannelT< T > * | getChannelGreen ()
ChannelT< T > * | getChannelBlue ()
ChannelT< T > * | getChannelAlpha ()
const ChannelT< T > * | getChannel (uint8_t ChannelT) const
const ChannelT< T > * | getChannelRed () const
const ChannelT< T > * | getChannelGreen () const
const ChannelT< T > * | getChannelBlue () const
const ChannelT< T > * | getChannelAlpha () const
ColorAT< T > | getPixel (Vec2i pos) const
| Convenience method for getting a single pixel. For performance-sensitive code consider Surface::Iter instead.
void | setPixel (Vec2i pos, const ColorT< T > &c)
| Convenience method for setting a single pixel. For performance-sensitive code consider SurfaceT<T>::Iter instead.
void | setPixel (Vec2i pos, const ColorAT< T > &c)
| Convenience method for setting a single pixel. For performance-sensitive code consider SurfaceT<T>::Iter instead.
void | copyFrom (const SurfaceT< T > &srcSurface, const Area &srcArea, const Vec2i &relativeOffset=Vec2i::zero())
ColorT< T > | areaAverage (const Area &area) const
Iter | getIter ()
Iter | getIter (const Area &area)
ConstIter | getIter () const
ConstIter | getIter (const Area &area) const
typedef shared_ptr< Obj > SurfaceT::* | unspecified_bool_type
| Emulates shared_ptr-like behavior.
| operator unspecified_bool_type ()
| Emulates shared_ptr-like behavior.
void | reset ()
| Emulates shared_ptr-like behavior.

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

## Member Typedef Documentation

template<typename T>

typedef shared_ptr<Obj> SurfaceT::* cinder::SurfaceT< T >::unspecified_bool_type

Emulates shared_ptr-like behavior.

## Constructor & Destructor Documentation

template<typename T>

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

template<typename T >

cinder::SurfaceT< T >::SurfaceT | ( | int32_t | aWidth,
|  | int32_t | aHeight,
|  | bool | alpha,
|  | SurfaceChannelOrder | aChannelOrder = `SurfaceChannelOrder::UNSPECIFIED` |
| ) |  |  |

template<typename T >

cinder::SurfaceT< T >::SurfaceT | ( | int32_t | aWidth,
|  | int32_t | aHeight,
|  | bool | alpha,
|  | const SurfaceConstraints & | constraints |
| ) |  |  |

template<typename T>

cinder::SurfaceT< T >::SurfaceT | ( | T * | aData,
|  | int32_t | aWidth,
|  | int32_t | aHeight,
|  | int32_t | aRowBytes,
|  | SurfaceChannelOrder | aChannelOrder |
| ) |  |  |

template<typename T>

cinder::SurfaceT< T >::SurfaceT | ( | shared_ptr< class ImageSource > | imageSource,
|  | const SurfaceConstraints & | constraints = `SurfaceConstraintsDefault()`,
|  | boost::tribool | alpha = `boost::logic::indeterminate` |
| ) |  |  |

## Member Function Documentation

template<typename T >

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

template<typename T>

int32_t cinder::SurfaceT< T >::getWidth | ( |  | ) | const

Returns the width of the Surface in pixels.

template<typename T>

int32_t cinder::SurfaceT< T >::getHeight | ( |  | ) | const

Returns the height of the Surface in pixels.

template<typename T>

Vec2i cinder::SurfaceT< T >::getSize | ( |  | ) | const

Returns the size of the Surface in pixels.

template<typename T>

float cinder::SurfaceT< T >::getAspectRatio | ( |  | ) | const

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

template<typename T>

Area cinder::SurfaceT< T >::getBounds | ( |  | ) | const

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

template<typename T>

bool cinder::SurfaceT< T >::hasAlpha | ( |  | ) | const

Returns whether the Surface contains an alpha channel.

template<typename T>

bool cinder::SurfaceT< T >::isPremultiplied | ( |  | ) | const

Returns whether the Surface color data is premultiplied by its alpha channel or not.

template<typename T>

bool cinder::SurfaceT< T >::setPremultiplied | ( | bool | premult = `true` | ) | const

Sets whether the Surface color data should be interpreted as being premultiplied by its alpha channel or not.

template<typename T>

int32_t cinder::SurfaceT< T >::getRowBytes | ( |  | ) | const

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

template<typename T>

uint8_t cinder::SurfaceT< T >::getPixelInc | ( |  | ) | const

Returns the amount to increment a T* to increment by a pixel. Analogous to the number of channels, which is either 3 or 4.

template<typename T >

SurfaceT< T > cinder::SurfaceT< T >::clone | ( | bool | copyPixels = `true` | ) | const

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

template<typename T >

SurfaceT< T > cinder::SurfaceT< T >::clone | ( | const Area & | area,
|  | bool | copyPixels = `true` |
| ) |  |  | const

Returns a new Surface 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>

T* cinder::SurfaceT< T >::getData | ( |  | ) |

template<typename T>

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

template<typename T>

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

template<typename T>

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

template<typename T>

T* cinder::SurfaceT< T >::getDataRed | ( | const Vec2i & | offset | ) |

template<typename T>

const T* cinder::SurfaceT< T >::getDataRed | ( | const Vec2i & | offset | ) | const

template<typename T>

T* cinder::SurfaceT< T >::getDataGreen | ( | const Vec2i & | offset | ) |

template<typename T>

const T* cinder::SurfaceT< T >::getDataGreen | ( | const Vec2i & | offset | ) | const

template<typename T>

T* cinder::SurfaceT< T >::getDataBlue | ( | const Vec2i & | offset | ) |

template<typename T>

const T* cinder::SurfaceT< T >::getDataBlue | ( | const Vec2i & | offset | ) | const

template<typename T>

T* cinder::SurfaceT< T >::getDataAlpha | ( | const Vec2i & | offset | ) |

template<typename T>

const T* cinder::SurfaceT< T >::getDataAlpha | ( | const Vec2i & | offset | ) | const

template<typename T>

void cinder::SurfaceT< T >::setData | ( | T * | aData,
|  | int32_t | aWidth,
|  | int32_t | aHeight,
|  | int32_t | aRowBytes |
| ) |  |  |

template<typename T >

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

Set's the deallocator, an optional callback which will fire upon the Surface::Obj's destruction. This is useful when a Surface is wrapping another API's image data structure whose lifetime is tied to the Surface's.

template<typename T>

const SurfaceChannelOrder& cinder::SurfaceT< T >::getChannelOrder | ( |  | ) | const

template<typename T>

uint8_t cinder::SurfaceT< T >::getRedOffset | ( |  | ) | const

template<typename T>

uint8_t cinder::SurfaceT< T >::getGreenOffset | ( |  | ) | const

template<typename T>

uint8_t cinder::SurfaceT< T >::getBlueOffset | ( |  | ) | const

template<typename T>

uint8_t cinder::SurfaceT< T >::getAlphaOffset | ( |  | ) | const

template<typename T >

void cinder::SurfaceT< T >::setChannelOrder | ( | const SurfaceChannelOrder & | aChannelOrder | ) |

template<typename T>

ChannelT<T>* cinder::SurfaceT< T >::getChannel | ( | uint8_t | ChannelT | ) |

template<typename T>

ChannelT<T>* cinder::SurfaceT< T >::getChannelRed | ( |  | ) |

template<typename T>

ChannelT<T>* cinder::SurfaceT< T >::getChannelGreen | ( |  | ) |

template<typename T>

ChannelT<T>* cinder::SurfaceT< T >::getChannelBlue | ( |  | ) |

template<typename T>

ChannelT<T>* cinder::SurfaceT< T >::getChannelAlpha | ( |  | ) |

template<typename T>

const ChannelT<T>* cinder::SurfaceT< T >::getChannel | ( | uint8_t | ChannelT | ) | const

template<typename T>

const ChannelT<T>* cinder::SurfaceT< T >::getChannelRed | ( |  | ) | const

template<typename T>

const ChannelT<T>* cinder::SurfaceT< T >::getChannelGreen | ( |  | ) | const

template<typename T>

const ChannelT<T>* cinder::SurfaceT< T >::getChannelBlue | ( |  | ) | const

template<typename T>

const ChannelT<T>* cinder::SurfaceT< T >::getChannelAlpha | ( |  | ) | const

template<typename T>

ColorAT<T> cinder::SurfaceT< T >::getPixel | ( | Vec2i | pos | ) | const

Convenience method for getting a single pixel. For performance-sensitive code consider Surface::Iter instead.

template<typename T>

void cinder::SurfaceT< T >::setPixel | ( | Vec2i | pos,
|  | const ColorT< T > & | c |
| ) |  |  |

Convenience method for setting a single pixel. For performance-sensitive code consider SurfaceT<T>::Iter instead.

template<typename T>

void cinder::SurfaceT< T >::setPixel | ( | Vec2i | pos,
|  | const ColorAT< T > & | c |
| ) |  |  |

Convenience method for setting a single pixel. For performance-sensitive code consider SurfaceT<T>::Iter instead.

template<typename T>

void cinder::SurfaceT< T >::copyFrom | ( | const SurfaceT< T > & | srcSurface,
|  | const Area & | srcArea,
|  | const Vec2i & | relativeOffset = `Vec2i::zero()` |
| ) |  |  |

template<typename T >

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

template<typename T>

cinder::SurfaceT< T >::operator unspecified_bool_type | ( |  | ) |

Emulates shared_ptr-like behavior.

template<typename T>

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

Emulates shared_ptr-like behavior.

template<typename T>

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

template<typename T>

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

template<typename T>

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

template<typename T>

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

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

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