all: split reusable components into workspace crates
This commit is contained in:
parent
2a079ed800
commit
657e7ce2f7
225 changed files with 7422 additions and 17602 deletions
|
|
@ -2871,7 +2871,7 @@ impl ColorTransforms {
|
|||
mut color: Color,
|
||||
) -> Color {
|
||||
if let Some(ct) = self.get_or_create(src, dst, intent) {
|
||||
color = ct.matrix * color;
|
||||
color = apply_color_matrix(ct.matrix, color);
|
||||
};
|
||||
color
|
||||
}
|
||||
|
|
@ -2896,6 +2896,25 @@ impl ColorTransforms {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply_color_matrix(matrix: ColorMatrix, color: Color) -> Color {
|
||||
let mut rgba = color.to_array(Eotf::Linear);
|
||||
let a = rgba[3];
|
||||
if a < 1.0 && a > 0.0 {
|
||||
for c in &mut rgba[..3] {
|
||||
*c /= a;
|
||||
}
|
||||
}
|
||||
let [r, g, b] = matrix * [rgba[0] as f64, rgba[1] as f64, rgba[2] as f64];
|
||||
Color::new(
|
||||
Eotf::Linear,
|
||||
AlphaMode::Straight,
|
||||
r as f32,
|
||||
g as f32,
|
||||
b as f32,
|
||||
a,
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct EotfArgsCache {
|
||||
map: AHashMap<(EotfCacheKey, bool), EotfArg>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue