MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / View

Method View

src/OpenColorIO/transforms/MatrixTransform.cpp:269–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267 }
268}
269void MatrixTransform::View(double * m44, double * offset4,
270 int * channelHot4,
271 const double * lumaCoef3)
272{
273 if(!channelHot4 || !lumaCoef3) return;
274
275 if(offset4)
276 {
277 offset4[0] = 0.0;
278 offset4[1] = 0.0;
279 offset4[2] = 0.0;
280 offset4[3] = 0.0;
281 }
282
283 if(m44)
284 {
285 memset(m44, 0, 16*sizeof(double));
286
287 // All channels are hot, return identity
288 if(channelHot4[0] && channelHot4[1] &&
289 channelHot4[2] && channelHot4[3])
290 {
291 Identity(m44, 0x0);
292 }
293 // If not all the channels are hot, but alpha is,
294 // just show it.
295 else if(channelHot4[3])
296 {
297 for(int i=0; i<4; ++i)
298 {
299 m44[4*i+3] = 1.0;
300 }
301 }
302 // Blend rgb as specified, place it in all 3 output
303 // channels (to make a grayscale final image)
304 else
305 {
306 double values[3] = { 0.0, 0.0, 0.0 };
307
308 for(int i = 0; i < 3; ++i)
309 {
310 values[i] += lumaCoef3[i] * (channelHot4[i] ? 1.0 : 0.0);
311 }
312
313 double sum = values[0] + values[1] + values[2];
314 if(!IsScalarEqualToZero(sum))
315 {
316 values[0] /= sum;
317 values[1] /= sum;
318 values[2] /= sum;
319 }
320
321 // Copy rgb into rgb rows
322 for(int row=0; row<3; ++row)
323 {
324 for(int i=0; i<3; i++)
325 {
326 m44[4*row+i] = values[i];

Callers 2

test_interfaceMethod · 0.95
test_interfaceMethod · 0.95

Calls 1

IsScalarEqualToZeroFunction · 0.85

Tested by 2

test_interfaceMethod · 0.76
test_interfaceMethod · 0.76