forked from AcademySoftwareFoundation/OpenImageIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ColorConfig additions (AcademySoftwareFoundation#2248)
Background: ColorConfig is our wrapper around some OpenColorIO functionality, so that apps whose only need for OCIO is for the sake of OIIO color conversion functions, they can go though this thin interface instead of directly needing to navigate the more complicated APIs of OCIO. It also allows us to abstract whether OCIO is actually available, if it's not it understands just a couple hard-coded color transformations. * Add getColoSpaceFamilyByName, which was some OCIO functionality we did not expose before. * Add methods that return a vector of strings containing the list of all color spaces, looks, displays, or views for a display. * Expose all this to Python. And add a simple unit test. * Make sure one Travis test disables OCIO support, so we know what breaks under those circumstances.
- Loading branch information
Showing
14 changed files
with
307 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
Copyright 2015 Larry Gritz and the other authors and contributors. | ||
All Rights Reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the software's owners nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
(This is the Modified BSD License) | ||
*/ | ||
|
||
#include <utility> | ||
|
||
#include "py_oiio.h" | ||
#include <OpenImageIO/color.h> | ||
|
||
namespace PyOpenImageIO { | ||
|
||
|
||
// Declare the OIIO ColorConfig class to Python | ||
void | ||
declare_colorconfig(py::module& m) | ||
{ | ||
using namespace pybind11::literals; | ||
|
||
py::class_<ColorConfig>(m, "ColorConfig") | ||
|
||
.def(py::init<>()) | ||
.def(py::init<const std::string&>()) | ||
.def("geterror", | ||
[](ColorConfig& self) { return PY_STR(self.geterror()); }) | ||
|
||
.def("getNumColorSpaces", &ColorConfig::getNumColorSpaces) | ||
.def("getColorSpaceNames", &ColorConfig::getColorSpaceNames) | ||
.def("getColorSpaceNameByIndex", &ColorConfig::getColorSpaceNameByIndex) | ||
.def( | ||
"getColorSpaceNameByRole", | ||
[](const ColorConfig& self, const std::string& role) { | ||
return self.getColorSpaceNameByRole(role); | ||
}, | ||
"role"_a) | ||
.def( | ||
"getColorSpaceDataType", | ||
[](const ColorConfig& self, const std::string& name) { | ||
int bits = 0; | ||
TypeDesc type = self.getColorSpaceDataType(name, &bits); | ||
return std::make_pair(type, bits); | ||
}, | ||
"name"_a) | ||
.def( | ||
"getColorSpaceFamilyByName", | ||
[](const ColorConfig& self, const std::string& name) { | ||
return self.getColorSpaceFamilyByName(name); | ||
}, | ||
"name"_a) | ||
|
||
.def("getNumLooks", &ColorConfig::getNumLooks) | ||
.def("getLookNameByIndex", &ColorConfig::getLookNameByIndex) | ||
.def("getLookNames", &ColorConfig::getLookNames) | ||
|
||
.def("getNumDisplays", &ColorConfig::getNumDisplays) | ||
.def("getDisplayNameByIndex", &ColorConfig::getDisplayNameByIndex) | ||
.def("getDisplayNames", &ColorConfig::getDisplayNames) | ||
.def("getDefaultDisplayName", &ColorConfig::getDefaultDisplayName) | ||
|
||
.def( | ||
"getNumViews", | ||
[](const ColorConfig& self, const std::string& display) { | ||
return self.getNumViews(display); | ||
}, | ||
"display"_a = "") | ||
.def( | ||
"getViewNameByIndex", | ||
[](const ColorConfig& self, const std::string& display, int index) { | ||
return self.getViewNameByIndex(display, index); | ||
}, | ||
"display"_a = "", "index"_a) | ||
.def( | ||
"getViewNames", | ||
[](const ColorConfig& self, const std::string& display) { | ||
return self.getViewNames(display); | ||
}, | ||
"display"_a = "") | ||
.def( | ||
"getDefaultViewName", | ||
[](const ColorConfig& self, const std::string& display) { | ||
return self.getDefaultViewName(display); | ||
}, | ||
"display"_a = "") | ||
.def("parseColorSpaceFromString", | ||
[](const ColorConfig& self, const std::string& str) { | ||
return std::string(self.parseColorSpaceFromString(str)); | ||
}) | ||
.def("configname", &ColorConfig::configname); | ||
|
||
m.attr("supportsOpenColorIO") = ColorConfig::supportsOpenColorIO(); | ||
} | ||
|
||
} // namespace PyOpenImageIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
getNumColorSpaces = 6 | ||
getColorSpaceNames = ['linear', 'default', 'rgb', 'RGB', 'sRGB', 'Rec709'] | ||
getNumLooks = 0 | ||
getLookNames = [] | ||
getNumDisplays = 0 | ||
getDisplayNames = [] | ||
getDefaultDisplayName = None | ||
getNumViews = 0 | ||
getViewNames = [] | ||
getDefaultViewName = None | ||
|
||
Done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
getNumColorSpaces = 6 | ||
getColorSpaceNames = [u'linear', u'default', u'rgb', u'RGB', u'sRGB', u'Rec709'] | ||
getNumLooks = 0 | ||
getLookNames = [] | ||
getNumDisplays = 0 | ||
getDisplayNames = [] | ||
getDefaultDisplayName = None | ||
getNumViews = 0 | ||
getViewNames = [] | ||
getDefaultViewName = None | ||
|
||
Done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
getNumColorSpaces = 14 | ||
getColorSpaceNames = [u'linear', u'sRGB', u'sRGBf', u'rec709', u'Cineon', u'Gamma1.8', u'Gamma2.2', u'Panalog', u'REDLog', u'ViperLog', u'AlexaV3LogC', u'PLogLin', u'SLog', u'raw'] | ||
getNumLooks = 0 | ||
getLookNames = [] | ||
getNumDisplays = 1 | ||
getDisplayNames = [u'default'] | ||
getDefaultDisplayName = default | ||
getNumViews = 3 | ||
getViewNames = [u'None', u'sRGB', u'rec709'] | ||
getDefaultViewName = | ||
|
||
Done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
getNumColorSpaces = 14 | ||
getColorSpaceNames = ['linear', 'sRGB', 'sRGBf', 'rec709', 'Cineon', 'Gamma1.8', 'Gamma2.2', 'Panalog', 'REDLog', 'ViperLog', 'AlexaV3LogC', 'PLogLin', 'SLog', 'raw'] | ||
getNumLooks = 0 | ||
getLookNames = [] | ||
getNumDisplays = 1 | ||
getDisplayNames = ['default'] | ||
getDefaultDisplayName = default | ||
getNumViews = 3 | ||
getViewNames = ['None', 'sRGB', 'rec709'] | ||
getDefaultViewName = | ||
|
||
Done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
|
||
os.environ['OCIO'] = colorconfig_file | ||
|
||
command += pythonbin + " src/test_colorconfig.py > out.txt" | ||
|
Oops, something went wrong.