本文整理汇总了C++中ImageBuf::pixels_valid方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageBuf::pixels_valid方法的具体用法?C++ ImageBuf::pixels_valid怎么用?C++ ImageBuf::pixels_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageBuf
的用法示例。
在下文中一共展示了ImageBuf::pixels_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zero
// DEPRECATED version
bool
ImageBufAlgo::add (ImageBuf &dst, const ImageBuf &A, const ImageBuf &B,
int options)
{
// Sanity checks
// dst must be distinct from A and B
if ((const void *)&A == (const void *)&dst ||
(const void *)&B == (const void *)&dst) {
dst.error ("destination image must be distinct from source");
return false;
}
// all three images must have the same number of channels
if (A.spec().nchannels != B.spec().nchannels) {
dst.error ("channel number mismatch: %d vs. %d",
A.spec().nchannels, B.spec().nchannels);
return false;
}
// If dst has not already been allocated, set it to the right size,
// make it unconditinally float
if (! dst.pixels_valid()) {
ImageSpec dstspec = A.spec();
dstspec.set_format (TypeDesc::TypeFloat);
dst.alloc (dstspec);
}
// Clear dst pixels if instructed to do so
if (options & ADD_CLEAR_DST) {
zero (dst);
}
ASSERT (A.spec().format == TypeDesc::FLOAT &&
B.spec().format == TypeDesc::FLOAT &&
dst.spec().format == TypeDesc::FLOAT);
ImageBuf::ConstIterator<float,float> a (A);
ImageBuf::ConstIterator<float,float> b (B);
ImageBuf::Iterator<float> d (dst);
int nchannels = A.nchannels();
// Loop over all pixels in A
for ( ; a.valid(); ++a) {
// Point the iterators for B and dst to the corresponding pixel
if (options & ADD_RETAIN_WINDOWS) {
b.pos (a.x(), a.y());
} else {
// ADD_ALIGN_WINDOWS: make B line up with A
b.pos (a.x()-A.xbegin()+B.xbegin(), a.y()-A.ybegin()+B.ybegin());
}
d.pos (a.x(), b.y());
if (! b.valid() || ! d.valid())
continue; // Skip pixels that don't align
// Add the pixel
for (int c = 0; c < nchannels; ++c)
d[c] = a[c] + b[c];
}
return true;
}