|
| Iter (SurfaceT< T > &SurfaceT, const Area &area) |
|
T & | r () const |
| Returns a reference to the red value of the pixel that the Iter currently points to. More...
|
|
T & | g () const |
| Returns a reference to the green value of the pixel that the Iter currently points to. More...
|
|
T & | b () const |
| Returns a reference to the blue value of the pixel that the Iter currently points to. More...
|
|
T & | a () const |
| Returns a reference to the alpha value of the pixel that the Iter currently points to. More...
|
|
T & | r (int32_t xOff, int32_t yOff) const |
| Returns a reference to the red value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. More...
|
|
T & | g (int32_t xOff, int32_t yOff) const |
| Returns a reference to the green value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. More...
|
|
T & | b (int32_t xOff, int32_t yOff) const |
| Returns a reference to the blue value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. More...
|
|
T & | a (int32_t xOff, int32_t yOff) const |
| Returns a reference to the alpha value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. Undefined in the absence of an alpha channel. More...
|
|
T & | rClamped (int32_t xOff, int32_t yOff) const |
| Returns a reference to the red value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. Clamps offset to the bounds of the Iter. More...
|
|
T & | gClamped (int32_t xOff, int32_t yOff) const |
| Returns a reference to the green value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. Clamps offset to the bounds of the Iter. More...
|
|
T & | bClamped (int32_t xOff, int32_t yOff) const |
| Returns a reference to the blue value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. Clamps offset to the bounds of the Iter. More...
|
|
T & | aClamped (int32_t xOff, int32_t yOff) const |
| Returns a reference to the alpha value of the pixel that the Iter currently points to, offset by (xOff, yOff) pixels. Clamps offset to the bounds of the Iter. Undefined in the absence of an alpha channel. More...
|
|
const int32_t | x () const |
| Returns the x coordinate of the pixel the Iter currently points to. More...
|
|
const int32_t | y () const |
| Returns the y coordinate of the pixel the Iter currently points to. More...
|
|
Vec2i | getPos () const |
| Returns the coordinate of the pixel the Iter currently points to. More...
|
|
bool | pixel () |
| Increments which pixel of the current row the Iter points to, and returns false when no pixels remain in the current row. More...
|
|
bool | line () |
| Increments which row the Iter points to, and returns false when no rows remain in the Surface. More...
|
|
int32_t | getWidth () const |
| Returns the width of the Area the Iter iterates. More...
|
|
int32_t | getHeight () const |
| Returns the height of the Area the Iter iterates. More...
|
|
template<typename T>
class cinder::SurfaceT< T >::Iter
Convenience class for iterating the pixels of a Surface.
The Iter class can be used to walk the pixels of a Surface using a nested for-loop, where the outer loop calls line(), and the inner calls pixel().
The code below implements an invert on the Area area of surface:
Surface::Iter iter = surface.getIter( area );
while( iter.line() ) {
while( iter.pixel() ) {
iter.r() = 255 - iter.r();
iter.g() = 255 - iter.g();
iter.b() = 255 - iter.b();
}
}
In addition to r(), g(), b() and a(), the Iter provides accessors which accept an offset in x & y relative to the current location:
inputIter.r(1, 1);
inputIter.b(0, -1);
A final family accessors, rClamped(), gClamped(), bClamped() and aClamped() also accept an x & y relative offset, but will not sample outside of the bounds of the iterator.
inputIter.rClamped(-2,0);
- See also
- Images in Cinder