Skip to content

Commit

Permalink
IB: Fix bug in propagating unassociated alpha behavior request (Acade…
Browse files Browse the repository at this point in the history
…mySoftwareFoundation#2172)

The unassociated alpha handling setting of the ImageCache was
overriding the setting specific to the ImageBuf itself, for the path
where for "forced" reads bypass the cache. Good intentions to still
honor the IC setting, but IB-specific request should take precedent.
  • Loading branch information
lgritz committed Feb 11, 2019
1 parent 8a036e2 commit 322477c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/libOpenImageIO/imagebuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,18 @@ ImageBufImpl::read(int subimage, int miplevel, int chbegin, int chend,
// loss of range or precision resulting from going through the
// cache. Or the caller requested a forced read, for that case we
// also do a direct read now.
int unassoc = 0;
if (m_imagecache->getattribute("unassociatedalpha", unassoc)) {
// Since IB needs to act as if it's backed by an ImageCache,
// even though in this case we're bypassing the IC, we need to
// honor the IC's "unassociatedalpha" flag.
add_configspec();
m_configspec->attribute("oiio:UnassociatedAlpha", unassoc);
if (!m_configspec
|| !m_configspec->find_attribute("oiio:UnassociatedAlpha")) {
int unassoc = 0;
if (m_imagecache->getattribute("unassociatedalpha", unassoc)) {
// Since IB needs to act as if it's backed by an ImageCache,
// even though in this case we're bypassing the IC, we need
// to honor the IC's "unassociatedalpha" flag. But only if
// this IB wasn't already given a config spec that dictated
// a specific unassociated alpha behavior.
add_configspec();
m_configspec->attribute("oiio:UnassociatedAlpha", unassoc);
}
}
auto in = ImageInput::open(m_name.string(), m_configspec.get());
bool ok = true;
Expand Down

0 comments on commit 322477c

Please sign in to comment.