diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-07-17 15:38:31 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-07-17 15:38:31 +0100 |
| commit | 9cf113df8b50c0c6f5132d3bd8b803db5332d9e6 (patch) | |
| tree | b7dbdf0aa80b2dc3b45eb031ceb7e04582e2d9e4 | |
| parent | 7e3657d7783b7a6cdb48719d17ec3ac381dd8ae7 (diff) | |
glitchy blend modes
| -rw-r--r-- | rotord/cvimage.cpp | 14 | ||||
| -rw-r--r-- | rotord/cvimage.h | 3 | ||||
| -rwxr-xr-x | rotord/rotor.h | 10 |
3 files changed, 25 insertions, 2 deletions
diff --git a/rotord/cvimage.cpp b/rotord/cvimage.cpp index 5402a8e..a82c1ec 100644 --- a/rotord/cvimage.cpp +++ b/rotord/cvimage.cpp @@ -33,7 +33,19 @@ namespace Rotor { else { for (int i=0;i<w*h*3;i++){ //creates rainbow overload, openCV doesn't do this - RGBdata[i]=(unsigned char)(((int)other.RGBdata[i]+(int)RGBdata[i])); + rgb.data[i]=(unsigned char)(((int)other.rgb.data[i]+(int)rgb.data[i])); + } + } + return *this; + } + Image & Image::divide_wrap(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot add images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl; + } + else { + for (int i=0;i<w*h*3;i++){ + //creates rainbow overload, openCV doesn't do this + rgb/=other.rgb; //does funny glitchy stuff } } return *this; diff --git a/rotord/cvimage.h b/rotord/cvimage.h index 0b767d8..a8a7a09 100644 --- a/rotord/cvimage.h +++ b/rotord/cvimage.h @@ -160,10 +160,11 @@ namespace Rotor { //believe these still work, don't know if these optimisations are better than opencvs.. Image & operator+=(const Image &other); Image & operator*=(const Image &other); - Image & add_wrap(const Image &other); Image & alpha_blend(const Image &other); Image & alpha_blend_cv(const Image &other); Image & alpha_merge(const Image &other); + Image & add_wrap(const Image &other); + Image & divide_wrap(const Image &other); Image & operator*=(const float &amount); Image * operator*(const float &amount); Image * operator+(const float &amount); diff --git a/rotord/rotor.h b/rotord/rotor.h index 136d812..1b68f2b 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -1010,6 +1010,8 @@ namespace Rotor { #define BLEND_multiply 2 #define BLEND_blend 3 #define BLEND_alpha 4 + #define BLEND_screen_wrap 5 + #define BLEND_multiply_wrap 6 class Blend: public Image_node { public: Blend(){image=nullptr;}; @@ -1022,6 +1024,8 @@ namespace Rotor { if (_mode=="multiply") mode=BLEND_multiply; if (_mode=="blend") mode=BLEND_blend; if (_mode=="alpha") mode=BLEND_alpha; + if (_mode=="screen_wrap") mode=BLEND_screen_wrap; + if (_mode=="multiply_wrap") mode=BLEND_multiply_wrap; }; void link_params() { for (auto p:parameter_inputs){ @@ -1048,6 +1052,12 @@ namespace Rotor { case BLEND_alpha: (*image)=(*image).alpha_blend(*(((Image_node*)image_inputs[1]->connection)->get_output(frame))); break; + case BLEND_screen_wrap: + (*image)=(*image).add_wrap(*(((Image_node*)image_inputs[1]->connection)->get_output(frame))); + break; + case BLEND_multiply_wrap: + (*image)=(*image).divide_wrap(*(((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; |
