Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge remote-tracking branch 'origin/main' into cmyk-native-composite

SBaksaa4cb23a33f0d
diff --cc crates/compose/src/lib.rs
index 5fb4408e1,3cf2f1dc1..635d5f47e
--- a/crates/compose/src/lib.rs
+++ b/crates/compose/src/lib.rs
@@@ -19,9 -19,9 +19,10 @@@
pub mod adjust;
pub mod advanced;
pub mod bounds;
+pub mod cmyk;
pub mod effects;
pub mod fill_layout;
+ pub mod filter_mask;
pub mod gradient_fill;
pub mod masks;
pub mod multichannel;
@@@ -260,11 -269,9 +270,12 @@@ pub fn band_rows_for(width: u32, reques
/// leaves colour behind in CMYK (K = 100%) and Lab (neutral a/b = 0.5), and those pixels would
/// otherwise count as content: the result would span the whole canvas.
///
-/// A CMYK document of plain Normal layers is composited in its ink values instead
-/// ([`native::flatten_cmyk`]), so flattening doesn't round-trip its pixels through RGB (#3778),
-/// and a Lab one in its L, a and b ([`native_lab::flatten_lab`]).
+/// A CMYK document flattened to CMYK is composited in its ink values instead, so flattening
+/// doesn't round-trip its pixels through RGB: plain Normal layers by [`native::flatten_cmyk`]
+/// (#3778), and masks, groups, clipping, other blend modes and the other layer kinds by [`cmyk`]
+/// where its layers mix on their inks (#2220). Otherwise the composite goes back to CMYK through
- /// the document's own profile, the one its layers were read through.
++/// the document's own profile, the one its layers were read through. A Lab document of plain
++/// layers is composited in its L, a and b ([`native_lab::flatten_lab`]).
pub fn flatten_to_surface(doc: &Document, fmt: photocraft_color::PixelFormat, background: Option<[f32; 3]>) -> Surface {
composite_to_surface(doc, doc.bounds(), fmt, background)
}
diff --cc crates/io/tests/cmyk_composite_export.rs
index b0c3da62a,31c0b6969..83e6b3781
--- a/crates/io/tests/cmyk_composite_export.rs
+++ b/crates/io/tests/cmyk_composite_export.rs
@@@ -1,8 -1,8 +1,8 @@@
use photocraft_cms::{Builtin, Intent, Profile, Transform};
use photocraft_codecs::{ChannelLayout, SampleType as CodecSample, decode};
- use photocraft_color::{BlendMode, ColorMode, SampleType};
- use photocraft_doc::{Document, Layer, LayerContent};
- use photocraft_geom::Size;
-use photocraft_color::{ColorMode, PixelFormat, SampleType};
++use photocraft_color::{BlendMode, ColorMode, PixelFormat, SampleType};
+ use photocraft_doc::{Document, Layer, LayerContent, LayerMask};
+ use photocraft_geom::{Rect, Size};
use photocraft_io::{ExportOptions, document_to_image, export};
use photocraft_raster::Surface;