summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-07-17 12:16:12 +0100
committerTim Redfern <tim@herge.(none)>2013-07-17 12:16:12 +0100
commit44c13aad4de51fc0d30992f5dccb053669fa29d6 (patch)
treea8796f8b68ced170faa279040231afa19c7d4edd /rotord
parent17bde044aceadf9484d9ac999e8d4b9b2381f9c8 (diff)
timed pixelcorps version of alpha_merge is faster than openCV
Diffstat (limited to 'rotord')
-rw-r--r--rotord/cvimage.cpp7
-rw-r--r--rotord/cvimage.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/rotord/cvimage.cpp b/rotord/cvimage.cpp
index ca094d3..cb10fdd 100644
--- a/rotord/cvimage.cpp
+++ b/rotord/cvimage.cpp
@@ -33,8 +33,8 @@ namespace Rotor {
}
return *this;
}
- //THESE CAN BE OPTIMISED - LOOK INTO USING OPENCV HERE
- Image & Image::alpha_blend(const Image &other) {
+ //THIS OPENCV VERSION IS SLOWER THAN THE OLDSKOOL VERSION BELOW
+ Image & Image::alpha_blend_cv(const Image &other) {
if (other.w!=w||other.h!=h) {
cerr<<"Rotor: cannot blend images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl;
//why not??
@@ -67,7 +67,7 @@ namespace Rotor {
return *this;
}
- Image & Image::alpha_blend_old(const Image &other) {
+ Image & Image::alpha_blend(const Image &other) {
if (other.w!=w||other.h!=h) {
cerr<<"Rotor: cannot blend images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl;
//why not??
@@ -77,7 +77,6 @@ namespace Rotor {
rgb=other.rgb.clone();
}
else {
- rgb+=other.rgb;
for (int i=0;i<w*h*3;i++) {
rgb.data[i]=(uint8_t)(((((int)rgb.data[i])*(0xFF-other.alpha.data[i/3]))>>8)+((((int)other.rgb.data[i])*((int)other.alpha.data[i/3]))>>8));
}
diff --git a/rotord/cvimage.h b/rotord/cvimage.h
index c73ba70..0b767d8 100644
--- a/rotord/cvimage.h
+++ b/rotord/cvimage.h
@@ -162,7 +162,7 @@ namespace Rotor {
Image & operator*=(const Image &other);
Image & add_wrap(const Image &other);
Image & alpha_blend(const Image &other);
- Image & alpha_blend_old(const Image &other);
+ Image & alpha_blend_cv(const Image &other);
Image & alpha_merge(const Image &other);
Image & operator*=(const float &amount);
Image * operator*(const float &amount);