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_VIEW_HPP
0009 #define BOOST_GIL_IO_READ_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 an image view without conversion. No memory is allocated.
0025 /// \param reader    An image reader.
0026 /// \param view      The image view in which the data is read into.
0027 /// \param settings  Specifies read settings depending on the image format.
0028 /// \throw std::ios_base::failure
0029 template <typename Reader, typename View>
0030 inline
0031 void read_view(Reader reader, View const& view,
0032     typename std::enable_if
0033     <
0034         mp11::mp_and
0035         <
0036             detail::is_reader<Reader>,
0037             typename is_format_tag<typename Reader::format_tag_t>::type,
0038             typename is_read_supported
0039             <
0040                 typename get_pixel_type<View>::type,
0041                 typename Reader::format_tag_t
0042             >::type
0043         >::value
0044     >::type* /*dummy*/ = nullptr)
0045 {
0046     reader.check_image_size(view.dimensions());
0047     reader.init_view(view, reader._settings);
0048     reader.apply(view);
0049 }
0050 
0051 /// \brief Reads an image view without conversion. No memory is allocated.
0052 /// \param file      It's a device. Must satisfy is_input_device metafunction.
0053 /// \param view      The image view in which the data is read into.
0054 /// \param settings  Specifies read settings depending on the image format.
0055 /// \throw std::ios_base::failure
0056 template <typename Device, typename View, typename FormatTag>
0057 inline
0058 void read_view(
0059     Device& file,
0060     View const& view,
0061     image_read_settings<FormatTag> const& settings,
0062     typename std::enable_if
0063     <
0064         mp11::mp_and
0065         <
0066             detail::is_read_device<FormatTag, Device>,
0067             typename is_format_tag<FormatTag>::type,
0068             typename is_read_supported
0069             <
0070                 typename get_pixel_type<View>::type,
0071                 FormatTag
0072             >::type
0073         >::value
0074     >::type* /*dummy*/ = nullptr)
0075 {
0076     using reader_t =
0077         typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
0078 
0079     reader_t reader = make_reader(file, settings, detail::read_and_no_convert());
0080     read_view(reader, view);
0081 }
0082 
0083 /// \brief Reads an image view without conversion. No memory is allocated.
0084 /// \param file It's a device. Must satisfy is_input_device metafunction or is_adaptable_input_device.
0085 /// \param view The image view in which the data is read into.
0086 /// \param tag  Defines the image format. Must satisfy is_format_tag metafunction.
0087 /// \throw std::ios_base::failure
0088 template <typename Device, typename View, typename FormatTag>
0089 inline
0090 void read_view(Device& file, View const& view, FormatTag const& tag,
0091     typename std::enable_if
0092     <
0093         mp11::mp_and
0094         <
0095             typename is_format_tag<FormatTag>::type,
0096             detail::is_read_device<FormatTag, Device>,
0097             typename is_read_supported
0098             <
0099                 typename get_pixel_type<View>::type,
0100                 FormatTag
0101             >::type
0102         >::value>::type* /*dummy*/ = nullptr)
0103 {
0104     using reader_t =
0105         typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
0106 
0107     reader_t reader = make_reader(file, tag, detail::read_and_no_convert());
0108     read_view(reader, view);
0109 }
0110 
0111 /// \brief Reads an image view without conversion. No memory is allocated.
0112 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0113 /// \param view      The image view in which the data is read into.
0114 /// \param settings  Specifies read settings depending on the image format.
0115 /// \throw std::ios_base::failure
0116 template <typename String, typename View, typename FormatTag>
0117 inline
0118 void read_view(
0119     String const& file_name,
0120     View const& view,
0121     image_read_settings<FormatTag> const& settings,
0122     typename std::enable_if
0123     <
0124         mp11::mp_and
0125         <
0126             typename detail::is_supported_path_spec<String>::type,
0127             typename is_format_tag<FormatTag>::type,
0128             typename is_read_supported
0129             <
0130                 typename get_pixel_type<View>::type,
0131                 FormatTag
0132             >::type
0133         >::value
0134     >::type* /*dummy*/ = nullptr)
0135 {
0136     using reader_t =
0137         typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
0138 
0139     reader_t reader = make_reader(file_name, settings, detail::read_and_no_convert());
0140     read_view(reader, view);
0141 }
0142 
0143 /// \brief Reads an image view without conversion. No memory is allocated.
0144 /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
0145 /// \param view      The image view in which the data is read into.
0146 /// \param tag       Defines the image format. Must satisfy is_format_tag metafunction.
0147 /// \throw std::ios_base::failure
0148 template <typename String, typename View, typename FormatTag>
0149 inline
0150 void read_view(String const& file_name, View const& view, FormatTag const& tag,
0151     typename std::enable_if
0152     <
0153         mp11::mp_and
0154         <
0155             typename detail::is_supported_path_spec<String>::type,
0156             typename is_format_tag<FormatTag>::type,
0157             typename is_read_supported
0158             <
0159                 typename get_pixel_type<View>::type,
0160                 FormatTag
0161             >::type
0162         >::value
0163     >::type* /*dummy*/ = nullptr)
0164 {
0165     using reader_t =
0166         typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
0167 
0168     reader_t reader = make_reader(file_name, tag, detail::read_and_no_convert());
0169     read_view(reader, view);
0170 }
0171 
0172 }}  // namespace boost::gil
0173 
0174 #endif