OLD | NEW |
1 //------------------------------------------------------------------------------
--- | 1 //------------------------------------------------------------------------------
--- |
2 // | 2 // |
3 // Little Color Management System | 3 // Little Color Management System |
4 // Copyright (c) 1998-2012 Marti Maria Saguer | 4 // Copyright (c) 1998-2012 Marti Maria Saguer |
5 // | 5 // |
6 // Permission is hereby granted, free of charge, to any person obtaining | 6 // Permission is hereby granted, free of charge, to any person obtaining |
7 // a copy of this software and associated documentation files (the "Software"), | 7 // a copy of this software and associated documentation files (the "Software"), |
8 // to deal in the Software without restriction, including without limitation | 8 // to deal in the Software without restriction, including without limitation |
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e | 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 cmsStage* NewMPE; | 384 cmsStage* NewMPE; |
385 | 385 |
386 n = Rows * Cols; | 386 n = Rows * Cols; |
387 | 387 |
388 // Check for overflow | 388 // Check for overflow |
389 if (n == 0) return NULL; | 389 if (n == 0) return NULL; |
390 if (n >= UINT_MAX / Cols) return NULL; | 390 if (n >= UINT_MAX / Cols) return NULL; |
391 if (n >= UINT_MAX / Rows) return NULL; | 391 if (n >= UINT_MAX / Rows) return NULL; |
392 if (n < Rows || n < Cols) return NULL; | 392 if (n < Rows || n < Cols) return NULL; |
393 | 393 |
394 NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigMatrixElemType, Rows, Co
ls, | 394 NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigMatrixElemType, Cols, Ro
ws, |
395 EvaluateMatrix, MatrixElemDup, MatrixElemTy
peFree, NULL ); | 395 EvaluateMatrix, MatrixElemDup, MatrixElemTy
peFree, NULL ); |
396 if (NewMPE == NULL) return NULL; | 396 if (NewMPE == NULL) return NULL; |
397 | 397 |
398 | 398 |
399 NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageM
atrixData)); | 399 NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageM
atrixData)); |
400 if (NewElem == NULL) return NULL; | 400 if (NewElem == NULL) return NULL; |
401 | 401 |
402 | 402 |
403 NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFl
oat64Number)); | 403 NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFl
oat64Number)); |
404 | 404 |
405 if (NewElem->Double == NULL) { | 405 if (NewElem->Double == NULL) { |
406 MatrixElemTypeFree(NewMPE); | 406 MatrixElemTypeFree(NewMPE); |
407 return NULL; | 407 return NULL; |
408 } | 408 } |
409 | 409 |
410 for (i=0; i < n; i++) { | 410 for (i=0; i < n; i++) { |
411 NewElem ->Double[i] = Matrix[i]; | 411 NewElem ->Double[i] = Matrix[i]; |
412 } | 412 } |
413 | 413 |
414 | 414 |
415 if (Offset != NULL) { | 415 if (Offset != NULL) { |
416 | 416 |
417 NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Cols, sizeo
f(cmsFloat64Number)); | 417 NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Rows, sizeo
f(cmsFloat64Number)); |
418 if (NewElem->Offset == NULL) { | 418 if (NewElem->Offset == NULL) { |
419 MatrixElemTypeFree(NewMPE); | 419 MatrixElemTypeFree(NewMPE); |
420 return NULL; | 420 return NULL; |
421 } | 421 } |
422 | 422 |
423 for (i=0; i < Cols; i++) { | 423 for (i=0; i < Rows; i++) { |
424 NewElem ->Offset[i] = Offset[i]; | 424 NewElem ->Offset[i] = Offset[i]; |
425 } | 425 } |
426 | 426 |
427 } | 427 } |
428 | 428 |
429 NewMPE ->Data = (void*) NewElem; | 429 NewMPE ->Data = (void*) NewElem; |
430 return NewMPE; | 430 return NewMPE; |
431 } | 431 } |
432 | 432 |
433 | 433 |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 // Some clipping.... | 1784 // Some clipping.... |
1785 for (j=0; j < 3; j++) { | 1785 for (j=0; j < 3; j++) { |
1786 if (x[j] < 0) x[j] = 0; | 1786 if (x[j] < 0) x[j] = 0; |
1787 else | 1787 else |
1788 if (x[j] > 1.0) x[j] = 1.0; | 1788 if (x[j] > 1.0) x[j] = 1.0; |
1789 } | 1789 } |
1790 } | 1790 } |
1791 | 1791 |
1792 return TRUE; | 1792 return TRUE; |
1793 } | 1793 } |
OLD | NEW |