volmetrics
diff src/image.cc @ 4:1fbbe10c8e08
quick backup
author | Eleni Maria Stea <elene.mst@gmail.com> |
---|---|
date | Sat, 11 Jan 2014 23:49:58 +0200 |
parents | 927c29b93009 |
children |
line diff
1.1 --- a/src/image.cc Sat Jan 11 22:55:27 2014 +0200 1.2 +++ b/src/image.cc Sat Jan 11 23:49:58 2014 +0200 1.3 @@ -14,6 +14,48 @@ 1.4 delete [] pixels; 1.5 } 1.6 1.7 +//copy constructor - assignment operator 1.8 +Image::Image(const Image &img) 1.9 +{ 1.10 + pixels = 0; 1.11 + set_pixels(img.pixels, img.width, img.height); 1.12 +} 1.13 + 1.14 +Image &Image::operator = (const Image &img) 1.15 +{ 1.16 + if(&img != this) { 1.17 + set_pixels(img.pixels, img.width, img.height); 1.18 + } 1.19 + return *this; 1.20 +} 1.21 + 1.22 +//move constructor - move operator c++11 R-value reference to image 1.23 +Image::Image(Image &&img) 1.24 +{ 1.25 + pixels = img.pixels; 1.26 + width = img.width; 1.27 + height = img.height; 1.28 + 1.29 + img.pixels = 0; 1.30 + img.width = 0; 1.31 + img.height = 0; 1.32 +} 1.33 + 1.34 +Image &Image::operator = (Image &&img) 1.35 +{ 1.36 + if(&img != this) { 1.37 + pixels = img.pixels; 1.38 + width = img.width; 1.39 + height = img.height; 1.40 + 1.41 + img.pixels = 0; 1.42 + img.width = 0; 1.43 + img.height = 0; 1.44 + } 1.45 + 1.46 + return *this; 1.47 +} 1.48 + 1.49 bool Image::load(const char *fname) 1.50 { 1.51 int new_width, new_height;