File indexing completed on 2025-01-18 09:37:03
0001
0002
0003
0004
0005
0006
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
0023
0024
0025
0026
0027
0028
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* = nullptr)
0045 {
0046 reader.check_image_size(view.dimensions());
0047 reader.init_view(view, reader._settings);
0048 reader.apply(view);
0049 }
0050
0051
0052
0053
0054
0055
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* = 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
0084
0085
0086
0087
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* = 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
0112
0113
0114
0115
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* = 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
0144
0145
0146
0147
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* = 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 }}
0173
0174 #endif