]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/gil/io/read_and_convert_view.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / gil / io / read_and_convert_view.hpp
CommitLineData
92f5a8d4
TL
1//
2// Copyright 2007-2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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_IO_READ_AND_CONVERT_VIEW_HPP
9#define BOOST_GIL_IO_READ_AND_CONVERT_VIEW_HPP
10
11#include <boost/gil/io/base.hpp>
12#include <boost/gil/io/conversion_policies.hpp>
13#include <boost/gil/io/device.hpp>
14#include <boost/gil/io/get_reader.hpp>
15#include <boost/gil/io/path_spec.hpp>
16#include <boost/gil/detail/mp11.hpp>
17
18#include <type_traits>
19
20namespace boost{ namespace gil {
21
22/// \ingroup IO
23
24/// \brief Reads and color-converts an image view. No memory is allocated.
25/// \param reader An image reader.
26/// \param img The image in which the data is read into.
27/// \param settings Specifies read settings depending on the image format.
28/// \param cc Color converter function object.
29/// \throw std::ios_base::failure
30template <typename Reader, typename View>
31inline
32void read_and_convert_view(Reader& reader, View const& view,
33 typename std::enable_if
34 <
35 mp11::mp_and
36 <
37 detail::is_reader<Reader>,
38 is_format_tag<typename Reader::format_tag_t>
39 >::value
40 >::type* /*dummy*/ = nullptr)
41{
42 reader.check_image_size(view.dimensions());
43 reader.init_view(view, reader._settings);
44 reader.apply(view);
45}
46
47/// \brief Reads and color-converts an image view. No memory is allocated.
48/// \param file It's a device. Must satisfy is_input_device metafunction.
49/// \param view The image view in which the data is read into.
50/// \param settings Specifies read settings depending on the image format.
51/// \param cc Color converter function object.
52/// \throw std::ios_base::failure
53template <typename Device, typename View, typename ColorConverter, typename FormatTag>
54inline
55void read_and_convert_view(
56 Device& device,
57 View const& view,
58 image_read_settings<FormatTag> const& settings,
59 ColorConverter const& cc,
60 typename std::enable_if
61 <
62 mp11::mp_and
63 <
64 detail::is_read_device<FormatTag, Device>,
65 is_format_tag<FormatTag>
66 >::value
67 >::type* /*dummy*/ = nullptr)
68{
69 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
70 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
71
72 reader_t reader = make_reader(device, settings, read_and_convert_t{cc});
73 read_and_convert_view(reader, view);
74}
75
76/// \brief Reads and color-converts an image view. No memory is allocated.
77/// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
78/// \param view The image view in which the data is read into.
79/// \param settings Specifies read settings depending on the image format.
80/// \param cc Color converter function object.
81/// \throw std::ios_base::failure
82template <typename String, typename View, typename ColorConverter, typename FormatTag>
83inline
84void read_and_convert_view(
85 String const& file_name,
86 View const& view,
87 image_read_settings<FormatTag> const& settings,
88 ColorConverter const& cc,
89 typename std::enable_if
90 <
91 mp11::mp_and
92 <
93 is_format_tag<FormatTag>,
94 detail::is_supported_path_spec<String>
95 >::value
96 >::type* /*dummy*/ = nullptr)
97{
98 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
99 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
100
101 reader_t reader = make_reader(file_name, settings, read_and_convert_t{cc});
102 read_and_convert_view(reader, view);
103}
104
105/// \brief Reads and color-converts an image view. No memory is allocated.
106/// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
107/// \param view The image view in which the data is read into.
108/// \param cc Color converter function object.
109/// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
110/// \throw std::ios_base::failure
111template <typename String, typename View, typename ColorConverter, typename FormatTag>
112inline
113void read_and_convert_view(
114 String const& file_name,
115 View const& view,
116 ColorConverter const& cc,
117 FormatTag const& tag,
118 typename std::enable_if
119 <
120 mp11::mp_and
121 <
122 is_format_tag<FormatTag>,
123 detail::is_supported_path_spec<String>
124 >::value
125 >::type* /*dummy*/ = nullptr)
126{
127 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
128 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
129
130 reader_t reader = make_reader(file_name, tag, read_and_convert_t{cc});
131 read_and_convert_view(reader, view);
132}
133
134/// \brief Reads and color-converts an image view. No memory is allocated.
135/// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
136/// \param view The image view in which the data is read into.
137/// \param cc Color converter function object.
138/// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
139/// \throw std::ios_base::failure
140template <typename Device, typename View, typename ColorConverter, typename FormatTag>
141inline
142void read_and_convert_view(
143 Device& device,
144 View const& view,
145 ColorConverter const& cc,
146 FormatTag const& tag,
147 typename std::enable_if
148 <
149 mp11::mp_and
150 <
151 detail::is_read_device<FormatTag, Device>,
152 is_format_tag<FormatTag>
153 >::value
154 >::type* /*dummy*/ = nullptr)
155{
156 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
157 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
158
159 reader_t reader = make_reader(device, tag, read_and_convert_t{cc});
160 read_and_convert_view(reader, view);
161}
162
163/// \brief Reads and color-converts an image view. No memory is allocated.
164/// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
165/// \param view The image view in which the data is read into.
166/// \param settings Specifies read settings depending on the image format.
167/// \throw std::ios_base::failure
168template <typename String, typename View, typename FormatTag>
169inline
170void read_and_convert_view(
171 String const& file_name,
172 View const& view,
173 image_read_settings<FormatTag> const& settings,
174 typename std::enable_if
175 <
176 mp11::mp_and
177 <
178 is_format_tag<FormatTag>,
179 detail::is_supported_path_spec<String>
180 >::value
181 >::type* /*dummy*/ = nullptr)
182{
183 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
184 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
185
186 reader_t reader = make_reader(file_name, settings, read_and_convert_t{});
187 read_and_convert_view(reader, view);
188}
189
190/// \brief Reads and color-converts an image view. No memory is allocated.
191/// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
192/// \param view The image view in which the data is read into.
193/// \param settings Specifies read settings depending on the image format.
194/// \throw std::ios_base::failure
195template <typename Device, typename View, typename FormatTag>
196inline
197void read_and_convert_view(
198 Device& device,
199 View const& view,
200 image_read_settings<FormatTag> const& settings,
201 typename std::enable_if
202 <
203 mp11::mp_and
204 <
205 detail::is_read_device<FormatTag, Device>,
206 is_format_tag<FormatTag>
207 >::value
208 >::type* /*dummy*/ = nullptr)
209{
210 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
211 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
212
213 reader_t reader = make_reader(device, settings, read_and_convert_t{});
214 read_and_convert_view(reader, view);
215}
216
217/// \brief Reads and color-converts an image view. No memory is allocated.
218/// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
219/// \param view The image view in which the data is read into.
220/// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
221/// \throw std::ios_base::failure
222template <typename String, typename View, typename FormatTag>
223inline
224void read_and_convert_view(
225 String const& file_name,
226 View const& view,
227 FormatTag const& tag,
228 typename std::enable_if
229 <
230 mp11::mp_and
231 <
232 is_format_tag<FormatTag>,
233 detail::is_supported_path_spec<String>
234 >::value
235 >::type* /*dummy*/ = nullptr)
236{
237 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
238 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
239
240 reader_t reader = make_reader(file_name, tag, read_and_convert_t{});
241 read_and_convert_view(reader, view);
242}
243
244/// \brief Reads and color-converts an image view. No memory is allocated.
245/// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
246/// \param view The image view in which the data is read into.
247/// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
248/// \throw std::ios_base::failure
249template <typename Device, typename View, typename FormatTag>
250inline
251void read_and_convert_view(
252 Device& device,
253 View const& view,
254 FormatTag const& tag,
255 typename std::enable_if
256 <
257 mp11::mp_and
258 <
259 detail::is_read_device<FormatTag, Device>,
260 is_format_tag<FormatTag>
261 >::value
262 >::type* /*dummy*/ = nullptr)
263{
264 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
265 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
266
267 reader_t reader = make_reader(device, tag, read_and_convert_t{});
268 read_and_convert_view(reader, view);
269}
270
271}} // namespace boost::gill
272
273#endif