2 // Copyright 2007-2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 #ifndef BOOST_GIL_IO_WRITE_VIEW_HPP
9 #define BOOST_GIL_IO_WRITE_VIEW_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_writer.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 {
23 template<typename Writer, typename View>
25 void write_view(Writer& writer, View const& view,
26 typename std::enable_if
30 typename detail::is_writer<Writer>::type,
31 typename is_format_tag<typename Writer::format_tag_t>::type,
32 typename is_write_supported
34 typename get_pixel_type<View>::type,
35 typename Writer::format_tag_t
38 >::type* /* ptr */ = nullptr)
44 template<typename Device, typename View, typename FormatTag>
46 void write_view(Device& device, View const& view, FormatTag const& tag,
47 typename std::enable_if
51 typename detail::is_write_device<FormatTag, Device>::type,
52 typename is_format_tag<FormatTag>::type,
53 typename is_write_supported
55 typename get_pixel_type<View>::type,
59 >::type* /* ptr */ = nullptr)
61 using writer_t = typename get_writer<Device, FormatTag>::type;
62 writer_t writer = make_writer(device, tag);
63 write_view(writer, view);
67 template<typename String, typename View, typename FormatTag>
69 void write_view(String const& file_name, View const& view, FormatTag const& tag,
70 typename std::enable_if
74 typename detail::is_supported_path_spec<String>::type,
75 typename is_format_tag<FormatTag>::type,
76 typename is_write_supported
78 typename get_pixel_type<View>::type,
82 >::type* /* ptr */ = nullptr)
84 using writer_t = typename get_writer<String, FormatTag>::type;
85 writer_t writer = make_writer(file_name, tag);
86 write_view(writer, view);
90 template<typename Device, typename View, typename FormatTag, typename Log>
93 Device& device, View const& view, image_write_info<FormatTag, Log> const& info,
94 typename std::enable_if
98 typename detail::is_write_device<FormatTag, Device>::type,
99 typename is_format_tag<FormatTag>::type,
100 typename is_write_supported
102 typename get_pixel_type<View>::type,
106 >::type* /* ptr */ = nullptr)
108 using writer_t = typename get_writer<Device, FormatTag>::type;
109 writer_t writer = make_writer(device, info);
110 write_view(writer, view);
114 template<typename String, typename View, typename FormatTag, typename Log>
117 String const& file_name, View const& view, image_write_info<FormatTag, Log> const& info,
118 typename std::enable_if
122 typename detail::is_supported_path_spec<String>::type,
123 typename is_format_tag<FormatTag>::type,
124 typename is_write_supported
126 typename get_pixel_type<View>::type,
130 >::type* /* ptr */ = nullptr)
132 using writer_t = typename get_writer<String, FormatTag>::type;
133 writer_t writer = make_writer(file_name, info);
134 write_view(writer, view);
137 ////////////////////////////////////// dynamic_image
139 // without image_write_info
140 template <typename Writer, typename Views>
142 void write_view(Writer& writer, any_image_view<Views> const& view,
143 typename std::enable_if
147 typename detail::is_dynamic_image_writer<Writer>::type,
148 typename is_format_tag<typename Writer::format_tag_t>::type
150 >::type * /* ptr */ = nullptr)
155 // without image_write_info
156 template <typename Device, typename Views, typename FormatTag>
159 Device& device, any_image_view<Views> const& views, FormatTag const& tag,
160 typename std::enable_if
164 typename detail::is_write_device<FormatTag, Device>::type,
165 typename is_format_tag<FormatTag>::type
167 >::type * /* ptr */ = 0)
169 using writer_t = typename get_dynamic_image_writer<Device, FormatTag>::type;
170 writer_t writer = make_dynamic_image_writer(device, tag);
171 write_view(writer, views);
174 template <typename String, typename Views, typename FormatTag>
177 String const& file_name, any_image_view<Views> const& views, FormatTag const& tag,
178 typename std::enable_if
182 typename detail::is_supported_path_spec<String>::type,
183 typename is_format_tag<FormatTag>::type
185 >::type * /* ptr */ = nullptr)
187 using writer_t = typename get_dynamic_image_writer<String, FormatTag>::type;
188 writer_t writer = make_dynamic_image_writer(file_name, tag);
189 write_view(writer, views);
192 // with image_write_info
194 template <typename Device, typename Views, typename FormatTag, typename Log>
197 Device& device, any_image_view<Views> const& views, image_write_info<FormatTag, Log> const& info,
198 typename std::enable_if
202 typename detail::is_write_device<FormatTag, Device>::type,
203 typename is_format_tag<FormatTag>::type
205 >::type * /* ptr */ = 0)
207 using writer_t = typename get_dynamic_image_writer<Device, FormatTag>::type;
208 writer_t writer = make_dynamic_image_writer(device, info);
209 write_view(writer, views);
212 template <typename String, typename Views, typename FormatTag, typename Log>
215 String const& file_name, any_image_view<Views> const& views, image_write_info<FormatTag, Log> const& info,
216 typename std::enable_if
220 typename detail::is_supported_path_spec<String>::type,
221 typename is_format_tag<FormatTag>::type
223 >::type * /* ptr */ = nullptr)
225 using writer_t = typename get_dynamic_image_writer<String, FormatTag>::type;
226 writer_t writer = make_dynamic_image_writer(file_name, info);
227 write_view(writer, views);
230 }} // namespace boost::gil