tags.hpp 6.2 KB

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