8 #ifndef BOOST_GIL_IO_READ_IMAGE_HPP
9 #define BOOST_GIL_IO_READ_IMAGE_HPP
11 #include <boost/gil/extension/toolbox/dynamic_images.hpp>
13 #include <boost/gil/io/base.hpp>
14 #include <boost/gil/io/conversion_policies.hpp>
15 #include <boost/gil/io/device.hpp>
16 #include <boost/gil/io/get_reader.hpp>
17 #include <boost/gil/io/path_spec.hpp>
18 #include <boost/gil/detail/mp11.hpp>
20 #include <type_traits>
22 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>,
41 typename get_pixel_type<typename Image::view_t>::type,
42 typename Reader::format_tag_t
47 reader.init_image(img, reader._settings);
48 reader.apply(
view(img));
56 template <
typename Device,
typename Image,
typename FormatTag>
61 image_read_settings<FormatTag>
const& settings,
62 typename std::enable_if
66 detail::is_read_device<FormatTag, Device>,
67 is_format_tag<FormatTag>,
70 typename get_pixel_type<typename Image::view_t>::type,
77 typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
79 reader_t reader = make_reader(file, settings, detail::read_and_no_convert());
88 template <
typename Device,
typename Image,
typename FormatTag>
90 void read_image(Device& file, Image& img, FormatTag
const& tag,
91 typename std::enable_if
95 detail::is_read_device<FormatTag, Device>,
96 is_format_tag<FormatTag>,
99 typename get_pixel_type<typename Image::view_t>::type,
106 typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
108 reader_t reader = make_reader(file, tag, detail::read_and_no_convert());
117 template <
typename String,
typename Image,
typename FormatTag>
120 String
const& file_name,
122 image_read_settings<FormatTag>
const& settings,
123 typename std::enable_if
127 detail::is_supported_path_spec<String>,
128 is_format_tag<FormatTag>,
131 typename get_pixel_type<typename Image::view_t>::type,
138 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
140 reader_t reader = make_reader(file_name, settings, detail::read_and_no_convert());
149 template <
typename String,
typename Image,
typename FormatTag>
151 void read_image(String
const& file_name, Image& img, FormatTag
const& tag,
152 typename std::enable_if
154 mp11::mp_and<detail::is_supported_path_spec<String>,
155 is_format_tag<FormatTag>,
158 typename get_pixel_type<typename Image::view_t>::type,
165 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
167 reader_t reader = make_reader(file_name, tag, detail::read_and_no_convert());
173 template <
typename Reader,
typename ...Images>
175 void read_image(Reader& reader, any_image<Images...>& images,
176 typename std::enable_if
180 detail::is_dynamic_image_reader<Reader>,
181 is_format_tag<typename Reader::format_tag_t>
185 reader.apply(images);
193 template <
typename Device,
typename ...Images,
typename FormatTag>
197 any_image<Images...>& images,
198 image_read_settings<FormatTag>
const& settings,
199 typename std::enable_if
203 detail::is_read_device<FormatTag, Device>,
204 is_format_tag<FormatTag>
208 using reader_t =
typename get_dynamic_image_reader<Device, FormatTag>::type;
210 reader_t reader = make_dynamic_image_reader(file, settings);
219 template <
typename Device,
typename ...Images,
typename FormatTag>
221 void read_image(Device& file, any_image<Images...>& images, FormatTag
const& tag,
222 typename std::enable_if
226 detail::is_read_device<FormatTag, Device>,
227 is_format_tag<FormatTag>
231 using reader_t =
typename get_dynamic_image_reader<Device, FormatTag>::type;
233 reader_t reader = make_dynamic_image_reader(file, tag);
242 template <
typename String,
typename ...Images,
typename FormatTag>
245 String
const& file_name,
246 any_image<Images...>& images,
247 image_read_settings<FormatTag>
const& settings,
248 typename std::enable_if
252 detail::is_supported_path_spec<String>,
253 is_format_tag<FormatTag>
257 using reader_t =
typename get_dynamic_image_reader<String, FormatTag>::type;
259 reader_t reader = make_dynamic_image_reader(file_name, settings);
268 template <
typename String,
typename ...Images,
typename FormatTag>
270 void read_image(String
const& file_name, any_image<Images...>& images, FormatTag
const& tag,
271 typename std::enable_if
275 detail::is_supported_path_spec<String>,
276 is_format_tag<FormatTag>
280 using reader_t =
typename get_dynamic_image_reader<String, FormatTag>::type;
282 reader_t reader = make_dynamic_image_reader(file_name, tag);
void read_image(Reader reader, Image &img, typename std::enable_if< mp11::mp_and< detail::is_reader< Reader >, is_format_tag< typename Reader::format_tag_t >, is_read_supported< typename get_pixel_type< typename Image::view_t >::type, typename Reader::format_tag_t > >::value >::type *=nullptr)
Reads an image without conversion. Image memory is allocated.
Definition: read_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