cinderChannelT

Iter /

#includecinder/Channel.h

Convenience class for iterating the pixels of a Channel.

The Iter class can be used to walk the pixels of a Channel 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 \a area of \a channel:


Channel::Iter iter = channel.getIter( area );
while( iter.line() ) {
	while( iter.pixel() ) {
		iter.v() = 255 - iter.v();
	}
}

In addition to v(), the Iter provides an accessor which accepts an offset in x & y relative to the current location:


inputIter.v(1, 1); // will return the value of the pixel to the lower right of the current pixel
inputIter.v(0, -1); // will return the value of the pixel directly above the current pixel

A final accessor, vClamped() also accepts an x & y relative offset, but will not sample outside of the bounds of the iterator.


inputIter.vClamped(-2,0); // when called on the left edge of a row,
						  // this will simply return the left-most pixel's value

Public Member Functions

  • Iter (ChannelT< T > &channelT, const Area &area)