HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageBuf::Iterator< BUFT, USERT > Class Template Reference

#include <imagebuf.h>

+ Inheritance diagram for ImageBuf::Iterator< BUFT, USERT >:

Public Member Functions

 Iterator (ImageBuf &ib, WrapMode wrap=WrapDefault)
 
 Iterator (ImageBuf &ib, int x, int y, int z=0, WrapMode wrap=WrapDefault)
 
 Iterator (ImageBuf &ib, const ROI &roi, WrapMode wrap=WrapDefault)
 Construct read-write iteration region from ImageBuf and ROI. More...
 
 Iterator (ImageBuf &ib, int xbegin, int xend, int ybegin, int yend, int zbegin=0, int zend=1, WrapMode wrap=WrapDefault)
 
 Iterator (Iterator &i)
 
 ~Iterator ()
 
const Iteratoroperator= (const Iterator &i)
 
DataArrayProxy< BUFT, USERT > & operator* ()
 
USERT operator[] (int i) const
 
DataProxy< BUFT, USERT > operator[] (int i)
 
voidrawptr () const
 
void set_deep_samples (int n)
 
USERT deep_value (int c, int s) const
 Retrieve the deep data value of sample s of channel c. More...
 
uint32_t deep_value_uint (int c, int s) const
 
void set_deep_value (int c, int s, float value)
 
void set_deep_value (int c, int s, uint32_t value)
 
- Public Member Functions inherited from ImageBuf::IteratorBase
 IteratorBase (const ImageBuf &ib, WrapMode wrap)
 
 IteratorBase (const ImageBuf &ib, const ROI &roi, WrapMode wrap)
 Construct valid iteration region from ImageBuf and ROI. More...
 
 IteratorBase (const ImageBuf &ib, int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, WrapMode wrap)
 
 IteratorBase (const IteratorBase &i)
 
 ~IteratorBase ()
 
const IteratorBaseassign_base (const IteratorBase &i)
 
int x () const
 
int y () const
 
int z () const
 
bool valid () const
 Is the current location within the designated iteration range? More...
 
bool valid (int x_, int y_, int z_=0) const
 
bool exists (int x_, int y_, int z_=0) const
 
bool exists () const
 
bool done () const
 Are we finished iterating over the region? More...
 
int deep_samples () const
 Retrieve the number of deep data samples at this pixel. More...
 
WrapMode wrap () const
 Return the wrap mode. More...
 
void pos (int x_, int y_, int z_=0)
 
OIIO_FORCEINLINE void operator++ ()
 
void operator++ (int)
 
ROI range () const
 Return the iteration range. More...
 
void rerange (int xbegin, int xend, int ybegin, int yend, int zbegin, int zend, WrapMode wrap=WrapDefault)
 

Additional Inherited Members

- Protected Member Functions inherited from ImageBuf::IteratorBase
void init_ib (WrapMode wrap)
 
void range_is_image ()
 
OIIO_FORCEINLINE void pos_xincr ()
 
void pos_done ()
 
void make_writable ()
 
void OIIO_API release_tile ()
 
- Protected Attributes inherited from ImageBuf::IteratorBase
const ImageBufm_ib = nullptr
 
bool m_valid = false
 
bool m_exists = false
 
bool m_deep = false
 
bool m_localpixels = false
 
int m_img_xbegin
 
int m_img_xend
 
int m_img_ybegin
 
int m_img_yend
 
int m_img_zbegin
 
int m_img_zend
 
int m_rng_xbegin
 
int m_rng_xend
 
int m_rng_ybegin
 
int m_rng_yend
 
int m_rng_zbegin
 
int m_rng_zend
 
int m_x
 
int m_y
 
int m_z
 
pvt::ImageCacheTile * m_tile = nullptr
 
int m_tilexbegin
 
int m_tileybegin
 
int m_tilezbegin
 
int m_tilexend
 
int m_nchannels
 
stride_t m_pixel_stride
 
char * m_proxydata = nullptr
 
WrapMode m_wrap = WrapBlack
 

Detailed Description

template<typename BUFT, typename USERT = float>
class ImageBuf::Iterator< BUFT, USERT >

Templated class for referring to an individual pixel in an ImageBuf, iterating over the pixels of an ImageBuf, or iterating over the pixels of a specified region of the ImageBuf [xbegin..xend) X [ybegin..yend). It is templated on BUFT, the type known to be in the internal representation of the ImageBuf, and USERT, the type that the user wants to retrieve or set the data (defaulting to float). the whole idea is to allow this:

ImageBuf img (...);
ImageBuf::Iterator<float> pixel (img, 0, 512, 0, 512);
for ( ; ! pixel.done(); ++pixel) {
for (int c = 0; c < img.nchannels(); ++c) {
float x = pixel[c];
pixel[c] = ...;
}
}

Definition at line 1562 of file imagebuf.h.

Constructor & Destructor Documentation

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::Iterator ( ImageBuf ib,
WrapMode  wrap = WrapDefault 
)
inline

Construct from just an ImageBuf – iterate over the whole region, starting with the upper left pixel of the region.

Definition at line 1566 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::Iterator ( ImageBuf ib,
int  x,
int  y,
int  z = 0,
WrapMode  wrap = WrapDefault 
)
inline

Construct from an ImageBuf and a specific pixel index. The iteration range is the full image.

Definition at line 1577 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::Iterator ( ImageBuf ib,
const ROI roi,
WrapMode  wrap = WrapDefault 
)
inline

Construct read-write iteration region from ImageBuf and ROI.

Definition at line 1585 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::Iterator ( ImageBuf ib,
int  xbegin,
int  xend,
int  ybegin,
int  yend,
int  zbegin = 0,
int  zend = 1,
WrapMode  wrap = WrapDefault 
)
inline

Construct from an ImageBuf and designated region – iterate over region, starting with the upper left pixel.

Definition at line 1596 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::Iterator ( Iterator< BUFT, USERT > &  i)
inline

Copy constructor.

Definition at line 1608 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
ImageBuf::Iterator< BUFT, USERT >::~Iterator ( )
inline

Definition at line 1615 of file imagebuf.h.

Member Function Documentation

template<typename BUFT, typename USERT = float>
USERT ImageBuf::Iterator< BUFT, USERT >::deep_value ( int  c,
int  s 
) const
inline

Retrieve the deep data value of sample s of channel c.

Definition at line 1661 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
uint32_t ImageBuf::Iterator< BUFT, USERT >::deep_value_uint ( int  c,
int  s 
) const
inline

Definition at line 1666 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
DataArrayProxy<BUFT, USERT>& ImageBuf::Iterator< BUFT, USERT >::operator* ( )
inline

Dereferencing the iterator gives us a proxy for the pixel, which we can index for reading or assignment.

Definition at line 1628 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
const Iterator& ImageBuf::Iterator< BUFT, USERT >::operator= ( const Iterator< BUFT, USERT > &  i)
inline

Assign one Iterator to another

Definition at line 1619 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
USERT ImageBuf::Iterator< BUFT, USERT >::operator[] ( int  i) const
inline

Array indexing retrieves the value of the i-th channel of the current pixel.

Definition at line 1635 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
DataProxy<BUFT, USERT> ImageBuf::Iterator< BUFT, USERT >::operator[] ( int  i)
inline

Array referencing retrieve a proxy (which may be "assigned to") of i-th channel of the current pixel, so that this works: me[i] = val;

Definition at line 1644 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
void* ImageBuf::Iterator< BUFT, USERT >::rawptr ( ) const
inline

Definition at line 1650 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
void ImageBuf::Iterator< BUFT, USERT >::set_deep_samples ( int  n)
inline

Set the number of deep data samples at this pixel. (Only use this if deep_alloc() has not yet been called on the buffer.)

Definition at line 1654 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
void ImageBuf::Iterator< BUFT, USERT >::set_deep_value ( int  c,
int  s,
float  value 
)
inline

Set the deep data value of sample s of channel c. (Only use this if deep_alloc() has been called.)

Definition at line 1673 of file imagebuf.h.

template<typename BUFT, typename USERT = float>
void ImageBuf::Iterator< BUFT, USERT >::set_deep_value ( int  c,
int  s,
uint32_t  value 
)
inline

Definition at line 1678 of file imagebuf.h.


The documentation for this class was generated from the following file: