mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 20:14:31 +01:00
craft-pst, craft-exr, craft-cms, craft-prepress: smaller or sampled passes
This commit is contained in:
1 parent
e448589df8
commit
459aae1e80
6 files changed
+14
-7
No files matched your search
@@ -70,10 +70,12 @@ fn the_destination_black_matches_the_source_lightness() {
|
||||
for intent in [Intent::RelativeColorimetric, Intent::Perceptual] {
|
||||
for bpc in [true, false] {
|
||||
let o = TransformOptions { intent, bpc, ..opts() };
|
||||
for (src, dst) in [(coated(), fogra()), (fogra(), coated())] {
|
||||
// Both directions for one setting; the other settings in the forward one.
|
||||
let directions = if intent == Intent::RelativeColorimetric && bpc { 2 } else { 1 };
|
||||
for (src, dst) in [(coated(), fogra()), (fogra(), coated())].into_iter().take(directions) {
|
||||
let bp = BlackPreserving::new(src, dst, o).unwrap();
|
||||
let dst_black = lightness(dst, o, [0.0, 0.0, 0.0, 1.0]);
|
||||
for k in [0.1f32, 0.3, 0.5, 0.7, 0.9, 1.0] {
|
||||
for k in [0.1f32, 0.5, 0.9, 1.0] {
|
||||
let want = lightness(src, o, [0.0, 0.0, 0.0, k]);
|
||||
if want <= dst_black {
|
||||
assert_eq!(bp.map_k(k), 1.0, "darker than the destination's black clamps to K = 1");
|
||||
|
||||
@@ -1413,11 +1413,11 @@ fn groups_must_be_slots_of_one_part_each_in_one_group() {
|
||||
#[test]
|
||||
fn the_estimate_covers_what_the_read_does() {
|
||||
// A flat colour in ZIP16 (decodes to far more than it reads), lines of a ramp, and tiles.
|
||||
let (w, h) = (1024usize, 600usize);
|
||||
let (w, h) = (256usize, 160usize);
|
||||
let list = vec![AnyChannel::new("R", FlatSamples::F32(vec![0.25; w * h])), AnyChannel::new("G", FlatSamples::F32(vec![0.5; w * h]))];
|
||||
let encoding = Encoding { compression: Compression::ZIP16, blocks: Blocks::ScanLines, line_order: LineOrder::Increasing };
|
||||
let flat = file(vec![Layer::new((w, h), LayerAttributes::default(), encoding, AnyChannels::sort(list.into()))], (w, h));
|
||||
let ramp = file(vec![layer(None, (0, 0), (1024, 600), &["R", "G"], false, Compression::Uncompressed)], (1024, 600));
|
||||
let ramp = file(vec![layer(None, (0, 0), (256, 160), &["R", "G"], false, Compression::Uncompressed)], (256, 160));
|
||||
let tiled = file(vec![layer(None, (0, 0), (300, 200), &["R", "G", "B"], true, Compression::PIZ)], (300, 200));
|
||||
for bytes in [&flat, &ramp, &tiled] {
|
||||
let index = indexed(bytes);
|
||||
|
||||
@@ -20,6 +20,7 @@ linesweeper = { version = "0.5", optional = true }
|
||||
ttf-parser = { version = "=0.25.1", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
craft-plate-test = { workspace = true }
|
||||
ttf-parser = "=0.25.1"
|
||||
|
||||
|
||||
@@ -532,7 +532,8 @@ endstream endobj
|
||||
fn bands_reach_resolutions_past_the_plate_cap_and_can_stop() {
|
||||
let pdf = disc_and_spot();
|
||||
// 40 pt at 3700 dpi is 2055 pixels a side: 4.2 MP, past `MAX_PLATE_PIXELS`.
|
||||
assert!(plates(&pdf, 0, 3700.0, &Options::default()).unwrap().dpi < 3700.0);
|
||||
// (The whole-page entry point reduces by `plate_scale`; the bands below are not reduced.)
|
||||
assert!(plate_scale(40.0, 40.0, 3700.0 / 72.0) < 3700.0 / 72.0);
|
||||
let mut bands = Vec::new();
|
||||
plates_in_bands(&pdf, 0, 3700.0, &Options::default(), |band| {
|
||||
let p = &band.plates;
|
||||
|
||||
@@ -20,5 +20,6 @@ workspace = true
|
||||
[dependencies]
|
||||
|
||||
[dev-dependencies]
|
||||
craft-testkit = { workspace = true }
|
||||
craft-pst = { path = ".", features = ["test-support"] }
|
||||
proptest = { workspace = true }
|
||||
@@ -248,7 +248,9 @@ fn a_reader_that_fails_or_runs_out_ends_the_call() {
|
||||
}
|
||||
};
|
||||
let mut failed = 0;
|
||||
for (fail, short) in (1..=reads).flat_map(|n| [(n, false), (n, true)]) {
|
||||
// The gate fails every divisor-th read; nightly fails each one.
|
||||
let step = craft_testkit::hostile::divisor();
|
||||
for (fail, short) in (1..=reads).step_by(step).flat_map(|n| [(n, false), (n, true)]) {
|
||||
let Ok(mut pst) = Pst::open(Flaky { inner: Cursor::new(&bytes[..]), reads: 0, fail, short }) else { continue };
|
||||
let got = answers(&mut pst, &folders, &items);
|
||||
failed += got.iter().filter(|r| r.is_err()).count();
|
||||
@@ -257,7 +259,7 @@ fn a_reader_that_fails_or_runs_out_ends_the_call() {
|
||||
}
|
||||
assert!(failed > 0);
|
||||
let mut capped = 0;
|
||||
for floor in (0..bytes.len() as u64 * 4).step_by(256) {
|
||||
for floor in (0..bytes.len() as u64 * 4).step_by(256 * step) {
|
||||
let limits = Limits { read_multiple: 0, read_floor: floor, ..Default::default() };
|
||||
let Ok(mut pst) = Pst::open_with(Cursor::new(&bytes[..]), limits) else { continue };
|
||||
let got = answers(&mut pst, &folders, &items);
|
||||
|
||||
Reference in new issue
Block a user