Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/gil/io/write_view.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // Copyright 2007-2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_IO_WRITE_VIEW_HPP
0009 #define BOOST_GIL_IO_WRITE_VIEW_HPP
0010 
0011 #include <boost/gil/io/base.hpp>
0012 #include <boost/gil/io/conversion_policies.hpp>
0013 #include <boost/gil/io/device.hpp>
0014 #include <boost/gil/io/get_writer.hpp>
0015 #include <boost/gil/io/path_spec.hpp>
0016 #include <boost/gil/detail/mp11.hpp>
0017 
0018 #include <type_traits>
0019 
0020 namespace boost{ namespace gil {
0021 
0022 /// \ingroup IO
0023 template<typename Writer, typename View>
0024 inline
0025 void write_view(Writer& writer, View const& view,
0026     typename std::enable_if
0027     <
0028         mp11::mp_and
0029         <
0030             typename detail::is_writer<Writer>::type,
0031             typename is_format_tag<typename Writer::format_tag_t>::type,
0032             typename is_write_supported
0033             <
0034                 typename get_pixel_type<View>::type,
0035                 typename Writer::format_tag_t
0036             >::type
0037         >::value
0038     >::type* /* ptr */ = nullptr)
0039 {
0040     writer.apply(view);
0041 }
0042 
0043 /// \ingroup IO
0044 template<typename Device, typename View, typename FormatTag>
0045 inline
0046 void write_view(Device& device, View const& view, FormatTag const& tag,
0047     typename std::enable_if
0048     <
0049         mp11::mp_and
0050         <
0051             typename detail::is_write_device<FormatTag, Device>::type,
0052             typename is_format_tag<FormatTag>::type,
0053             typename is_write_supported
0054             <
0055                 typename get_pixel_type<View>::type,
0056                 FormatTag
0057             >::type
0058         >::value
0059     >::type* /* ptr */ = nullptr)
0060 {
0061     using writer_t = typename get_writer<Device, FormatTag>::type;
0062     writer_t writer = make_writer(device, tag);
0063     write_view(writer, view);
0064 }
0065 
0066 /// \ingroup IO
0067 template<typename String, typename View, typename FormatTag>
0068 inline
0069 void write_view(String const& file_name, View const& view, FormatTag const& tag,
0070     typename std::enable_if
0071     <
0072         mp11::mp_and
0073         <
0074             typename detail::is_supported_path_spec<String>::type,
0075             typename is_format_tag<FormatTag>::type,
0076             typename is_write_supported
0077             <
0078                 typename get_pixel_type<View>::type,
0079                 FormatTag
0080             >::type
0081         >::value
0082     >::type* /* ptr */ = nullptr)
0083 {
0084     using writer_t = typename get_writer<String, FormatTag>::type;
0085     writer_t writer = make_writer(file_name, tag);
0086     write_view(writer, view);
0087 }
0088 
0089 /// \ingroup IO
0090 template<typename Device, typename View, typename FormatTag, typename Log>
0091 inline
0092 void write_view(
0093     Device& device, View const& view, image_write_info<FormatTag, Log> const& info,
0094     typename std::enable_if
0095     <
0096         mp11::mp_and
0097         <
0098             typename detail::is_write_device<FormatTag, Device>::type,
0099             typename is_format_tag<FormatTag>::type,
0100             typename is_write_supported
0101             <
0102                 typename get_pixel_type<View>::type,
0103                 FormatTag
0104             >::type
0105         >::value
0106     >::type* /* ptr */ = nullptr)
0107 {
0108     using writer_t = typename get_writer<Device, FormatTag>::type;
0109     writer_t writer = make_writer(device, info);
0110     write_view(writer, view);
0111 }
0112 
0113 /// \ingroup IO
0114 template<typename String, typename View, typename FormatTag, typename Log>
0115 inline
0116 void write_view(
0117     String const& file_name, View const& view, image_write_info<FormatTag, Log> const& info,
0118     typename std::enable_if
0119     <
0120         mp11::mp_and
0121         <
0122             typename detail::is_supported_path_spec<String>::type,
0123             typename is_format_tag<FormatTag>::type,
0124             typename is_write_supported
0125             <
0126                 typename get_pixel_type<View>::type,
0127                 FormatTag
0128             >::type
0129         >::value
0130     >::type* /* ptr */ = nullptr)
0131 {
0132     using writer_t = typename get_writer<String, FormatTag>::type;
0133     writer_t writer = make_writer(file_name, info);
0134     write_view(writer, view);
0135 }
0136 
0137 ////////////////////////////////////// dynamic_image
0138 
0139 // without image_write_info
0140 template <typename Writer, typename ...Views>
0141 inline
0142 void write_view(Writer& writer, any_image_view<Views...> const& view,
0143     typename std::enable_if
0144     <
0145         mp11::mp_and
0146         <
0147             typename detail::is_dynamic_image_writer<Writer>::type,
0148             typename is_format_tag<typename Writer::format_tag_t>::type
0149         >::value
0150     >::type * /* ptr */ = nullptr)
0151 {
0152     writer.apply(view);
0153 }
0154 
0155 // without image_write_info
0156 template <typename Device, typename ...Views, typename FormatTag>
0157 inline
0158 void write_view(
0159     Device& device, any_image_view<Views...> const& views, FormatTag const& tag,
0160     typename std::enable_if
0161     <
0162         mp11::mp_and
0163         <
0164             typename detail::is_write_device<FormatTag, Device>::type,
0165             typename is_format_tag<FormatTag>::type
0166         >::value
0167     >::type * /* ptr */ = 0)
0168 {
0169     using writer_t = typename get_dynamic_image_writer<Device, FormatTag>::type;
0170     writer_t writer = make_dynamic_image_writer(device, tag);
0171     write_view(writer, views);
0172 }
0173 
0174 template <typename String, typename ...Views, typename FormatTag>
0175 inline
0176 void write_view(
0177     String const& file_name, any_image_view<Views...> const& views, FormatTag const& tag,
0178     typename std::enable_if
0179     <
0180         mp11::mp_and
0181         <
0182             typename detail::is_supported_path_spec<String>::type,
0183             typename is_format_tag<FormatTag>::type
0184         >::value
0185     >::type * /* ptr */ = nullptr)
0186 {
0187     using writer_t = typename get_dynamic_image_writer<String, FormatTag>::type;
0188     writer_t writer = make_dynamic_image_writer(file_name, tag);
0189     write_view(writer, views);
0190 }
0191 
0192 // with image_write_info
0193 /// \ingroup IO
0194 template <typename Device, typename ...Views, typename FormatTag, typename Log>
0195 inline
0196 void write_view(
0197     Device& device, any_image_view<Views...> const& views, image_write_info<FormatTag, Log> const& info,
0198     typename std::enable_if
0199     <
0200         mp11::mp_and
0201         <
0202             typename detail::is_write_device<FormatTag, Device>::type,
0203             typename is_format_tag<FormatTag>::type
0204         >::value
0205     >::type * /* ptr */ = 0)
0206 {
0207     using writer_t = typename get_dynamic_image_writer<Device, FormatTag>::type;
0208     writer_t writer = make_dynamic_image_writer(device, info);
0209     write_view(writer, views);
0210 }
0211 
0212 template <typename String, typename ...Views, typename FormatTag, typename Log>
0213 inline
0214 void write_view(
0215     String const& file_name, any_image_view<Views...> const& views, image_write_info<FormatTag, Log> const& info,
0216     typename std::enable_if
0217     <
0218         mp11::mp_and
0219         <
0220             typename detail::is_supported_path_spec<String>::type,
0221             typename is_format_tag<FormatTag>::type
0222         >::value
0223     >::type * /* ptr */ = nullptr)
0224 {
0225     using writer_t = typename get_dynamic_image_writer<String, FormatTag>::type;
0226     writer_t writer = make_dynamic_image_writer(file_name, info);
0227     write_view(writer, views);
0228 }
0229 
0230 }} // namespace boost::gil
0231 
0232 #endif