Skip to content

Commit

Permalink
Adding support for OpenEXR with non-(0,0) windows
Browse files Browse the repository at this point in the history
OpenEXRs semantics for interpreting target frame buffers for reading
requires offsetting the input data pointer in such a way that the first
window pixel, applying the passed stride, again leads to the start of
the data buffer.
  • Loading branch information
cbreak-black committed Oct 8, 2018
1 parent e95cece commit 8dd899a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wrap/exr-wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ EXRImage loadEXRRaw(char const * buffer, std::size_t size)
{
auto const & name = it.name();
image.planes[name].resize(image.width * image.height);
fb.insert(name, Slice(FLOAT, (char*)image.planes[name].data(), strideX, strideY));
// OpenEXR needs to be passed a pointer that, when the window is applied,
// leads to the start of the data buffer, even if that pointer is illegal
auto startOffset = window.min.x + window.min.y * image.width;
fb.insert(name, Slice(FLOAT,
reinterpret_cast<char*>(image.planes[name].data() - startOffset),
strideX, strideY));
}
file.setFrameBuffer(fb);
file.readPixels(window.min.y, window.max.y);
Expand Down

0 comments on commit 8dd899a

Please sign in to comment.