feat: implement layer mask editing support with scratch buffer and coordinate normalization
This commit is contained in:
@@ -615,7 +615,7 @@ pub fn parse_psd_sequential_full(bytes: &[u8]) -> Result<ParsedPsdData, String>
|
||||
let mut mask_default_color = 0;
|
||||
|
||||
for channel in &layer.channels {
|
||||
if channel.id == -2 {
|
||||
if (channel.id == -2 || channel.id == -3) && decompressed_mask.is_none() {
|
||||
if let Some(mask) = &layer.mask_info {
|
||||
let w = (mask.right - mask.left) as u32;
|
||||
let h = (mask.bottom - mask.top) as u32;
|
||||
@@ -892,3 +892,19 @@ pub fn import_psd(path: &Path) -> Result<Vec<hcie_protocol::Layer>, String> {
|
||||
|
||||
Ok(flat_layers)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_example3_mask_import() {
|
||||
let path = std::path::Path::new("/mnt/extra/00_PROJECTS/hcie-rust-v3.05/_images/_test_images/example3/Example3-mini.psd");
|
||||
if path.exists() {
|
||||
let layers = import_psd(path).expect("import_psd failed");
|
||||
for l in &layers {
|
||||
println!("TEST_LAYER: '{}' has_mask={} bounds={:?}", l.name, l.mask_pixels.is_some(), l.mask_bounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user