7 #define OPENIMAGEIO_IMAGEBUF_H
12 # pragma warning(disable : 4251)
324 bool make_writable(
bool keep_cache_type =
false);
328 bool make_writeable(
bool keep_cache_type =
false);
411 bool read(
int subimage = 0,
int miplevel = 0,
bool force =
false,
414 void* progress_callback_data =
nullptr);
433 bool read(
int subimage,
int miplevel,
int chbegin,
int chend,
bool force,
435 void* progress_callback_data =
nullptr);
509 void* progress_callback_data =
nullptr)
const;
511 #ifndef DOXYGEN_SHOULD_SKIP_THIS
513 OIIO_DEPRECATED(
"use other write() that takes the dtype argument (1.9)")
516 void* progress_callback_data =
nullptr)
const
518 return write(filename,
TypeUnknown, fileformat, progress_callback,
519 progress_callback_data);
521 #endif // DOXYGEN_SHOULD_SKIP_THIS
594 void* progress_callback_data =
nullptr)
const;
672 float getchannel(
int x,
int y,
int z,
int c,
673 WrapMode wrap = WrapBlack)
const;
691 void getpixel(
int x,
int y,
int z,
float* pixel,
int maxchannels = 1000,
692 WrapMode wrap = WrapBlack)
const;
695 void getpixel(
int x,
int y,
float* pixel,
int maxchannels = 1000)
const
697 getpixel(x, y, 0, pixel, maxchannels);
715 void interppixel(
float x,
float y,
float* pixel,
716 WrapMode wrap = WrapBlack)
const;
724 void interppixel_NDC(
float s,
float t,
float* pixel,
725 WrapMode wrap = WrapBlack)
const;
727 #ifndef DOXYGEN_SHOULD_SKIP_THIS
730 void interppixel_NDC_full(
float s,
float t,
float* pixel,
731 WrapMode wrap = WrapBlack) const;
735 void interppixel_bicubic(
float x,
float y,
float* pixel,
736 WrapMode wrap = WrapBlack)
const;
741 void interppixel_bicubic_NDC(
float s,
float t,
float* pixel,
742 WrapMode wrap = WrapBlack)
const;
750 setpixel(x, y, 0, pixel);
758 setpixel(x, y, z, pixel.
data(),
int(pixel.
size()));
773 void setpixel(
int x,
int y,
const float* pixel,
int maxchannels = 1000)
775 setpixel(x, y, 0, pixel, maxchannels);
781 void setpixel(
int x,
int y,
int z,
const float* pixel,
782 int maxchannels = 1000);
787 void setpixel(
int i,
const float* pixel,
int maxchannels = 1000);
823 bool initialized()
const;
859 bool has_thumbnail()
const;
864 std::shared_ptr<ImageBuf> get_thumbnail()
const;
869 void set_thumbnail(
const ImageBuf& thumb);
873 void clear_thumbnail();
891 int subimage()
const;
903 int nsubimages()
const;
909 int miplevel()
const;
915 int nmiplevels()
const;
919 int nchannels()
const;
948 int orientation()
const;
951 void set_orientation(
int orient);
955 int oriented_width()
const;
956 int oriented_height()
const;
957 int oriented_x()
const;
958 int oriented_y()
const;
959 int oriented_full_width()
const;
960 int oriented_full_height()
const;
961 int oriented_full_x()
const;
962 int oriented_full_y()
const;
968 void set_origin(
int x,
int y,
int z = 0);
977 void set_full(
int xbegin,
int xend,
int ybegin,
int yend,
int zbegin,
984 ROI roi_full()
const;
992 bool contains_roi(
ROI roi)
const;
994 bool pixels_valid(
void)
const;
1008 void* localpixels();
1009 const void* localpixels()
const;
1024 bool contiguous()
const;
1028 bool cachedpixels()
const;
1037 const void* pixeladdr(
int x,
int y,
int z = 0,
int ch = 0)
const;
1038 void* pixeladdr(
int x,
int y,
int z = 0,
int ch = 0);
1042 int pixelindex(
int x,
int y,
int z,
bool check_range =
false)
const;
1055 void threads(
int n)
const;
1058 int threads()
const;
1072 template<
typename... Args>
1081 template<
typename... Args>
1091 template<
typename... Args>
1093 const Args&...
args)
const
1100 template<
typename... Args>
1102 void fmterror(const
char* fmt, const Args&...
args)
const
1115 std::string
geterror(
bool clear =
true)
const;
1130 int deep_samples(
int x,
int y,
int z = 0)
const;
1138 const void* deep_pixel_ptr(
int x,
int y,
int z,
int c,
int s = 0)
const;
1144 float deep_value(
int x,
int y,
int z,
int c,
int s)
const;
1150 uint32_t deep_value_uint(
int x,
int y,
int z,
int c,
int s)
const;
1155 void set_deep_samples(
int x,
int y,
int z,
int nsamples);
1159 void deep_insert_samples(
int x,
int y,
int z,
int samplepos,
int nsamples);
1163 void deep_erase_samples(
int x,
int y,
int z,
int samplepos,
int nsamples);
1168 void set_deep_value(
int x,
int y,
int z,
int c,
int s,
float value);
1173 void set_deep_value(
int x,
int y,
int z,
int c,
int s, uint32_t
value);
1177 bool copy_deep_pixel(
int x,
int y,
int z,
const ImageBuf&
src,
int srcx,
1178 int srcy,
int srcz);
1199 bool write =
false);
1202 WrapMode wrap,
bool write =
false);
1206 bool write =
false);
1211 int ybegin,
int yend,
int zbegin,
int zend,
1212 WrapMode wrap,
bool write =
false);
1215 OIIO_API IteratorBase(
const IteratorBase& i);
1228 int x()
const {
return m_x; }
1230 int y()
const {
return m_y; }
1232 int z()
const {
return m_z; }
1239 bool valid(
int x_,
int y_,
int z_ = 0)
const
1241 return (x_ >= m_rng_xbegin && x_ < m_rng_xend && y_ >= m_rng_ybegin
1242 && y_ < m_rng_yend && z_ >= m_rng_zbegin
1243 && z_ < m_rng_zend);
1248 bool exists(
int x_,
int y_,
int z_ = 0)
const
1250 return (x_ >= m_img_xbegin && x_ < m_img_xend && y_ >= m_img_ybegin
1251 && y_ < m_img_yend && z_ >= m_img_zbegin
1252 && z_ < m_img_zend);
1265 return (m_valid ==
false && m_x == m_rng_xbegin
1266 && m_y == m_rng_ybegin && m_z == m_rng_zend);
1277 void OIIO_API pos(
int x_,
int y_,
int z_ = 0);
1283 if (++m_x < m_rng_xend) {
1294 if (++m_y >= m_rng_yend) {
1296 if (++m_z >= m_rng_zend) {
1310 return ROI(m_rng_xbegin, m_rng_xend, m_rng_ybegin, m_rng_yend,
1311 m_rng_zbegin, m_rng_zend, 0, m_ib->nchannels());
1317 void OIIO_API rerange(
int xbegin,
int xend,
int ybegin,
int yend,
1318 int zbegin,
int zend,
1321 const void*
rawptr()
const {
return m_proxydata; }
1326 return m_ib->deep_value(m_x, m_y, m_z, c, s);
1331 return m_ib->deep_value_uint(m_x, m_y, m_z, c, s);
1344 friend class ImageBufImpl;
1346 bool m_valid =
false, m_exists =
false;
1347 bool m_deep =
false;
1348 bool m_localpixels =
false;
1350 int m_img_xbegin, m_img_xend, m_img_ybegin, m_img_yend, m_img_zbegin,
1353 int m_rng_xbegin, m_rng_xend, m_rng_ybegin, m_rng_yend, m_rng_zbegin,
1356 pvt::ImageCacheTile* m_tile =
nullptr;
1361 char* m_proxydata =
nullptr;
1363 bool m_readerror =
false;
1380 if (m_localpixels) {
1382 m_proxydata += m_pixel_stride;
1384 pos_xincr_local_past_end();
1385 }
else if (!m_deep) {
1387 m_proxydata += m_pixel_stride;
1388 bool e = m_x < m_img_xend;
1391 m_proxydata = (
char*)m_ib->retile(m_x, m_y, m_z, m_tile,
1394 m_tilezbegin, m_tilexend,
1395 m_readerror, e, m_wrap);
1402 void OIIO_API pos_xincr_local_past_end();
1431 template<
typename BUFT,
typename USERT =
float>
1455 int zbegin = 0,
int zend = 1,
WrapMode wrap = WrapDefault)
1456 :
IteratorBase(ib, xbegin, xend, ybegin, yend, zbegin, zend, wrap,
1499 return const_cast<ImageBuf*
>(m_ib)->set_deep_samples(m_x, m_y, m_z,
1507 return const_cast<ImageBuf*
>(m_ib)->set_deep_value(m_x, m_y, m_z, c,
1512 return const_cast<ImageBuf*
>(m_ib)->set_deep_value(m_x, m_y, m_z, c,
1520 template<
typename BUFT,
typename USERT =
float>
1545 int yend,
int zbegin = 0,
int zend = 1,
1547 :
IteratorBase(ib, xbegin, xend, ybegin, yend, zbegin, zend, wrap)
1572 static void impl_deleter(ImageBufImpl*);
1573 std::unique_ptr<ImageBufImpl, decltype(&impl_deleter)>
m_impl;
1579 const void* retile(
int x,
int y,
int z, pvt::ImageCacheTile*& tile,
1580 int& tilexbegin,
int& tileybegin,
int& tilezbegin,
1581 int& tilexend,
bool& haderr,
bool exists,
1585 const void* retile(
int x,
int y,
int z, pvt::ImageCacheTile*& tile,
1586 int& tilexbegin,
int& tileybegin,
int& tilezbegin,
1589 const void* blackpixel()
const;
1595 bool do_wrap(
int&
x,
int&
y,
int&
z,
WrapMode wrap)
const;
GLuint GLsizei const GLchar * message
OIIO_API std::string geterror(bool clear=true)
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
OIIO_API bool has_error()
Is there a pending global error message waiting to be retrieved?
GT_API const UT_StringHolder filename
void swap(ImageBuf &other)
Swap the entire contents with another ImageBuf.
uint32_t deep_value_uint(int c, int s) const
void setpixel(int i, cspan< float > pixel)
ConstIterator(const ImageBuf &ib, const ROI &roi, WrapMode wrap=WrapDefault)
Construct read-only iteration region from ImageBuf and ROI.
void getpixel(int x, int y, float *pixel, int maxchannels=1000) const
OIIO_API void set_roi(ImageSpec &spec, const ROI &newroi)
getFileOption("OpenEXR:storage") storage
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
GLsizei const GLfloat * value
OIIO_FORMAT_DEPRECATED void error(const char *fmt, const Args &...args) const
GLdouble GLdouble GLdouble z
Iterator(ImageBuf &ib, const ROI &roi, WrapMode wrap=WrapDefault)
Construct read-write iteration region from ImageBuf and ROI.
USERT operator[](int i) const
int x() const
Retrieve the current x location of the iterator.
OIIO_NODISCARD std::string format(const Str &fmt, Args &&...args)
DataArrayProxy< BUFT, USERT > & operator*()
bool valid(int x_, int y_, int z_=0) const
ROI range() const
Return the iteration range.
void set_deep_value(int c, int s, float value)
std::unique_ptr< ImageBufImpl, decltype(&impl_deleter)> m_impl
Tto convert(const Tfrom &source)
**But if you need a result
OIIO_API ROI get_roi(const ImageSpec &spec)
Return pixel data window for this ImageSpec as a ROI.
ConstIterator(const ImageBuf &ib, int x_, int y_, int z_=0, WrapMode wrap=WrapDefault)
void setpixel(int x, int y, const float *pixel, int maxchannels=1000)
basic_string_view< char > string_view
OIIO_INLINE_CONSTEXPR TypeDesc TypeUnknown(TypeDesc::UNKNOWN)
GLint GLsizei GLsizei height
void setpixel(int x, int y, cspan< float > pixel)
const void * rawptr() const
OIIO_API ROI get_roi_full(const ImageSpec &spec)
Return full/display window for this ImageSpec as a ROI.
bool(* ProgressCallback)(void *opaque_data, float portion_done)
int z() const
Retrieve the current z location of the iterator.
void errorf(const char *fmt, const Args &...args) const
GLint GLint GLsizei GLint GLenum format
float deep_value(int c, int s) const
Retrieve the deep data value of sample s of channel c.
bool valid() const
Is the current location within the designated iteration range?
constexpr size_type size() const noexcept
OIIO_UTIL_API bool exists(string_view path) noexcept
GLuint const GLchar * name
int y() const
Retrieve the current y location of the iterator.
ConstDataArrayProxy< BUFT, USERT > & operator*() const
Iterator(ImageBuf &ib, int x, int y, int z=0, WrapMode wrap=WrapDefault)
GA_API const UT_StringHolder orient
void operator++(int)
Increment to the next pixel in the region.
void errorfmt(const char *fmt, const Args &...args) const
void set_deep_value(int c, int s, uint32_t value)
Iterator(ImageBuf &ib, WrapMode wrap=WrapDefault)
ConstIterator(const ImageBuf &ib, WrapMode wrap=WrapDefault)
GLint GLint GLsizei GLsizei GLsizei depth
bool exists(int x_, int y_, int z_=0) const
SIM_API const UT_StringHolder force
const stride_t AutoStride
int deep_samples() const
Retrieve the number of deep data samples at this pixel.
USERT operator[](int i) const
LeafData & operator=(const LeafData &)=delete
ConstIterator(const ImageBuf &ib, int xbegin, int xend, int ybegin, int yend, int zbegin=0, int zend=1, WrapMode wrap=WrapDefault)
Iterator(ImageBuf &ib, int xbegin, int xend, int ybegin, int yend, int zbegin=0, int zend=1, WrapMode wrap=WrapDefault)
**If you just want to fire and args
#define OIIO_FORMAT_DEPRECATED
bool done() const
Are we finished iterating over the region?
void set_deep_samples(int n)
#define OIIO_NAMESPACE_END
auto sprintf(const S &fmt, const T &...args) -> std::basic_string< Char >
WrapMode wrap() const
Return the wrap mode.
constexpr pointer data() const noexcept
DataProxy< BUFT, USERT > operator[](int i)
OIIO_API void set_roi_full(ImageSpec &spec, const ROI &newroi)
void setpixel(int x, int y, int z, cspan< float > pixel)
#define OIIO_NAMESPACE_BEGIN