00001
00002 #ifndef vil1_memory_image_of_h_
00003 #define vil1_memory_image_of_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <vil1/vil1_image.h>
00027 #include <vil1/vil1_memory_image.h>
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 template <class T>
00046 class vil1_memory_image_of : public vil1_memory_image
00047 {
00048 public:
00049
00050 typedef T pixel_type;
00051
00052
00053 typedef T *iterator;
00054 inline iterator begin() { return get_buffer(); }
00055 inline iterator end () { return get_buffer() + rows()*cols(); }
00056
00057 typedef T const *const_iterator;
00058 inline const_iterator begin() const { return get_buffer(); }
00059 inline const_iterator end () const { return get_buffer() + rows()*cols(); }
00060
00061 inline unsigned size() const { return rows() * cols(); }
00062
00063
00064 vil1_memory_image_of();
00065
00066
00067 vil1_memory_image_of(vil1_memory_image_of<T> const &);
00068
00069
00070
00071 explicit
00072 vil1_memory_image_of(vil1_image const& image);
00073
00074
00075 vil1_memory_image_of(int sizex, int sizey);
00076
00077
00078 vil1_memory_image_of(T *buf, int sizex, int sizey);
00079 #if 0
00080
00081 vil1_memory_image_of(int sizex, int sizey, T const& value);
00082 #endif
00083
00084 inline ~vil1_memory_image_of() {}
00085
00086
00087 vil1_memory_image_of<T>& operator=(vil1_memory_image_of<T> const &);
00088
00089
00090
00091
00092 vil1_memory_image_of<T>& operator=(vil1_image const &);
00093
00094
00095 void set(vil1_image const& image);
00096
00097
00098 void resize(int width, int height);
00099 private:
00100
00101 void resize(int planes, int width, int height);
00102 public:
00103
00104
00105
00106
00107 inline T& operator () (int x, int y) { return ((T**)rows0_)[y][x]; }
00108 inline T const& operator () (int x, int y) const { return ((T const* const*)rows0_)[y][x]; }
00109
00110
00111 inline T* operator [] (int y) { return ((T**)rows0_)[y]; }
00112 inline T const* operator [] (int y) const { return ((T const* const*)rows0_)[y]; }
00113
00114
00115 inline T* const* row_array() { return (T**)rows0_; }
00116 inline T const* const* row_array() const { return (T**)rows0_; }
00117
00118
00119 inline T* get_buffer() { return (T*)rows0_[0]; }
00120 inline T const* get_buffer() const { return (T*)rows0_[0]; }
00121
00122
00123 inline bool in_range(int x, int y) const { return (0 <= x) && (0 <= y) && (x < width_) && (y < height_); }
00124
00125
00126 inline bool in_range_window(int x, int y, int w) const {
00127 return (w <= x) && (w <= y) && (x + w < width_) && (y + w < height_);
00128 }
00129
00130
00131 inline bool in_range(int x, int y, unsigned w, unsigned h) const {
00132 return (0<=x && x+int(w)<=width_) && (0<=y && y+int(h)<=height_);
00133 }
00134
00135
00136 void fill(T const& );
00137 };
00138
00139 #endif // vil1_memory_image_of_h_