Пример #1
0
JNIEXPORT jstring JNICALL
Java_org_OpenColorIO_Processor_getCpuCacheID(JNIEnv * env, jobject self) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    return env->NewStringUTF(ptr->getCpuCacheID());
    OCIO_JNITRY_EXIT(NULL)
}
Пример #2
0
JNIEXPORT void JNICALL
Java_org_OpenColorIO_Processor_applyRGBA(JNIEnv * env, jobject self, jfloatArray pixel) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    ptr->applyRGBA(GetJFloatArrayValue(env, pixel, "pixel", 4)());
    OCIO_JNITRY_EXIT()
}
Пример #3
0
JNIEXPORT jboolean JNICALL
Java_org_OpenColorIO_Processor_hasChannelCrosstalk(JNIEnv * env, jobject self) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    return (jboolean)ptr->hasChannelCrosstalk();
    OCIO_JNITRY_EXIT(false)
}
Пример #4
0
JNIEXPORT jstring JNICALL
Java_org_OpenColorIO_Processor_getGpuShaderText(JNIEnv * env, jobject self, jobject shaderDesc) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    ConstGpuShaderDescRcPtr desc = GetConstJOCIO<ConstGpuShaderDescRcPtr, GpuShaderDescJNI>(env, shaderDesc);
    return env->NewStringUTF(ptr->getGpuShaderText(*desc.get()));
    OCIO_JNITRY_EXIT(NULL)
}
Пример #5
0
JNIEXPORT void JNICALL
Java_org_OpenColorIO_Processor_apply(JNIEnv * env, jobject self, jobject img) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    ImageDescRcPtr _img = GetEditableJOCIO<ImageDescRcPtr, ImageDescJNI>(env, img);
    ptr->apply(*_img.get());
    OCIO_JNITRY_EXIT()
}
Пример #6
0
JNIEXPORT void JNICALL
Java_org_OpenColorIO_Processor_getGpuLut3D(JNIEnv * env, jobject self, jobject lut3d, jobject shaderDesc) {
    OCIO_JNITRY_ENTER()
    ConstProcessorRcPtr ptr = GetConstJOCIO<ConstProcessorRcPtr, ProcessorJNI>(env, self);
    ConstGpuShaderDescRcPtr desc = GetConstJOCIO<ConstGpuShaderDescRcPtr, GpuShaderDescJNI>(env, shaderDesc);
    int len = desc->getLut3DEdgeLen();
    int size = 3*len*len*len;
    float* _lut3d = GetJFloatBuffer(env, lut3d, size);
    ptr->getGpuLut3D(_lut3d, *desc.get());
    OCIO_JNITRY_EXIT()
}
 void LocalFileFormat::Write(const Baker & baker,
                             const std::string & formatName,
                             std::ostream & ostream) const
 {
     
     static const int DEFAULT_CUBE_SIZE = 32;
     
     if(formatName != "iridas_cube")
     {
         std::ostringstream os;
         os << "Unknown cube format name, '";
         os << formatName << "'.";
         throw Exception(os.str().c_str());
     }
     
     ConstConfigRcPtr config = baker.getConfig();
     
     int cubeSize = baker.getCubeSize();
     if(cubeSize==-1) cubeSize = DEFAULT_CUBE_SIZE;
     cubeSize = std::max(2, cubeSize); // smallest cube is 2x2x2
     
     std::vector<float> cubeData;
     cubeData.resize(cubeSize*cubeSize*cubeSize*3);
     GenerateIdentityLut3D(&cubeData[0], cubeSize, 3, LUT3DORDER_FAST_RED);
     PackedImageDesc cubeImg(&cubeData[0], cubeSize*cubeSize*cubeSize, 1, 3);
     
     // Apply our conversion from the input space to the output space.
     ConstProcessorRcPtr inputToTarget;
     std::string looks = baker.getLooks();
     if(!looks.empty())
     {
         LookTransformRcPtr transform = LookTransform::Create();
         transform->setLooks(looks.c_str());
         transform->setSrc(baker.getInputSpace());
         transform->setDst(baker.getTargetSpace());
         inputToTarget = config->getProcessor(transform, TRANSFORM_DIR_FORWARD);
     }
     else
     {
         inputToTarget = config->getProcessor(baker.getInputSpace(), baker.getTargetSpace());
     }
     inputToTarget->apply(cubeImg);
     
     if(baker.getMetadata() != NULL)
     {
         std::string metadata = baker.getMetadata();
         std::vector<std::string> metadatavec;
         pystring::split(pystring::strip(metadata), metadatavec, "\n");
         if(metadatavec.size() > 0)
         {
             for(size_t i = 0; i < metadatavec.size(); ++i)
             {
                 ostream << "# " << metadatavec[i] << "\n";
             }
             ostream << "\n";
         }
     }
     ostream << "LUT_3D_SIZE " << cubeSize << "\n";
     if(cubeSize < 2)
     {
         throw Exception("Internal cube size exception");
     }
     
     // Set to a fixed 6 decimal precision
     ostream.setf(std::ios::fixed, std::ios::floatfield);
     ostream.precision(6);
     for(int i=0; i<cubeSize*cubeSize*cubeSize; ++i)
     {
         ostream << cubeData[3*i+0] << " "
                 << cubeData[3*i+1] << " "
                 << cubeData[3*i+2] << "\n";
     }
 }