io.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. Copyright 2007-2008 Christian Henning, Andreas Pokorny
  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_IO_HPP
  9. #define BOOST_GIL_IO_IO_HPP
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. /// \file
  12. /// \brief
  13. /// \author Christian Henning, Andreas Pokorny \n
  14. ///
  15. /// \date 2007-2008 \n
  16. ///
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. /*!
  19. * \page iobackend Adding a new io backend
  20. * \section Overview of backend requirements
  21. * To add support for a new IO backend the following is required:
  22. * - a format tag, to identify the image format, derived from boost::gil::format_tag
  23. * - boolean meta function is_supported<PixelType,FormatTag> must be implemented for
  24. * the new format tag
  25. * - explicit specialisation of image_read_info<FormatTag> must be provided, containing
  26. * runtime information available before/at reading the image
  27. * - explicit specialisation of image_write_info<FormatTag> must be provided, containing
  28. * runtime encoding parameters for writing an image
  29. * - An image reader must be specialized:
  30. * \code
  31. * template<typename IODevice, typename ConversionPolicy>
  32. * struct boost::gil::reader<IODevice,FormatTag,ConversionPolicy>
  33. * {
  34. * reader( IODevice & device )
  35. * reader( IODevice & device, typename ConversionPolicy::color_converter_type const& cc )
  36. * image_read_info<FormatTag> get_info();
  37. * template<typename Image>
  38. * void read_image( Image &, point_t const& top_left );
  39. * template<typename View>
  40. * void read_view( View &, point_t const& top_left );
  41. * };
  42. * \endcode
  43. * - An image writer must be specialized:
  44. * \code
  45. * \template <typename IODevice>
  46. * struct boost::gil::writer<IODevice,FormatTag>
  47. * {
  48. * writer( IODevice & device )
  49. * template<typename View>
  50. * void apply( View const&, point_t const& top_left );
  51. * template<typename View>
  52. * void apply( View const&, point_t const& top_left, image_write_info<FormatTag> const& );
  53. * };
  54. * \endcode
  55. *
  56. * Or instead of the items above implement overloads of read_view, read_and_convert_view, read_image,
  57. * read_and_convert_image, write_view and read_image_info.
  58. *
  59. * \section ConversionPolicy Interface of the ConversionPolicy
  60. * There are two different conversion policies in use, when reading images:
  61. * read_and_convert<ColorConverter> and read_and_no_convert. ColorConverter
  62. * can be a user defined color converter.
  63. *
  64. * \code
  65. * struct ConversionPolicy
  66. * {
  67. * template<typename InputIterator,typename OutputIterator>
  68. * void read( InputIterator in_begin, InputIterator in_end,
  69. * OutputIterator out_end );
  70. * };
  71. * \endcode
  72. *
  73. * Methods like read_view and read_image are supposed to bail out with an
  74. * exception instead of converting the image
  75. *
  76. * \section IODevice Concept of IO Device
  77. * A Device is simply an object used to read and write data to and from a stream.
  78. * The IODevice was added as a template paramter to be able to replace the file_name
  79. * access functionality. This is only an interim solution, as soon as boost provides
  80. * a good IO library, interfaces/constraints provided by that library could be used.
  81. *
  82. * \code
  83. * concept IODevice
  84. * {
  85. * void IODevice::read( unsigned char* data, int count );
  86. * void IODevice::write( unsigned char* data, int count );
  87. * void IODevice::seek(long count, int whence);
  88. * void IODevice::flush();
  89. * };
  90. * \endcode
  91. *
  92. * For the time being a boolean meta function must be specialized:
  93. * \code
  94. * namespace boost{namespace gil{namespace detail{
  95. * template<typename Device>
  96. * struct detail::is_input_device;
  97. * }}}
  98. * \endcode
  99. *
  100. */
  101. #endif