]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/gil/extension/io/raw/detail/reader_backend.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / gil / extension / io / raw / detail / reader_backend.hpp
1 //
2 // Copyright 2012 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_DETAIL_READER_BACKEND_HPP
9 #define BOOST_GIL_EXTENSION_IO_RAW_DETAIL_READER_BACKEND_HPP
10
11 #include <boost/gil/extension/io/raw/tags.hpp>
12
13 namespace boost { namespace gil {
14
15 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
16 #pragma warning(push)
17 #pragma warning(disable:4512) //assignment operator could not be generated
18 #endif
19
20 ///
21 /// RAW Backend
22 ///
23 template< typename Device >
24 struct reader_backend< Device
25 , raw_tag
26 >
27 {
28 public:
29
30 using format_tag_t = raw_tag;
31
32 public:
33
34 reader_backend( const Device& io_dev
35 , const image_read_settings< raw_tag >& settings
36 )
37 : _io_dev ( io_dev )
38 , _settings( settings )
39 , _info()
40 , _scanline_length( 0 )
41 {
42 read_header();
43
44 if( _settings._dim.x == 0 )
45 {
46 _settings._dim.x = _info._width;
47 }
48
49 if( _settings._dim.y == 0 )
50 {
51 _settings._dim.y = _info._height;
52 }
53 }
54
55 void read_header()
56 {
57 _io_dev.get_mem_image_format( &_info._width
58 , &_info._height
59 , &_info._samples_per_pixel
60 , &_info._bits_per_pixel
61 );
62
63 // iparams
64 _info._camera_manufacturer = _io_dev.get_camera_manufacturer();
65 _info._camera_model = _io_dev.get_camera_model();
66 _info._raw_images_count = _io_dev.get_raw_count();
67 _info._dng_version = _io_dev.get_dng_version();
68 _info._number_colors = _io_dev.get_colors();
69 //_io_dev.get_filters();
70 _info._colors_description = _io_dev.get_cdesc();
71
72 // image_sizes
73 _info._raw_width = _io_dev.get_raw_width();
74 _info._raw_height = _io_dev.get_raw_height();
75 _info._visible_width = _io_dev.get_image_width();
76 _info._visible_height = _io_dev.get_image_height();
77 _info._top_margin = _io_dev.get_top_margin();
78 _info._left_margin = _io_dev.get_left_margin();
79 _info._output_width = _io_dev.get_iwidth();
80 _info._output_height = _io_dev.get_iheight();
81 _info._pixel_aspect = _io_dev.get_pixel_aspect();
82 _info._flip = _io_dev.get_flip();
83
84 // imgother
85 _info._iso_speed = _io_dev.get_iso_speed();
86 _info._shutter = _io_dev.get_shutter();
87 _info._aperture = _io_dev.get_aperture();
88 _info._focal_length = _io_dev.get_focal_len();
89 _info._timestamp = _io_dev.get_timestamp();
90 _info._shot_order = static_cast< uint16_t >( _io_dev.get_shot_order() );
91 //_io_dev.get_gpsdata();
92 _info._image_description = _io_dev.get_desc();
93 _info._artist = _io_dev.get_artist();
94
95 _info._libraw_version = _io_dev.get_version();
96
97 _info._valid = true;
98 }
99
100 /// Check if image is large enough.
101 void check_image_size( const point_t& img_dim )
102 {
103 if( _settings._dim.x > 0 )
104 {
105 if( img_dim.x < _settings._dim.x ) { io_error( "Supplied image is too small" ); }
106 }
107 else
108 {
109 if( img_dim.x < _info._width ) { io_error( "Supplied image is too small" ); }
110 }
111
112
113 if( _settings._dim.y > 0 )
114 {
115 if( img_dim.y < _settings._dim.y ) { io_error( "Supplied image is too small" ); }
116 }
117 else
118 {
119 if( img_dim.y < _info._height ) { io_error( "Supplied image is too small" ); }
120 }
121 }
122
123 public:
124
125 Device _io_dev;
126
127 image_read_settings< raw_tag > _settings;
128 image_read_info< raw_tag > _info;
129
130 std::size_t _scanline_length;
131 };
132
133 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
134 #pragma warning(pop)
135 #endif
136
137 } // namespace gil
138 } // namespace boost
139
140 #endif