Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / io / raw / tags.hpp
1 //
2 // Copyright 2013 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_RAW_TAGS_HPP
9 #define BOOST_GIL_EXTENSION_IO_RAW_TAGS_HPP
10
11 #include <boost/gil/io/base.hpp>
12
13 // Historically, LibRaw expects WIN32, not _WIN32 (see https://github.com/LibRaw/LibRaw/pull/206)
14 #ifdef _MSC_VER
15 #ifndef WIN32
16 #define WIN32
17 #endif
18 #pragma warning(push)
19 #pragma warning(disable:4251) // 'type' needs to have dll-interface to be used by clients of class
20 #endif
21
22 #include <libraw/libraw.h>
23
24 namespace boost { namespace gil {
25
26 /// Defines tiff tag.
27 struct raw_tag : format_tag {};
28
29 /// Defines type for image width property.
30 struct raw_image_width : property_base< int32_t > {};
31
32 /// Defines type for image height property.
33 struct raw_image_height : property_base< int32_t > {};
34
35 /// Defines type for samples per pixel property.
36 struct raw_samples_per_pixel : property_base< int32_t > {};
37
38 /// Defines type for bits per pixel property.
39 struct raw_bits_per_pixel : property_base< int32_t > {};
40
41 /// Defines type for camera manufacturer.
42 struct raw_camera_manufacturer : property_base< std::string > {};
43
44 /// Defines type for camera model.
45 struct raw_camera_model : property_base< std::string > {};
46
47 /// Defines type for raw images count.
48 struct raw_raw_images_count : property_base< unsigned > {};
49
50 /// Defines type for dng version.
51 struct raw_dng_version : property_base< unsigned > {};
52
53 /// Defines type for number of colors.
54 struct raw_number_colors : property_base< int32_t > {};
55
56 /// Defines type for colors description.
57 struct raw_colors_description : property_base< std::string > {};
58
59 /// Defines type for raw height.
60 struct raw_raw_height : property_base< uint16_t > {};
61
62 /// Defines type for raw width.
63 struct raw_raw_width : property_base< uint16_t > {};
64
65 /// Defines type for visible height.
66 struct raw_visible_height : property_base< uint16_t > {};
67
68 /// Defines type for visible width.
69 struct raw_visible_width : property_base< uint16_t > {};
70
71 /// Defines type for top margin.
72 struct raw_top_margin : property_base< uint16_t > {};
73
74 /// Defines type for left margin.
75 struct raw_left_margin : property_base< uint16_t > {};
76
77 /// Defines type for output height.
78 struct raw_output_height : property_base< uint16_t > {};
79
80 /// Defines type for output width.
81 struct raw_output_width : property_base< uint16_t > {};
82
83 /// Defines type for pixel aspect.
84 struct raw_pixel_aspect : property_base< double > {};
85
86 /// Defines type for image orientation.
87 struct raw_flip : property_base< uint32_t > {};
88
89 /// Defines type for iso speed.
90 struct raw_iso_speed : property_base< float > {};
91
92 /// Defines type for shutter.
93 struct raw_shutter : property_base< float > {};
94
95 /// Defines type for aperture.
96 struct raw_aperture : property_base< float > {};
97
98 /// Defines type for focal length.
99 struct raw_focal_length : property_base< float > {};
100
101 /// Defines type for timestamp.
102 struct raw_timestamp : property_base< time_t > {};
103
104 /// Defines type for shot order.
105 struct raw_shot_order : property_base< uint16_t > {};
106
107 /// Defines type for image description.
108 struct raw_image_description : property_base< std::string > {};
109
110 /// Defines type for artist.
111 struct raw_artist : property_base< std::string > {};
112
113 /// Defines type for libraw version.
114 struct raw_libraw_version : property_base< std::string > {};
115
116 /// Defines type for unpack function name.
117 struct raw_unpack_function_name : property_base< std::string > {};
118
119 /// Read information for raw images.
120 ///
121 /// The structure is returned when using read_image_info.
122 template<>
123 struct image_read_info< raw_tag >
124 {
125     /// Default contructor.
126     image_read_info< raw_tag >()
127     : _valid( false )
128     {}
129
130     // Here, width and height of the image are the ones of the output height (ie after having been processed by dcraw emulator)
131     raw_image_width::type       _width;
132     raw_image_height::type      _height;
133     raw_samples_per_pixel::type _samples_per_pixel;
134     raw_bits_per_pixel::type    _bits_per_pixel;
135
136     raw_camera_manufacturer::type _camera_manufacturer;
137     raw_camera_model::type        _camera_model;
138
139     raw_raw_images_count::type   _raw_images_count;
140     raw_dng_version::type        _dng_version;
141     raw_number_colors::type      _number_colors;
142     raw_colors_description::type _colors_description;
143
144     raw_raw_width::type      _raw_width;
145     raw_raw_height::type     _raw_height;
146     raw_visible_width::type  _visible_width;
147     raw_visible_height::type _visible_height;
148     raw_top_margin::type     _top_margin;
149     raw_left_margin::type    _left_margin;
150     raw_output_width::type   _output_width;
151     raw_output_height::type  _output_height;
152     raw_pixel_aspect::type   _pixel_aspect;
153     raw_flip::type           _flip;
154
155     raw_iso_speed::type         _iso_speed;
156     raw_shutter::type           _shutter;
157     raw_aperture::type          _aperture;
158     raw_focal_length::type      _focal_length;
159     raw_timestamp::type         _timestamp;
160     raw_shot_order::type        _shot_order;
161     raw_image_description::type _image_description;
162     raw_artist::type            _artist;
163
164     raw_libraw_version::type       _libraw_version;
165     raw_unpack_function_name::type _unpack_function_name;
166
167     /// Used internaly to identify if the header has been read.
168     bool _valid;
169 };
170
171 /// Read settings for raw images.
172 ///
173 /// The structure can be used for all read_xxx functions, except read_image_info.
174 template<>
175 struct image_read_settings< raw_tag > : public image_read_settings_base
176 {
177     /// Default constructor
178     image_read_settings()
179     : image_read_settings_base()
180     {}
181
182     /// Constructor
183     /// \param top_left Top left coordinate for reading partial image.
184     /// \param dim      Dimensions for reading partial image.
185     image_read_settings( const point_t& top_left
186                        , const point_t& dim
187                        )
188     : image_read_settings_base( top_left
189                               , dim
190                               )
191     {}
192 };
193
194 /// Write information for raw images.
195 ///
196 /// The structure can be used for write_view() function.
197 template<>
198 struct image_write_info< raw_tag >
199 {
200 };
201
202 }} // namespace boost::gil
203
204 #ifdef _MSC_VER
205 #pragma warning(pop)
206 #endif
207
208 #endif