File indexing completed on 2025-01-18 09:37:03
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_IO_READ_IMAGE_HPP
0009 #define BOOST_GIL_IO_READ_IMAGE_HPP
0010
0011 #include <boost/gil/extension/toolbox/dynamic_images.hpp>
0012
0013 #include <boost/gil/io/base.hpp>
0014 #include <boost/gil/io/conversion_policies.hpp>
0015 #include <boost/gil/io/device.hpp>
0016 #include <boost/gil/io/get_reader.hpp>
0017 #include <boost/gil/io/path_spec.hpp>
0018 #include <boost/gil/detail/mp11.hpp>
0019
0020 #include <type_traits>
0021
0022 namespace boost { namespace gil {
0023
0024
0025
0026
0027
0028
0029
0030 template <typename Reader, typename Image>
0031 inline
0032 void read_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 is_read_supported
0040 <
0041 typename get_pixel_type<typename Image::view_t>::type,
0042 typename Reader::format_tag_t
0043 >
0044 >::value
0045 >::type* = nullptr)
0046 {
0047 reader.init_image(img, reader._settings);
0048 reader.apply(view(img));
0049 }
0050
0051
0052
0053
0054
0055
0056 template <typename Device, typename Image, typename FormatTag>
0057 inline
0058 void read_image(
0059 Device& file,
0060 Image& img,
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 is_format_tag<FormatTag>,
0068 is_read_supported
0069 <
0070 typename get_pixel_type<typename Image::view_t>::type,
0071 FormatTag
0072 >
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_image(reader, img);
0081 }
0082
0083
0084
0085
0086
0087
0088 template <typename Device, typename Image, typename FormatTag>
0089 inline
0090 void read_image(Device& file, Image& img, FormatTag const& tag,
0091 typename std::enable_if
0092 <
0093 mp11::mp_and
0094 <
0095 detail::is_read_device<FormatTag, Device>,
0096 is_format_tag<FormatTag>,
0097 is_read_supported
0098 <
0099 typename get_pixel_type<typename Image::view_t>::type,
0100 FormatTag
0101 >
0102 >::value
0103 >::type* = nullptr)
0104 {
0105 using reader_t =
0106 typename get_reader<Device, FormatTag, detail::read_and_no_convert>::type;
0107
0108 reader_t reader = make_reader(file, tag, detail::read_and_no_convert());
0109 read_image(reader, img);
0110 }
0111
0112
0113
0114
0115
0116
0117 template <typename String, typename Image, typename FormatTag>
0118 inline
0119 void read_image(
0120 String const& file_name,
0121 Image& img,
0122 image_read_settings<FormatTag> const& settings,
0123 typename std::enable_if
0124 <
0125 mp11::mp_and
0126 <
0127 detail::is_supported_path_spec<String>,
0128 is_format_tag<FormatTag>,
0129 is_read_supported
0130 <
0131 typename get_pixel_type<typename Image::view_t>::type,
0132 FormatTag
0133 >
0134 >::value
0135 >::type* = nullptr)
0136 {
0137 using reader_t =
0138 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
0139
0140 reader_t reader = make_reader(file_name, settings, detail::read_and_no_convert());
0141 read_image(reader, img);
0142 }
0143
0144
0145
0146
0147
0148
0149 template <typename String, typename Image, typename FormatTag>
0150 inline
0151 void read_image(String const& file_name, Image& img, FormatTag const& tag,
0152 typename std::enable_if
0153 <
0154 mp11::mp_and<detail::is_supported_path_spec<String>,
0155 is_format_tag<FormatTag>,
0156 is_read_supported
0157 <
0158 typename get_pixel_type<typename Image::view_t>::type,
0159 FormatTag
0160 >
0161 >::value
0162 >::type* = nullptr)
0163 {
0164 using reader_t =
0165 typename get_reader<String, FormatTag, detail::read_and_no_convert>::type;
0166
0167 reader_t reader = make_reader(file_name, tag, detail::read_and_no_convert());
0168 read_image(reader, img);
0169 }
0170
0171
0172
0173 template <typename Reader, typename ...Images>
0174 inline
0175 void read_image(Reader& reader, any_image<Images...>& images,
0176 typename std::enable_if
0177 <
0178 mp11::mp_and
0179 <
0180 detail::is_dynamic_image_reader<Reader>,
0181 is_format_tag<typename Reader::format_tag_t>
0182 >::value
0183 >::type* = nullptr)
0184 {
0185 reader.apply(images);
0186 }
0187
0188
0189
0190
0191
0192
0193 template <typename Device, typename ...Images, typename FormatTag>
0194 inline
0195 void read_image(
0196 Device& file,
0197 any_image<Images...>& images,
0198 image_read_settings<FormatTag> const& settings,
0199 typename std::enable_if
0200 <
0201 mp11::mp_and
0202 <
0203 detail::is_read_device<FormatTag, Device>,
0204 is_format_tag<FormatTag>
0205 >::value
0206 >::type* = nullptr)
0207 {
0208 using reader_t = typename get_dynamic_image_reader<Device, FormatTag>::type;
0209
0210 reader_t reader = make_dynamic_image_reader(file, settings);
0211 read_image(reader, images);
0212 }
0213
0214
0215
0216
0217
0218
0219 template <typename Device, typename ...Images, typename FormatTag>
0220 inline
0221 void read_image(Device& file, any_image<Images...>& images, FormatTag const& tag,
0222 typename std::enable_if
0223 <
0224 mp11::mp_and
0225 <
0226 detail::is_read_device<FormatTag, Device>,
0227 is_format_tag<FormatTag>
0228 >::value
0229 >::type* = nullptr)
0230 {
0231 using reader_t = typename get_dynamic_image_reader<Device, FormatTag>::type;
0232
0233 reader_t reader = make_dynamic_image_reader(file, tag);
0234 read_image(reader, images);
0235 }
0236
0237
0238
0239
0240
0241
0242 template <typename String, typename ...Images, typename FormatTag>
0243 inline
0244 void read_image(
0245 String const& file_name,
0246 any_image<Images...>& images,
0247 image_read_settings<FormatTag> const& settings,
0248 typename std::enable_if
0249 <
0250 mp11::mp_and
0251 <
0252 detail::is_supported_path_spec<String>,
0253 is_format_tag<FormatTag>
0254 >::value
0255 >::type* = nullptr)
0256 {
0257 using reader_t = typename get_dynamic_image_reader<String, FormatTag>::type;
0258
0259 reader_t reader = make_dynamic_image_reader(file_name, settings);
0260 read_image(reader, images);
0261 }
0262
0263
0264
0265
0266
0267
0268 template <typename String, typename ...Images, typename FormatTag>
0269 inline
0270 void read_image(String const& file_name, any_image<Images...>& images, FormatTag const& tag,
0271 typename std::enable_if
0272 <
0273 mp11::mp_and
0274 <
0275 detail::is_supported_path_spec<String>,
0276 is_format_tag<FormatTag>
0277 >::value
0278 >::type* = nullptr)
0279 {
0280 using reader_t = typename get_dynamic_image_reader<String, FormatTag>::type;
0281
0282 reader_t reader = make_dynamic_image_reader(file_name, tag);
0283 read_image(reader, images);
0284 }
0285
0286 }}
0287
0288 #endif