mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 07:18:11 +08:00
Raw-rs: make decoder for ARW1 and ARW2 formats (#1775)
* convert Tag into a trait * Create ARW 1 decoder * add decoder for sony tone curve table * create decoder for arw 2.1 format * add windsock.arw to the tests * create derive macro for Tag and use it in decoders * add license to tag-derive * add code to identify model * impl Display for Ifd * Code review * Fix type variable name * Fix compilation --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
c9a33e44bd
commit
fd3613018a
@@ -2,3 +2,29 @@ pub struct Rational<T> {
|
||||
pub numerator: T,
|
||||
pub denominator: T,
|
||||
}
|
||||
|
||||
pub struct CurveLookupTable {
|
||||
table: Vec<u16>,
|
||||
}
|
||||
|
||||
impl CurveLookupTable {
|
||||
pub fn from_sony_tone_table(values: [u16; 4]) -> CurveLookupTable {
|
||||
let mut sony_curve = [0, 0, 0, 0, 0, 4095];
|
||||
for i in 0..4 {
|
||||
sony_curve[i + 1] = values[i] >> 2 & 0xfff;
|
||||
}
|
||||
|
||||
let mut table = vec![0_u16; (sony_curve[5] + 1).into()];
|
||||
for i in 0..5 {
|
||||
for j in (sony_curve[i] + 1)..=sony_curve[i + 1] {
|
||||
table[j as usize] = table[(j - 1) as usize] + (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
CurveLookupTable { table }
|
||||
}
|
||||
|
||||
pub fn get(&self, x: usize) -> u16 {
|
||||
self.table[x]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user