HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageBuf Class Reference

#include <imagebuf.h>

Classes

class  ConstIterator
 
class  Iterator
 
class  IteratorBase
 

Public Types

enum  IBStorage { UNINITIALIZED, LOCALBUFFER, APPBUFFER, IMAGECACHE }
 Description of where the pixels live for this ImageBuf. More...
 
enum  WrapMode {
  WrapDefault, WrapBlack, WrapClamp, WrapPeriodic,
  WrapMirror, _WrapLast
}
 

Public Member Functions

 ImageBuf ()
 
 ImageBuf (string_view name, int subimage=0, int miplevel=0, ImageCache *imagecache=NULL, const ImageSpec *config=NULL)
 
 ImageBuf (string_view name, ImageCache *imagecache)
 
 ImageBuf (const ImageSpec &spec)
 
 ImageBuf (string_view name, const ImageSpec &spec)
 
 ImageBuf (const ImageSpec &spec, void *buffer)
 
 ImageBuf (string_view name, const ImageSpec &spec, void *buffer)
 
 ImageBuf (const ImageBuf &src)
 
 ImageBuf (ImageBuf &&src)
 
 ~ImageBuf ()
 
void clear ()
 
void reset (string_view name, int subimage, int miplevel, ImageCache *imagecache=NULL, const ImageSpec *config=NULL)
 
void reset (string_view name, ImageCache *imagecache=NULL)
 
void reset (const ImageSpec &spec)
 
void reset (string_view name, const ImageSpec &spec)
 
const ImageBufoperator= (const ImageBuf &src)
 
const ImageBufoperator= (ImageBuf &&src)
 Move assignment. More...
 
IBStorage storage () const
 Which type of storage is being used for the pixels? More...
 
bool initialized () const
 Is this ImageBuf object initialized? More...
 
bool read (int subimage=0, int miplevel=0, bool force=false, TypeDesc convert=TypeDesc::UNKNOWN, ProgressCallback progress_callback=NULL, void *progress_callback_data=NULL)
 
bool read (int subimage, int miplevel, int chbegin, int chend, bool force, TypeDesc convert, ProgressCallback progress_callback=NULL, void *progress_callback_data=NULL)
 
bool init_spec (string_view filename, int subimage, int miplevel)
 
bool write (string_view filename, TypeDesc dtype=TypeUnknown, string_view fileformat=string_view(), ProgressCallback progress_callback=nullptr, void *progress_callback_data=nullptr) const
 
bool write (string_view filename, string_view fileformat, ProgressCallback progress_callback=nullptr, void *progress_callback_data=nullptr) const
 
void set_write_format (TypeDesc format)
 
void set_write_tiles (int width=0, int height=0, int depth=0)
 
bool write (ImageOutput *out, ProgressCallback progress_callback=NULL, void *progress_callback_data=NULL) const
 
bool make_writeable (bool keep_cache_type=false)
 
void copy_metadata (const ImageBuf &src)
 
bool copy_pixels (const ImageBuf &src)
 
bool copy (const ImageBuf &src, TypeDesc format=TypeUnknown)
 
ImageBuf copy (TypeDesc format) const
 
void swap (ImageBuf &other)
 Swap with another ImageBuf. More...
 
void error (const std::string &message) const
 Add simple string to the error message list for this IB. More...
 
template<typename... Args>
void fmterror (const char *fmt, const Args &...args) const
 
template<typename... Args>
void errorf (const char *fmt, const Args &...args) const
 Error reporting for ImageBuf: call this with printf-like arguments. More...
 
template<typename... Args>
void error (const char *fmt, const Args &...args) const
 
bool has_error (void) const
 
std::string geterror (void) const
 
const ImageSpecspec () const
 
ImageSpecspecmod ()
 
const ImageSpecnativespec () const
 
string_view name (void) const
 
string_view file_format_name (void) const
 
int subimage () const
 
int nsubimages () const
 
int miplevel () const
 
int nmiplevels () const
 
int nchannels () const
 
float getchannel (int x, int y, int z, int c, WrapMode wrap=WrapBlack) const
 
void getpixel (int x, int y, float *pixel, int maxchannels=1000) const
 
void getpixel (int x, int y, int z, float *pixel, int maxchannels=1000, WrapMode wrap=WrapBlack) const
 
void interppixel (float x, float y, float *pixel, WrapMode wrap=WrapBlack) const
 
void interppixel_NDC (float s, float t, float *pixel, WrapMode wrap=WrapBlack) const
 
void interppixel_NDC_full (float s, float t, float *pixel, WrapMode wrap=WrapBlack) const
 DEPCRECATED (1.5) synonym for interppixel_NDC. More...
 
void interppixel_bicubic (float x, float y, float *pixel, WrapMode wrap=WrapBlack) const
 
void interppixel_bicubic_NDC (float s, float t, float *pixel, WrapMode wrap=WrapBlack) const
 
void setpixel (int x, int y, const float *pixel, int maxchannels=1000)
 
void setpixel (int x, int y, int z, const float *pixel, int maxchannels=1000)
 
void setpixel (int i, const float *pixel, int maxchannels=1000)
 
bool get_pixels (ROI roi, TypeDesc format, void *result, stride_t xstride=AutoStride, stride_t ystride=AutoStride, stride_t zstride=AutoStride) const
 
bool set_pixels (ROI roi, TypeDesc format, const void *data, stride_t xstride=AutoStride, stride_t ystride=AutoStride, stride_t zstride=AutoStride)
 
int orientation () const
 
void set_orientation (int orient)
 
int oriented_width () const
 
int oriented_height () const
 
int oriented_x () const
 
int oriented_y () const
 
int oriented_full_width () const
 
int oriented_full_height () const
 
int oriented_full_x () const
 
int oriented_full_y () const
 
int xbegin () const
 Return the beginning (minimum) x coordinate of the defined image. More...
 
int xend () const
 Return the end (one past maximum) x coordinate of the defined image. More...
 
int ybegin () const
 Return the beginning (minimum) y coordinate of the defined image. More...
 
int yend () const
 Return the end (one past maximum) y coordinate of the defined image. More...
 
int zbegin () const
 Return the beginning (minimum) z coordinate of the defined image. More...
 
int zend () const
 Return the end (one past maximum) z coordinate of the defined image. More...
 
int xmin () const
 Return the minimum x coordinate of the defined image. More...
 
int xmax () const
 Return the maximum x coordinate of the defined image. More...
 
int ymin () const
 Return the minimum y coordinate of the defined image. More...
 
int ymax () const
 Return the maximum y coordinate of the defined image. More...
 
int zmin () const
 Return the minimum z coordinate of the defined image. More...
 
int zmax () const
 Return the maximum z coordinate of the defined image. More...
 
void set_origin (int x, int y, int z=0)
 Set a new origin position for the pixel data. More...
 
void set_full (int xbegin, int xend, int ybegin, int yend, int zbegin, int zend)
 
ROI roi () const
 Return pixel data window for this ImageBuf as a ROI. More...
 
ROI roi_full () const
 Return full/display window for this ImageBuf as a ROI. More...
 
void set_roi_full (const ROI &newroi)
 
bool contains_roi (ROI roi) const
 
bool pixels_valid (void) const
 
TypeDesc pixeltype () const
 
voidlocalpixels ()
 
const voidlocalpixels () const
 
stride_t pixel_stride () const
 Pixel-to-pixel stride within the localpixels memory. More...
 
stride_t scanline_stride () const
 Scanline-to-scanline stride within the localpixels memory. More...
 
stride_t z_stride () const
 Z plane stride within the localpixels memory. More...
 
bool cachedpixels () const
 
ImageCacheimagecache () const
 
const voidpixeladdr (int x, int y, int z=0, int ch=0) const
 
voidpixeladdr (int x, int y, int z=0, int ch=0)
 
int pixelindex (int x, int y, int z, bool check_range=false) const
 
bool deep () const
 Does this ImageBuf store deep data? More...
 
int deep_samples (int x, int y, int z=0) const
 
const voiddeep_pixel_ptr (int x, int y, int z, int c, int s=0) const
 
float deep_value (int x, int y, int z, int c, int s) const
 
uint32_t deep_value_uint (int x, int y, int z, int c, int s) const
 Retrieve deep sample value within a pixel, as an untigned int. More...
 
void set_deep_samples (int x, int y, int z, int nsamples)
 Set the number of deep samples for a particular pixel. More...
 
void deep_insert_samples (int x, int y, int z, int samplepos, int nsamples)
 Set the number of deep samples for a particular pixel. More...
 
void deep_erase_samples (int x, int y, int z, int samplepos, int nsamples)
 Set the number of deep samples for a particular pixel. More...
 
void set_deep_value (int x, int y, int z, int c, int s, float value)
 Set deep sample value within a pixel, as a float. More...
 
void set_deep_value (int x, int y, int z, int c, int s, uint32_t value)
 Set deep sample value within a pixel, as a uint32. More...
 
DeepDatadeepdata ()
 Retrieve the "deep" data. More...
 
const DeepDatadeepdata () const
 
void threads (int n) const
 
int threads () const
 Retrieve the current thread-spawning policy of this ImageBuf. More...
 

Static Public Member Functions

static WrapMode WrapMode_from_string (string_view name)
 Named wrap mode to enum WrapMode. More...
 

Protected Member Functions

ImageBufImpl * impl ()
 
const ImageBufImpl * impl () const
 
const voidretile (int x, int y, int z, ImageCache::Tile *&tile, int &tilexbegin, int &tileybegin, int &tilezbegin, int &tilexend, bool exists, WrapMode wrap=WrapDefault) const
 
const voidblackpixel () const
 
bool do_wrap (int &x, int &y, int &z, WrapMode wrap) const
 

Protected Attributes

std::unique_ptr< ImageBufImplBasem_impl
 

Friends

class IteratorBase
 

Detailed Description

An ImageBuf is a simple in-memory representation of a 2D image. It uses ImageInput and ImageOutput underneath for its file I/O, and has simple routines for setting and getting individual pixels, that hides most of the details of memory layout and data representation (translating to/from float automatically).

Definition at line 96 of file imagebuf.h.

Member Enumeration Documentation

Description of where the pixels live for this ImageBuf.

Enumerator
UNINITIALIZED 
LOCALBUFFER 
APPBUFFER 
IMAGECACHE 

Definition at line 157 of file imagebuf.h.

Wrap mode describes what happens when an iterator points to a value outside the usual data range of an image.

Enumerator
WrapDefault 
WrapBlack 
WrapClamp 
WrapPeriodic 
WrapMirror 
_WrapLast 

Definition at line 392 of file imagebuf.h.

Constructor & Destructor Documentation

ImageBuf::ImageBuf ( )

Construct an empty/uninitialized ImageBuf. This is relatively useless until you call reset().

ImageBuf::ImageBuf ( string_view  name,
int  subimage = 0,
int  miplevel = 0,
ImageCache imagecache = NULL,
const ImageSpec config = NULL 
)
explicit

Construct an ImageBuf to read the named image (at the designated subimage/MIPlevel – but don't actually read it yet! The image will actually be read when other methods need to access the spec and/or pixels, or when an explicit call to init_spec() or read() is made, whichever comes first. If a non-NULL imagecache is supplied, it will specifiy a custom ImageCache to use; if otherwise, the global/shared ImageCache will be used. If 'config' is not NULL, it points to an ImageSpec giving requests or special instructions to be passed on to the eventual ImageInput::open() call.

ImageBuf::ImageBuf ( string_view  name,
ImageCache imagecache 
)

Construct an ImageBuf to read the named image – but don't actually read it yet! The image will actually be read when other methods need to access the spec and/or pixels, or when an explicit call to init_spec() or read() is made, whichever comes first. If a non-NULL imagecache is supplied, it will specifiy a custom ImageCache to use; if otherwise, the global/shared ImageCache will be used.

ImageBuf::ImageBuf ( const ImageSpec spec)
explicit

Construct an Imagebuf given a proposed spec describing the image size and type, and allocate storage for the pixels of the image (whose values will be uninitialized).

ImageBuf::ImageBuf ( string_view  name,
const ImageSpec spec 
)

Construct an Imagebuf given both a name and a proposed spec describing the image size and type, and allocate storage for the pixels of the image (whose values will be undefined).

ImageBuf::ImageBuf ( const ImageSpec spec,
void buffer 
)

Construct an ImageBuf that "wraps" a memory buffer owned by the calling application. It can write pixels to this buffer, but can't change its resolution or data type.

ImageBuf::ImageBuf ( string_view  name,
const ImageSpec spec,
void buffer 
)

Construct an ImageBuf that "wraps" a memory buffer owned by the calling application. It can write pixels to this buffer, but can't change its resolution or data type.

ImageBuf::ImageBuf ( const ImageBuf src)

Construct a copy of an ImageBuf.

ImageBuf::ImageBuf ( ImageBuf &&  src)

Move a copy of an ImageBuf.

ImageBuf::~ImageBuf ( )

Destructor for an ImageBuf.

Member Function Documentation

const void* ImageBuf::blackpixel ( ) const
protected
bool ImageBuf::cachedpixels ( ) const

Are the pixels backed by an ImageCache, rather than the whole image being in RAM somewhere?

void ImageBuf::clear ( )

Restore the ImageBuf to an uninitialized state.

Examples:
field3d/f3d_io.C.
bool ImageBuf::contains_roi ( ROI  roi) const

Is the specified roi completely contained in the data window of this ImageBuf?

bool ImageBuf::copy ( const ImageBuf src,
TypeDesc  format = TypeUnknown 
)

Try to copy the pixels and metadata from src to *this (optionally with an explicit data format conversion), returning true upon success and false upon error/failure.

If the previous state of *this was uninitialized, owning its own local pixel memory, or referring to a read-only image backed by ImageCache, then local pixel memory will be allocated to hold the new pixels and the call always succeeds unless the memory cannot be allocated.

If *this previously referred to an app-owned memory buffer, the memory cannot be re-allocated, so the call will only succeed if the app-owned buffer is already the correct resolution and number of channels. The data type of the pixels will be converted automatically to the data type of the app buffer.

ImageBuf ImageBuf::copy ( TypeDesc  format) const

Return a full copy of this ImageBuf (optionally with an explicit data format conversion).

void ImageBuf::copy_metadata ( const ImageBuf src)

Copy all the metadata from src to *this (except for pixel data resolution, channel information, and data format).

bool ImageBuf::copy_pixels ( const ImageBuf src)

Copy the pixel data from src to *this, automatically converting to the existing data format of *this. It only copies pixels in the overlap regions (and channels) of the two images; pixel data in *this that do exist in src will be set to 0, and pixel data in src that do not exist in *this will not be copied.

bool ImageBuf::deep ( ) const

Does this ImageBuf store deep data?

void ImageBuf::deep_erase_samples ( int  x,
int  y,
int  z,
int  samplepos,
int  nsamples 
)

Set the number of deep samples for a particular pixel.

void ImageBuf::deep_insert_samples ( int  x,
int  y,
int  z,
int  samplepos,
int  nsamples 
)

Set the number of deep samples for a particular pixel.

const void* ImageBuf::deep_pixel_ptr ( int  x,
int  y,
int  z,
int  c,
int  s = 0 
) const

Return a pointer to the raw data of pixel (x,y,z), channel c, sample s. Return NULL if the pixel coordinates or channel number are out of range, if the pixel/channel has no deep samples, or if the image is not deep.

int ImageBuf::deep_samples ( int  x,
int  y,
int  z = 0 
) const

Retrieve the number of deep data samples corresponding to pixel (x,y,z). Return 0 if not a deep image or if the pixel is out of range or has no deep samples.

float ImageBuf::deep_value ( int  x,
int  y,
int  z,
int  c,
int  s 
) const

Return the value (as a float) of sample s of channel c of pixel (x,y,z). Return 0.0 if not a deep image or if the pixel coordinates or channel number are out of range or if it has no deep samples.

uint32_t ImageBuf::deep_value_uint ( int  x,
int  y,
int  z,
int  c,
int  s 
) const

Retrieve deep sample value within a pixel, as an untigned int.

DeepData* ImageBuf::deepdata ( )

Retrieve the "deep" data.

const DeepData* ImageBuf::deepdata ( ) const
bool ImageBuf::do_wrap ( int x,
int y,
int z,
WrapMode  wrap 
) const
protected
void ImageBuf::error ( const std::string message) const

Add simple string to the error message list for this IB.

template<typename... Args>
void ImageBuf::error ( const char *  fmt,
const Args &...  args 
) const
inline

Error reporting for ImageBuf: call this with Strutil::format formatting conventions. Beware, this is in transition, is currently printf-like but will someday change to python-like!

Definition at line 330 of file imagebuf.h.

template<typename... Args>
void ImageBuf::errorf ( const char *  fmt,
const Args &...  args 
) const
inline

Error reporting for ImageBuf: call this with printf-like arguments.

Definition at line 321 of file imagebuf.h.

string_view ImageBuf::file_format_name ( void  ) const

Return the name of the image file format of the disk file we read into this image. Returns an empty string if this image was not the result of a read().

template<typename... Args>
void ImageBuf::fmterror ( const char *  fmt,
const Args &...  args 
) const
inline

Error reporting for ImageBuf: call this with Python / {fmt} / std::format style formatting specification.

Definition at line 314 of file imagebuf.h.

bool ImageBuf::get_pixels ( ROI  roi,
TypeDesc  format,
void result,
stride_t  xstride = AutoStride,
stride_t  ystride = AutoStride,
stride_t  zstride = AutoStride 
) const

Retrieve the rectangle of pixels spanning the ROI (including channels) at the current subimage and MIP-map level, storing the pixel values beginning at the address specified by result and with the given strides (by default, AutoStride means the usual contiguous packing of pixels) and converting into the data type described by 'format'. It is up to the caller to ensure that result points to an area of memory big enough to accommodate the requested rectangle. Return true if the operation could be completed, otherwise return false.

float ImageBuf::getchannel ( int  x,
int  y,
int  z,
int  c,
WrapMode  wrap = WrapBlack 
) const

Retrieve a single channel of one pixel.

std::string ImageBuf::geterror ( void  ) const

Return the text of all error messages issued since geterror() was called (or an empty string if no errors are pending). This also clears the error message for next time.

void ImageBuf::getpixel ( int  x,
int  y,
float *  pixel,
int  maxchannels = 1000 
) const
inline

Retrieve the pixel value by x and y pixel indices, storing the floating point version in pixel[]. Retrieve at most maxchannels (will be clamped to the actual number of channels).

Definition at line 412 of file imagebuf.h.

void ImageBuf::getpixel ( int  x,
int  y,
int  z,
float *  pixel,
int  maxchannels = 1000,
WrapMode  wrap = WrapBlack 
) const

Retrieve the pixel value by x, y, z pixel indices, storing the floating point version in pixel[]. Retrieve at most maxchannels (will be clamped to the actual number of channels).

bool ImageBuf::has_error ( void  ) const

Return true if the IB has had an error and has an error message to retrieve via geterror().

ImageCache* ImageBuf::imagecache ( ) const
ImageBufImpl* ImageBuf::impl ( )
inlineprotected

Definition at line 1251 of file imagebuf.h.

const ImageBufImpl* ImageBuf::impl ( ) const
inlineprotected

Definition at line 1252 of file imagebuf.h.

bool ImageBuf::init_spec ( string_view  filename,
int  subimage,
int  miplevel 
)

Initialize this ImageBuf with the named image file, and read its header to fill out the spec correctly. Return true if this succeeded, false if the file could not be read. But don't allocate or read the pixels.

bool ImageBuf::initialized ( ) const

Is this ImageBuf object initialized?

void ImageBuf::interppixel ( float  x,
float  y,
float *  pixel,
WrapMode  wrap = WrapBlack 
) const

Sample the image plane at coordinates (x,y), using linear interpolation between pixels, placing the result in pixel[0..n-1] where n is the smaller of maxchannels or the actual number of channels stored in the buffer. It is up to the application to ensure that pixel points to enough memory to hold the required number of channels. Note that pixel data values themselves are at the pixel centers, so pixel (i,j) is at image plane coordinate (i+0.5, j+0.5).

void ImageBuf::interppixel_bicubic ( float  x,
float  y,
float *  pixel,
WrapMode  wrap = WrapBlack 
) const

Bicubic interpolation at pixel coordinates (x,y), where (0,0) is the upper left corner, (xres,yres) the lower right corner of the pixel data.

void ImageBuf::interppixel_bicubic_NDC ( float  s,
float  t,
float *  pixel,
WrapMode  wrap = WrapBlack 
) const

Bicubic interpolattion at NDC space coordinates (s,t), where (0,0) is the upper left corner of the display (aka "full") window, (1,1) the lower right corner of the display window.

void ImageBuf::interppixel_NDC ( float  s,
float  t,
float *  pixel,
WrapMode  wrap = WrapBlack 
) const

Linearly interpolate at NDC coordinates (s,t), where (0,0) is the upper left corner of the display window, (1,1) the lower right corner of the display window.

void ImageBuf::interppixel_NDC_full ( float  s,
float  t,
float *  pixel,
WrapMode  wrap = WrapBlack 
) const

DEPCRECATED (1.5) synonym for interppixel_NDC.

void* ImageBuf::localpixels ( )

A raw pointer to "local" pixel memory, if they are fully in RAM and not backed by an ImageCache, or nullptr otherwise. You can also test it like a bool to find out if pixels are local.

const void* ImageBuf::localpixels ( ) const
bool ImageBuf::make_writeable ( bool  keep_cache_type = false)

Force the ImageBuf to be writeable. That means that if it was previously backed by ImageCache (storage was IMAGECACHE), it will force a full read so that the whole image is in local memory. This will invalidate any current iterators on the image. It has no effect if the image storage not IMAGECACHE. Return true if it works (including if no read was necessary), false if something went horribly wrong. If keep_cache_type is true, it preserves any IC- forced data types (you might want to do this if it is critical that the apparent data type doesn't change, for example if you are calling make_writeable from within a type-specialized function).

int ImageBuf::miplevel ( ) const

Return the index of the miplevel are we currently viewing

string_view ImageBuf::name ( void  ) const

Return the name of this image.

const ImageSpec& ImageBuf::nativespec ( ) const

Return a read-only (const) reference to the "native" image spec (that describes the file, which may be slightly different than the spec of the ImageBuf, particularly if the IB is backed by an ImageCache that is imposing some particular data format or tile size).

int ImageBuf::nchannels ( ) const

Return the number of color channels in the image.

int ImageBuf::nmiplevels ( ) const

Return the number of miplevels of the current subimage.

int ImageBuf::nsubimages ( ) const

Return the number of subimages in the file.

const ImageBuf& ImageBuf::operator= ( const ImageBuf src)
const ImageBuf& ImageBuf::operator= ( ImageBuf &&  src)

Move assignment.

int ImageBuf::orientation ( ) const
int ImageBuf::oriented_full_height ( ) const
int ImageBuf::oriented_full_width ( ) const
int ImageBuf::oriented_full_x ( ) const
int ImageBuf::oriented_full_y ( ) const
int ImageBuf::oriented_height ( ) const
int ImageBuf::oriented_width ( ) const
int ImageBuf::oriented_x ( ) const
int ImageBuf::oriented_y ( ) const
stride_t ImageBuf::pixel_stride ( ) const

Pixel-to-pixel stride within the localpixels memory.

const void* ImageBuf::pixeladdr ( int  x,
int  y,
int  z = 0,
int  ch = 0 
) const

Return the address where pixel (x,y,z), channel ch, is stored in the image buffer. Use with extreme caution! Will return nullptr if the pixel values aren't local.

void* ImageBuf::pixeladdr ( int  x,
int  y,
int  z = 0,
int  ch = 0 
)

Return the address where pixel (x,y,z), channel ch, is stored in the image buffer. Use with extreme caution! Will return nullptr if the pixel values aren't local.

int ImageBuf::pixelindex ( int  x,
int  y,
int  z,
bool  check_range = false 
) const

Return the index of pixel (x,y,z). If check_range is true, return -1 for an invalid coordinate that is not within the data window.

bool ImageBuf::pixels_valid ( void  ) const
TypeDesc ImageBuf::pixeltype ( ) const
bool ImageBuf::read ( int  subimage = 0,
int  miplevel = 0,
bool  force = false,
TypeDesc  convert = TypeDesc::UNKNOWN,
ProgressCallback  progress_callback = NULL,
void progress_callback_data = NULL 
)

Read the file from disk. Generally will skip the read if we've already got a current version of the image in memory, unless force==true. This uses ImageInput underneath, so will read any file format for which an appropriate imageio plugin can be found. Return value is true if all is ok, otherwise false.

bool ImageBuf::read ( int  subimage,
int  miplevel,
int  chbegin,
int  chend,
bool  force,
TypeDesc  convert,
ProgressCallback  progress_callback = NULL,
void progress_callback_data = NULL 
)

Read the file from disk, if possible only allocating and reading a subset of channels, [chbegin..chend-1] from disk. This can be a performance and memory improvement if you know that any use of the ImageBuf will only access a subset of channels from a many-channel file. If chbegin==0 and chend is either negative or greater than the number of channels in the file, all channels will be read. Please note that it is "advisory" and not guaranteed to be honored by the underlying implementation.

void ImageBuf::reset ( string_view  name,
int  subimage,
int  miplevel,
ImageCache imagecache = NULL,
const ImageSpec config = NULL 
)

Forget all previous info, reset this ImageBuf to a new image that is uninitialized (no pixel values, no size or spec). If 'config' is not NULL, it points to an ImageSpec giving requests or special instructions to be passed on to the eventual ImageInput::open() call.

void ImageBuf::reset ( string_view  name,
ImageCache imagecache = NULL 
)

Forget all previous info, reset this ImageBuf to a new image that is uninitialized (no pixel values, no size or spec).

void ImageBuf::reset ( const ImageSpec spec)

Forget all previous info, reset this ImageBuf to a blank image of the given dimensions.

void ImageBuf::reset ( string_view  name,
const ImageSpec spec 
)

Forget all previous info, reset this ImageBuf to a blank image of the given name and dimensions.

const void* ImageBuf::retile ( int  x,
int  y,
int  z,
ImageCache::Tile *&  tile,
int tilexbegin,
int tileybegin,
int tilezbegin,
int tilexend,
bool  exists,
WrapMode  wrap = WrapDefault 
) const
protected
ROI ImageBuf::roi ( ) const

Return pixel data window for this ImageBuf as a ROI.

ROI ImageBuf::roi_full ( ) const

Return full/display window for this ImageBuf as a ROI.

stride_t ImageBuf::scanline_stride ( ) const

Scanline-to-scanline stride within the localpixels memory.

void ImageBuf::set_deep_samples ( int  x,
int  y,
int  z,
int  nsamples 
)

Set the number of deep samples for a particular pixel.

void ImageBuf::set_deep_value ( int  x,
int  y,
int  z,
int  c,
int  s,
float  value 
)

Set deep sample value within a pixel, as a float.

void ImageBuf::set_deep_value ( int  x,
int  y,
int  z,
int  c,
int  s,
uint32_t  value 
)

Set deep sample value within a pixel, as a uint32.

void ImageBuf::set_full ( int  xbegin,
int  xend,
int  ybegin,
int  yend,
int  zbegin,
int  zend 
)

Set the "full" (a.k.a. display) window to [xbegin,xend) x [ybegin,yend) x [zbegin,zend).

void ImageBuf::set_orientation ( int  orient)
void ImageBuf::set_origin ( int  x,
int  y,
int  z = 0 
)

Set a new origin position for the pixel data.

bool ImageBuf::set_pixels ( ROI  roi,
TypeDesc  format,
const void data,
stride_t  xstride = AutoStride,
stride_t  ystride = AutoStride,
stride_t  zstride = AutoStride 
)

Copy the data into the given ROI of the ImageBuf. The data points to values specified by 'format', with layout detailed by the stride values (in bytes, with AutoStride indicating "contiguous" layout). It is up to the caller to ensure that data points to an area of memory big enough to account for the ROI. Return true if the operation could be completed, otherwise return false.

void ImageBuf::set_roi_full ( const ROI newroi)

Set full/display window for this ImageBuf to a ROI. Does NOT change the channels of the spec, regardless of newroi.

void ImageBuf::set_write_format ( TypeDesc  format)

Inform the ImageBuf what data format you'd like for any subsequent write().

void ImageBuf::set_write_tiles ( int  width = 0,
int  height = 0,
int  depth = 0 
)

Inform the ImageBuf what tile size (or no tiling, for 0) for any subsequent write().

void ImageBuf::setpixel ( int  x,
int  y,
const float *  pixel,
int  maxchannels = 1000 
)
inline

Set the pixel with coordinates (x,y,0) to have the values in pixel[0..n-1]. The number of channels copied, n, is the minimum of maxchannels and the actual number of channels in the image.

Definition at line 460 of file imagebuf.h.

void ImageBuf::setpixel ( int  x,
int  y,
int  z,
const float *  pixel,
int  maxchannels = 1000 
)

Set the pixel with coordinates (x,y,z) to have the values in pixel[0..n-1]. The number of channels copied, n, is the minimum of maxchannels and the actual number of channels in the image.

void ImageBuf::setpixel ( int  i,
const float *  pixel,
int  maxchannels = 1000 
)

Set the i-th pixel value of the image (out of width*height*depth), from floating-point values in pixel[]. Set at most maxchannels (will be clamped to the actual number of channels).

const ImageSpec& ImageBuf::spec ( ) const

Return a read-only (const) reference to the image spec that describes the buffer.

ImageSpec& ImageBuf::specmod ( )

Return a writable reference to the image spec that describes the buffer. Use with extreme caution! If you use this for anything other than adding attribute metadata, you are really taking your chances!

IBStorage ImageBuf::storage ( ) const

Which type of storage is being used for the pixels?

int ImageBuf::subimage ( ) const

Return the index of the subimage are we currently viewing

void ImageBuf::swap ( ImageBuf other)
inline

Swap with another ImageBuf.

Definition at line 306 of file imagebuf.h.

void ImageBuf::threads ( int  n) const

Set the current thread-spawning policy: the maximum number of threads that may be spawned by ImagBuf internals. A value of 1 means all work will be done by the calling thread; 0 means to use the global OIIO::attribute("threads") value.

int ImageBuf::threads ( ) const

Retrieve the current thread-spawning policy of this ImageBuf.

static WrapMode ImageBuf::WrapMode_from_string ( string_view  name)
static

Named wrap mode to enum WrapMode.

bool ImageBuf::write ( string_view  filename,
TypeDesc  dtype = TypeUnknown,
string_view  fileformat = string_view(),
ProgressCallback  progress_callback = nullptr,
void progress_callback_data = nullptr 
) const

Write the image to the named file, converted to the specified pixel data type dtype (TypeUnknown signifies to use the data type of the buffer), and file format ("" means to infer the type from the filename extension). Return true if all went ok, false if there were errors writing.

bool ImageBuf::write ( string_view  filename,
string_view  fileformat,
ProgressCallback  progress_callback = nullptr,
void progress_callback_data = nullptr 
) const
inline

Definition at line 238 of file imagebuf.h.

bool ImageBuf::write ( ImageOutput out,
ProgressCallback  progress_callback = NULL,
void progress_callback_data = NULL 
) const

Write the image to the open ImageOutput 'out'. Return true if all went ok, false if there were errors writing. It does NOT close the file when it's done (and so may be called in a loop to write a multi-image file).

int ImageBuf::xbegin ( ) const

Return the beginning (minimum) x coordinate of the defined image.

int ImageBuf::xend ( ) const

Return the end (one past maximum) x coordinate of the defined image.

int ImageBuf::xmax ( ) const

Return the maximum x coordinate of the defined image.

int ImageBuf::xmin ( ) const

Return the minimum x coordinate of the defined image.

int ImageBuf::ybegin ( ) const

Return the beginning (minimum) y coordinate of the defined image.

int ImageBuf::yend ( ) const

Return the end (one past maximum) y coordinate of the defined image.

int ImageBuf::ymax ( ) const

Return the maximum y coordinate of the defined image.

int ImageBuf::ymin ( ) const

Return the minimum y coordinate of the defined image.

stride_t ImageBuf::z_stride ( ) const

Z plane stride within the localpixels memory.

int ImageBuf::zbegin ( ) const

Return the beginning (minimum) z coordinate of the defined image.

int ImageBuf::zend ( ) const

Return the end (one past maximum) z coordinate of the defined image.

int ImageBuf::zmax ( ) const

Return the maximum z coordinate of the defined image.

int ImageBuf::zmin ( ) const

Return the minimum z coordinate of the defined image.

Friends And Related Function Documentation

friend class IteratorBase
friend

Definition at line 659 of file imagebuf.h.

Member Data Documentation

std::unique_ptr<ImageBufImplBase> ImageBuf::m_impl
protected

Definition at line 1249 of file imagebuf.h.


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