MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / getColorAt

Method getColorAt

Gui/ViewerGL.cpp:4367–4465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4365} // getColorAtInternal
4366
4367bool
4368ViewerGL::getColorAt(double x,
4369 double y, // x and y in canonical coordinates
4370 bool forceLinear,
4371 int textureIndex,
4372 float* r,
4373 float* g,
4374 float* b,
4375 float* a,
4376 unsigned int* imgMmlevel) // output values
4377{
4378 // always running in the main thread
4379 assert( qApp && qApp->thread() == QThread::currentThread() );
4380 assert(r && g && b && a);
4381 assert(textureIndex == 0 || textureIndex == 1);
4382
4383
4384 unsigned int mipMapLevel = (unsigned int)getMipMapLevelCombinedToZoomFactor();
4385 ImagePtr image = getLastRenderedImageByMipMapLevel(textureIndex, mipMapLevel);
4386
4387
4388 if (!image) {
4389 return false;
4390 ///Don't do this as this is 8bit data
4391 /*double colorGPU[4];
4392 getTextureColorAt(x, y, &colorGPU[0], &colorGPU[1], &colorGPU[2], &colorGPU[3]);
4393 * a = colorGPU[3];
4394 if ( forceLinear && (_imp->displayingImageLut != eViewerColorSpaceLinear) ) {
4395 const Color::Lut* srcColorSpace = ViewerInstance::lutFromColorspace(_imp->displayingImageLut);
4396
4397 * r = srcColorSpace->fromColorSpaceFloatToLinearFloat(colorGPU[0]);
4398 * g = srcColorSpace->fromColorSpaceFloatToLinearFloat(colorGPU[1]);
4399 * b = srcColorSpace->fromColorSpaceFloatToLinearFloat(colorGPU[2]);
4400 } else {
4401 * r = colorGPU[0];
4402 * g = colorGPU[1];
4403 * b = colorGPU[2];
4404 }
4405 return true;*/
4406 }
4407
4408 ImageBitDepthEnum depth = image->getBitDepth();
4409 ViewerColorSpaceEnum srcCS = _imp->viewerTab->getGui()->getApp()->getDefaultColorSpaceForBitDepth(depth);
4410 const Color::Lut* dstColorSpace;
4411 const Color::Lut* srcColorSpace;
4412 if ( (srcCS == _imp->displayingImageLut)
4413 && ( (_imp->displayingImageLut == eViewerColorSpaceLinear) || !forceLinear ) ) {
4414 // identity transform
4415 srcColorSpace = 0;
4416 dstColorSpace = 0;
4417 } else {
4418 if ( image->getComponents().isColorPlane() ) {
4419 srcColorSpace = ViewerInstance::lutFromColorspace(srcCS);
4420 dstColorSpace = ViewerInstance::lutFromColorspace(_imp->displayingImageLut);
4421 } else {
4422 srcColorSpace = dstColorSpace = 0;
4423 }
4424 }

Callers

nothing calls this directly

Calls 10

lutFromColorspaceFunction · 0.85
getComponentsMethod · 0.80
floorFunction · 0.50
getBitDepthMethod · 0.45
getAppMethod · 0.45
getGuiMethod · 0.45
isColorPlaneMethod · 0.45
getPixelAspectRatioMethod · 0.45
getMipMapLevelMethod · 0.45

Tested by

no test coverage detected