From b60ef5570f005374e688d62c69017543befca74e Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 5 Nov 2013 15:05:23 +0000 Subject: overlay in blend mode --- rotord/src/cvimage.cpp | 12 ++++++++++++ rotord/src/cvimage.h | 8 ++++++++ rotord/src/nodes_channels.h | 6 +++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index 74a21dd..8f2c181 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -138,6 +138,18 @@ namespace Rotor { //} return *this; } + Image & Image::overlay(cv::Mat &other){ + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot overlay images with different sizes! (wanted "<>7):255-(((0xFF-i)*(0xFF-j))>>7); } } mono_weights=new uint8_t*[3]; @@ -50,9 +53,11 @@ namespace Rotor { for (int i=0;i<256;i++){ delete[] add[i]; delete[] multiply[i]; + delete[] overlay[i]; } delete[] add; delete[] multiply; + delete[] overlay; for (int i=0;i<3;i++) { delete[] mono_weights[i]; } @@ -60,7 +65,9 @@ namespace Rotor { } uint8_t **add; uint8_t **multiply; + uint8_t **overlay; uint8_t **mono_weights; + }; static pixeltables pixels; class Image{ @@ -200,6 +207,7 @@ namespace Rotor { Image & alpha_from_cv(cv::Mat &other); Image & add_wrap(const Image &other); Image & divide_wrap(const Image &other); + Image & overlay(const Image &other); Image & operator*=(const float &amount); Image & operator+=(const float &amount); Image & operator-=(const float &amount); diff --git a/rotord/src/nodes_channels.h b/rotord/src/nodes_channels.h index fe129ea..e991660 100644 --- a/rotord/src/nodes_channels.h +++ b/rotord/src/nodes_channels.h @@ -69,13 +69,14 @@ namespace Rotor { #define BLEND_alpha 4 #define BLEND_wrap 5 #define BLEND_xor 6 +#define BLEND_overlay 7 class Blend: public Image_node { public: Blend(){ create_image_input("image input 1","Image input 1"); create_image_input("image input 2","Image input 2"); create_parameter("amount","number","amount to blend input 2","Blend amount",0.5f,0.0f,1.0f); - create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor"}); + create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay"}); title ="Blend"; description="Blend images in various modes"; UID="12ed7af0-2d0a-11e3-ae32-2b44203b93c9"; @@ -107,6 +108,9 @@ namespace Rotor { case BLEND_wrap: image=image.add_wrap(*in2); break; + case BLEND_overlay: + image=image.overlay(*in2); + break; case BLEND_blend: //has to be last because of initialser of *in? go figure image*=(1.0f-parameters["amount"]->value); -- cgit v1.2.3