Generic Image Library: read_and_convert_view.hpp Source File

###  | #  |

read_and_convert_view.hpp
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
23
30template <typename Reader, typename View>
31inline
32 void 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
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
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
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
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
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
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
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
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
boost::gil::read_and_convert_view
void read_and_convert_view(Reader &reader, View const &view, typename std::enable_if< mp11::mp_and< detail::is_reader< Reader >, is_format_tag< typename Reader::format_tag_t > >::value >::type *=nullptr)
Reads and color-converts an image view. No memory is allocated.
Definition read_and_convert_view.hpp:32
boost::gil::view
auto view(image< Pixel, IsPlanar, Alloc > &img) -> typename image< Pixel, IsPlanar, Alloc >::view_t const &
Returns the non-constant-pixel view of an image.
Definition image.hpp:565
boost
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition algorithm.hpp:36