io.hpp 3.5 KB

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