1 //
2 // Copyright 2007-2008 Christian Henning
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_EXTENSION_IO_TIFF_OLD_HPP
9 #define BOOST_GIL_EXTENSION_IO_TIFF_OLD_HPP
10 
11 #include <boost/gil/extension/io/tiff.hpp>
12 
13 namespace boost { namespace gil {
14 
15 /// \ingroup TIFF_IO
16 /// \brief Returns the width and height of the TIFF file at the specified location.
17 /// Throws std::ios_base::failure if the location does not correspond to a valid TIFF file
18 template<typename String>
tiff_read_dimensions(String const & filename)19 inline point_t tiff_read_dimensions(String const& filename)
20 {
21     using backend_t = typename get_reader_backend<String, tiff_tag>::type;
22     backend_t backend = read_image_info(filename, tiff_tag());
23     return { backend._info._width, backend._info._height };
24 }
25 
26 /// \ingroup TIFF_IO
27 /// \brief Loads the image specified by the given tiff image file name into the given view.
28 /// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension.
29 /// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not
30 /// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
31 template< typename String
32         , typename View
33         >
34 inline
tiff_read_view(const String & filename,const View & view)35 void tiff_read_view( const String& filename
36                    , const View&   view
37                    )
38 {
39     read_view( filename
40              , view
41              , tiff_tag()
42              );
43 }
44 
45 /// \ingroup TIFF_IO
46 /// \brief Allocates a new image whose dimensions are determined by the given tiff image file, and loads the pixels into it.
47 /// Triggers a compile assert if the image color space or channel depth are not supported by the TIFF library or by the I/O extension.
48 /// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its color space or channel depth are not
49 /// compatible with the ones specified by Image
50 template< typename String
51         , typename Image
52         >
53 inline
tiff_read_image(const String & filename,Image & img)54 void tiff_read_image( const String& filename
55                     , Image&        img
56                     )
57 {
58     read_image( filename
59               , img
60               , tiff_tag()
61               );
62 }
63 
64 /// \ingroup TIFF_IO
65 /// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
66 /// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view.
67 template< typename String
68         , typename View
69         , typename CC
70         >
71 inline
tiff_read_and_convert_view(const String & filename,const View & view,CC cc)72 void tiff_read_and_convert_view( const String& filename
73                                , const View&   view
74                                , CC            cc
75                                )
76 {
77     read_and_convert_view( filename
78                          , view
79                          , cc
80                          , tiff_tag()
81                          );
82 }
83 
84 /// \ingroup TIFF_IO
85 /// \brief Loads and color-converts the image specified by the given tiff image file name into the given view.
86 /// Throws std::ios_base::failure if the file is not a valid TIFF file, or if its dimensions don't match the ones of the view.
87 template< typename String
88         , typename View
89         >
90 inline
tiff_read_and_convert_view(const String & filename,const View & view)91 void tiff_read_and_convert_view( const String& filename
92                                , const View&   view
93                                )
94 {
95     read_and_convert_view( filename
96                          , view
97                          , tiff_tag()
98                          );
99 }
100 
101 /// \ingroup TIFF_IO
102 /// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
103 /// Throws std::ios_base::failure if the file is not a valid TIFF file
104 template< typename String
105         , typename Image
106         , typename CC
107         >
108 inline
tiff_read_and_convert_image(const String & filename,Image & img,CC cc)109 void tiff_read_and_convert_image( const String& filename
110                                 , Image& img
111                                 , CC     cc
112                                 )
113 {
114     read_and_convert_image( filename
115                           , img
116                           , cc
117                           , tiff_tag()
118                           );
119 }
120 
121 /// \ingroup TIFF_IO
122 /// \brief Allocates a new image whose dimensions are determined by the given tiff image file, loads and color-converts the pixels into it.
123 /// Throws std::ios_base::failure if the file is not a valid TIFF file
124 template< typename String
125         , typename Image
126         >
127 inline
tiff_read_and_convert_image(const String filename,Image & img)128 void tiff_read_and_convert_image( const String filename
129                                 , Image&       img
130                                 )
131 {
132     read_and_convert_image( filename
133                           , img
134                           , tiff_tag()
135                           );
136 }
137 
138 
139 /// \ingroup TIFF_IO
140 /// \brief Saves the view to a tiff file specified by the given tiff image file name.
141 /// Triggers a compile assert if the view color space and channel depth are not supported by the TIFF library or by the I/O extension.
142 /// Throws std::ios_base::failure if it fails to create the file.
143 template< typename String
144         , typename View
145         >
146 inline
tiff_write_view(const String & filename,const View & view)147 void tiff_write_view( const String& filename
148                     , const View&   view
149                     )
150 {
151     write_view( filename
152               , view
153               , tiff_tag()
154               );
155 }
156 
157 }  // namespace gil
158 }  // namespace boost
159 
160 #endif
161