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_IMAGE_HPP
0009 #define BOOST_GIL_IO_READ_AND_CONVERT_IMAGE_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 Image>
0031 inline
0032 void read_and_convert_image(Reader& reader, Image& img,
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.init_image(img, reader._settings);
0043 reader.apply(view(img));
0044 }
0045
0046
0047
0048
0049
0050
0051
0052 template <typename Device, typename Image, typename ColorConverter, typename FormatTag>
0053 inline
0054 void read_and_convert_image(
0055 Device& device,
0056 Image& img,
0057 image_read_settings<FormatTag> const& settings,
0058 ColorConverter const& cc,
0059 typename std::enable_if
0060 <
0061 mp11::mp_and
0062 <
0063 detail::is_read_device<FormatTag, Device>,
0064 is_format_tag<FormatTag>
0065 >::value
0066 >::type* = nullptr)
0067 {
0068 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0069 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0070
0071 reader_t reader = make_reader(device, settings, read_and_convert_t{cc});
0072 read_and_convert_image(reader, img);
0073 }
0074
0075
0076
0077
0078
0079
0080
0081 template <typename String, typename Image, typename ColorConverter, typename FormatTag>
0082 inline
0083 void read_and_convert_image(
0084 String const& file_name,
0085 Image& img,
0086 image_read_settings<FormatTag> const& settings,
0087 ColorConverter const& cc,
0088 typename std::enable_if
0089 <
0090 mp11::mp_and
0091 <
0092 is_format_tag<FormatTag>,
0093 detail::is_supported_path_spec<String>
0094 >::value
0095 >::type* = nullptr)
0096 {
0097 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0098 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0099
0100 reader_t reader = make_reader(file_name, settings, read_and_convert_t{cc});
0101 read_and_convert_image(reader, img);
0102 }
0103
0104
0105
0106
0107
0108
0109
0110 template <typename String, typename Image, typename ColorConverter, typename FormatTag>
0111 inline
0112 void read_and_convert_image(
0113 String const& file_name,
0114 Image& img,
0115 ColorConverter const& cc,
0116 FormatTag const& tag,
0117 typename std::enable_if
0118 <
0119 mp11::mp_and
0120 <
0121 is_format_tag<FormatTag>,
0122 detail::is_supported_path_spec<String>
0123 >::value
0124 >::type* = nullptr)
0125 {
0126 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0127 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0128
0129 reader_t reader = make_reader(file_name, tag, read_and_convert_t{cc});
0130 read_and_convert_image(reader, img);
0131 }
0132
0133
0134
0135
0136
0137
0138
0139 template <typename Device, typename Image, typename ColorConverter, typename FormatTag>
0140 inline
0141 void read_and_convert_image(
0142 Device& device,
0143 Image& img,
0144 ColorConverter const& cc,
0145 FormatTag const& tag,
0146 typename std::enable_if
0147 <
0148 mp11::mp_and
0149 <
0150 detail::is_read_device<FormatTag, Device>,
0151 is_format_tag<FormatTag>
0152 >::value
0153 >::type* = nullptr)
0154 {
0155 using read_and_convert_t = detail::read_and_convert<ColorConverter>;
0156 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0157
0158 reader_t reader = make_reader(device, tag, read_and_convert_t{cc});
0159 read_and_convert_image(reader, img);
0160 }
0161
0162
0163
0164
0165
0166
0167 template <typename String, typename Image, typename FormatTag>
0168 inline void read_and_convert_image(
0169 String const& file_name,
0170 Image& img,
0171 image_read_settings<FormatTag> const& settings,
0172 typename std::enable_if
0173 <
0174 mp11::mp_and
0175 <
0176 is_format_tag<FormatTag>,
0177 detail::is_supported_path_spec<String>
0178 >::value
0179 >::type* = nullptr)
0180 {
0181 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0182 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0183
0184 reader_t reader = make_reader(file_name, settings, read_and_convert_t{});
0185 read_and_convert_image(reader, img);
0186 }
0187
0188
0189
0190
0191
0192
0193 template <typename Device, typename Image, typename FormatTag>
0194 inline void read_and_convert_image(
0195 Device& device,
0196 Image& img,
0197 image_read_settings<FormatTag> const& settings,
0198 typename std::enable_if
0199 <
0200 mp11::mp_and
0201 <
0202 detail::is_read_device<FormatTag, Device>,
0203 is_format_tag<FormatTag>
0204 >::value
0205 >::type* = nullptr)
0206 {
0207 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0208 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0209
0210 reader_t reader = make_reader(device, settings, read_and_convert_t{});
0211 read_and_convert_image(reader, img);
0212 }
0213
0214
0215
0216
0217
0218
0219 template <typename String, typename Image, typename FormatTag>
0220 inline
0221 void read_and_convert_image(
0222 String const& file_name,
0223 Image& img,
0224 FormatTag const& tag,
0225 typename std::enable_if
0226 <
0227 mp11::mp_and
0228 <
0229 is_format_tag<FormatTag>,
0230 detail::is_supported_path_spec<String>
0231 >::value
0232 >::type* = nullptr)
0233 {
0234 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0235 using reader_t = typename get_reader<String, FormatTag, read_and_convert_t>::type;
0236
0237 reader_t reader = make_reader(file_name, tag, read_and_convert_t{});
0238 read_and_convert_image(reader, img);
0239 }
0240
0241
0242
0243
0244
0245
0246 template <typename Device, typename Image, typename FormatTag>
0247 inline void read_and_convert_image(
0248 Device& device,
0249 Image& img,
0250 FormatTag const& tag,
0251 typename std::enable_if
0252 <
0253 mp11::mp_and
0254 <
0255 detail::is_read_device<FormatTag, Device>,
0256 is_format_tag<FormatTag>
0257 >::value
0258 >::type* = nullptr)
0259 {
0260 using read_and_convert_t = detail::read_and_convert<default_color_converter>;
0261 using reader_t = typename get_reader<Device, FormatTag, read_and_convert_t>::type;
0262
0263 reader_t reader = make_reader(device, tag, read_and_convert_t{});
0264 read_and_convert_image(reader, img);
0265 }
0266
0267 }}
0268
0269 #endif