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