]> Creatis software - creaImageIO.git/blob - src2/creaImageIOImageReader.h
2f3e7d0141fad6fc5ea30b50e7ff4dc7bdbd4a9f
[creaImageIO.git] / src2 / creaImageIOImageReader.h
1 #ifndef __creaImageIOImageReader_h_INCLUDED__
2 #define __creaImageIOImageReader_h_INCLUDED__
3
4
5 #include <creaImageIOTreeAttributeDescriptor.h>
6
7 #include <vtkImageData.h>
8 #include <string>
9 #include <vector>
10 #include <map>
11
12 namespace creaImageIO
13 {
14
15
16         /**
17         * \ingroup Model
18         */
19   //=====================================================================
20   /// Image reader of a specific image format
21   class SpecificImageReader;
22   //=====================================================================
23
24   //=====================================================================
25   /// Generic image reader which stores a vector of SpecificImageReader
26   class ImageReader
27   {
28   public:
29     ImageReader();
30     ~ImageReader();
31
32  
33     /// Returns true iff the file is readable
34     bool CanRead( const std::string& filename, 
35                   const std::string& exclude = "");
36     /// Reads and returns the image data. 
37     /// Returns an "Unreadable image" picture if fails
38     vtkImageData* ReadImage( const std::string& filename,
39                              const std::string& exclude = "");
40     
41     /// Reads the attributes of the image.
42     /// Requested attributes names are provided as keys 
43     /// in a string to string map
44     /// On return, the values of the map are the values 
45     /// of the attributes (empty string if not available).
46     void ReadAttributes(const std::string& filename, 
47                         std::map<std::string,std::string>& attr);
48
49     /// Returns the known extensions
50     const std::vector<std::string>& GetKnownExtensions()  
51     { return mKnownExtensions; }
52
53   protected:
54     
55     void Register(SpecificImageReader*);
56
57     std::vector<SpecificImageReader*> mReader;
58     std::vector<std::string> mKnownExtensions;
59     vtkImageData* mUnreadableImage;
60
61     std::string mLastFilename;
62     SpecificImageReader* mLastReader;
63     
64   private:
65
66   }; // class ImageReader
67   //=====================================================================
68
69
70
71 } // namespace creaImageIO
72
73
74
75 #endif // #ifndef __creaImageIOImageReader_h_INCLUDED__