1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub const BENCH_FLAG: &str = "QUICKRAW_BENCH";
use thiserror::Error;
pub mod data;
mod color;
mod utility;
mod maker;
mod raw;
mod decode;
pub use decode::new_image_from_file;
pub use decode::new_image_from_buffer;
pub mod export;
pub use export::Export;
const BIT_SHIFT: u32 = 13u32;
#[derive(Debug)]
struct ColorConversion {
white_balance: [i32; 3],
gamma_lut: [u16; 65536],
color_space: [i32; 9],
}
#[derive(Clone)]
pub enum DemosaicingMethod {
None,
SuperPixel,
Linear,
}
#[derive(Clone)]
pub enum OutputType {
Raw8,
Raw16,
Image8(String),
Image16(String),
}
pub enum Input<'a> {
ByFile(&'a str),
ByBuffer(Vec<u8>),
}
#[allow(dead_code)]
#[derive(Clone)]
pub struct Output {
demosaicing_method: DemosaicingMethod,
color_space: [f32; 9],
gamma: [f32; 2],
output_type: OutputType,
auto_crop: bool,
auto_rotate: bool,
}
impl Output {
pub fn new(
demosaicing_method: DemosaicingMethod,
color_space: [f32; 9],
gamma: [f32; 2],
output_type: OutputType,
auto_crop: bool,
auto_rotate: bool,
) -> Output {
Output {
demosaicing_method,
color_space,
gamma,
output_type,
auto_crop,
auto_rotate,
}
}
}
#[derive(Error, Debug)]
pub enum RawFileReadingError {
#[error("Exif parsing error.")]
ExifParseError(#[from] quickexif::parser::Error),
#[error("Exif parsed info error.")]
ExifParseInfoError(#[from] quickexif::parsed_info::Error),
#[error("Cannot read the raw file.")]
DecodingError(#[from] maker::DecodingError),
#[error("The file '{0}' is not existed.")]
FileNotExisted(String),
#[error("The metadata of file '{0}' cannot be read.")]
FileMetadataReadingError(String),
#[error("The content of file '{0}' cannot be read.")]
FileContentReadingError(String),
#[error("Cannot read Make info from this raw file.")]
CannotReadMake,
#[error("Cannot read Model info from this raw file.")]
CannotReadModel,
#[error("This raw file from maker: '{0}' is not supported yet.")]
MakerIsNotSupportedYet(String),
#[error("This raw file model: '{0}' is not supported yet.")]
ModelIsNotSupportedYet(String),
}