![]() |
Cinder
0.9.1
|
#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 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 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) |
An in-memory representation of an image. Implicitly shared object.
cinder::SurfaceT< T >::SurfaceT | ( | ) |
A null Surface.
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.
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.
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.
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.
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.
cinder::SurfaceT< T >::SurfaceT | ( | SurfaceT< T > && | rhs | ) |
Surface move constructor.
|
static |
Creates a SurfaceRef of size width X height, with an optional alpha channel. The default value for channelOrder selects a platform default.
|
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.
|
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.
|
static |
Creates a SurfaceRef from an imageSource and optional constraints. Default value for alpha chooses one based on the contents of the ImageSource.
|
static |
Creates s SurfaceRef which is a clone of the Surface surface, and with its own dataStore.
SurfaceT< T > & cinder::SurfaceT< T >::operator= | ( | const SurfaceT< T > & | rhs | ) |
SurfaceT< T > & cinder::SurfaceT< T >::operator= | ( | SurfaceT< T > && | rhs | ) |
cinder::SurfaceT< T >::operator ImageSourceRef | ( | ) | const |
cinder::SurfaceT< T >::operator ImageTargetRef | ( | ) |
int32_t cinder::SurfaceT< T >::getWidth | ( | ) | const |
Returns the width of the Surface in pixels.
int32_t cinder::SurfaceT< T >::getHeight | ( | ) | const |
Returns the height of the Surface in pixels.
ivec2 cinder::SurfaceT< T >::getSize | ( | ) | const |
Returns the size of the Surface in pixels.
float cinder::SurfaceT< T >::getAspectRatio | ( | ) | const |
Returns the Surface aspect ratio, which is its width / height.
Area cinder::SurfaceT< T >::getBounds | ( | ) | const |
Returns the bounding Area of the Surface in pixels: [0,0]-(width,height)
bool cinder::SurfaceT< T >::hasAlpha | ( | ) | const |
Returns whether the Surface contains an alpha channel.
bool cinder::SurfaceT< T >::isPremultiplied | ( | ) | const |
Returns whether the Surface color data is premultiplied by its alpha channel or not.
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.
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()
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.
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)
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.
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.
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.
const T* cinder::SurfaceT< T >::getData | ( | ) | const |
T* cinder::SurfaceT< T >::getData | ( | const ivec2 & | offset | ) |
const T* cinder::SurfaceT< T >::getData | ( | const ivec2 & | offset | ) | const |
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.
const T* cinder::SurfaceT< T >::getDataRed | ( | const ivec2 & | offset | ) | const |
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.
const T* cinder::SurfaceT< T >::getDataGreen | ( | const ivec2 & | offset | ) | const |
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.
const T* cinder::SurfaceT< T >::getDataBlue | ( | const ivec2 & | offset | ) | const |
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.
const T* cinder::SurfaceT< T >::getDataAlpha | ( | const ivec2 & | offset | ) | const |
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.
const SurfaceChannelOrder& cinder::SurfaceT< T >::getChannelOrder | ( | ) | const |
Returns the channel order of the Surface, the in-memory ordering of the channels of each pixel.
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.
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.
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.
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.
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.
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.
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.
ChannelT<T>& cinder::SurfaceT< T >::getChannelRed | ( | ) |
Returns a reference to the red Channel of the Surface
ChannelT<T>& cinder::SurfaceT< T >::getChannelGreen | ( | ) |
Returns a reference to the green Channel of the Surface
ChannelT<T>& cinder::SurfaceT< T >::getChannelBlue | ( | ) |
Returns a reference to the blue Channel of the Surface
ChannelT<T>& cinder::SurfaceT< T >::getChannelAlpha | ( | ) |
Returns a reference to the alpha Channel of the Surface. Undefined in the absence of an alpha channel.
const ChannelT<T>& cinder::SurfaceT< T >::getChannelRed | ( | ) | const |
Returns a const reference to the red Channel of the Surface
const ChannelT<T>& cinder::SurfaceT< T >::getChannelGreen | ( | ) | const |
Returns a const reference to the green Channel of the Surface
const ChannelT<T>& cinder::SurfaceT< T >::getChannelBlue | ( | ) | const |
Returns a const reference to the blue Channel of the Surface
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.
ColorAT<T> cinder::SurfaceT< T >::getPixel | ( | ivec2 | pos | ) | const |
Convenience method for getting a single pixel. For performance-sensitive code consider Surface::Iter instead.
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.
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.
void cinder::SurfaceT< T >::copyFrom | ( | const SurfaceT< T > & | srcSurface, |
const Area & | srcArea, | ||
const ivec2 & | relativeOffset = ivec2() |
||
) |
ColorT< T > cinder::SurfaceT< T >::areaAverage | ( | const Area & | area | ) | const |
Returns an averaged color for the Area defined by area.
Iter cinder::SurfaceT< T >::getIter | ( | ) |
Returns an Iter which iterates the entire Surface.
Iter cinder::SurfaceT< T >::getIter | ( | const Area & | area | ) |
ConstIter cinder::SurfaceT< T >::getIter | ( | ) | const |
Returns a ConstIter which iterates the entire Surface.
ConstIter cinder::SurfaceT< T >::getIter | ( | const Area & | area | ) | const |