PSD: share the duplicated decode, placed-transform and writer helpers (#1133)
One decode_plane for raw/RLE/ZIP (decode_channel and composite), placed::eight and quad_from for the SoLd/PlLd transforms, the writer's big-endian and UTF-16 helpers from descriptor.rs, one delimiter const in engine_data.rs, and the dead binding in write.rs. No behaviour change; adds ZIP and RLE composite tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
470ea7a3af
commit
cf22417c1a
@@ -35,7 +35,7 @@ pub struct Warp {
|
||||
pub mesh: Vec<[f64; 2]>,
|
||||
}
|
||||
|
||||
fn floats(v: Option<&DValue>) -> Vec<f64> {
|
||||
pub(crate) fn floats(v: Option<&DValue>) -> Vec<f64> {
|
||||
match v {
|
||||
Some(DValue::UnitFloats(_, v)) => v.clone(),
|
||||
Some(DValue::List(l)) => l
|
||||
@@ -50,6 +50,16 @@ fn floats(v: Option<&DValue>) -> Vec<f64> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The eight numbers of a transform entry (`Trnf`, `nonAffineTransform`), when it has exactly eight.
|
||||
pub(crate) fn eight(d: &Descriptor, key: &str) -> Option<[f64; 8]> {
|
||||
floats(d.get(key)).try_into().ok()
|
||||
}
|
||||
|
||||
/// The corner quad (top-left, top-right, bottom-right, bottom-left) from x0 y0 … x3 y3.
|
||||
pub(crate) fn quad_from(t: [f64; 8]) -> [[f64; 2]; 4] {
|
||||
[[t[0], t[1]], [t[2], t[3]], [t[4], t[5]], [t[6], t[7]]]
|
||||
}
|
||||
|
||||
impl Warp {
|
||||
/// Read a `warp` descriptor; `None` for no warp.
|
||||
pub fn read(d: &Descriptor) -> Option<Warp> {
|
||||
|
||||
Reference in New Issue
Block a user