base.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 <boost/type_traits/is_base_of.hpp>
  18. #include <istream>
  19. #include <ostream>
  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> struct is_format_tag : is_base_and_derived< format_tag
  29. , FormatTag
  30. > {};
  31. struct image_read_settings_base
  32. {
  33. protected:
  34. image_read_settings_base()
  35. : _top_left( 0, 0 )
  36. , _dim ( 0, 0 )
  37. {}
  38. image_read_settings_base( const point_t& top_left
  39. , const point_t& dim
  40. )
  41. : _top_left( top_left )
  42. , _dim ( dim )
  43. {}
  44. public:
  45. void set( const point_t& top_left
  46. , const point_t& dim
  47. )
  48. {
  49. _top_left = top_left;
  50. _dim = dim;
  51. }
  52. public:
  53. point_t _top_left;
  54. point_t _dim;
  55. };
  56. /**
  57. * Boolean meta function, mpl::true_ if the pixel type \a PixelType is supported
  58. * by the image format identified with \a FormatTag.
  59. * \todo the name is_supported is to generic, pick something more IO realted.
  60. */
  61. // Depending on image type the parameter Pixel can be a reference type
  62. // for bit_aligned images or a pixel for byte images.
  63. template< typename Pixel, typename FormatTag > struct is_read_supported {};
  64. template< typename Pixel, typename FormatTag > struct is_write_supported {};
  65. namespace detail {
  66. template< typename Property >
  67. struct property_base
  68. {
  69. using type = Property;
  70. };
  71. } // namespace detail
  72. struct read_support_true { static constexpr bool is_supported = true; };
  73. struct read_support_false { static constexpr bool is_supported = false; };
  74. struct write_support_true { static constexpr bool is_supported = true; };
  75. struct write_support_false{ static constexpr bool is_supported = false; };
  76. class no_log {};
  77. template< typename Device, typename FormatTag > struct reader_backend;
  78. template< typename Device, typename FormatTag > struct writer_backend;
  79. template< typename FormatTag > struct image_read_info;
  80. template< typename FormatTag > struct image_read_settings;
  81. template< typename FormatTag, typename Log = no_log > struct image_write_info;
  82. } // namespace gil
  83. } // namespace boost
  84. #endif