From 17bde044aceadf9484d9ac999e8d4b9b2381f9c8 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 17 Jul 2013 12:09:28 +0100 Subject: rendering timer --- rotord/cvimage.cpp | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'rotord/cvimage.cpp') diff --git a/rotord/cvimage.cpp b/rotord/cvimage.cpp index a623bfd..ca094d3 100644 --- a/rotord/cvimage.cpp +++ b/rotord/cvimage.cpp @@ -49,25 +49,39 @@ namespace Rotor { //how to invert a matrix? //'invert' is matrix invert - different //subtract from a scalar (1) ? - //vector ichans,ochans; - //vector compchans; - //cv::split(rgb,ichans); - //cv::split(other.rgb,ochans); - //uint8_t b=0xFF; - //cv::Mat iA=b-other.alpha; - //cv::Mat iA=cv::Mat(h,w,CV_8UC1); - //for (int i=0;i ichans,ochans; + vector compchans; + cv::split(rgb,ichans); + cv::split(other.rgb,ochans); + uint8_t b=0xFF; + cv::Mat iA=b-other.alpha; + for (int i=0;i<3;i++) { + compchans.push_back(ichans[i].mul(iA,1.0/255.0)+ochans[i].mul(other.alpha,1.0/255.0)); + } + merge(compchans,rgb); //rgb+=other.rgb; + //for (int i=0;i>8)+((((int)other.rgb.data[i])*((int)other.alpha.data[i/3]))>>8)); + //} + } + + return *this; + } + Image & Image::alpha_blend_old(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot blend images with different sizes! (wanted "<>8)+((((int)other.rgb.data[i])*((int)other.alpha.data[i/3]))>>8)); - } } - return *this; } Image & Image::alpha_merge(const Image &other) { @@ -76,15 +90,7 @@ namespace Rotor { cerr<<"Rotor: cannot merge alpha with different size! (wanted "<