base.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // Copyright 2007-2008 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_BASE_HPP
  9. #define BOOST_GIL_IO_BASE_HPP
  10. #include <boost/gil/extension/toolbox/toolbox.hpp>
  11. #include <boost/gil/bit_aligned_pixel_reference.hpp>
  12. #include <boost/gil/bit_aligned_pixel_iterator.hpp>
  13. #include <boost/gil/color_convert.hpp>
  14. #include <boost/gil/utilities.hpp>
  15. #include <boost/gil/io/error.hpp>
  16. #include <boost/gil/io/typedefs.hpp>
  17. #include <istream>
  18. #include <ostream>
  19. #include <type_traits>
  20. #include <vector>
  21. namespace boost { namespace gil {
  22. struct format_tag {};
  23. template< typename Property >
  24. struct property_base
  25. {
  26. using type = Property;
  27. };
  28. template<typename FormatTag>
  29. struct is_format_tag : std::is_base_of<format_tag, FormatTag> {};
  30. struct image_read_settings_base
  31. {
  32. protected:
  33. image_read_settings_base()
  34. : _top_left( 0, 0 )
  35. , _dim ( 0, 0 )
  36. {}
  37. image_read_settings_base( const point_t& top_left
  38. , const point_t& dim
  39. )
  40. : _top_left( top_left )
  41. , _dim ( dim )
  42. {}
  43. public:
  44. void set( const point_t& top_left
  45. , const point_t& dim
  46. )
  47. {
  48. _top_left = top_left;
  49. _dim = dim;
  50. }
  51. public:
  52. point_t _top_left;
  53. point_t _dim;
  54. };
  55. /**
  56. * Boolean meta function, std::true_type if the pixel type \a PixelType is supported
  57. * by the image format identified with \a FormatTag.
  58. * \todo the name is_supported is to generic, pick something more IO realted.
  59. */
  60. // Depending on image type the parameter Pixel can be a reference type
  61. // for bit_aligned images or a pixel for byte images.
  62. template< typename Pixel, typename FormatTag > struct is_read_supported {};
  63. template< typename Pixel, typename FormatTag > struct is_write_supported {};
  64. namespace detail {
  65. template< typename Property >
  66. struct property_base
  67. {
  68. using type = Property;
  69. };
  70. } // namespace detail
  71. struct read_support_true { static constexpr bool is_supported = true; };
  72. struct read_support_false { static constexpr bool is_supported = false; };
  73. struct write_support_true { static constexpr bool is_supported = true; };
  74. struct write_support_false{ static constexpr bool is_supported = false; };
  75. class no_log {};
  76. template< typename Device, typename FormatTag > struct reader_backend;
  77. template< typename Device, typename FormatTag > struct writer_backend;
  78. template< typename FormatTag > struct image_read_info;
  79. template< typename FormatTag > struct image_read_settings;
  80. template< typename FormatTag, typename Log = no_log > struct image_write_info;
  81. } // namespace gil
  82. } // namespace boost
  83. #endif