summaryrefslogtreecommitdiff
path: root/rotord/src/cvimage.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-08-15 17:48:41 +0100
committerTim Redfern <tim@herge.(none)>2013-08-15 17:48:41 +0100
commitae77e77ac1524121580281126a4ae85b70b5abae (patch)
tree8155476ceaf65a0f1b9d4fda9714f32fb23993c3 /rotord/src/cvimage.cpp
parent15d7e3dadff62b20173fb2b5b354e72d3c916c9a (diff)
new class structure to support listnodes
Diffstat (limited to 'rotord/src/cvimage.cpp')
-rw-r--r--rotord/src/cvimage.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp
index a03d81c..361999b 100644
--- a/rotord/src/cvimage.cpp
+++ b/rotord/src/cvimage.cpp
@@ -126,6 +126,15 @@ namespace Rotor {
}
return *this;
}
+ Image & Image::operator=(const Image &other) {
+ //can be optimised? was trying to use other.data.clone()
+ setup(other.w,other.h);
+ //for (int i=0;i<h*w*3;i++) {
+ // rgb.data[i]=other.rgb.data[i];
+ //}
+ memcpy(rgb.data,other.rgb.data,h*w*3); //saves ~2.4 ms copying a 640x360 image
+ return *this;
+ }
//channel rearrangement
//RGBAZ - these are channels 0-4
//HSB - can also have these virtual channels 5-7
@@ -135,7 +144,25 @@ namespace Rotor {
//maybe this could not be the case if the data is owned by this image?
//need to look into auto_ptr
Image & Image::operator*=(const float &amount) {
- rgb*=amount;
+ //cerr<<"amount: "<<amount<<endl;
+ //rgb*=amount;
+ uint8_t amt=(uint8_t)(amount*255.0f);
+ for (int i=0;i<h*w*3;i++) {
+ rgb.data[i]=pixels.multiply[rgb.data[i]][amt];
+ }
+ //again this is faster
+ return *this;
+ }
+ Image & Image::operator+=(const float &amount) {
+ rgb+=(amount*255.0f);
+ return *this;
+ }
+ Image & Image::operator-=(const float &amount) {
+ rgb-=(amount*255.0f);
+ return *this;
+ }
+ Image & Image::operator/=(const float &amount) {
+ rgb/=amount;
return *this;
}
Image * Image::operator*(const float &amount) {
@@ -160,4 +187,5 @@ namespace Rotor {
other->rgb=rgb/amount;
return other;
}
+
}