本文整理汇总了C++中ocio_namespace::ConstConfigRcPtr::getColorSpaceNameByIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstConfigRcPtr::getColorSpaceNameByIndex方法的具体用法?C++ ConstConfigRcPtr::getColorSpaceNameByIndex怎么用?C++ ConstConfigRcPtr::getColorSpaceNameByIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ocio_namespace::ConstConfigRcPtr
的用法示例。
在下文中一共展示了ConstConfigRcPtr::getColorSpaceNameByIndex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _validate
void OCIOColorSpace::_validate(bool for_real)
{
if(!m_hasColorSpaces)
{
error("No color spaces available for input and/or output.");
return;
}
int inputColorSpaceCount = static_cast<int>(m_inputColorSpaceCstrNames.size()) - 1;
if(m_inputColorSpaceIndex < 0 || m_inputColorSpaceIndex >= inputColorSpaceCount)
{
std::ostringstream err;
err << "Input color space index (" << m_inputColorSpaceIndex << ") out of range.";
error(err.str().c_str());
return;
}
int outputColorSpaceCount = static_cast<int>(m_outputColorSpaceCstrNames.size()) - 1;
if(m_outputColorSpaceIndex < 0 || m_outputColorSpaceIndex >= outputColorSpaceCount)
{
std::ostringstream err;
err << "Output color space index (" << m_outputColorSpaceIndex << ") out of range.";
error(err.str().c_str());
return;
}
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * inputName = config->getColorSpaceNameByIndex(m_inputColorSpaceIndex);
const char * outputName = config->getColorSpaceNameByIndex(m_outputColorSpaceIndex);
OCIO::ConstContextRcPtr context = getLocalContext();
m_processor = config->getProcessor(context, inputName, outputName);
}
catch(OCIO::Exception &e)
{
error(e.what());
return;
}
if(m_processor->isNoOp())
{
set_out_channels(DD::Image::Mask_None); // prevents engine() from being called
} else {
set_out_channels(DD::Image::Mask_All);
}
DD::Image::PixelIop::_validate(for_real);
}
示例2: PopulateOCIOMenus
static void PopulateOCIOMenus()
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
int csMenuID = glutCreateMenu(imageColorSpace_CB);
for(int i=0; i<config->getNumColorSpaces(); ++i)
{
glutAddMenuEntry(config->getColorSpaceNameByIndex(i), i);
}
int deviceMenuID = glutCreateMenu(displayDevice_CB);
for(int i=0; i<config->getNumDisplays(); ++i)
{
glutAddMenuEntry(config->getDisplay(i), i);
}
int transformMenuID = glutCreateMenu(transform_CB);
const char * defaultDisplay = config->getDefaultDisplay();
for(int i=0; i<config->getNumViews(defaultDisplay); ++i)
{
glutAddMenuEntry(config->getView(defaultDisplay, i), i);
}
glutCreateMenu(menuCallback);
glutAddSubMenu("Image ColorSpace", csMenuID);
glutAddSubMenu("Transform", transformMenuID);
glutAddSubMenu("Device", deviceMenuID);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
示例3: catch
OCIOColorSpace::OCIOColorSpace(Node *n) : DD::Image::PixelIop(n)
{
m_hasColorSpaces = false;
m_inputColorSpaceIndex = 0;
m_outputColorSpaceIndex = 0;
m_layersToProcess = DD::Image::Mask_RGB;
// Query the colorspace names from the current config
// TODO (when to) re-grab the list of available colorspaces? How to save/load?
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
std::string defaultColorSpaceName = config->getColorSpace(OCIO::ROLE_SCENE_LINEAR)->getName();
for(int i = 0; i < config->getNumColorSpaces(); i++)
{
std::string csname = config->getColorSpaceNameByIndex(i);
m_colorSpaceNames.push_back(csname);
if(csname == defaultColorSpaceName)
{
m_inputColorSpaceIndex = i;
m_outputColorSpaceIndex = i;
}
}
}
catch (OCIO::Exception& e)
{
std::cerr << "OCIOColorSpace: " << e.what() << std::endl;
}
catch (...)
{
std::cerr << "OCIOColorSpace: Unknown exception during OCIO setup." << std::endl;
}
// Then, create a cstr array for passing to Nuke
// This must be done in a second pass, lest the original m_colorSpaceNames
// std::string be reallocated in the interim
for(unsigned int i=0; i<m_colorSpaceNames.size(); ++i)
{
m_inputColorSpaceCstrNames.push_back(m_colorSpaceNames[i].c_str());
m_outputColorSpaceCstrNames.push_back(m_colorSpaceNames[i].c_str());
}
m_inputColorSpaceCstrNames.push_back(NULL);
m_outputColorSpaceCstrNames.push_back(NULL);
m_hasColorSpaces = (!m_colorSpaceNames.empty());
if(!m_hasColorSpaces)
{
std::cerr << "OCIOColorSpace: No ColorSpaces available for input and/or output." << std::endl;
}
}
示例4: imageColorSpace_CB
void imageColorSpace_CB(int id)
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * name = config->getColorSpaceNameByIndex(id);
if(!name) return;
g_inputColorSpace = name;
UpdateOCIOGLState();
glutPostRedisplay();
}
示例5: assert
static void
buildChoiceMenu(OCIO::ConstConfigRcPtr config,
ChoiceParamType* choice,
bool cascading,
const std::string& name = "")
{
#ifdef DEBUG
//printf("%p->resetOptions\n", (void*)choice);
#endif
choice->resetOptions();
assert(choice->getNOptions() == 0);
if (!config) {
return;
}
int def = -1;
int defaultcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_DEFAULT);
int referencecs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_REFERENCE);
int datacs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_DATA);
int colorpickingcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COLOR_PICKING);
int scenelinearcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_SCENE_LINEAR);
int compositinglogcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COMPOSITING_LOG);
int colortimingcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_COLOR_TIMING);
int texturepaintcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_TEXTURE_PAINT);
int mattepaintcs = config->getIndexForColorSpace(OCIO_NAMESPACE::ROLE_MATTE_PAINT);
for (int i = 0; i < config->getNumColorSpaces(); ++i) {
std::string csname = config->getColorSpaceNameByIndex(i);
std::string msg;
// set the default value, in case the GUI uses it
if (!name.empty() && csname == name) {
def = i;
}
OCIO_NAMESPACE::ConstColorSpaceRcPtr cs = config->getColorSpace(csname.c_str());
if (cascading) {
std::string family = config->getColorSpace(csname.c_str())->getFamily();
if (!family.empty()) {
csname = family + "/" + csname;
}
}
std::string csdesc = cs ? cs->getDescription() : "(no colorspace)";
csdesc = whitespacify(trim(csdesc));
int csdesclen = csdesc.size();
if ( csdesclen > 0 ) {
msg += csdesc;
}
bool first = true;
int roles = 0;
if (i == defaultcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_DEFAULT;
first = false;
++roles;
}
if (i == referencecs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_REFERENCE;
first = false;
++roles;
}
if (i == datacs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_DATA;
first = false;
++roles;
}
if (i == colorpickingcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_COLOR_PICKING;
first = false;
++roles;
}
if (i == scenelinearcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_SCENE_LINEAR;
first = false;
++roles;
}
if (i == compositinglogcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_COMPOSITING_LOG;
first = false;
++roles;
}
if (i == colortimingcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_COLOR_TIMING;
first = false;
++roles;
}
if (i == texturepaintcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_TEXTURE_PAINT;
first = false;
++roles;
}
if (i == mattepaintcs) {
msg += first ? " (" : ", ";
msg += OCIO_NAMESPACE::ROLE_MATTE_PAINT;
first = false;
++roles;
}
//.........这里部分代码省略.........
示例6: catch
OCIOLookTransform::OCIOLookTransform(Node *n) : DD::Image::PixelIop(n)
{
m_hasColorSpaces = false;
m_inputColorSpaceIndex = 0;
m_outputColorSpaceIndex = 0;
m_lookIndex = 0;
m_dirIndex = 0;
m_ignoreErrors = false;
// Query the colorspace names from the current config
// TODO (when to) re-grab the list of available colorspaces? How to save/load?
OCIO::ConstConfigRcPtr config;
std::string linear;
try
{
config = OCIO::GetCurrentConfig();
OCIO::ConstColorSpaceRcPtr linearcs = config->getColorSpace(OCIO::ROLE_SCENE_LINEAR);
if(!linearcs) throw std::runtime_error("ROLE_SCENE_LINEAR not defined.");
linear = linearcs->getName();
}
catch (const OCIO::Exception& e)
{
std::cerr << "OCIOLookTransform: " << e.what() << std::endl;
}
catch (...)
{
std::cerr << "OCIOLookTransform: Unknown exception during OCIO setup." << std::endl;
}
if(!config)
{
m_hasColorSpaces = false;
return;
}
// Step 1: Make the std::vectors
for(int i=0; i<config->getNumLooks(); ++i)
{
m_lookNames.push_back(config->getLookNameByIndex(i));
}
for(int i = 0; i < config->getNumColorSpaces(); i++)
{
std::string csname = config->getColorSpaceNameByIndex(i);
#ifdef OCIO_CASCADE
std::string family = config->getColorSpace(csname.c_str())->getFamily();
if(family.empty())
m_colorSpaceNames.push_back(csname.c_str());
else
m_colorSpaceNames.push_back(family + "/" + csname);
#else
m_colorSpaceNames.push_back(csname);
#endif
if(csname == linear)
{
m_inputColorSpaceIndex = i;
m_outputColorSpaceIndex = i;
}
}
// Step 2: Create a cstr array for passing to Nuke
// (This must be done in a second pass, lest the original strings be reallocated)
for(unsigned int i=0; i<m_lookNames.size(); ++i)
{
m_lookCstrNames.push_back(m_lookNames[i].c_str());
}
m_lookCstrNames.push_back(NULL);
for(unsigned int i=0; i<m_colorSpaceNames.size(); ++i)
{
m_inputColorSpaceCstrNames.push_back(m_colorSpaceNames[i].c_str());
m_outputColorSpaceCstrNames.push_back(m_colorSpaceNames[i].c_str());
}
m_inputColorSpaceCstrNames.push_back(NULL);
m_outputColorSpaceCstrNames.push_back(NULL);
m_hasColorSpaces = (!m_colorSpaceNames.empty());
if(!m_hasColorSpaces)
{
std::cerr << "OCIOLookTransform: No ColorSpaces available for input and/or output." << std::endl;
}
}
示例7: _validate
void OCIOLookTransform::_validate(bool for_real)
{
if(!m_hasColorSpaces)
{
error("No colorspaces available for input and/or output.");
return;
}
int inputColorSpaceCount = static_cast<int>(m_inputColorSpaceCstrNames.size()) - 1;
if(m_inputColorSpaceIndex < 0 || m_inputColorSpaceIndex >= inputColorSpaceCount)
{
std::ostringstream err;
err << "Input colorspace index (" << m_inputColorSpaceIndex << ") out of range.";
error(err.str().c_str());
return;
}
int outputColorSpaceCount = static_cast<int>(m_outputColorSpaceCstrNames.size()) - 1;
if(m_outputColorSpaceIndex < 0 || m_outputColorSpaceIndex >= outputColorSpaceCount)
{
std::ostringstream err;
err << "Output colorspace index (" << m_outputColorSpaceIndex << ") out of range.";
error(err.str().c_str());
return;
}
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * inputName = config->getColorSpaceNameByIndex(m_inputColorSpaceIndex);
const char * outputName = config->getColorSpaceNameByIndex(m_outputColorSpaceIndex);
OCIO::LookTransformRcPtr transform = OCIO::LookTransform::Create();
const char * look = m_lookCstrNames[m_lookIndex];
if(look != NULL)
{
transform->setLooks(look);
}
OCIO::ConstContextRcPtr context = getLocalContext();
OCIO::TransformDirection direction = OCIO::TRANSFORM_DIR_UNKNOWN;
bool invertTransform = (m_dirIndex == 0) ? false : true;
// Forward
if(!invertTransform)
{
transform->setSrc(inputName);
transform->setDst(outputName);
direction = OCIO::TRANSFORM_DIR_FORWARD;
}
else
{
// The TRANSFORM_DIR_INVERSE applies an inverse for the end-to-end transform,
// which would otherwise do dst->inv look -> src.
// This is an unintuitive result for the artist (who would expect in, out to
// remain unchanged), so we account for that here by flipping src/dst
transform->setSrc(outputName);
transform->setDst(inputName);
direction = OCIO::TRANSFORM_DIR_INVERSE;
}
try
{
m_processor = config->getProcessor(context, transform, direction);
}
// We only catch the exceptions for missing files, and try to succeed
// in this case. All other errors represent more serious problems and
// should fail through.
catch(const OCIO::ExceptionMissingFile &e)
{
if(!m_ignoreErrors) throw;
m_processor = config->getProcessor(context, inputName, outputName);
}
}
catch(const OCIO::Exception &e)
{
error(e.what());
return;
}
catch (...)
{
error("OCIOLookTransform: Unknown exception during _validate.");
return;
}
if(m_processor->isNoOp())
{
set_out_channels(DD::Image::Mask_None); // prevents engine() from being called
} else {
set_out_channels(DD::Image::Mask_All);
}
DD::Image::PixelIop::_validate(for_real);
}
示例8: main
//.........这里部分代码省略.........
}
for(int i=0; i<config->getNumRoles(); ++i)
{
const char * role = config->getRoleName(i);
if(usedroles.find(role) != usedroles.end()) continue;
OCIO::ConstColorSpaceRcPtr cs = config->getColorSpace(role);
if(cs)
{
std::cout << cs->getName() << " (" << role << ": user)" << std::endl;
}
else
{
std::cout << "ERROR: NOT DEFINED" << " (" << role << ")" << std::endl;
errorcount += 1;
}
}
}
std::cout << std::endl;
std::cout << "** ColorSpaces **" << std::endl;
OCIO::ConstColorSpaceRcPtr lin = config->getColorSpace(OCIO::ROLE_SCENE_LINEAR);
if(!lin)
{
std::cout << "Error: scene_linear role must be defined." << std::endl;
errorcount += 1;
}
else
{
for(int i=0; i<config->getNumColorSpaces(); ++i)
{
OCIO::ConstColorSpaceRcPtr cs = config->getColorSpace(config->getColorSpaceNameByIndex(i));
bool convertsToLinear = true;
std::string convertsToLinearErrorText;
bool convertsFromLinear = true;
std::string convertsFromLinearErrorText;
try
{
OCIO::ConstProcessorRcPtr p = config->getProcessor(cs, lin);
}
catch(OCIO::Exception & exception)
{
convertsToLinear = false;
convertsToLinearErrorText = exception.what();
}
try
{
OCIO::ConstProcessorRcPtr p = config->getProcessor(lin, cs);
}
catch(OCIO::Exception & exception)
{
convertsFromLinear = false;
convertsFromLinearErrorText = exception.what();
}
if(convertsToLinear && convertsFromLinear)
{
std::cout << cs->getName() << std::endl;
}
else if(!convertsToLinear && !convertsFromLinear)
示例9: PopulateOCIOMenus
static void PopulateOCIOMenus()
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
int csMenuID = glutCreateMenu(imageColorSpace_CB);
std::map<std::string, int> families;
for(int i=0; i<config->getNumColorSpaces(); ++i)
{
const char * csName = config->getColorSpaceNameByIndex(i);
if(csName && *csName)
{
OCIO::ConstColorSpaceRcPtr cs = config->getColorSpace(csName);
if(cs)
{
const char * family = cs->getFamily();
if(family && *family)
{
if(families.find(family)==families.end())
{
families[family] = glutCreateMenu(imageColorSpace_CB);
glutAddMenuEntry(csName, i);
glutSetMenu(csMenuID);
glutAddSubMenu(family, families[family]);
}
else
{
glutSetMenu(families[family]);
glutAddMenuEntry(csName, i);
}
}
else
{
glutSetMenu(csMenuID);
glutAddMenuEntry(csName, i);
}
}
}
}
int deviceMenuID = glutCreateMenu(displayDevice_CB);
for(int i=0; i<config->getNumDisplays(); ++i)
{
glutAddMenuEntry(config->getDisplay(i), i);
}
int transformMenuID = glutCreateMenu(transform_CB);
const char * defaultDisplay = config->getDefaultDisplay();
for(int i=0; i<config->getNumViews(defaultDisplay); ++i)
{
glutAddMenuEntry(config->getView(defaultDisplay, i), i);
}
int lookMenuID = glutCreateMenu(look_CB);
for(int i=0; i<config->getNumLooks(); ++i)
{
glutAddMenuEntry(config->getLookNameByIndex(i), i);
}
glutCreateMenu(menuCallback);
glutAddSubMenu("Image ColorSpace", csMenuID);
glutAddSubMenu("Transform", transformMenuID);
glutAddSubMenu("Device", deviceMenuID);
glutAddSubMenu("Looks Override", lookMenuID);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}