read_image_info.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Copyright 2007-2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_IO_READ_IMAGE_INFO_HPP
  9. #define BOOST_GIL_IO_READ_IMAGE_INFO_HPP
  10. #include <boost/gil/io/base.hpp>
  11. #include <boost/gil/io/device.hpp>
  12. #include <boost/gil/io/get_reader.hpp>
  13. #include <boost/gil/io/path_spec.hpp>
  14. #include <boost/gil/detail/mp11.hpp>
  15. #include <type_traits>
  16. namespace boost{ namespace gil {
  17. /// \ingroup IO
  18. /// \brief Returns the image format backend. Backend is format specific.
  19. /// \param file It's a device. Must satisfy is_adaptable_input_device metafunction.
  20. /// \param settings Specifies read settings depending on the image format.
  21. /// \return image_read_info object dependent on the image format.
  22. /// \throw std::ios_base::failure
  23. template <typename Device, typename FormatTag>
  24. inline
  25. auto read_image_info(Device& file, image_read_settings<FormatTag> const& settings,
  26. typename std::enable_if
  27. <
  28. mp11::mp_and
  29. <
  30. detail::is_adaptable_input_device<FormatTag, Device>,
  31. is_format_tag<FormatTag>
  32. >::value
  33. >::type* /*dummy*/ = nullptr)
  34. -> typename get_reader_backend<Device, FormatTag>::type
  35. {
  36. return make_reader_backend(file, settings);
  37. }
  38. /// \brief Returns the image format backend. Backend is format specific.
  39. /// \param file It's a device. Must satisfy is_adaptable_input_device metafunction.
  40. /// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
  41. /// \return image_read_info object dependent on the image format.
  42. /// \throw std::ios_base::failure
  43. template <typename Device, typename FormatTag>
  44. inline
  45. auto read_image_info(Device& file, FormatTag const&,
  46. typename std::enable_if
  47. <
  48. mp11::mp_and
  49. <
  50. detail::is_adaptable_input_device<FormatTag, Device>,
  51. is_format_tag<FormatTag>
  52. >::value
  53. >::type* /*dummy*/ = nullptr)
  54. -> typename get_reader_backend<Device, FormatTag>::type
  55. {
  56. return read_image_info(file, image_read_settings<FormatTag>());
  57. }
  58. /// \brief Returns the image format backend. Backend is format specific.
  59. /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
  60. /// \param settings Specifies read settings depending on the image format.
  61. /// \return image_read_info object dependent on the image format.
  62. /// \throw std::ios_base::failure
  63. template <typename String, typename FormatTag>
  64. inline
  65. auto read_image_info(
  66. String const& file_name, image_read_settings<FormatTag> const& settings,
  67. typename std::enable_if
  68. <
  69. mp11::mp_and
  70. <
  71. is_format_tag<FormatTag>,
  72. detail::is_supported_path_spec<String>
  73. >::value
  74. >::type* /*dummy*/ = nullptr)
  75. -> typename get_reader_backend<String, FormatTag>::type
  76. {
  77. return make_reader_backend(file_name, settings);
  78. }
  79. /// \brief Returns the image format backend. Backend is format specific.
  80. /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
  81. /// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
  82. /// \return image_read_info object dependent on the image format.
  83. /// \throw std::ios_base::failure
  84. template <typename String, typename FormatTag>
  85. inline
  86. auto read_image_info(String const& file_name, FormatTag const&,
  87. typename std::enable_if
  88. <
  89. mp11::mp_and
  90. <
  91. is_format_tag<FormatTag>,
  92. detail::is_supported_path_spec<String>
  93. >::value
  94. >::type* /*dummy*/ = nullptr)
  95. -> typename get_reader_backend<String, FormatTag>::type
  96. {
  97. return read_image_info(file_name, image_read_settings<FormatTag>());
  98. }
  99. }} // namespace boost::gil
  100. #endif