File indexing completed on 2025-01-18 09:37:03
0001
0002
0003
0004
0005
0006
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
0023
0024
0025
0026
0027
0028
0029
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* = nullptr)
0041 {
0042 reader.check_image_size(view.dimensions());
0043 reader.init_view(view, reader._settings);
0044 reader.apply(view);
0045 }
0046
0047
0048
0049
0050
0051
0052
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* = 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
0077
0078
0079
0080
0081
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* = 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
0106
0107
0108
0109
0110
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* = 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
0135
0136
0137
0138
0139
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* = 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
0164
0165
0166
0167
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* = 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
0191
0192
0193
0194
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* = 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
0218
0219
0220
0221
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* = 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
0245
0246
0247
0248
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* = 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 }}
0272
0273 #endif