コード例 #1
0
ファイル: manager.cpp プロジェクト: JohanAberg/Ramen
void manager_t::get_displays()
{
	OCIO::ConstConfigRcPtr cfg = config();
    default_display_ = cfg->getDefaultDisplay();
    int num_device_names = cfg->getNumDisplays();

    for(int i = 0; i < num_device_names; i++)
    {
        std::string dispname = cfg->getDisplay( i);
        displays_.push_back( dispname);

        if( default_display_ == dispname)
            default_display_index_ = i;
    }
}
コード例 #2
0
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);
    }

}