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>
19 #include <boost/mpl/and.hpp>
20 #include <boost/type_traits/is_base_and_derived.hpp>
22 #include <type_traits>
24 namespace boost {
namespace gil {
32 template <
typename Reader,
typename Image>
35 typename std::enable_if
39 detail::is_reader<Reader>,
40 is_format_tag<typename Reader::format_tag_t>,
43 typename get_pixel_type<typename Image::view_t>::type,
44 typename Reader::format_tag_t
49 reader.init_image(img, reader._settings);
50 reader.apply(
view(img));
58 template <
typename Device,
typename Image,
typename FormatTag>
63 image_read_settings<FormatTag>
const& settings,
64 typename std::enable_if
68 detail::is_read_device<FormatTag, Device>,
69 is_format_tag<FormatTag>,
72 typename get_pixel_type<typename Image::view_t>::type,
79 typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
81 reader_t reader = make_reader(file, settings, detail::read_and_no_convert());
90 template <
typename Device,
typename Image,
typename FormatTag>
92 void read_image(Device& file, Image& img, FormatTag
const& tag,
93 typename std::enable_if
97 detail::is_read_device<FormatTag, Device>,
98 is_format_tag<FormatTag>,
101 typename get_pixel_type<typename Image::view_t>::type,
108 typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
110 reader_t reader = make_reader(file, tag, detail::read_and_no_convert());
119 template <
typename String,
typename Image,
typename FormatTag>
122 String
const& file_name,
124 image_read_settings<FormatTag>
const& settings,
125 typename std::enable_if
129 detail::is_supported_path_spec<String>,
130 is_format_tag<FormatTag>,
133 typename get_pixel_type<typename Image::view_t>::type,
140 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
142 reader_t reader = make_reader(file_name, settings, detail::read_and_no_convert());
151 template <
typename String,
typename Image,
typename FormatTag>
153 void read_image(String
const& file_name, Image& img, FormatTag
const& tag,
154 typename std::enable_if
156 mpl::and_<detail::is_supported_path_spec<String>,
157 is_format_tag<FormatTag>,
160 typename get_pixel_type<typename Image::view_t>::type,
167 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
169 reader_t reader = make_reader(file_name, tag, detail::read_and_no_convert());
175 template <
typename Reader,
typename Images>
177 void read_image(Reader& reader, any_image<Images>& images,
178 typename std::enable_if
182 detail::is_dynamic_image_reader<Reader>,
183 is_format_tag<typename Reader::format_tag_t>
187 reader.apply(images);
195 template <
typename Device,
typename Images,
typename FormatTag>
199 any_image<Images>& images,
200 image_read_settings<FormatTag>
const& settings,
201 typename std::enable_if
205 detail::is_read_device<FormatTag, Device>,
206 is_format_tag<FormatTag>
210 using reader_t =
typename get_dynamic_image_reader<Device, FormatTag>::type;
212 reader_t reader = make_dynamic_image_reader(file, settings);
221 template <
typename Device,
typename Images,
typename FormatTag>
223 void read_image(Device& file, any_image<Images>& images, FormatTag
const& tag,
224 typename std::enable_if
228 detail::is_read_device<FormatTag, Device>,
229 is_format_tag<FormatTag>
233 using reader_t =
typename get_dynamic_image_reader<Device, FormatTag>::type;
235 reader_t reader = make_dynamic_image_reader(file, tag);
244 template <
typename String,
typename Images,
typename FormatTag>
247 String
const& file_name,
248 any_image<Images>& images,
249 image_read_settings<FormatTag>
const& settings,
250 typename std::enable_if
254 detail::is_supported_path_spec<String>,
255 is_format_tag<FormatTag>
259 using reader_t =
typename get_dynamic_image_reader<String, FormatTag>::type;
261 reader_t reader = make_dynamic_image_reader(file_name, settings);
270 template <
typename String,
typename Images,
typename FormatTag>
272 void read_image(String
const& file_name, any_image<Images>& images, FormatTag
const& tag,
273 typename std::enable_if
277 detail::is_supported_path_spec<String>,
278 is_format_tag<FormatTag>
282 using reader_t =
typename get_dynamic_image_reader<String, FormatTag>::type;
284 reader_t reader = make_dynamic_image_reader(file_name, tag);
void read_image(Reader reader, Image &img, typename std::enable_if< mpl::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 > >::type::value >::type *=nullptr)
Reads an image without conversion. Image memory is allocated.
Definition: read_image.hpp:34
const image< Pixel, IsPlanar, Alloc >::view_t & view(image< Pixel, IsPlanar, Alloc > &img)
Returns the non-constant-pixel view of an image.
Definition: image.hpp:460