Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/gil/io/make_dynamic_image_writer.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 2012 Christian Henning
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_MAKE_DYNAMIC_IMAGE_WRITER_HPP
0009 #define BOOST_GIL_IO_MAKE_DYNAMIC_IMAGE_WRITER_HPP
0010 
0011 #include <boost/gil/detail/mp11.hpp>
0012 #include <boost/gil/io/get_writer.hpp>
0013 
0014 #include <type_traits>
0015 
0016 namespace boost { namespace gil {
0017 
0018 template <typename String, typename FormatTag>
0019 inline
0020 auto make_dynamic_image_writer(
0021     String const& file_name, image_write_info<FormatTag> const& info,
0022     typename std::enable_if
0023     <
0024         mp11::mp_and
0025         <
0026             detail::is_supported_path_spec<String>,
0027             is_format_tag<FormatTag>
0028         >::value
0029     >::type* /*dummy*/ = nullptr)
0030     -> typename get_dynamic_image_writer<String, FormatTag>::type
0031 {
0032     using deveice_t = typename get_write_device<String, FormatTag>::type;
0033     deveice_t device(
0034         detail::convert_to_native_string(file_name),
0035         typename detail::file_stream_device<FormatTag>::write_tag());
0036 
0037     return typename get_dynamic_image_writer<String, FormatTag>::type(device, info);
0038 }
0039 
0040 template< typename FormatTag >
0041 inline
0042 auto make_dynamic_image_writer(std::wstring const& file_name, image_write_info<FormatTag> const& info)
0043     -> typename get_dynamic_image_writer< std::wstring, FormatTag>::type
0044 {
0045     const char* str = detail::convert_to_native_string( file_name );
0046 
0047     typename get_write_device< std::wstring
0048                     , FormatTag
0049                     >::type device( str
0050                                   , typename detail::file_stream_device< FormatTag >::write_tag()
0051                                   );
0052 
0053     delete[] str; // TODO: RAII
0054 
0055     return typename get_dynamic_image_writer< std::wstring
0056                                             , FormatTag
0057                                             >::type( device
0058                                                    , info
0059                                                    );
0060 }
0061 
0062 template <typename FormatTag>
0063 inline
0064 auto make_dynamic_image_writer(detail::filesystem::path const& path, image_write_info<FormatTag> const& info)
0065     -> typename get_dynamic_image_writer<std::wstring, FormatTag>::type
0066 {
0067     return make_dynamic_image_writer(path.wstring(), info);
0068 }
0069 
0070 template <typename Device, typename FormatTag>
0071 inline
0072 auto make_dynamic_image_writer(Device& file, image_write_info<FormatTag> const& info,
0073     typename std::enable_if
0074     <
0075         mp11::mp_and
0076         <
0077             typename detail::is_adaptable_output_device<FormatTag, Device>::type,
0078             is_format_tag<FormatTag>
0079         >::value
0080     >::type* /*dummy*/ = nullptr)
0081     -> typename get_dynamic_image_writer<Device, FormatTag>::type
0082 {
0083     typename get_write_device<Device, FormatTag>::type device(file);
0084     return typename get_dynamic_image_writer<Device, FormatTag>::type(device, info);
0085 }
0086 
0087 // no image_write_info
0088 
0089 template <typename String, typename FormatTag>
0090 inline
0091 auto make_dynamic_image_writer(String const& file_name, FormatTag const&,
0092     typename std::enable_if
0093     <
0094         mp11::mp_and
0095         <
0096             detail::is_supported_path_spec<String>,
0097             is_format_tag<FormatTag>
0098         >::value
0099     >::type* /*dummy*/ = nullptr)
0100     -> typename get_dynamic_image_writer<String, FormatTag>::type
0101 {
0102     return make_dynamic_image_writer(file_name, image_write_info<FormatTag>());
0103 }
0104 
0105 template <typename FormatTag>
0106 inline
0107 auto make_dynamic_image_writer(std::wstring const& file_name, FormatTag const&)
0108     -> typename get_dynamic_image_writer<std::wstring, FormatTag>::type
0109 {
0110     return make_dynamic_image_writer( file_name
0111                                     , image_write_info< FormatTag >()
0112                                     );
0113 }
0114 
0115 template <typename FormatTag>
0116 inline
0117 auto make_dynamic_image_writer(detail::filesystem::path const& path, FormatTag const&)
0118     -> typename get_dynamic_image_writer<std::wstring, FormatTag>::type
0119 {
0120     return make_dynamic_image_writer(path.wstring(), image_write_info<FormatTag>());
0121 }
0122 
0123 template <typename Device, typename FormatTag>
0124 inline
0125 auto make_dynamic_image_writer(Device& file, FormatTag const&,
0126     typename std::enable_if
0127     <
0128         mp11::mp_and
0129         <
0130             typename detail::is_adaptable_output_device<FormatTag, Device>::type,
0131             is_format_tag<FormatTag>
0132         >::value
0133     >::type* /*dummy*/ = nullptr)
0134     -> typename get_dynamic_image_writer<Device, FormatTag>::type
0135 {
0136     return make_dynamic_image_writer(file, image_write_info<FormatTag>());
0137 }
0138 
0139 }} // namespace boost::gil
0140 
0141 #endif