mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 21:57:12 -06:00
PDF: colorized images count as transparency for PDF 1.3 and PDF/X
A colorized grayscale or 1-bit image draws its white pixels transparent and is written to PDF with the image as a soft mask. Node::shows_transparency did not count it, so a PDF 1.3, PDF/X-1a or PDF/X-3 export whose only transparency was a colorized image was not flattened and kept the soft mask. A legacy .ai save also wrote such an image as opaque. - shows_transparency counts a visible image with a colorize paint. - The legacy .ai writer flattens or leaves out colorized images like other see-through images.
This commit is contained in:
@@ -683,8 +683,8 @@ impl Node {
|
||||
|
||||
impl Node {
|
||||
/// Whether this object shows any transparency, itself or anything inside it: object, fill or
|
||||
/// stroke opacity below 100%, a blend mode, an opacity mask, effects or transparent gradient
|
||||
/// stops. Hidden objects show none.
|
||||
/// stroke opacity below 100%, a blend mode, an opacity mask, effects, transparent gradient
|
||||
/// stops or a colorized image. Hidden objects show none.
|
||||
pub fn shows_transparency(&self) -> bool {
|
||||
use vectorcraft_color::Paint;
|
||||
let see_through = |p: &Paint| matches!(p, Paint::Gradient(g) if g.gradient.stops.iter().any(|s| s.opacity < 1.0));
|
||||
@@ -693,6 +693,7 @@ impl Node {
|
||||
&& (self.opacity < 1.0
|
||||
|| self.blend != BlendMode::Normal
|
||||
|| self.extras().mask.as_ref().is_some_and(|m| !m.disabled)
|
||||
|| (matches!(self.kind, NodeKind::Image(_)) && self.extras().colorize.is_some())
|
||||
|| effects(&self.appearance.effects)
|
||||
|| self
|
||||
.appearance
|
||||
|
||||
Reference in New Issue
Block a user