$search
00001 #ifndef __OwnedImage_H__ 00002 #define __OwnedImage_H__ 00003 00004 #include "Image.h" 00005 00006 namespace EdgeDetection 00007 { 00008 class OwnedImage : public Image 00009 { 00010 private: double* values; 00011 00012 public: double Get(int x, int y) 00013 { 00014 if (x < 0 || x >= GetWidth()) throw "The parameter 'x' was out of range."; 00015 if (y < 0 || y >= GetHeight()) throw "The parameter 'y' was out of range."; 00016 00017 return values[x + y * GetWidth()]; 00018 } 00019 public: void Set(int x, int y, double value) 00020 { 00021 if (x < 0 || x >= GetWidth()) throw "The parameter 'x' was out of range."; 00022 if (y < 0 || y >= GetHeight()) throw "The parameter 'y' was out of range."; 00023 00024 values[x + y * GetWidth()] = value; 00025 } 00026 00027 public: OwnedImage(int width, int height) : Image(width, height) 00028 { 00029 this->values = new double[GetWidth() * GetHeight()]; 00030 00031 for (int index = 0; index < GetWidth() * GetHeight(); index++) values[index] = 0; 00032 } 00033 public: OwnedImage(Image* image) : Image(image->GetWidth(), image->GetHeight()) 00034 { 00035 this->values = new double[GetWidth() * GetHeight()]; 00036 00037 for (int y = 0; y < GetHeight(); y++) 00038 for (int x = 0; x < GetWidth(); x++) 00039 Set(x, y, image->Get(x, y)); 00040 } 00041 public: ~OwnedImage() 00042 { 00043 delete[] this->values; 00044 } 00045 00046 public: Image* GetRegion(int left, int right, int top, int bottom); 00047 }; 00048 }; 00049 00050 #endif