read_image_info.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/mpl/and.hpp>
  15. #include <boost/type_traits/is_base_and_derived.hpp>
  16. #include <type_traits>
  17. namespace boost{ namespace gil {
  18. /// \ingroup IO
  19. /// \brief Returns the image format backend. Backend is format specific.
  20. /// \param file It's a device. Must satisfy is_adaptable_input_device metafunction.
  21. /// \param settings Specifies read settings depending on the image format.
  22. /// \return image_read_info object dependent on the image format.
  23. /// \throw std::ios_base::failure
  24. template <typename Device, typename FormatTag>
  25. inline
  26. auto read_image_info(Device& file, image_read_settings<FormatTag> const& settings,
  27. typename std::enable_if
  28. <
  29. mpl::and_
  30. <
  31. detail::is_adaptable_input_device<FormatTag, Device>,
  32. is_format_tag<FormatTag>
  33. >::value
  34. >::type* /*dummy*/ = nullptr)
  35. -> typename get_reader_backend<Device, FormatTag>::type
  36. {
  37. return make_reader_backend(file, settings);
  38. }
  39. /// \brief Returns the image format backend. Backend is format specific.
  40. /// \param file It's a device. Must satisfy is_adaptable_input_device metafunction.
  41. /// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
  42. /// \return image_read_info object dependent on the image format.
  43. /// \throw std::ios_base::failure
  44. template <typename Device, typename FormatTag>
  45. inline
  46. auto read_image_info(Device& file, FormatTag const&,
  47. typename std::enable_if
  48. <
  49. mpl::and_
  50. <
  51. detail::is_adaptable_input_device<FormatTag, Device>,
  52. is_format_tag<FormatTag>
  53. >::value
  54. >::type* /*dummy*/ = nullptr)
  55. -> typename get_reader_backend<Device, FormatTag>::type
  56. {
  57. return read_image_info(file, image_read_settings<FormatTag>());
  58. }
  59. /// \brief Returns the image format backend. Backend is format specific.
  60. /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
  61. /// \param settings Specifies read settings depending on the image format.
  62. /// \return image_read_info object dependent on the image format.
  63. /// \throw std::ios_base::failure
  64. template <typename String, typename FormatTag>
  65. inline
  66. auto read_image_info(
  67. String const& file_name, image_read_settings<FormatTag> const& settings,
  68. typename std::enable_if
  69. <
  70. mpl::and_
  71. <
  72. is_format_tag<FormatTag>,
  73. detail::is_supported_path_spec<String>
  74. >::value
  75. >::type* /*dummy*/ = nullptr)
  76. -> typename get_reader_backend<String, FormatTag>::type
  77. {
  78. return make_reader_backend(file_name, settings);
  79. }
  80. /// \brief Returns the image format backend. Backend is format specific.
  81. /// \param file_name File name. Must satisfy is_supported_path_spec metafunction.
  82. /// \param tag Defines the image format. Must satisfy is_format_tag metafunction.
  83. /// \return image_read_info object dependent on the image format.
  84. /// \throw std::ios_base::failure
  85. template <typename String, typename FormatTag>
  86. inline
  87. auto read_image_info(String const& file_name, FormatTag const&,
  88. typename std::enable_if
  89. <
  90. mpl::and_
  91. <
  92. is_format_tag<FormatTag>,
  93. detail::is_supported_path_spec<String>
  94. >::value
  95. >::type* /*dummy*/ = nullptr)
  96. -> typename get_reader_backend<String, FormatTag>::type
  97. {
  98. return read_image_info(file_name, image_read_settings<FormatTag>());
  99. }
  100. }} // namespace boost::gil
  101. #endif