OpenImageIO/oiio — pull request #531 by lgritz (2013-02-26 08:03:10+00:00)
Title: Iterators with wrap

This overhaul of ImageBuf iterators allows them to be created with a "wrap" mode. Choices are WrapBlack (default), WrapClamp, WrapPeriodic, and WrapMirror. It's very analogous to texture lookups.

So now (readable) iterators always point to some valid data and may always be dereferenced. They may point to a black pixel (every ImageBuf allocates one pixel sized bit of black that it can point iterators to), or clamp/wrap appropriately. This greatly simplifies the iterator loops in ImageBufAlgo functions, which used to be riddled with "if" statements about whether the iterator currently points to a valid existing pixel or not. Well, it will -- I haven't overhauled the IBA use of iterators yet; I figured this was more than enough for one review.

Also changed IB::getchannel and getpixel to take wrap, and removed the "unclamped" bool flag to the Iterator constructors (especially now that iterators point to valid data even when nominally out of range, you really always want unclamped iteration).