8 #ifndef BOOST_GIL_IO_MAKE_WRITER_HPP 9 #define BOOST_GIL_IO_MAKE_WRITER_HPP 11 #include <boost/gil/io/get_writer.hpp> 13 #include <boost/mpl/and.hpp> 15 #include <type_traits> 17 namespace boost {
namespace gil {
19 template <
typename String,
typename FormatTag>
21 auto make_writer(String
const& file_name, image_write_info<FormatTag>
const& info,
22 typename std::enable_if
26 detail::is_supported_path_spec<String>,
27 is_format_tag<FormatTag>
28 >::value>::type* =
nullptr)
29 ->
typename get_writer<String, FormatTag>::type
31 typename get_write_device<String, FormatTag>::type device(
32 detail::convert_to_native_string(file_name),
33 typename detail::file_stream_device<FormatTag>::write_tag());
35 return typename get_writer<String, FormatTag>::type(device, info);
38 template<
typename FormatTag >
40 typename get_writer< std::wstring
43 make_writer(
const std::wstring& file_name
44 ,
const image_write_info< FormatTag >& info
47 const char* str = detail::convert_to_native_string( file_name );
49 typename get_write_device< std::wstring
52 ,
typename detail::file_stream_device< FormatTag >::write_tag()
57 return typename get_writer< std::wstring
64 #ifdef BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 65 template<
typename FormatTag >
67 typename get_writer< std::wstring
70 make_writer(
const filesystem::path& path
71 ,
const image_write_info< FormatTag >& info
74 return make_writer( path.wstring()
78 #endif // BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 80 template <
typename Device,
typename FormatTag>
82 auto make_writer(Device& file, image_write_info<FormatTag>
const& info,
83 typename std::enable_if
87 typename detail::is_adaptable_output_device<FormatTag, Device>::type,
88 is_format_tag<FormatTag>
91 ->
typename get_writer<Device, FormatTag>::type
93 typename get_write_device<Device, FormatTag>::type device(file);
94 return typename get_writer<Device, FormatTag>::type(device, info);
99 template <
typename String,
typename FormatTag>
101 auto make_writer(String
const& file_name, FormatTag
const&,
102 typename std::enable_if
106 detail::is_supported_path_spec<String>,
107 is_format_tag<FormatTag>
110 ->
typename get_writer<String, FormatTag>::type
112 return make_writer(file_name, image_write_info<FormatTag>());
115 template<
typename FormatTag >
117 typename get_writer< std::wstring
120 make_writer(
const std::wstring& file_name
124 return make_writer( file_name
125 , image_write_info< FormatTag >()
129 #ifdef BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 130 template<
typename FormatTag >
132 typename get_writer< std::wstring
135 make_writer(
const filesystem::path& path
136 ,
const FormatTag& tag
139 return make_writer( path.wstring()
143 #endif // BOOST_GIL_IO_ADD_FS_PATH_SUPPORT 145 template <
typename Device,
typename FormatTag>
147 auto make_writer(Device& file, FormatTag
const&,
148 typename std::enable_if
152 typename detail::is_adaptable_output_device<FormatTag, Device>::type,
153 is_format_tag<FormatTag>
156 ->
typename get_writer<Device, FormatTag>::type
158 return make_writer(file, image_write_info<FormatTag>());
Definition: algorithm.hpp:30