diff options
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index f630391..1f4c423 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -1005,6 +1005,7 @@ namespace Rotor { #define BLEND_screen 1 #define BLEND_multiply 2 #define BLEND_blend 3 + #define BLEND_alpha 4 class Blend: public Image_node { public: Blend(){image=nullptr;}; @@ -1016,6 +1017,7 @@ namespace Rotor { if (_mode=="screen") mode=BLEND_screen; if (_mode=="multiply") mode=BLEND_multiply; if (_mode=="blend") mode=BLEND_blend; + if (_mode=="alpha") mode=BLEND_alpha; }; void link_params() { for (auto p:parameter_inputs){ @@ -1039,12 +1041,16 @@ namespace Rotor { case BLEND_multiply: (*image)*=(*(((Image_node*)image_inputs[1]->connection)->get_output(frame))); break; - case BLEND_blend: + case BLEND_alpha: + (*image)=(*image).alpha_blend(*(((Image_node*)image_inputs[1]->connection)->get_output(frame))); + break; + case BLEND_blend: //has to be last because of initialser of *in? go figure (*image)*=(1.0f-amount); Image *in=(*(((Image_node*)image_inputs[1]->connection)->get_output(frame)))*amount; (*image)+=(*in); delete in; break; + } return image; } @@ -1246,6 +1252,34 @@ namespace Rotor { float tX,tY,oX,oY,r,s; //todo - quality settings }; + class Alpha_merge: public Image_node { + public: + Alpha_merge(){image=nullptr;}; + Alpha_merge(map<string,string> &settings) { + base_settings(settings); + }; + ~Alpha_merge(){ if (image) delete image;}; + Alpha_merge* clone(map<string,string> &_settings) { return new Alpha_merge(_settings);}; + Image *output(const Frame_spec &frame){ + if (image_inputs.size()) { + if (image_inputs[0]->connection){ + //copy incoming image **writable + if (image) delete image; + image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone(); + if (image_inputs.size()>1) { + if (image_inputs[1]->connection) { + image->alpha_merge(*((Image_node*)image_inputs[0]->connection)->get_output(frame)); + } + } + //if there aren't 2 image inputs connected just return the first + return image; + } + } + return nullptr; + } + private: + Image *image; //is an image generator + }; //------------------------------------------------------------------- class Node_factory{ public: |
