Skip to content

Commit 896561a

Browse files
committed
fix: Fix some legacy 'Linear' color references
Convert to modern oiio color space nomenclature. Signed-off-by: Larry Gritz <[email protected]>
1 parent 8887077 commit 896561a

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/dpx.imageio/dpxinput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ DPXInput::seek_subimage(int subimage, int miplevel)
312312

313313
// image linearity
314314
switch (m_dpx.header.Transfer(subimage)) {
315-
case dpx::kLinear: m_spec.set_colorspace("Linear"); break;
315+
case dpx::kLinear: m_spec.set_colorspace("lin_rec709_scene"); break;
316316
case dpx::kLogarithmic: m_spec.set_colorspace("KodakLog"); break;
317-
case dpx::kITUR709: m_spec.set_colorspace("Rec709"); break;
317+
case dpx::kITUR709: m_spec.set_colorspace("srgb_rec709_scene"); break;
318318
case dpx::kUserDefined:
319319
if (!std::isnan(m_dpx.header.Gamma()) && m_dpx.header.Gamma() != 0) {
320320
set_colorspace_rec709_gamma(m_spec, float(m_dpx.header.Gamma()));

src/dpx.imageio/dpxoutput.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "libdpx/DPX.h"
1313
#include "libdpx/DPXColorConverter.h"
1414

15+
#include <OpenImageIO/color.h>
1516
#include <OpenImageIO/fmath.h>
1617
#include <OpenImageIO/imageio.h>
1718
#include <OpenImageIO/strutil.h>
@@ -435,14 +436,18 @@ DPXOutput::prep_subimage(int s, bool allocate)
435436
m_desc = get_image_descriptor();
436437

437438
// transfer function
439+
const ColorConfig& colorconfig = ColorConfig::default_colorconfig();
438440
std::string colorspace = spec_s.get_string_attribute("oiio:ColorSpace", "");
439-
if (Strutil::iequals(colorspace, "Linear"))
441+
if (colorconfig.equivalent(colorspace, "lin_rec709_scene"))
440442
m_transfer = dpx::kLinear;
441-
else if (Strutil::istarts_with(colorspace, "Gamma"))
442-
m_transfer = dpx::kUserDefined;
443-
else if (Strutil::iequals(colorspace, "Rec709"))
443+
else if (colorconfig.equivalent(colorspace, "srgb_rec709_scene"))
444444
m_transfer = dpx::kITUR709;
445-
else if (Strutil::iequals(colorspace, "KodakLog"))
445+
else if (colorconfig.equivalent(colorspace, "g22_rec709_scene")
446+
|| colorconfig.equivalent(colorspace, "g24_rec709_scene")
447+
|| colorconfig.equivalent(colorspace, "g18_rec709_scene")
448+
|| Strutil::istarts_with(colorspace, "Gamma"))
449+
m_transfer = dpx::kUserDefined;
450+
else if (colorconfig.equivalent(colorspace, "KodakLog"))
446451
m_transfer = dpx::kLogarithmic;
447452
else {
448453
std::string dpxtransfer = spec_s.get_string_attribute("dpx:Transfer",

testsuite/python-imagebufalgo/src/test_imagebufalgo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ def test_iba (func: Callable[..., oiio.ImageBuf], *args, **kwargs) -> oiio.Image
374374
b.setpixel(0, 1, (.5,.5,.5,1))
375375
b.setpixel(1, 1, (1,1,1,1))
376376
dumpimg (b, msg="linear src=")
377-
r = test_iba (ImageBufAlgo.colorconvert, b, "Linear", "sRGB")
377+
r = test_iba (ImageBufAlgo.colorconvert, b, "lin_rec709", "sRGB")
378378
dumpimg (r, msg="to srgb =")
379-
r = ImageBufAlgo.colorconvert(r, "sRGB", "Linear")
379+
r = ImageBufAlgo.colorconvert(r, "sRGB", "lin_rec709")
380380
dumpimg (r, msg="back to linear =")
381381
# Just to test, make a matrix that halves red, doubles green,
382382
# adds 0.1 to blue.

0 commit comments

Comments
 (0)