8 #ifndef BOOST_GIL_IO_MAKE_DYNAMIC_IMAGE_READER_HPP 9 #define BOOST_GIL_IO_MAKE_DYNAMIC_IMAGE_READER_HPP 11 #include <boost/gil/detail/mp11.hpp> 12 #include <boost/gil/io/get_reader.hpp> 14 #include <type_traits> 16 namespace boost {
namespace gil {
18 template <
typename String,
typename FormatTag>
20 auto make_dynamic_image_reader(
21 String
const& file_name, image_read_settings<FormatTag>
const& settings,
22 typename std::enable_if
26 detail::is_supported_path_spec<String>,
27 is_format_tag<FormatTag>
30 ->
typename get_dynamic_image_reader<String, FormatTag>::type
32 using device_t =
typename get_read_device<String, FormatTag>::type;
34 detail::convert_to_native_string(file_name),
35 typename detail::file_stream_device<FormatTag>::read_tag());
37 return typename get_dynamic_image_reader<String, FormatTag>::type(device, settings);
40 template <
typename FormatTag>
42 auto make_dynamic_image_reader(
43 std::wstring
const& file_name, image_read_settings<FormatTag>
const& settings)
44 ->
typename get_dynamic_image_reader<std::wstring, FormatTag>::type
46 char const* str = detail::convert_to_native_string(file_name);
48 using device_t =
typename get_read_device<std::wstring, FormatTag>::type;
49 device_t device(str,
typename detail::file_stream_device<FormatTag>::read_tag());
54 typename get_dynamic_image_reader<std::wstring, FormatTag>::type(device, settings);
57 #ifdef BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 58 template <
typename FormatTag>
60 auto make_dynamic_image_reader(
61 filesystem::path
const& path, image_read_settings<FormatTag>
const& settings)
62 ->
typename get_dynamic_image_reader<std::wstring, FormatTag>::type
64 return make_dynamic_image_reader(path.wstring(), settings);
66 #endif // BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 68 template <
typename Device,
typename FormatTag>
70 auto make_dynamic_image_reader(
71 Device& file, image_read_settings<FormatTag>
const& settings,
72 typename std::enable_if
76 detail::is_adaptable_input_device<FormatTag, Device>,
77 is_format_tag<FormatTag>
80 ->
typename get_dynamic_image_reader<Device, FormatTag>::type
82 typename get_read_device<Device, FormatTag>::type device(file);
83 return typename get_dynamic_image_reader<Device, FormatTag>::type(device, settings);
88 template <
typename String,
typename FormatTag>
90 auto make_dynamic_image_reader(String
const& file_name, FormatTag
const&,
91 typename std::enable_if
95 detail::is_supported_path_spec<String>,
96 is_format_tag<FormatTag>
99 ->
typename get_dynamic_image_reader<String, FormatTag>::type
101 return make_dynamic_image_reader(file_name, image_read_settings<FormatTag>());
104 template <
typename FormatTag>
106 auto make_dynamic_image_reader(std::wstring
const& file_name, FormatTag
const&)
107 ->
typename get_dynamic_image_reader<std::wstring, FormatTag>::type
109 return make_dynamic_image_reader(file_name, image_read_settings<FormatTag>());
112 #ifdef BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 113 template <
typename FormatTag>
115 auto make_dynamic_image_reader(filesystem::path
const& path, FormatTag
const&)
116 ->
typename get_dynamic_image_reader<std::wstring, FormatTag>::type
118 return make_dynamic_image_reader(path.wstring(), image_read_settings<FormatTag>());
120 #endif // BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 122 template <
typename Device,
typename FormatTag>
124 auto make_dynamic_image_reader(Device& file, FormatTag
const&,
125 typename std::enable_if
129 detail::is_adaptable_input_device<FormatTag, Device>,
130 is_format_tag<FormatTag>
133 ->
typename get_dynamic_image_reader<Device, FormatTag>::type
135 return make_dynamic_image_reader(file, image_read_settings<FormatTag>());