本文整理汇总了C++中imf::InputFile::setFrameBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ InputFile::setFrameBuffer方法的具体用法?C++ InputFile::setFrameBuffer怎么用?C++ InputFile::setFrameBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imf::InputFile
的用法示例。
在下文中一共展示了InputFile::setFrameBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clamp
bool
OpenEXRInput::read_native_scanlines (int ybegin, int yend, int z,
int chbegin, int chend, void *data)
{
chend = clamp (chend, chbegin+1, m_spec.nchannels);
// std::cerr << "openexr rns " << ybegin << ' ' << yend << ", channels "
// << chbegin << "-" << (chend-1) << "\n";
if (m_input_scanline == NULL && m_scanline_input_part == NULL) {
error ("called OpenEXRInput::read_native_scanlines without an open file");
return false;
}
// Compute where OpenEXR needs to think the full buffers starts.
// OpenImageIO requires that 'data' points to where the client wants
// to put the pixels being read, but OpenEXR's frameBuffer.insert()
// wants where the address of the "virtual framebuffer" for the
// whole image.
const PartInfo &part (m_parts[m_subimage]);
size_t pixelbytes = m_spec.pixel_bytes (chbegin, chend, true);
size_t scanlinebytes = (size_t)m_spec.width * pixelbytes;
char *buf = (char *)data
- m_spec.x * pixelbytes
- ybegin * scanlinebytes;
try {
Imf::FrameBuffer frameBuffer;
size_t chanoffset = 0;
for (int c = chbegin; c < chend; ++c) {
size_t chanbytes = m_spec.channelformat(c).size();
frameBuffer.insert (m_spec.channelnames[c].c_str(),
Imf::Slice (part.pixeltype[c],
buf + chanoffset,
pixelbytes, scanlinebytes));
chanoffset += chanbytes;
}
if (m_input_scanline) {
m_input_scanline->setFrameBuffer (frameBuffer);
m_input_scanline->readPixels (ybegin, yend-1);
#ifdef USE_OPENEXR_VERSION2
} else if (m_scanline_input_part) {
m_scanline_input_part->setFrameBuffer (frameBuffer);
m_scanline_input_part->readPixels (ybegin, yend-1);
#endif
} else {
error ("Attempted to read scanline from a non-scanline file.");
return false;
}
} catch (const std::exception &e) {
error ("Failed OpenEXR read: %s", e.what());
return false;
} catch (...) { // catch-all for edge cases or compiler bugs
error ("Failed OpenEXR read: unknown exception");
return false;
}
return true;
}
示例2: catch
bool
OpenEXRInput::read_native_scanlines (int ybegin, int yend, int z,
int firstchan, int nchans, void *data)
{
// std::cerr << "openexr rns " << ybegin << ' ' << yend << ", channels "
// << firstchan << "-" << (firstchan+nchans-1) << "\n";
if (m_input_scanline == NULL)
return false;
// Compute where OpenEXR needs to think the full buffers starts.
// OpenImageIO requires that 'data' points to where the client wants
// to put the pixels being read, but OpenEXR's frameBuffer.insert()
// wants where the address of the "virtual framebuffer" for the
// whole image.
size_t pixelbytes = m_spec.pixel_bytes (firstchan, nchans, true);
size_t scanlinebytes = (size_t)m_spec.width * pixelbytes;
char *buf = (char *)data
- m_spec.x * pixelbytes
- ybegin * scanlinebytes;
try {
Imf::FrameBuffer frameBuffer;
size_t chanoffset = 0;
for (int c = 0; c < nchans; ++c) {
size_t chanbytes = m_spec.channelformats.size()
? m_spec.channelformats[c+firstchan].size()
: m_spec.format.size();
frameBuffer.insert (m_spec.channelnames[c+firstchan].c_str(),
Imf::Slice (m_pixeltype[c+firstchan],
buf + chanoffset,
pixelbytes, scanlinebytes));
chanoffset += chanbytes;
}
m_input_scanline->setFrameBuffer (frameBuffer);
m_input_scanline->readPixels (ybegin, yend-1);
}
catch (const std::exception &e) {
error ("Failed OpenEXR read: %s", e.what());
return false;
}
return true;
}
示例3:
void OpenEXRImpl :: load_channels(Imf::InputFile &file, Matrix& mat, int numChannels, const char *channelNames) {
Imath::Box2i dw = file.header().dataWindow();
int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
mat.create(numChannels, Matrix::FLOAT32, width, height);
Imf::FrameBuffer frameBuffer;
for(int i=0; i < numChannels; i++) {
char c[2];
c[0] = channelNames[i];
c[1] = '\0';
frameBuffer.insert(c,
Imf::Slice(Imf::FLOAT,
(char *)(mat.data.fl + i),
sizeof(float)*numChannels,
sizeof(float)*numChannels*width));
}
file.setFrameBuffer(frameBuffer);
file.readPixels(dw.min.y, dw.max.y);
}
示例4: ASSERT
bool
OpenEXRInput::read_native_scanline (int y, int z, void *data)
{
ASSERT (m_input_scanline != NULL);
// Compute where OpenEXR needs to think the full buffers starts.
// OpenImageIO requires that 'data' points to where the client wants
// to put the pixels being read, but OpenEXR's frameBuffer.insert()
// wants where the address of the "virtual framebuffer" for the
// whole image.
size_t pixelbytes = m_spec.pixel_bytes (true);
size_t scanlinebytes = m_spec.scanline_bytes (true);
char *buf = (char *)data
- m_spec.x * pixelbytes
- y * scanlinebytes;
try {
Imf::FrameBuffer frameBuffer;
size_t chanoffset = 0;
for (int c = 0; c < m_spec.nchannels; ++c) {
size_t chanbytes = m_spec.channelformats.size()
? m_spec.channelformats[c].size()
: m_spec.format.size();
frameBuffer.insert (m_spec.channelnames[c].c_str(),
Imf::Slice (m_pixeltype[c],
buf + chanoffset,
pixelbytes, scanlinebytes));
chanoffset += chanbytes;
}
m_input_scanline->setFrameBuffer (frameBuffer);
m_input_scanline->readPixels (y, y);
}
catch (const std::exception &e) {
error ("Failed OpenEXR read: %s", e.what());
return false;
}
return true;
}