1 | // |
---|---|
2 | // Copyright 2012 Olivier Tournaire |
3 | // Copyright 2007 Christian Henning |
4 | // |
5 | // Distributed under the Boost Software License, Version 1.0 |
6 | // See accompanying file LICENSE_1_0.txt or copy at |
7 | // http://www.boost.org/LICENSE_1_0.txt |
8 | // |
9 | #ifndef BOOST_GIL_EXTENSION_IO_RAW_DETAIL_DEVICE_HPP |
10 | #define BOOST_GIL_EXTENSION_IO_RAW_DETAIL_DEVICE_HPP |
11 | |
12 | #include <boost/gil/extension/io/raw/tags.hpp> |
13 | |
14 | #include <boost/gil/io/base.hpp> |
15 | #include <boost/gil/io/device.hpp> |
16 | |
17 | #include <memory> |
18 | #include <string> |
19 | #include <type_traits> |
20 | |
21 | namespace boost { namespace gil { namespace detail { |
22 | |
23 | class raw_device_base |
24 | { |
25 | public: |
26 | |
27 | /// |
28 | /// Constructor |
29 | /// |
30 | raw_device_base() |
31 | : _processor_ptr( new LibRaw ) |
32 | {} |
33 | |
34 | // iparams getters |
35 | std::string get_camera_manufacturer() { return std::string(_processor_ptr.get()->imgdata.idata.make); } |
36 | std::string get_camera_model() { return std::string(_processor_ptr.get()->imgdata.idata.model); } |
37 | unsigned get_raw_count() { return _processor_ptr.get()->imgdata.idata.raw_count; } |
38 | unsigned get_dng_version() { return _processor_ptr.get()->imgdata.idata.dng_version; } |
39 | int get_colors() { return _processor_ptr.get()->imgdata.idata.colors; } |
40 | unsigned get_filters() { return _processor_ptr.get()->imgdata.idata.filters; } |
41 | std::string get_cdesc() { return std::string(_processor_ptr.get()->imgdata.idata.cdesc); } |
42 | |
43 | // image_sizes getters |
44 | unsigned short get_raw_width() { return _processor_ptr.get()->imgdata.sizes.raw_width; } |
45 | unsigned short get_raw_height() { return _processor_ptr.get()->imgdata.sizes.raw_height; } |
46 | unsigned short get_image_width() { return _processor_ptr.get()->imgdata.sizes.width; } |
47 | unsigned short get_image_height() { return _processor_ptr.get()->imgdata.sizes.height; } |
48 | unsigned short get_top_margin() { return _processor_ptr.get()->imgdata.sizes.top_margin; } |
49 | unsigned short get_left_margin() { return _processor_ptr.get()->imgdata.sizes.left_margin; } |
50 | unsigned short get_iwidth() { return _processor_ptr.get()->imgdata.sizes.iwidth; } |
51 | unsigned short get_iheight() { return _processor_ptr.get()->imgdata.sizes.iheight; } |
52 | double get_pixel_aspect() { return _processor_ptr.get()->imgdata.sizes.pixel_aspect; } |
53 | int get_flip() { return _processor_ptr.get()->imgdata.sizes.flip; } |
54 | |
55 | // colordata getters |
56 | // TODO |
57 | |
58 | // imgother getters |
59 | float get_iso_speed() { return _processor_ptr.get()->imgdata.other.iso_speed; } |
60 | float get_shutter() { return _processor_ptr.get()->imgdata.other.shutter; } |
61 | float get_aperture() { return _processor_ptr.get()->imgdata.other.aperture; } |
62 | float get_focal_len() { return _processor_ptr.get()->imgdata.other.focal_len; } |
63 | time_t get_timestamp() { return _processor_ptr.get()->imgdata.other.timestamp; } |
64 | unsigned int get_shot_order() { return _processor_ptr.get()->imgdata.other.shot_order; } |
65 | unsigned* get_gpsdata() { return _processor_ptr.get()->imgdata.other.gpsdata; } |
66 | std::string get_desc() { return std::string(_processor_ptr.get()->imgdata.other.desc); } |
67 | std::string get_artist() { return std::string(_processor_ptr.get()->imgdata.other.artist); } |
68 | |
69 | std::string get_version() { return std::string(_processor_ptr.get()->version()); } |
70 | std::string get_unpack_function_name() { return std::string(_processor_ptr.get()->unpack_function_name()); } |
71 | |
72 | void get_mem_image_format(int *widthp, int *heightp, int *colorsp, int *bpp) { _processor_ptr.get()->get_mem_image_format(widthp, heightp, colorsp, bpp); } |
73 | |
74 | int unpack() { return _processor_ptr.get()->unpack(); } |
75 | int dcraw_process() { return _processor_ptr.get()->dcraw_process(); } |
76 | libraw_processed_image_t* dcraw_make_mem_image(int* error_code=nullptr) { return _processor_ptr.get()->dcraw_make_mem_image(error_code); } |
77 | |
78 | protected: |
79 | |
80 | using libraw_ptr_t = std::shared_ptr<LibRaw>; |
81 | libraw_ptr_t _processor_ptr; |
82 | }; |
83 | |
84 | /*! |
85 | * |
86 | * file_stream_device specialization for raw images |
87 | */ |
88 | template<> |
89 | class file_stream_device< raw_tag > : public raw_device_base |
90 | { |
91 | public: |
92 | |
93 | struct read_tag {}; |
94 | |
95 | /// |
96 | /// Constructor |
97 | /// |
98 | file_stream_device( std::string const& file_name |
99 | , read_tag = read_tag() |
100 | ) |
101 | { |
102 | io_error_if( _processor_ptr.get()->open_file( file_name.c_str() ) != LIBRAW_SUCCESS |
103 | , "file_stream_device: failed to open file" |
104 | ); |
105 | } |
106 | |
107 | /// |
108 | /// Constructor |
109 | /// |
110 | file_stream_device( const char* file_name |
111 | , read_tag = read_tag() |
112 | ) |
113 | { |
114 | io_error_if( _processor_ptr.get()->open_file( file_name ) != LIBRAW_SUCCESS |
115 | , "file_stream_device: failed to open file" |
116 | ); |
117 | } |
118 | }; |
119 | |
120 | template< typename FormatTag > |
121 | struct is_adaptable_input_device<FormatTag, LibRaw, void> : std::true_type |
122 | { |
123 | using device_type = file_stream_device<FormatTag>; |
124 | }; |
125 | |
126 | |
127 | } // namespace detail |
128 | } // namespace gil |
129 | } // namespace boost |
130 | |
131 | #endif |
132 |
Definitions
- raw_device_base
- get_camera_manufacturer
- get_camera_model
- get_raw_count
- get_dng_version
- get_colors
- get_filters
- get_cdesc
- get_raw_width
- get_raw_height
- get_image_width
- get_image_height
- get_top_margin
- get_left_margin
- get_iwidth
- get_iheight
- get_pixel_aspect
- get_flip
- get_iso_speed
- get_shutter
- get_aperture
- get_focal_len
- get_timestamp
- get_shot_order
- get_gpsdata
- get_desc
- get_artist
- get_version
- get_unpack_function_name
- get_mem_image_format
- unpack
- dcraw_process
- dcraw_make_mem_image
- file_stream_device
- read_tag
- file_stream_device
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more