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