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

#include <Surface.h>

Classes

class  ConstIter
 
class  Iter
 

Public Member Functions

 SurfaceT ()
 
 SurfaceT (int32_t width, int32_t height, bool alpha, SurfaceChannelOrder channelOrder=SurfaceChannelOrder::UNSPECIFIED)
 
 SurfaceT (int32_t width, int32_t height, bool alpha, const SurfaceConstraints &constraints)
 
 SurfaceT (T *data, int32_t width, int32_t height, int32_t rowBytes, SurfaceChannelOrder channelOrder)
 
 SurfaceT (ImageSourceRef imageSource, const SurfaceConstraints &constraints=SurfaceConstraintsDefault(), boost::tribool alpha=boost::logic::indeterminate)
 
 SurfaceT (const SurfaceT &rhs)
 
 SurfaceT (SurfaceT &&rhs)
 
SurfaceT< T > & operator= (const SurfaceT< T > &rhs)
 
SurfaceT< T > & operator= (SurfaceT< T > &&rhs)
 
 operator ImageSourceRef () const
 
 operator ImageTargetRef ()
 
int32_t getWidth () const
 
int32_t getHeight () const
 
ivec2 getSize () const
 
float getAspectRatio () const
 
Area getBounds () const
 
bool hasAlpha () const
 
bool isPremultiplied () const
 
void setPremultiplied (bool premult=true)
 
int32_t getRowBytes () const
 
uint8_t getPixelInc () const
 
uint8_t getPixelBytes () const
 
SurfaceT clone (bool copyPixels=true) const
 
SurfaceT clone (const Area &area, bool copyPixels=true) const
 
T * getData ()
 
const T * getData () const
 
T * getData (const ivec2 &offset)
 
const T * getData (const ivec2 &offset) const
 
T * getDataRed (const ivec2 &offset)
 
const T * getDataRed (const ivec2 &offset) const
 
T * getDataGreen (const ivec2 &offset)
 
const T * getDataGreen (const ivec2 &offset) const
 
T * getDataBlue (const ivec2 &offset)
 
const T * getDataBlue (const ivec2 &offset) const
 
T * getDataAlpha (const ivec2 &offset)
 
const T * getDataAlpha (const ivec2 &offset) const
 
std::shared_ptr< T > getDataStore () const
 
const SurfaceChannelOrdergetChannelOrder () 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 channelIndex)
 
const ChannelT< T > & getChannel (uint8_t channelIndex) const
 
ChannelT< T > & getChannelRed ()
 
ChannelT< T > & getChannelGreen ()
 
ChannelT< T > & getChannelBlue ()
 
ChannelT< T > & getChannelAlpha ()
 
const ChannelT< T > & getChannelRed () const
 
const ChannelT< T > & getChannelGreen () const
 
const ChannelT< T > & getChannelBlue () const
 
const ChannelT< T > & getChannelAlpha () const
 
ColorAT< T > getPixel (ivec2 pos) const
 
void setPixel (ivec2 pos, const ColorT< T > &c)
 
void setPixel (ivec2 pos, const ColorAT< T > &c)
 
void copyFrom (const SurfaceT< T > &srcSurface, const Area &srcArea, const ivec2 &relativeOffset=ivec2())
 
ColorT< T > areaAverage (const Area &area) 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< SurfaceT< T > > create (int32_t width, int32_t height, bool alpha, SurfaceChannelOrder channelOrder=SurfaceChannelOrder::UNSPECIFIED)
 
static std::shared_ptr< SurfaceT< T > > create (int32_t width, int32_t height, bool alpha, const SurfaceConstraints &constraints)
 
static std::shared_ptr< SurfaceT< T > > create (T *data, int32_t width, int32_t height, int32_t rowBytes, SurfaceChannelOrder channelOrder)
 
static std::shared_ptr< SurfaceT< T > > create (ImageSourceRef imageSource, const SurfaceConstraints &constraints=SurfaceConstraintsDefault(), boost::tribool alpha=boost::logic::indeterminate)
 
static std::shared_ptr< SurfaceT< T > > create (const SurfaceT< T > &surface)
 

Detailed Description

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

An in-memory representation of an image. Implicitly shared object.

Constructor & Destructor Documentation

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

A null Surface.

template<typename T >
cinder::SurfaceT< T >::SurfaceT ( int32_t  width,
int32_t  height,
bool  alpha,
SurfaceChannelOrder  channelOrder = SurfaceChannelOrder::UNSPECIFIED 
)

Allocates a Surface of size width X height, with an optional alpha channel. The default value for channelOrder selects a platform default.

template<typename T >
cinder::SurfaceT< T >::SurfaceT ( int32_t  width,
int32_t  height,
bool  alpha,
const SurfaceConstraints constraints 
)

Allocates a Surface of size width X height, with an optional alpha channel. constraints allows specification of channel order and rowBytes constraints as a function of width.

template<typename T>
cinder::SurfaceT< T >::SurfaceT ( T *  data,
int32_t  width,
int32_t  height,
int32_t  rowBytes,
SurfaceChannelOrder  channelOrder 
)

Constructs a surface from the memory pointed to by data. Does not assume ownership of the memory in data, which consequently should not be freed while the Surface is still in use.

template<typename T>
cinder::SurfaceT< T >::SurfaceT ( ImageSourceRef  imageSource,
const SurfaceConstraints constraints = SurfaceConstraintsDefault(),
boost::tribool  alpha = boost::logic::indeterminate 
)

Constructs a Surface from an imageSource and optional constraints. Default value for alpha chooses one based on the contents of the ImageSource.

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

Creates a clone of rhs. Matches rowBytes and channel order of rhs, but creates its own dataStore.

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

Surface move constructor.

Member Function Documentation

template<typename T>
static std::shared_ptr<SurfaceT<T> > cinder::SurfaceT< T >::create ( int32_t  width,
int32_t  height,
bool  alpha,
SurfaceChannelOrder  channelOrder = SurfaceChannelOrder::UNSPECIFIED 
)
static

Creates a SurfaceRef of size width X height, with an optional alpha channel. The default value for channelOrder selects a platform default.

template<typename T>
static std::shared_ptr<SurfaceT<T> > cinder::SurfaceT< T >::create ( int32_t  width,
int32_t  height,
bool  alpha,
const SurfaceConstraints constraints 
)
static

Creates a SurfaceRef of size width X height, with an optional alpha channel. constraints allows specification of channel order and rowBytes constraints as a function of width.

template<typename T>
static std::shared_ptr<SurfaceT<T> > cinder::SurfaceT< T >::create ( T *  data,
int32_t  width,
int32_t  height,
int32_t  rowBytes,
SurfaceChannelOrder  channelOrder 
)
static

Creates a SurfaceRef from the memory pointed to by data. Does not assume ownership of the memory in data, which consequently should not be freed while the Surface is still in use.

template<typename T>
static std::shared_ptr<SurfaceT<T> > cinder::SurfaceT< T >::create ( ImageSourceRef  imageSource,
const SurfaceConstraints constraints = SurfaceConstraintsDefault(),
boost::tribool  alpha = boost::logic::indeterminate 
)
static

Creates a SurfaceRef from an imageSource and optional constraints. Default value for alpha chooses one based on the contents of the ImageSource.

template<typename T>
static std::shared_ptr<SurfaceT<T> > cinder::SurfaceT< T >::create ( const SurfaceT< T > &  surface)
static

Creates s SurfaceRef which is a clone of the Surface surface, and with its own dataStore.

template<typename T>
SurfaceT< T > & cinder::SurfaceT< T >::operator= ( const SurfaceT< T > &  rhs)
template<typename T>
SurfaceT< T > & cinder::SurfaceT< T >::operator= ( SurfaceT< T > &&  rhs)
template<typename T >
cinder::SurfaceT< T >::operator ImageSourceRef ( ) const
template<typename T >
cinder::SurfaceT< T >::operator ImageTargetRef ( )
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>
ivec2 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>
void cinder::SurfaceT< T >::setPremultiplied ( bool  premult = true)

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>
uint8_t cinder::SurfaceT< T >::getPixelBytes ( ) const

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

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

Retuns the raw data of an image as a pointer to either uin8t_t values in the case of a Surface8u or floats in the case of a Surface32f.

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

Returns a pointer to the red channel data of the pixel located at offset. Result is a uint8_t* for Surface8u and a float* for Surface32f.

template<typename T>
const T* cinder::SurfaceT< T >::getDataRed ( const ivec2 &  offset) const
template<typename T>
T* cinder::SurfaceT< T >::getDataGreen ( const ivec2 &  offset)

Returns a pointer to the green channel data of the pixel located at offset. Result is a uint8_t* for Surface8u and a float* for Surface32f.

template<typename T>
const T* cinder::SurfaceT< T >::getDataGreen ( const ivec2 &  offset) const
template<typename T>
T* cinder::SurfaceT< T >::getDataBlue ( const ivec2 &  offset)

Returns a pointer to the blue channel data of the pixel located at offset. Result is a uint8_t* for Surface8u and a float* for Surface32f.

template<typename T>
const T* cinder::SurfaceT< T >::getDataBlue ( const ivec2 &  offset) const
template<typename T>
T* cinder::SurfaceT< T >::getDataAlpha ( const ivec2 &  offset)

Returns a pointer to the alpha channel data of the pixel located at offset. Result is a uint8_t* for Surface8u and a float* for Surface32f. Undefined for Surfaces without an alpha channel.

template<typename T>
const T* cinder::SurfaceT< T >::getDataAlpha ( const ivec2 &  offset) const
template<typename T>
std::shared_ptr<T> cinder::SurfaceT< T >::getDataStore ( ) const

Returns the shared_ptr to the underlying pixel data. Maybe be nullptr if the Surface does not own its data.

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

Returns the channel order of the Surface, the in-memory ordering of the channels of each pixel.

template<typename T>
uint8_t cinder::SurfaceT< T >::getRedOffset ( ) const

Returns the in-memory offset relative to a pixel for the red data. For example, for RGBA, returns 0.

template<typename T>
uint8_t cinder::SurfaceT< T >::getGreenOffset ( ) const

Returns the in-memory offset relative to a pixel for the red data. For example, for RGBA, returns 1.

template<typename T>
uint8_t cinder::SurfaceT< T >::getBlueOffset ( ) const

Returns the in-memory offset relative to a pixel for the red data. For example, for RGBA, returns 2.

template<typename T>
uint8_t cinder::SurfaceT< T >::getAlphaOffset ( ) const

Returns the in-memory offset relative to a pixel for the red data. For example, for RGBA, returns 3. Returns SurfaceChannelOrder::INVALID in the absence of an alpha channel.

template<typename T >
void cinder::SurfaceT< T >::setChannelOrder ( const SurfaceChannelOrder aChannelOrder)

Sets the channel order of the Surface, the in-memory ordering of the channels of each pixel. Call does not modify any pixel data, but does modify its interpretation.

template<typename T>
ChannelT<T>& cinder::SurfaceT< T >::getChannel ( uint8_t  channelIndex)

Returns a reference to a Channel channelIndex indexed according to how the channels are arranged per the SurfaceChannelOrder.

template<typename T>
const ChannelT<T>& cinder::SurfaceT< T >::getChannel ( uint8_t  channelIndex) const

Returns a const reference to a Channel channelIndex indexed according to how the channels are arranged per the SurfaceChannelOrder.

template<typename T>
ChannelT<T>& cinder::SurfaceT< T >::getChannelRed ( )

Returns a reference to the red Channel of the Surface

template<typename T>
ChannelT<T>& cinder::SurfaceT< T >::getChannelGreen ( )

Returns a reference to the green Channel of the Surface

template<typename T>
ChannelT<T>& cinder::SurfaceT< T >::getChannelBlue ( )

Returns a reference to the blue Channel of the Surface

template<typename T>
ChannelT<T>& cinder::SurfaceT< T >::getChannelAlpha ( )

Returns a reference to the alpha Channel of the Surface. Undefined in the absence of an alpha channel.

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

Returns a const reference to the red Channel of the Surface

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

Returns a const reference to the green Channel of the Surface

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

Returns a const reference to the blue Channel of the Surface

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

Returns a const reference to the alpha Channel of the Surface. Undefined in the absence of an alpha channel.

template<typename T>
ColorAT<T> cinder::SurfaceT< T >::getPixel ( ivec2  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 ( ivec2  pos,
const ColorT< T > &  c 
)

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

template<typename T>
void cinder::SurfaceT< T >::setPixel ( ivec2  pos,
const ColorAT< T > &  c 
)

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

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

Copies the Area srcArea of the Surface srcSurface to this Surface. The destination Area is srcArea offset by relativeOffset.

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

Returns an averaged color for the Area defined by area.

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

Returns an Iter which iterates the entire Surface.

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

Returns an Iter which iterates the Area area.

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

Returns a ConstIter which iterates the entire Surface.

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

Returns a ConstIter which iterates the Area area.


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