diff options
Diffstat (limited to 'rotord/src/cvimage.cpp')
| -rw-r--r-- | rotord/src/cvimage.cpp | 30 |
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; } + } |
