base.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. Copyright 2007-2008 Christian Henning, Andreas Pokorny, Lubomir Bourdev
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. /*************************************************************************************************/
  8. #ifndef BOOST_GIL_IO_BASE_HPP
  9. #define BOOST_GIL_IO_BASE_HPP
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. /// \file
  12. /// \brief
  13. /// \author Christian Henning, Andreas Pokorny, Lubomir Bourdev \n
  14. ///
  15. /// \date 2007-2008 \n
  16. ///
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. #include <ostream>
  19. #include <istream>
  20. #include <vector>
  21. #include <boost/bind.hpp>
  22. #include <boost/type_traits/is_base_of.hpp>
  23. #include <boost/gil/utilities.hpp>
  24. #include <boost/gil/color_convert.hpp>
  25. #include <boost/gil/bit_aligned_pixel_reference.hpp>
  26. #include <boost/gil/bit_aligned_pixel_iterator.hpp>
  27. #include <boost/gil/extension/toolbox/toolbox.hpp>
  28. #include <boost/gil/io/typedefs.hpp>
  29. #include <boost/gil/io/error.hpp>
  30. namespace boost { namespace gil {
  31. struct format_tag {};
  32. template< typename Property >
  33. struct property_base
  34. {
  35. typedef Property type;
  36. };
  37. template<typename FormatTag> struct is_format_tag : is_base_and_derived< format_tag
  38. , FormatTag
  39. > {};
  40. struct image_read_settings_base
  41. {
  42. protected:
  43. image_read_settings_base()
  44. : _top_left( 0, 0 )
  45. , _dim ( 0, 0 )
  46. {}
  47. image_read_settings_base( const point_t& top_left
  48. , const point_t& dim
  49. )
  50. : _top_left( top_left )
  51. , _dim ( dim )
  52. {}
  53. public:
  54. void set( const point_t& top_left
  55. , const point_t& dim
  56. )
  57. {
  58. _top_left = top_left;
  59. _dim = dim;
  60. }
  61. public:
  62. point_t _top_left;
  63. point_t _dim;
  64. };
  65. /**
  66. * Boolean meta function, mpl::true_ if the pixel type \a PixelType is supported
  67. * by the image format identified with \a FormatTag.
  68. * \todo the name is_supported is to generic, pick something more IO realted.
  69. */
  70. // Depending on image type the parameter Pixel can be a reference type
  71. // for bit_aligned images or a pixel for byte images.
  72. template< typename Pixel, typename FormatTag > struct is_read_supported {};
  73. template< typename Pixel, typename FormatTag > struct is_write_supported {};
  74. namespace detail {
  75. template< typename Property >
  76. struct property_base
  77. {
  78. typedef Property type;
  79. };
  80. } // namespace detail
  81. struct read_support_true { BOOST_STATIC_CONSTANT( bool, is_supported = true ); };
  82. struct read_support_false { BOOST_STATIC_CONSTANT( bool, is_supported = false ); };
  83. struct write_support_true { BOOST_STATIC_CONSTANT( bool, is_supported = true ); };
  84. struct write_support_false{ BOOST_STATIC_CONSTANT( bool, is_supported = false ); };
  85. class no_log {};
  86. template< typename Device, typename FormatTag > struct reader_backend;
  87. template< typename Device, typename FormatTag > struct writer_backend;
  88. template< typename FormatTag > struct image_read_info;
  89. template< typename FormatTag > struct image_read_settings;
  90. template< typename FormatTag, typename Log = no_log > struct image_write_info;
  91. } // namespace gil
  92. } // namespace boost
  93. #endif