Changeset View
Changeset View
Standalone View
Standalone View
libs/pigment/compositeops/KoCompositeOpFunctions.h
Context not available. | |||||
479 | template<class T> | 479 | template<class T> | ||
---|---|---|---|---|---|
480 | inline T cfHeat(T src, T dst) { | 480 | inline T cfHeat(T src, T dst) { | ||
481 | using namespace Arithmetic; | 481 | using namespace Arithmetic; | ||
482 | // Heat, and Freeze only works properly on 8-bit images. It does not work properly on any other color depth. For now, if Heat and Freeze are proven useful for 8-bit painting, then there should be some way of solving this issue. | | |||
483 | 482 | | |||
484 | if(dst == zeroValue<T>()) { | 483 | return inv(cfGlow(inv(src),inv(dst))); | ||
484 | } | ||||
485 | | ||||
486 | template<class T> | ||||
487 | inline T cfFreeze(T src, T dst) { | ||||
488 | using namespace Arithmetic; | ||||
489 | | ||||
490 | return (cfHeat(dst,src)); | ||||
491 | } | ||||
492 | | ||||
493 | template<class T> | ||||
494 | inline T cfFrect(T src, T dst) { | ||||
495 | using namespace Arithmetic; | ||||
496 | // see http://www.pegtop.net/delphi/articles/blendmodes/quadratic.htm for formulas of Quadratic Blending Modes like Glow, Reflect, Freeze, and Heat | ||||
497 | | ||||
498 | if(cfHardMixPhotoshop(src,dst) == unitValue<T>()) { | ||||
499 | return cfHeat(src,dst); | ||||
500 | } | ||||
501 | | ||||
502 | return (cfGlow(src,dst)); | ||||
503 | } | ||||
504 | | ||||
505 | template<class T> | ||||
506 | inline T cfHelow(T src, T dst) { | ||||
507 | using namespace Arithmetic; | ||||
508 | | ||||
509 | if(src == zeroValue<T>()) { | ||||
485 | return zeroValue<T>(); | 510 | return zeroValue<T>(); | ||
486 | } | 511 | } | ||
487 | 512 | | |||
488 | if(src == unitValue<T>()) { | 513 | return (cfFrect(dst,src)); | ||
514 | } | ||||
515 | | ||||
516 | template<class T> | ||||
517 | inline T cfGleat(T src, T dst) { | ||||
518 | using namespace Arithmetic; | ||||
519 | // see http://www.pegtop.net/delphi/articles/blendmodes/quadratic.htm for formulas of Quadratic Blending Modes like Glow, Reflect, Freeze, and Heat | ||||
520 | | ||||
521 | if(cfHardMixPhotoshop(src,dst) == unitValue<T>()) { | ||||
522 | return cfGlow(src,dst); | ||||
523 | } | ||||
524 | | ||||
525 | return (cfHeat(src,dst)); | ||||
526 | } | ||||
527 | | ||||
528 | template<class T> | ||||
529 | inline T cfReeze(T src, T dst) { | ||||
530 | using namespace Arithmetic; | ||||
531 | | ||||
532 | return (cfGleat(dst,src)); | ||||
533 | } | ||||
534 | | ||||
535 | template<class T> | ||||
536 | inline T cfInterpolate(T src, T dst) { | ||||
537 | using namespace Arithmetic; | ||||
538 | typedef typename KoColorSpaceMathsTraits<T>::compositetype composite_type; | ||||
539 | // Interpolate does not work on integer images due to cos (pi*src), and cos (pi*dst). Another issue to be solved. | ||||
540 | | ||||
541 | composite_type half = cfAllanon(unitValue<T>(),zeroValue<T>()); | ||||
542 | composite_type four = cfAllanon(cfAllanon(unitValue<T>(),zeroValue<T>()),zeroValue<T>()); | ||||
543 | composite_type seta = cos(pi*src); | ||||
544 | composite_type setb = cos(pi*dst); | ||||
545 | | ||||
546 | return clamp<T>(half - seta * four - setb * four); | ||||
547 | } | ||||
548 | | ||||
549 | | ||||
550 | template<class T> | ||||
551 | inline T cfPenumbraB(T src, T dst) { | ||||
552 | using namespace Arithmetic; | ||||
553 | | ||||
554 | if(dst == unitValue<T>()) { | ||||
489 | return unitValue<T>(); | 555 | return unitValue<T>(); | ||
556 | } | ||||
557 | if(dst+src < unitValue<T>()) { | ||||
558 | return (cfColorDodge(dst,src)/2); | ||||
559 | } | ||||
560 | if(src == zeroValue<T>()) { | ||||
561 | return zeroValue<T>(); | ||||
490 | } | 562 | } | ||
491 | 563 | | |||
492 | return inv(clamp<T>(div(mul(inv(src), inv(src)),dst))); | 564 | return inv(clamp<T>(div(inv(dst),src)/2)); | ||
493 | } | 565 | } | ||
494 | 566 | | |||
495 | template<class T> | 567 | template<class T> | ||
496 | inline T cfFreeze(T src, T dst) { | 568 | inline T cfPenumbraA(T src, T dst) { | ||
497 | using namespace Arithmetic; | 569 | using namespace Arithmetic; | ||
498 | 570 | | |||
499 | return clamp<T>(cfHeat(dst,src)); | 571 | return (cfPenumbraB(dst,src)); | ||
500 | } | 572 | } | ||
501 | 573 | | |||
574 | template<class T> | ||||
575 | inline T cfSoftLightPegtopDelphi(T src, T dst) { | ||||
576 | using namespace Arithmetic; | ||||
577 | | ||||
578 | return clamp<T>(cfAddition(mul(dst,cfScreen(src,dst)),mul(mul(src,dst),inv(dst)))); | ||||
579 | } | ||||
580 | | ||||
581 | template<class T> | ||||
582 | inline T cfNegation(T src, T dst) { | ||||
583 | using namespace Arithmetic; | ||||
584 | typedef typename KoColorSpaceMathsTraits<T>::compositetype composite_type; | ||||
585 | | ||||
586 | composite_type unit = unitValue<T>(); | ||||
587 | composite_type a = unit - src - dst; | ||||
588 | composite_type s = abs(a); | ||||
589 | composite_type d = unit - s; | ||||
590 | | ||||
591 | return T(d); | ||||
592 | } | ||||
593 | | ||||
594 | template<class T> | ||||
595 | inline T cfPhoenix(T src, T dst) { | ||||
596 | using namespace Arithmetic; | ||||
597 | | ||||
598 | return clamp<T>(inv(cfDifference(src,dst))); | ||||
599 | } | ||||
600 | | ||||
601 | template<class T> | ||||
602 | inline T cfSignedDifference(T src, T dst) { | ||||
603 | using namespace Arithmetic; | ||||
604 | | ||||
605 | return clamp<T>((src-dst)/2 + halfValue<T>()); | ||||
606 | } | ||||
502 | 607 | | |||
503 | #endif // KOCOMPOSITEOP_FUNCTIONS_H_ | 608 | #endif // KOCOMPOSITEOP_FUNCTIONS_H_ | ||
Context not available. |