本文整理汇总了C++中ocio_namespace::ConstConfigRcPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ConstConfigRcPtr类的具体用法?C++ ConstConfigRcPtr怎么用?C++ ConstConfigRcPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstConfigRcPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLocalContext
OCIO::ConstContextRcPtr OCIOColorSpace::getLocalContext()
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
OCIO::ConstContextRcPtr context = config->getCurrentContext();
OCIO::ContextRcPtr mutableContext;
if(!m_contextKey1.empty())
{
if(!mutableContext) mutableContext = context->createEditableCopy();
mutableContext->setStringVar(m_contextKey1.c_str(), m_contextValue1.c_str());
}
if(!m_contextKey2.empty())
{
if(!mutableContext) mutableContext = context->createEditableCopy();
mutableContext->setStringVar(m_contextKey2.c_str(), m_contextValue2.c_str());
}
if(!m_contextKey3.empty())
{
if(!mutableContext) mutableContext = context->createEditableCopy();
mutableContext->setStringVar(m_contextKey3.c_str(), m_contextValue3.c_str());
}
if(!m_contextKey4.empty())
{
if(!mutableContext) mutableContext = context->createEditableCopy();
mutableContext->setStringVar(m_contextKey4.c_str(), m_contextValue4.c_str());
}
if(mutableContext) context = mutableContext;
return context;
}
示例2: parseArguments
void parseArguments(int argc, char **argv)
{
for(int i=1; i<argc; ++i)
{
if(0==strcmp(argv[i], "-v"))
{
g_verbose = true;
}
else if(0==strcmp(argv[i], "-gpulegacy"))
{
g_gpulegacy = true;
}
else if(0==strcmp(argv[i], "-gpuinfo"))
{
g_gpuinfo = true;
}
else if(0==strcmp(argv[i], "-h"))
{
std::cout << std::endl;
std::cout << "help:" << std::endl;
std::cout << " ociodisplay [OPTIONS] [image] where" << std::endl;
std::cout << std::endl;
std::cout << " OPTIONS:" << std::endl;
std::cout << " -h : displays the help and exit" << std::endl;
std::cout << " -v : displays the color space information" << std::endl;
std::cout << " -gpulegacy : use the legacy (i.e. baked) GPU color processing" << std::endl;
std::cout << " -gpuinfo : output the OCIO shader program" << std::endl;
std::cout << std::endl;
exit(0);
}
else
{
g_filename = argv[i];
}
}
if(g_verbose)
{
std::cout << std::endl;
if(!g_filename.empty())
{
std::cout << "Image:" << std::endl
<< "\t" << g_filename << std::endl;
}
std::cout << std::endl;
std::cout << "OIIO: " << std::endl
<< "\tversion = " << OIIO_VERSION_STRING << std::endl;
std::cout << std::endl;
std::cout << "OCIO: " << std::endl
<< "\tversion = " << OCIO::GetVersion() << std::endl;
if(getenv("OCIO"))
{
std::cout << "\tconfiguration = " << getenv("OCIO") << std::endl;
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
std::cout << "\tsearch_path = " << config->getSearchPath() << std::endl;
}
}
}
示例3: ColorProcessor_OCIO
ColorProcessor*
ColorConfig::createLookTransform (string_view looks,
string_view inputColorSpace,
string_view outputColorSpace,
bool inverse,
string_view context_key,
string_view context_val) const
{
#ifdef USE_OCIO
// Ask OCIO to make a Processor that can handle the requested
// transformation.
if (getImpl()->config_) {
OCIO::ConstConfigRcPtr config = getImpl()->config_;
OCIO::LookTransformRcPtr transform = OCIO::LookTransform::Create();
transform->setLooks (looks.c_str());
OCIO::TransformDirection dir;
if (inverse) {
// 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 (outputColorSpace.c_str());
transform->setDst (inputColorSpace.c_str());
dir = OCIO::TRANSFORM_DIR_INVERSE;
} else { // forward
transform->setSrc (inputColorSpace.c_str());
transform->setDst (outputColorSpace.c_str());
dir = OCIO::TRANSFORM_DIR_FORWARD;
}
OCIO::ConstContextRcPtr context = config->getCurrentContext();
if (context_key.size() && context_val.size()) {
OCIO::ContextRcPtr ctx = context->createEditableCopy();
ctx->setStringVar (context_key.c_str(), context_val.c_str());
context = ctx;
}
OCIO::ConstProcessorRcPtr p;
try {
// Get the processor corresponding to this transform.
p = getImpl()->config_->getProcessor (context, transform, dir);
}
catch(OCIO::Exception &e) {
getImpl()->error_ = e.what();
return NULL;
}
catch(...) {
getImpl()->error_ = "An unknown error occurred in OpenColorIO, getProcessor";
return NULL;
}
getImpl()->error_ = "";
return new ColorProcessor_OCIO(p);
}
#endif
return NULL; // if we get this far, we've failed
}
示例4: 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;
}
}
示例5: _validate
void OCIOColorSpace::_validate(bool for_real)
{
input0().validate(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
{
const char * inputName = m_inputColorSpaceCstrNames[m_inputColorSpaceIndex];
const char * outputName = m_outputColorSpaceCstrNames[m_outputColorSpaceIndex];
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
config->sanityCheck();
OCIO::ConstContextRcPtr context = getLocalContext();
m_processor = config->getProcessor(context, inputName, outputName);
}
catch(OCIO::Exception &e)
{
error(e.what());
return;
}
if(m_processor->isNoOp())
{
// TODO or call disable() ?
set_out_channels(DD::Image::Mask_None); // prevents engine() from being called
copy_info();
return;
}
set_out_channels(DD::Image::Mask_All);
DD::Image::PixelIop::_validate(for_real);
}
示例6: Generate
void Generate(int cubesize, int maxwidth,
const std::string & outputfile,
const std::string & configfile,
const std::string & incolorspace,
const std::string & outcolorspace)
{
int width = 0;
int height = 0;
int numchannels = 3;
GetLutImageSize(width, height, cubesize, maxwidth);
std::vector<float> img;
img.resize(width*height*numchannels, 0);
GenerateIdentityLut3D(&img[0], cubesize, numchannels, LUT3DORDER_FAST_RED);
if(!incolorspace.empty() || !outcolorspace.empty())
{
OCIO::ConstConfigRcPtr config = OCIO::Config::Create();
if(!configfile.empty())
{
config = OCIO::Config::CreateFromFile(configfile.c_str());
}
else if(getenv("OCIO"))
{
config = OCIO::Config::CreateFromEnv();
}
else
{
std::ostringstream os;
os << "You must specify an ocio configuration ";
os << "(either with --config or $OCIO).";
throw Exception(os.str().c_str());
}
OCIO::ConstProcessorRcPtr processor =
config->getProcessor(incolorspace.c_str(), outcolorspace.c_str());
OCIO::PackedImageDesc imgdesc(&img[0], width, height, 3);
processor->apply(imgdesc);
}
OIIO::ImageOutput* f = OIIO::ImageOutput::create(outputfile);
if(!f)
{
throw Exception( "Could not create output image.");
}
OIIO::ImageSpec spec(width, height, numchannels, OIIO::TypeDesc::TypeFloat);
// TODO: If DPX, force 16-bit output?
f->open(outputfile, spec);
f->write_image(OIIO::TypeDesc::FLOAT, &img[0]);
f->close();
delete f;
}
示例7: 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();
}
示例8:
static void
buildLookChoiceMenu(OCIO::ConstConfigRcPtr config,
ChoiceParamType* choice)
{
choice->resetOptions();
if (!config) {
return;
}
for (int i = 0; i < config->getNumLooks(); ++i) {
choice->appendOption(config->getLookNameByIndex(i));
}
}
示例9: transform_CB
void transform_CB(int id)
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * transform = config->getView(g_display.c_str(), id);
if(!transform) return;
g_transformName = transform;
UpdateOCIOGLState();
glutPostRedisplay();
}
示例10: look_CB
void look_CB(int id)
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * look = config->getLookNameByIndex(id);
if(!look || !*look) return;
g_look = look;
UpdateOCIOGLState();
glutPostRedisplay();
}
示例11: 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);
}
示例12: _validate
void OCIOFileTransform::_validate(bool for_real)
{
if(!m_file)
{
error("The source file must be specified.");
return;
}
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
transform->setSrc(m_file);
transform->setCCCId(m_cccid.c_str());
if(m_dirindex == 0) transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD);
else transform->setDirection(OCIO::TRANSFORM_DIR_INVERSE);
if(m_interpindex == 0) transform->setInterpolation(OCIO::INTERP_NEAREST);
else if(m_interpindex == 1) transform->setInterpolation(OCIO::INTERP_LINEAR);
else if(m_interpindex == 2) transform->setInterpolation(OCIO::INTERP_TETRAHEDRAL);
else if(m_interpindex == 3) transform->setInterpolation(OCIO::INTERP_BEST);
else
{
// Should never happen
error("Interpolation value out of bounds");
return;
}
m_processor = config->getProcessor(transform, OCIO::TRANSFORM_DIR_FORWARD);
}
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);
}
示例13: _validate
void OCIOFileTransform::_validate(bool for_real)
{
input0().validate(for_real);
if(!src)
{
error("The source file must be specified.");
return;
}
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
config->sanityCheck();
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
transform->setSrc(src);
// TODO: For some reason, cccid is NOT incorporated in this node's hash.
// Until then, cccid is considered broken. Figure out why.
transform->setCCCId(cccid.c_str());
if(dirindex == 0) transform->setDirection(OCIO::TRANSFORM_DIR_FORWARD);
else transform->setDirection(OCIO::TRANSFORM_DIR_INVERSE);
if(interpindex == 0) transform->setInterpolation(OCIO::INTERP_NEAREST);
else transform->setInterpolation(OCIO::INTERP_LINEAR);
processor = config->getProcessor(transform, OCIO::TRANSFORM_DIR_FORWARD);
}
catch(OCIO::Exception &e)
{
error(e.what());
return;
}
if(processor->isNoOp())
{
// TODO or call disable() ?
set_out_channels(DD::Image::Mask_None); // prevents engine() from being called
copy_info();
return;
}
set_out_channels(DD::Image::Mask_All);
DD::Image::PixelIop::_validate(for_real);
}
示例14: displayDevice_CB
void displayDevice_CB(int id)
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
const char * display = config->getDisplay(id);
if(!display) return;
g_display = display;
const char * csname = config->getDisplayColorSpaceName(g_display.c_str(), g_transformName.c_str());
if(!csname)
{
g_transformName = config->getDefaultView(g_display.c_str());
}
UpdateOCIOGLState();
glutPostRedisplay();
}
示例15: append
void OCIOColorSpace::append(DD::Image::Hash& localhash)
{
// TODO: Hang onto the context, what if getting it
// (and querying getCacheID) is expensive?
try
{
OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig();
OCIO::ConstContextRcPtr context = getLocalContext();
std::string configCacheID = config->getCacheID(context);
localhash.append(configCacheID);
}
catch(OCIO::Exception &e)
{
error(e.what());
return;
}
}