8 #ifndef BOOST_GIL_IO_READ_AND_CONVERT_IMAGE_HPP
9 #define BOOST_GIL_IO_READ_AND_CONVERT_IMAGE_HPP
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>
18 #include <type_traits>
20 namespace boost{
namespace gil {
30 template <
typename Reader,
typename Image>
33 typename std::enable_if
37 detail::is_reader<Reader>,
38 is_format_tag<typename Reader::format_tag_t>
42 reader.init_image(img, reader._settings);
43 reader.apply(
view(img));
52 template <
typename Device,
typename Image,
typename ColorConverter,
typename FormatTag>
57 image_read_settings<FormatTag>
const& settings,
58 ColorConverter
const& cc,
59 typename std::enable_if
63 detail::is_read_device<FormatTag, Device>,
64 is_format_tag<FormatTag>
68 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
69 using reader_t =
typename get_reader<Device, FormatTag, read_and_convert_t>::type;
71 reader_t reader = make_reader(device, settings, read_and_convert_t{cc});
81 template <
typename String,
typename Image,
typename ColorConverter,
typename FormatTag>
84 String
const& file_name,
86 image_read_settings<FormatTag>
const& settings,
87 ColorConverter
const& cc,
88 typename std::enable_if
92 is_format_tag<FormatTag>,
93 detail::is_supported_path_spec<String>
97 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
98 using reader_t =
typename get_reader<String, FormatTag, read_and_convert_t>::type;
100 reader_t reader = make_reader(file_name, settings, read_and_convert_t{cc});
110 template <
typename String,
typename Image,
typename ColorConverter,
typename FormatTag>
113 String
const& file_name,
115 ColorConverter
const& cc,
116 FormatTag
const& tag,
117 typename std::enable_if
121 is_format_tag<FormatTag>,
122 detail::is_supported_path_spec<String>
126 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
127 using reader_t =
typename get_reader<String, FormatTag, read_and_convert_t>::type;
129 reader_t reader = make_reader(file_name, tag, read_and_convert_t{cc});
139 template <
typename Device,
typename Image,
typename ColorConverter,
typename FormatTag>
144 ColorConverter
const& cc,
145 FormatTag
const& tag,
146 typename std::enable_if
150 detail::is_read_device<FormatTag, Device>,
151 is_format_tag<FormatTag>
155 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
156 using reader_t =
typename get_reader<Device, FormatTag, read_and_convert_t>::type;
158 reader_t reader = make_reader(device, tag, read_and_convert_t{cc});
167 template <
typename String,
typename Image,
typename FormatTag>
169 String
const& file_name,
171 image_read_settings<FormatTag>
const& settings,
172 typename std::enable_if
176 is_format_tag<FormatTag>,
177 detail::is_supported_path_spec<String>
181 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
182 using reader_t =
typename get_reader<String, FormatTag, read_and_convert_t>::type;
184 reader_t reader = make_reader(file_name, settings, read_and_convert_t{});
193 template <
typename Device,
typename Image,
typename FormatTag>
197 image_read_settings<FormatTag>
const& settings,
198 typename std::enable_if
202 detail::is_read_device<FormatTag, Device>,
203 is_format_tag<FormatTag>
207 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
208 using reader_t =
typename get_reader<Device, FormatTag, read_and_convert_t>::type;
210 reader_t reader = make_reader(device, settings, read_and_convert_t{});
219 template <
typename String,
typename Image,
typename FormatTag>
222 String
const& file_name,
224 FormatTag
const& tag,
225 typename std::enable_if
229 is_format_tag<FormatTag>,
230 detail::is_supported_path_spec<String>
234 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
235 using reader_t =
typename get_reader<String, FormatTag, read_and_convert_t>::type;
237 reader_t reader = make_reader(file_name, tag, read_and_convert_t{});
246 template <
typename Device,
typename Image,
typename FormatTag>
250 FormatTag
const& tag,
251 typename std::enable_if
255 detail::is_read_device<FormatTag, Device>,
256 is_format_tag<FormatTag>
260 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
261 using reader_t =
typename get_reader<Device, FormatTag, read_and_convert_t>::type;
263 reader_t reader = make_reader(device, tag, read_and_convert_t{});
void read_and_convert_image(Reader &reader, Image &img, 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. Image memory is allocated.
Definition: read_and_convert_image.hpp:32
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
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36