cinderChannelT

ConstIter /

#includecinder/Channel.h

Convenience class for iterating the pixels of a Channel. The iteration is const , performing read-only operations on the Channel.

The ConstIter 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 finds the maximum value in the Area \a area of \a channel:


Channel::ConstIter iter = channel.getIter( area );
uint8_t maxValue = 0;
while( iter.line() ) {
	while( iter.pixel() ) {
		if( iter.v() > maxValue )
			maxValue = 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

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