PSD export: check the Background's opacity from its tiles (#5998)

This commit is contained in:
Persi authored and GitHub committed 2026-10-19 14:20:22 -04:00
1 parent c136d2dd3d
commit f5af2f3ef5
2 files changed
+2 -4

No files matched your search

+1 -1
View File
@@ -495,7 +495,7 @@ fn drop_alpha(data: &mut Vec<u8>, color: usize, alpha: usize) {
}
/// Whether every pixel of `s` over `r` is fully opaque (read from the tiles, no copy).
fn opaque_surface(s: &Surface, r: Rect) -> bool {
pub(crate) fn opaque_surface(s: &Surface, r: Rect) -> bool {
let fmt = s.format();
let (ch, bps) = (fmt.channels(), fmt.sample.bytes());
let a = ch - 1;
+1 -3
View File
@@ -107,9 +107,7 @@ fn psd_background(doc: &Document) -> Option<photocraft_doc::LayerId> {
if canvas.is_empty() || s.content_bounds() != canvas {
return None;
}
let n = s.channels();
let opaque = s.read_region(canvas).chunks_exact(n).all(|p| p.last().is_some_and(|a| *a >= 1.0));
opaque.then_some(l.id)
crate::flat::opaque_surface(s, canvas).then_some(l.id)
}
/// How deep embedded documents are exported inside each other before a smart object is written