00001 #ifndef IO_IMAGE__HH
00002 #define IO_IMAGE__HH
00003
00004 #ifdef WIN32
00005 #include <iostream>
00006 #else
00007 #include <iostream.h>
00008 #endif
00009 using namespace std;
00010
00011 #include "image.H"
00060
00062 template <class T>
00063 class ImageIO {
00064 public:
00065
00072 static int ReadPGM(const char *const filename, Image<T> &image);
00073
00080 static int ReadPPM(const char *const filename, Image<T> &imageR,Image<T> &imageG,Image<T> &imageB);
00081
00086 static int ReadPPM(const char *const filename, Image<T> &image) { exit(-1); return(0); };
00087
00088
00095 static int ReadRawType(const char *const filename, Image<T> &image, const int largeur, const int hauteur);
00096
00101 static int WritePGM(const char *const filename, const Image<T> &image);
00102
00109 static int WritePPM(const char *const filename, const Image<T> &imageR,const Image<T> &imageG,const Image<T> &imageB);
00110
00115 static int WritePPM(const char *const filename, const Image<T> &image) { exit(-1); return(0); };
00116
00121 static int WriteRawType(const char *const filename, const Image<T> &image);
00123
00130 static int ReadPGMType(const char *const filename, Image<T> &image);
00131
00138 static int ReadRawUChar(const char *const filename, Image<T> &image, const int largeur, const int hauteur);
00139
00146 static int ReadRawShort(const char *const filename, Image<T> &image, const int largeur, const int hauteur);
00147
00152 static int ReadPGMUChar(const char *const filename, Image<T> &image);
00153
00162 static int ReadRawRGBUChar(const char *const filename, Image<T> &imageR,Image<T> &imageG,Image<T> &imageB, int largeur, int hauteur);
00163
00168 static int ReadPGMShort(const char *const filename, Image<T> &image);
00169
00175 static int ReadImageCCETT(const char *const filename, Image<T> &image, int numImage=1);
00176
00182 static int ReadTrameCCETT(const char *const filename, Image<T> &image, int numTrame=1);
00184
00191 static int WriteRawUChar(const char *const filename, const Image<T> &image);
00192
00197 static int WriteRawShort(const char *const filename, const Image<T> &image);
00198
00203 static int WritePGMType(const char *const filename, const Image<T> &image);
00204
00209 static int WritePGMUChar(const char *const filename, const Image<T> &image);
00210
00217 static int WriteRawRGBUChar(const char *const filename, const Image<T> &imageR,const Image<T> &imageG,const Image<T> &imageB);
00218
00223 static int WritePGMShort(const char *const filename, const Image<T> &image);
00225
00234 static int ReadRawType(istream &is, Image<T> &image, const int largeur, const int hauteur);
00235
00242 static int ReadRawUChar(istream &is, Image<T> &image, const int largeur, const int hauteur);
00243
00250 static int ReadRawShort(istream &is, Image<T> &image, const int largeur, const int hauteur);
00251
00256 static int ReadPGMType(istream &is, Image<T> &image);
00257
00262 static int ReadPGMUChar(istream &is, Image<T> &image);
00263
00268 static int ReadPGM(istream &is, Image<T> &image) { return ReadPGMUChar(is, image); }
00269
00278 static int ReadRawRGBUChar(istream &is, Image<T> &imageR,Image<T> &imageG,Image<T> &imageB, int largeur, int hauteur);
00279
00286 static int ReadPPM(istream &is, Image<T> &imageR,Image<T> &imageG,Image<T> &imageB);
00287
00292 static int ReadPGMShort(istream &is, Image<T> &image);
00294
00301 static int WriteRawType(ostream &os, const Image<T> &image);
00302
00307 static int WriteRawUChar(ostream &os, const Image<T> &image);
00308
00309
00314 static int WriteRawShort(ostream &os, const Image<T> &image);
00315
00320 static int WritePGMType(ostream &os, const Image<T> &image);
00321
00326 static int WritePGMUChar(ostream &os, const Image<T> &image);
00327
00332 static int WritePGM(ostream &os, const Image<T> &image) { return WritePGMUChar(os, image); }
00333
00340 static int WriteRawRGBUChar(ostream &os, const Image<T> &imageR,const Image<T> &imageG,const Image<T> &imageB);
00341
00348 static int WritePPM(ostream &os, const Image<T> &imageR,const Image<T> &imageG,const Image<T> &imageB);
00349
00354 static int WritePGMShort(ostream &os, const Image<T> &image);
00356
00364 static int InfoImagePGM(istream &is, int &largeur, int &hauteur);
00365
00371 static int InfoImagePGM(const char *const filename, int &largeur, int &hauteur);
00372
00378 static int InfoImagePPM(istream &is, int &largeur, int &hauteur);
00379
00385 static int InfoImagePPM(const char *const filename, int &largeur, int &hauteur);
00386
00393 static int InfoSequenceCCETT(const char *const filename, int &largeur, int &hauteur, int &nbImage);
00395 protected:
00400 static void SkipPGMWhiteSpace(istream &is);
00401
00406 static int ReadEntetePGM(istream &is, int &largeur, int &hauteur);
00407
00412 static int ReadEntetePPM(istream &is, int &largeur, int &hauteur);
00413
00418 static int WriteEntetePGM(ostream &os, const int largeur, const int hauteur);
00419
00424 static int WriteEntetePseudoPGM(ostream &os, const int largeur, const int hauteur);
00425
00430 static int WriteEntetePPM(ostream &os, const int largeur, const int hauteur);
00432 };
00434 #include "imageio.cpp"
00435
00436 #endif // IO_IMAGE__HH
00437
00438