tags.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // Copyright 2008 Christian Henning
  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_EXTENSION_IO_PNM_TAGS_HPP
  9. #define BOOST_GIL_EXTENSION_IO_PNM_TAGS_HPP
  10. #define BOOST_GIL_EXTENSION_IO_PNM_READ_ENABLED // TODO: Document, explain, review
  11. #include <boost/gil/io/base.hpp>
  12. #include <type_traits>
  13. namespace boost { namespace gil {
  14. /// Defines pnm tag.
  15. struct pnm_tag : format_tag {};
  16. /// see http://en.wikipedia.org/wiki/Portable_Bitmap_File_Format for reference
  17. /// Defines type for image type property.
  18. struct pnm_image_type : property_base< uint32_t >
  19. {
  20. using mono_asc_t = std::integral_constant<type, 1>;
  21. using gray_asc_t = std::integral_constant<type, 2>;
  22. using color_asc_t = std::integral_constant<type, 3>;
  23. using mono_bin_t = std::integral_constant<type, 4>;
  24. using gray_bin_t = std::integral_constant<type, 5>;
  25. using color_bin_t = std::integral_constant<type, 6>;
  26. };
  27. /// Defines type for image width property.
  28. struct pnm_image_width : property_base< uint32_t > {};
  29. /// Defines type for image height property.
  30. struct pnm_image_height : property_base< uint32_t > {};
  31. /// Defines type for image max value property.
  32. struct pnm_image_max_value : property_base< uint32_t > {};
  33. /// Read information for pnm images.
  34. ///
  35. /// The structure is returned when using read_image_info.
  36. template<>
  37. struct image_read_info< pnm_tag >
  38. {
  39. /// The image type.
  40. pnm_image_type::type _type;
  41. /// The image width.
  42. pnm_image_width::type _width;
  43. /// The image height.
  44. pnm_image_height::type _height;
  45. /// The image max value.
  46. pnm_image_max_value::type _max_value;
  47. };
  48. /// Read settings for pnm images.
  49. ///
  50. /// The structure can be used for all read_xxx functions, except read_image_info.
  51. template<>
  52. struct image_read_settings< pnm_tag > : public image_read_settings_base
  53. {
  54. /// Default constructor
  55. image_read_settings< pnm_tag >()
  56. : image_read_settings_base()
  57. {}
  58. /// Constructor
  59. /// \param top_left Top left coordinate for reading partial image.
  60. /// \param dim Dimensions for reading partial image.
  61. image_read_settings( const point_t& top_left
  62. , const point_t& dim
  63. )
  64. : image_read_settings_base( top_left
  65. , dim
  66. )
  67. {}
  68. };
  69. /// Write information for pnm images.
  70. ///
  71. /// The structure can be used for write_view() function.
  72. template<>
  73. struct image_write_info< pnm_tag >
  74. {
  75. };
  76. } // namespace gil
  77. } // namespace boost
  78. #endif