Files
Graphite/libraries/raw-rs/src/tiff/values.rs
Elbert Ronnie fd3613018a 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>
2024-06-28 03:23:05 -07:00

31 lines
621 B
Rust

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]
}
}