00001 /************************************************************************** 00002 ** Title: simple RGB image 00003 ** $RCSfile: SimpleRGBImage.hh,v $ 00004 ** $Revision: 1.1 $$Name: $ 00005 ** $Date: 2002/11/02 12:07:11 $ 00006 ** Copyright: GPL $Author: pigorsch $ 00007 ** Description: 00008 ** 00009 ** 00010 ** 00011 **------------------------------------------------------------------------- 00012 ** 00013 ** $Log: SimpleRGBImage.hh,v $ 00014 ** Revision 1.1 2002/11/02 12:07:11 pigorsch 00015 ** - initial revision 00016 ** 00017 ** Revision 1.7 2002/10/30 15:46:06 pigorsch 00018 ** - modified comments 00019 ** 00020 ** Revision 1.6 2002/10/30 15:45:16 pigorsch 00021 ** - changed image format from P6 to P3 00022 ** 00023 ** Revision 1.5 2002/10/30 15:35:52 pigorsch 00024 ** - added operator= 00025 ** 00026 ** Revision 1.3 2002/10/30 15:19:00 pigorsch 00027 ** - added Copy Constructor 00028 ** 00029 ** Revision 1.2 2002/10/25 10:13:59 pigorsch 00030 ** *** empty log message *** 00031 ** 00032 ** Revision 1.1 2002/10/24 10:11:43 pigorsch 00033 ** *** empty log message *** 00034 ** 00035 ** Revision 1.2 2001/04/26 09:21:46 haasdonk 00036 ** slight modifications 00037 ** 00038 ** 00039 **************************************************************************/ 00040 00041 #ifndef SIMPLERGBIMAGE_HH 00042 #define SIMPLERGBIMAGE_HH 00043 00044 #include <iostream> 00045 #include "RGBColor.hh" 00046 #include "MyError.hh" 00047 00048 00049 /*======================================================================*/ 00058 /*======================================================================*/ 00059 class SimpleRGBImage 00060 { 00061 00062 static const unsigned int MAX_DIMENSION = 16384; 00063 00064 public: 00065 /*----------------------------------------------------------------------- 00066 * Error classes 00067 *-----------------------------------------------------------------------*/ 00068 class ReadError: public MyError 00069 { 00070 public: 00071 ReadError(std::string s): 00072 MyError(s) 00073 {}; 00074 }; 00075 00076 class WriteError: public MyError 00077 { 00078 public: 00079 WriteError(std::string s): 00080 MyError(s) 00081 {}; 00082 }; 00083 00084 /*======================================================================*/ 00088 /*======================================================================*/ 00089 SimpleRGBImage(); 00090 00091 /*======================================================================*/ 00095 /*======================================================================*/ 00096 SimpleRGBImage(const SimpleRGBImage& image); 00097 00098 /*======================================================================*/ 00105 /*======================================================================*/ 00106 SimpleRGBImage(unsigned int width, unsigned int height); 00107 00108 /*======================================================================*/ 00115 /*======================================================================*/ 00116 SimpleRGBImage(std::istream& is); 00117 00118 /*======================================================================*/ 00122 /*======================================================================*/ 00123 ~SimpleRGBImage(); 00124 00125 /*======================================================================*/ 00133 /*======================================================================*/ 00134 void resize(unsigned int width, unsigned int height); 00135 00136 00137 /*======================================================================*/ 00150 /*======================================================================*/ 00151 void read(std::istream& is); 00152 00153 /*======================================================================*/ 00164 /*======================================================================*/ 00165 void write(std::ostream& os); 00166 00167 00168 /*======================================================================*/ 00177 /*======================================================================*/ 00178 RGBColor& operator()(unsigned int x, unsigned int y); 00179 const RGBColor& operator()(unsigned int x, unsigned int y) const; 00180 00181 00182 00183 /*======================================================================*/ 00189 /*======================================================================*/ 00190 unsigned int width() const; 00191 00192 00193 /*======================================================================*/ 00199 /*======================================================================*/ 00200 unsigned int height() const; 00201 00202 /*======================================================================*/ 00208 /*======================================================================*/ 00209 size_t size() const; 00210 00211 /*======================================================================*/ 00217 /*======================================================================*/ 00218 RGBColor* begin(); 00219 const RGBColor* begin() const; 00220 00221 /*======================================================================*/ 00228 /*======================================================================*/ 00229 RGBColor* end(); 00230 const RGBColor* end() const; 00231 00232 /*======================================================================*/ 00239 /*======================================================================*/ 00240 RGBColor& operator[](size_t n); 00241 const RGBColor& operator[](size_t n) const; 00242 00243 00244 /*======================================================================*/ 00251 /*======================================================================*/ 00252 SimpleRGBImage& operator=(const SimpleRGBImage& image); 00253 00254 private: 00255 unsigned int _width, _height, _size; 00256 RGBColor* _pixels; 00257 RGBColor* _pixelsEnd; 00258 RGBColor** _rowStart; 00259 }; 00260 00261 #include "SimpleRGBImage.icc" 00262 00263 #endif