Esempio n. 1
0
void manager_t::get_views( const std::string& display, std::vector<std::string>& views, int& default_index) const
{
    OCIO::ConstConfigRcPtr cfg = config();
    int num_views = cfg->getNumViews( display.c_str());
    std::string default_view = cfg->getDefaultView( display.c_str());
	default_index = 0;
	views.clear();

    for( int i = 0; i < num_views; ++i)
    {
        std::string vname = cfg->getView( display.c_str(), i);
        views.push_back( vname);

        if( default_view == vname)
            default_index = i;
    }
}
Esempio n. 2
0
void viewer_t::change_display_device( int index)
{
    display_device_ = display_devices_[index];

    // refresh the list of transforms
    ocio_transform_combo_->blockSignals( true);
    ocio_transform_combo_->clear();

    OCIO::ConstConfigRcPtr config = app().ocio_manager().config();

    std::string default_transform = config->getDefaultView( display_device_.c_str());
    int num_transform_names = config->getNumViews( display_device_.c_str());

    int default_index = 0, new_index = -1;
    QStringList slist;

    for( int i = 0; i < num_transform_names; ++i)
    {
        std::string trname = config->getView( display_device_.c_str(), i);
        display_transforms_.push_back( trname);
        slist << trname.c_str();

        if( display_transform_ == trname)
            new_index = i;

        if( default_transform == trname)
            default_index = i;
    }

    ocio_transform_combo_->addItems( slist);

    if( new_index < 0)
        new_index = default_index;

    ocio_transform_combo_->setCurrentIndex( new_index);
    display_transform_ = ocio_transform_combo_->itemText( new_index).toStdString();
    ocio_transform_combo_->blockSignals( false);
	view_->display_transform_changed();
}
void KisOcioDisplayFilterTest::test()
{
    KisExposureGammaCorrectionInterface *egInterface =
        new KisDumbExposureGammaCorrectionInterface();

    OcioDisplayFilter filter(egInterface);

    QString configFile = TestUtil::fetchDataFileLazy("./psyfiTestingConfig-master/config.ocio");
    dbgKrita << ppVar(configFile);

    Q_ASSERT(QFile::exists(configFile));

    OCIO::ConstConfigRcPtr ocioConfig =
        OCIO::Config::CreateFromFile(configFile.toUtf8());

    filter.config = ocioConfig;
    filter.inputColorSpaceName = ocioConfig->getColorSpaceNameByIndex(0);
    filter.displayDevice = ocioConfig->getDisplay(1);
    filter.view = ocioConfig->getView(filter.displayDevice, 0);
    filter.gamma = 1.0;
    filter.exposure = 0.0;
    filter.swizzle = RGBA;

    filter.blackPoint = 0.0;
    filter.whitePoint = 1.0;

    filter.forceInternalColorManagement = false;
    filter.setLockCurrentColorVisualRepresentation(false);

    filter.updateProcessor();

    dbgKrita << ppVar(filter.inputColorSpaceName);
    dbgKrita << ppVar(filter.displayDevice);
    dbgKrita << ppVar(filter.view);
    dbgKrita << ppVar(filter.gamma);
    dbgKrita << ppVar(filter.exposure);

    const KoColorSpace *paintingCS =
                KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), Float32BitsColorDepthID.id(), 0);

    KisImageSP image = utils::createImage(0, QSize(100, 100));
    image->convertImageColorSpace(paintingCS, KoColorConversionTransformation::InternalRenderingIntent, KoColorConversionTransformation::InternalConversionFlags);
    image->waitForDone();

dbgKrita << ppVar(paintingCS) << ppVar(image->root()->firstChild()->colorSpace());

    KoCanvasResourceManager *resourceManager =
        utils::createResourceManager(image,
                                     image->root(), "");

    KisDisplayColorConverter converter(resourceManager, 0);

    dbgKrita << ppVar(image->root()->firstChild());

    QVariant v;
    v.setValue(KisNodeWSP(image->root()->firstChild()));
    resourceManager->setResource(KisCanvasResourceProvider::CurrentKritaNode, v);

    converter.setDisplayFilter(&filter);
    dbgKrita << ppVar(converter.paintingColorSpace());

    {
        QColor refColor(255, 128, 0);
        KoColor realColor = converter.approximateFromRenderedQColor(refColor);
        QColor roundTripColor = converter.toQColor(realColor);

        dbgKrita << ppVar(refColor);
        dbgKrita << ppVar(realColor.colorSpace()) << ppVar(KoColor::toQString(realColor));
        dbgKrita << ppVar(roundTripColor);
    }

    {
        KoColor realColor(Qt::red, paintingCS);
        QColor roundTripColor = converter.toQColor(realColor);

        dbgKrita << ppVar(realColor.colorSpace()) << ppVar(KoColor::toQString(realColor));
        dbgKrita << ppVar(roundTripColor);
    }

}