Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dpx.imageio/dpxinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ DPXInput::seek_subimage(int subimage, int miplevel)

// image linearity
switch (m_dpx.header.Transfer(subimage)) {
case dpx::kLinear: m_spec.set_colorspace("Linear"); break;
case dpx::kLinear: m_spec.set_colorspace("lin_rec709_scene"); break;
case dpx::kLogarithmic: m_spec.set_colorspace("KodakLog"); break;
case dpx::kITUR709: m_spec.set_colorspace("Rec709"); break;
case dpx::kITUR709: m_spec.set_colorspace("srgb_rec709_scene"); break;
case dpx::kUserDefined:
if (!std::isnan(m_dpx.header.Gamma()) && m_dpx.header.Gamma() != 0) {
set_colorspace_rec709_gamma(m_spec, float(m_dpx.header.Gamma()));
Expand Down
15 changes: 10 additions & 5 deletions src/dpx.imageio/dpxoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "libdpx/DPX.h"
#include "libdpx/DPXColorConverter.h"

#include <OpenImageIO/color.h>
#include <OpenImageIO/fmath.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/strutil.h>
Expand Down Expand Up @@ -435,14 +436,18 @@ DPXOutput::prep_subimage(int s, bool allocate)
m_desc = get_image_descriptor();

// transfer function
const ColorConfig& colorconfig = ColorConfig::default_colorconfig();
std::string colorspace = spec_s.get_string_attribute("oiio:ColorSpace", "");
if (Strutil::iequals(colorspace, "Linear"))
if (colorconfig.equivalent(colorspace, "lin_rec709_scene"))
m_transfer = dpx::kLinear;
else if (Strutil::istarts_with(colorspace, "Gamma"))
m_transfer = dpx::kUserDefined;
else if (Strutil::iequals(colorspace, "Rec709"))
else if (colorconfig.equivalent(colorspace, "srgb_rec709_scene"))
m_transfer = dpx::kITUR709;
else if (Strutil::iequals(colorspace, "KodakLog"))
else if (colorconfig.equivalent(colorspace, "g22_rec709_scene")
|| colorconfig.equivalent(colorspace, "g24_rec709_scene")
|| colorconfig.equivalent(colorspace, "g18_rec709_scene")
|| Strutil::istarts_with(colorspace, "Gamma"))
m_transfer = dpx::kUserDefined;
else if (colorconfig.equivalent(colorspace, "KodakLog"))
m_transfer = dpx::kLogarithmic;
else {
std::string dpxtransfer = spec_s.get_string_attribute("dpx:Transfer",
Expand Down
4 changes: 2 additions & 2 deletions testsuite/python-imagebufalgo/src/test_imagebufalgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ def test_iba (func: Callable[..., oiio.ImageBuf], *args, **kwargs) -> oiio.Image
b.setpixel(0, 1, (.5,.5,.5,1))
b.setpixel(1, 1, (1,1,1,1))
dumpimg (b, msg="linear src=")
r = test_iba (ImageBufAlgo.colorconvert, b, "Linear", "sRGB")
r = test_iba (ImageBufAlgo.colorconvert, b, "lin_rec709", "sRGB")
dumpimg (r, msg="to srgb =")
r = ImageBufAlgo.colorconvert(r, "sRGB", "Linear")
r = ImageBufAlgo.colorconvert(r, "sRGB", "lin_rec709")
dumpimg (r, msg="back to linear =")
# Just to test, make a matrix that halves red, doubles green,
# adds 0.1 to blue.
Expand Down
Loading