SMIL  0.9.1
DImageIO.hpp
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #ifndef _D_IMAGE_IO_HPP
31 #define _D_IMAGE_IO_HPP
32 
33 
34 
35 
36 #include "IO/include/DCommonIO.h"
37 #include "Base/include/private/DImageArith.hpp"
38 
39 
40 
41 namespace smil
42 {
43 
50  template <class T=void>
52  {
53  public:
54  ImageFileHandler(const char *ext)
55  : fileExtention(ext)
56  {
57  }
58  virtual ~ImageFileHandler() {}
59 
60  const char *fileExtention;
61 
62  virtual RES_T getFileInfo(const char*, ImageFileInfo &)
63  {
64  return RES_ERR;
65  }
66 
67  virtual RES_T read(const char*)
68  {
69  return RES_ERR;
70  }
71 
72  virtual RES_T read(const char*, Image<T> &)
73  {
74  T *dum = NULL;
75  cout << getDataTypeAsString<T>(dum) << " data type not implemented for " << fileExtention << " files (read)." << endl;
76  return RES_ERR;
77  }
78  virtual RES_T write(const Image<T> &, const char*)
79  {
80  T *dum = NULL;
81  cout << getDataTypeAsString<T>(dum) << " data type not implemented for " << fileExtention << " files (write)." << endl;
82  return RES_ERR;
83  }
84  };
85 
86  template <class T>
87  ImageFileHandler<T> *getHandlerForFile(const char* filename);
88 
92  template <class T>
93  RES_T read(const char* filename, Image<T> &image);
94 
100  template <class T>
101  RES_T read(const vector<string> fileList, Image<T> &image);
102 
106  template <class T>
107  RES_T write(const Image<T> &image, const char *filename);
108 
121  template <class T>
122  RES_T write(const Image<T> &image, const vector<string> fileList);
123 
124  RES_T getFileInfo(const char *filename, ImageFileInfo &fInfo);
125 
126  BaseImage *createFromFile(const char *filename);
127 
130 } // namespace smil
131 
132 
133 
134 #endif // _D_IMAGE_IO_HPP
Definition: DColorConvert.h:38
Definition: DImageIO.hpp:51
Base Image class.
Definition: DBaseImage.h:50
Main Image class.
Definition: DQVtkViewer.hpp:44
Definition: DCommonIO.h:70