Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:03

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_READ_AND_CONVERT_VIEW_HPP
0009 #define BOOST_GIL_IO_READ_AND_CONVERT_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_reader.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 
0024 /// \brief Reads and color-converts an image view. No memory is allocated.
0025 /// \param reader    An image reader.
0026 /// \param img       The image in which the data is read into.
0027 /// \param settings  Specifies read settings depending on the image format.
0028 /// \param cc        Color converter function object.
0029 /// \throw std::ios_base::failure
0030 template <typename Reader, typename View>
0031 inline
0032 void read_and_convert_view(Reader& reader, View const& view,
0033     typename std::enable_if
0034     <
0035         mp11::mp_and
0036         <
0037             detail::is_reader<Reader>,
0038             is_format_tag<typename Reader::format_tag_t>
0039         >::value
0040     >::type* /*dummy*/ = nullptr)
0041 {
0042     reader.check_image_size(view.dimensions());
0043     reader.init_view(view, reader._settings);
0044     reader.apply(view);
0045 }
0046 
0047 /// \brief Reads and color-converts an image view. No memory is allocated.
0048 /// \param file      It's a device. Must satisfy is_input_device metafunction.
0049 /// \param view      The image view in which the data is read into.
0050 /// \param settings  Specifies read settings depending on the image format.
0051 /// \param cc        Color converter function object.
0052 /// \throw std::ios_base::failure
0053 template <typename Device, typename View, typename ColorConverter, typename FormatTag>
0054 inline
0055 void read_and_convert_view(
0056     Device& device,
0057     View const& view,
0058     image_read_settings<FormatTag> const& settings,
0059     ColorConverter const& cc,
0060     typename std::enable_if
0061     <
0062         mp11::mp_and
0063         <
0064             detail::is_read_device<FormatTag, Device>,
0065             is_format_tag<FormatTag>
0066         >::value
0067     >::type* /*dummy*/ = nullptr)
0068 {
0069     using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0070     using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0071 
0072     reader_t reader = make_reader(device, settings, read_and_convert_t{cc});
0073     read_and_convert_view(reader, view);
0074 }
0075 
0076 /// \brief Reads and color-converts an image view. No memory is allocated.
0077 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0078 /// \param view      The image view in which the data is read into.
0079 /// \param settings  Specifies read settings depending on the image format.
0080 /// \param cc        Color converter function object.
0081 /// \throw std::ios_base::failure
0082 template <typename String, typename View, typename ColorConverter, typename FormatTag>
0083 inline
0084 void read_and_convert_view(
0085     String const& file_name,
0086     View const& view,
0087     image_read_settings<FormatTag> const& settings,
0088     ColorConverter const& cc,
0089     typename std::enable_if
0090     <
0091         mp11::mp_and
0092         <
0093             is_format_tag<FormatTag>,
0094             detail::is_supported_path_spec<String>
0095         >::value
0096     >::type* /*dummy*/ = nullptr)
0097 {
0098     using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0099     using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0100 
0101     reader_t reader = make_reader(file_name, settings, read_and_convert_t{cc});
0102     read_and_convert_view(reader, view);
0103 }
0104 
0105 /// \brief Reads and color-converts an image view. No memory is allocated.
0106 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0107 /// \param view      The image view in which the data is read into.
0108 /// \param cc        Color converter function object.
0109 /// \param tag       Defines the image format. Must satisfy is_format_tag metafunction.
0110 /// \throw std::ios_base::failure
0111 template <typename String, typename View, typename ColorConverter, typename FormatTag>
0112 inline
0113 void read_and_convert_view(
0114     String const& file_name,
0115     View const& view,
0116     ColorConverter const& cc,
0117     FormatTag const& tag,
0118     typename std::enable_if
0119     <
0120         mp11::mp_and
0121         <
0122             is_format_tag<FormatTag>,
0123             detail::is_supported_path_spec<String>
0124         >::value
0125     >::type* /*dummy*/ = nullptr)
0126 {
0127     using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0128     using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0129 
0130     reader_t reader = make_reader(file_name, tag, read_and_convert_t{cc});
0131     read_and_convert_view(reader, view);
0132 }
0133 
0134 /// \brief Reads and color-converts an image view. No memory is allocated.
0135 /// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
0136 /// \param view The image view in which the data is read into.
0137 /// \param cc   Color converter function object.
0138 /// \param tag  Defines the image format. Must satisfy is_format_tag metafunction.
0139 /// \throw std::ios_base::failure
0140 template <typename Device, typename View, typename ColorConverter, typename FormatTag>
0141 inline
0142 void read_and_convert_view(
0143     Device& device,
0144     View const& view,
0145     ColorConverter const& cc,
0146     FormatTag const& tag,
0147     typename std::enable_if
0148     <
0149         mp11::mp_and
0150         <
0151             detail::is_read_device<FormatTag, Device>,
0152             is_format_tag<FormatTag>
0153         >::value
0154     >::type* /*dummy*/ = nullptr)
0155 {
0156     using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0157     using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0158 
0159     reader_t reader = make_reader(device, tag, read_and_convert_t{cc});
0160     read_and_convert_view(reader, view);
0161 }
0162 
0163 /// \brief Reads and color-converts an image view. No memory is allocated.
0164 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0165 /// \param view      The image view in which the data is read into.
0166 /// \param settings  Specifies read settings depending on the image format.
0167 /// \throw std::ios_base::failure
0168 template <typename String, typename View, typename FormatTag>
0169 inline
0170 void read_and_convert_view(
0171     String const& file_name,
0172     View const& view,
0173     image_read_settings<FormatTag> const& settings,
0174     typename std::enable_if
0175     <
0176         mp11::mp_and
0177         <
0178             is_format_tag<FormatTag>,
0179             detail::is_supported_path_spec<String>
0180         >::value
0181     >::type* /*dummy*/ = nullptr)
0182 {
0183     using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0184     using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0185 
0186     reader_t reader = make_reader(file_name, settings, read_and_convert_t{});
0187     read_and_convert_view(reader, view);
0188 }
0189 
0190 /// \brief Reads and color-converts an image view. No memory is allocated.
0191 /// \param file      It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
0192 /// \param view      The image view in which the data is read into.
0193 /// \param settings  Specifies read settings depending on the image format.
0194 /// \throw std::ios_base::failure
0195 template <typename Device, typename View, typename FormatTag>
0196 inline
0197 void read_and_convert_view(
0198     Device& device,
0199     View const& view,
0200     image_read_settings<FormatTag> const& settings,
0201     typename std::enable_if
0202     <
0203         mp11::mp_and
0204         <
0205             detail::is_read_device<FormatTag, Device>,
0206             is_format_tag<FormatTag>
0207         >::value
0208     >::type* /*dummy*/ = nullptr)
0209 {
0210     using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0211     using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0212 
0213     reader_t reader = make_reader(device, settings, read_and_convert_t{});
0214     read_and_convert_view(reader, view);
0215 }
0216 
0217 /// \brief Reads and color-converts an image view. No memory is allocated.
0218 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0219 /// \param view      The image view in which the data is read into.
0220 /// \param tag       Defines the image format. Must satisfy is_format_tag metafunction.
0221 /// \throw std::ios_base::failure
0222 template <typename String, typename View, typename FormatTag>
0223 inline
0224 void read_and_convert_view(
0225     String const& file_name,
0226     View const& view,
0227     FormatTag const& tag,
0228     typename std::enable_if
0229     <
0230         mp11::mp_and
0231         <
0232             is_format_tag<FormatTag>,
0233             detail::is_supported_path_spec<String>
0234         >::value
0235     >::type* /*dummy*/ = nullptr)
0236 {
0237     using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0238     using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0239 
0240     reader_t reader = make_reader(file_name, tag, read_and_convert_t{});
0241     read_and_convert_view(reader, view);
0242 }
0243 
0244 /// \brief Reads and color-converts an image view. No memory is allocated.
0245 /// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
0246 /// \param view The image view in which the data is read into.
0247 /// \param tag  Defines the image format. Must satisfy is_format_tag metafunction.
0248 /// \throw std::ios_base::failure
0249 template <typename Device, typename View, typename FormatTag>
0250 inline
0251 void read_and_convert_view(
0252     Device& device,
0253     View const& view,
0254     FormatTag const& tag,
0255     typename std::enable_if
0256     <
0257         mp11::mp_and
0258         <
0259             detail::is_read_device<FormatTag, Device>,
0260             is_format_tag<FormatTag>
0261         >::value
0262     >::type* /*dummy*/ = nullptr)
0263 {
0264     using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0265     using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0266 
0267     reader_t reader = make_reader(device, tag, read_and_convert_t{});
0268     read_and_convert_view(reader, view);
0269 }
0270 
0271 }} // namespace boost::gill
0272 
0273 #endif