Skip to content

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

Raw: open monochrome LinearRaw DNGs (1 sample per pixel) (#3497) (#3503)

David Mann39aa849b47f4
diff --git a/crates/io/src/raw.rs b/crates/io/src/raw.rs
index 71e8c8a0b..6ff2f5904 100644
--- a/crates/io/src/raw.rs
+++ b/crates/io/src/raw.rs
@@ -171,6 +171,7 @@ fn develop_fitted(bytes: &[u8], opts: &DevelopOptions) -> Result<photocraft_raw:
let mut opts = Cow::Borrowed(opts);
if opts.camera_look.is_none()
&& sensor.color.calibrations.is_empty()
+ && !sensor.is_monochrome()
&& let Ok(look) = fit_preview_look(bytes, &sensor, &opts)
{
opts.to_mut().camera_look = Some(look);
diff --git a/crates/io/tests/raw.rs b/crates/io/tests/raw.rs
index b9c62270e..d0bc370db 100644
--- a/crates/io/tests/raw.rs
+++ b/crates/io/tests/raw.rs
@@ -22,6 +22,18 @@ fn dng_opens_as_16_bit_prophoto() {
assert!(r.warnings.iter().any(|w| w.contains("DNG") && w.contains("ProPhoto")), "{:?}", r.warnings);
}
+/// #3497: a monochrome (one-sample LinearRaw) DNG, as VueScan writes film scans, opens as a
+/// 16-bit RGB document (neutral grey) instead of failing as unsupported.
+#[test]
+fn monochrome_dng_opens() {
+ let (w, h) = (40, 24);
+ let data: Vec<u16> = (0..w * h).map(|i| (i % w * 1600) as u16).collect();
+ let r = import("S261009_90_67.dng", &DngSpec::monochrome(w, h, data).build()).unwrap();
+ let d = &r.document;
+ assert_eq!((d.size.width, d.size.height, d.mode, d.depth), (40, 24, ColorMode::Rgb, SampleType::U16));
+ assert!(r.warnings.iter().all(|w| !w.contains("colour matrix") && !w.contains("preview")), "{:?}", r.warnings);
+}
+
#[test]
fn cr2_opens() {
let (w, h) = (48, 16);
diff --git a/crates/raw/README.md b/crates/raw/README.md
index 7fd1152fb..7bcfdcfe5 100644
--- a/crates/raw/README.md
+++ b/crates/raw/README.md
@@ -63,7 +63,7 @@ camera colour tables were copied.
| Format | Status |
|---|---|
-| DNG | Uncompressed (8–16 bit, packed or not), Deflate (compression 8, predictors 1 and 2), lossless JPEG and JPEG XL (DNG 1.7, e.g. Samsung Expert RAW; decoded by `jxl-oxide`; not in wasm32 builds, where it is `Unsupported`); strips and tiles; CFA (Bayer) and LinearRaw; LinearizationTable, BlackLevel (+ repeat, DeltaH/V), WhiteLevel, ActiveArea, DefaultCrop, ColorMatrix1/2, CameraCalibration, ForwardMatrix, AnalogBalance, AsShotNeutral / AsShotWhiteXY, BaselineExposure, Orientation, OpcodeList2 GainMap (lens shading) |
+| DNG | Uncompressed (8–16 bit, packed or not), Deflate (compression 8, predictors 1 and 2), lossless JPEG and JPEG XL (DNG 1.7, e.g. Samsung Expert RAW; decoded by `jxl-oxide`; not in wasm32 builds, where it is `Unsupported`); strips and tiles; CFA (Bayer) and LinearRaw (three-sample colour, or one-sample monochrome such as Leica Monochrom and film-scanner DNGs, developed as neutral grey with no white balance or colour matrix); LinearizationTable, BlackLevel (+ repeat, DeltaH/V), WhiteLevel, ActiveArea, DefaultCrop, ColorMatrix1/2, CameraCalibration, ForwardMatrix, AnalogBalance, AsShotNeutral / AsShotWhiteXY, BaselineExposure, Orientation, OpcodeList2 GainMap (lens shading) |
| DNG (lossy JPEG, floating point; opcodes other than GainMap; ProfileGainTableMap) | Unsupported / not applied (reported) |
| CR2 | Lossless JPEG with slices, borders and as-shot white balance from the maker note, black measured on the masked border. CR2 has no CFA tag and the row phase varies by model, so it is measured from the data (the green diagonal), with a Canon model-ID table as the fallback (see `src/cr2.rs`) |
| CR2 sRAW / mRAW | Unsupported |
diff --git a/crates/raw/src/develop.rs b/crates/raw/src/develop.rs
index 3c562dc28..8b69cc291 100644
--- a/crates/raw/src/develop.rs
+++ b/crates/raw/src/develop.rs
@@ -159,6 +159,10 @@ fn normalize(n: [f64; 3]) -> Option<[f64; 3]> {
/// The camera-space neutral (max component 1) for `opts.white_balance`, as
/// [`develop_sensor`] uses it (the same white balance [`crate::fit_look`] balances with).
pub(crate) fn resolve_neutral(s: &Sensor, opts: &DevelopOptions, sc: &Scale, warnings: &mut Vec<String>) -> Result<[f64; 3]> {
+ // Monochrome data has no colour to balance.
+ if s.is_monochrome() {
+ return Ok([1.0; 3]);
+ }
// White balance: camera-space neutral, max component 1.
let as_shot = s
.color
@@ -202,8 +206,10 @@ pub fn develop_sensor(s: &Sensor, opts: &DevelopOptions) -> Result<Developed> {
// Balanced camera → XYZ D50: a look fitted to the camera's JPEG, the file's calibration,
// or the neutral fallback.
- let look = opts.camera_look.as_ref().filter(|l| l.is_usable());
- if opts.camera_look.is_some() && look.is_none() {
+ // Monochrome data stays neutral grey: no camera look and no colour calibration.
+ let mono = s.is_monochrome();
+ let look = opts.camera_look.as_ref().filter(|l| l.is_usable() && !mono);
+ if opts.camera_look.is_some() && look.is_none() && !mono {
warnings.push("the supplied camera look is not usable (non-finite or singular); ignored".into());
}
let to_xyz: Mat3 = match (look, s.color.balanced_to_xyz_d50(neutral)) {
@@ -213,7 +219,7 @@ pub fn develop_sensor(s: &Sensor, opts: &DevelopOptions) -> Result<Developed> {
}
(None, Some(m)) => m,
(None, None) => {
- if s.format != RawFormat::Dng {
+ if s.format != RawFormat::Dng && !mono {
warnings.push("no colour calibration for this camera; camera colours are treated as sRGB primaries".into());
}
color::srgb_to_xyz_d50()
@@ -223,6 +229,9 @@ pub fn develop_sensor(s: &Sensor, opts: &DevelopOptions) -> Result<Developed> {
let out_m = color::scale(&color::mul(&color::xyz_d50_to_prophoto(), &to_xyz), gain);
let out_m: [[f32; 3]; 3] = out_m.map(|r| r.map(|v| v as f32));
+ // Neutral grey through `out_m`: the gain alone (the matrix maps camera white to ProPhoto
+ // white, up to rounding), so the three output channels stay exactly equal.
+ let grey_gain = gain as f32;
let (w, h) = (c.width, c.height);
let band = par::band_rows(w);
let mut rgb: Vec<f32>;
@@ -304,10 +313,12 @@ pub fn develop_sensor(s: &Sensor, opts: &DevelopOptions) -> Result<Developed> {
let y = c.y + b * band + r;
for i in 0..w {
for k in 0..3 {
- row[i * 3 + k] = (sc.value(c.x + i, y, k) * mult[k]).clamp(0.0, 1.0);
+ // Monochrome: the one sample in all three channels.
+ let sample = k.min(s.samples.saturating_sub(1));
+ row[i * 3 + k] = (sc.value(c.x + i, y, sample) * mult[k]).clamp(0.0, 1.0);
}
}
- for k in 0..3 {
+ for k in 0..s.samples.min(3) {
if let Some(g) = gain_row(s, y, c.x, w, k) {
for (i, g) in g.into_iter().enumerate() {
row[i * 3 + k] = (row[i * 3 + k] * g).clamp(0.0, 1.0);
@@ -329,6 +340,10 @@ pub fn develop_sensor(s: &Sensor, opts: &DevelopOptions) -> Result<Developed> {
let start = b * band * w * 3;
let src = &rgb[start..start + chunk.len()];
for (o, p) in chunk.as_chunks_mut::<3>().0.iter_mut().zip(src.as_chunks::<3>().0) {
+ if mono {
+ *o = [lut.encode(grey_gain * p[0]); 3];
+ continue;
+ }
for k in 0..3 {
o[k] = lut.encode(out_m[k][0] * p[0] + out_m[k][1] * p[1] + out_m[k][2] * p[2]);
}
diff --git a/crates/raw/src/dng.rs b/crates/raw/src/dng.rs
index 0cf3bb75d..5ff9fd14d 100644
--- a/crates/raw/src/dng.rs
+++ b/crates/raw/src/dng.rs
@@ -138,7 +138,9 @@ pub(crate) fn decode(t: &Tiff, limits: &Limits) -> Result<Sensor> {
if is_cfa && samples != 1 {
return Err(RawError::unsupported(format!("CFA data with {samples} samples per pixel")));
}
- if !is_cfa && samples != 3 {
+ // LinearRaw: three colour samples, or one for a monochrome camera or scanner (DNG 1.7,
+ // ColorPlanes 1: Leica Monochrom, VueScan film scans).
+ if !is_cfa && samples != 1 && samples != 3 {
return Err(RawError::unsupported(format!("LinearRaw data with {samples} samples per pixel")));
}
let active = rect_from(t, &raw, plane.width, plane.height);
@@ -242,7 +244,8 @@ pub(crate) fn decode(t: &Tiff, limits: &Limits) -> Result<Sensor> {
}
let color = color_info(t, &ifd0);
- if color.calibrations.is_empty() {
+ // A monochrome image has no colour to calibrate: it develops as neutral grey.
+ if color.calibrations.is_empty() && (is_cfa || samples != 1) {
warnings.push("the DNG has no colour matrix; colours are approximate".to_string());
}
let baseline_exposure = t.tag_floats(&ifd0, tag::BASELINE_EXPOSURE).first().copied().unwrap_or(0.0)
diff --git a/crates/raw/src/sensor.rs b/crates/raw/src/sensor.rs
index 14d4ba7a2..a775586de 100644
--- a/crates/raw/src/sensor.rs
+++ b/crates/raw/src/sensor.rs
@@ -129,7 +129,7 @@ pub struct Sensor {
/// Data width and height in pixels.
pub width: usize,
pub height: usize,
- /// Samples per pixel: 1 for CFA data, 3 for LinearRaw.
+ /// Samples per pixel: 1 for CFA data, 3 for LinearRaw (1 for monochrome LinearRaw).
pub samples: usize,
/// Row-major interleaved samples, `width * height * samples`.
pub data: Vec<u16>,
@@ -160,6 +160,14 @@ pub struct Sensor {
pub warnings: Vec<String>,
}
+impl Sensor {
+ /// `true` for monochrome data (one-sample LinearRaw: monochrome cameras, scanner DNGs), which
+ /// develops to neutral grey with no white balance or colour calibration.
+ pub fn is_monochrome(&self) -> bool {
+ self.samples == 1 && self.cfa.is_none()
+ }
+}
+
/// Raw samples read from one IFD.
pub(crate) struct Plane {
pub width: usize,
diff --git a/crates/raw/src/testgen.rs b/crates/raw/src/testgen.rs
index 1ba316d0e..fdacc1982 100644
--- a/crates/raw/src/testgen.rs
+++ b/crates/raw/src/testgen.rs
@@ -391,8 +391,10 @@ pub enum DngStorage {
pub struct DngSpec {
pub width: usize,
pub height: usize,
- /// 1 (CFA) or 3 (LinearRaw).
+ /// 1 (CFA, or monochrome LinearRaw with `monochrome`) or 3 (LinearRaw).
pub samples: usize,
+ /// With `samples` 1: a monochrome LinearRaw image (no CFA tags) instead of CFA data.
+ pub monochrome: bool,
/// Row-major samples (`width * height * samples`).
pub data: Vec<u16>,
pub bits: u16,
@@ -427,6 +429,8 @@ pub struct DngSpec {
pub orientation: u16,
pub make: String,
pub model: String,
+ /// Extra IFD0 entries, written after the generated ones (e.g. malformed colour tags).
+ pub ifd0_extra: Vec<(u16, Val)>,
}
impl DngSpec {
@@ -436,6 +440,7 @@ impl DngSpec {
width,
height,
samples: 1,
+ monochrome: false,
data,
bits: 16,
cfa: [0, 1, 1, 2],
@@ -461,9 +466,20 @@ impl DngSpec {
profile_gain_table_map: None,
make: "Photocraft".into(),
model: "Synthetic".into(),
+ ifd0_extra: Vec::new(),
}
}
+ /// A monochrome (one-sample LinearRaw) DNG around `data`, as monochrome cameras and film
+ /// scanners write them: no CFA tags and no colour matrices.
+ pub fn monochrome(width: usize, height: usize, data: Vec<u16>) -> Self {
+ DngSpec { monochrome: true, ..Self::cfa(width, height, data) }
+ }
+
+ fn is_cfa(&self) -> bool {
+ self.samples == 1 && !self.monochrome
+ }
+
fn pack(&self, rows: std::ops::Range<usize>) -> Vec<u8> {
let n = self.width * self.samples;
let vals = &self.data[rows.start * n..rows.end * n];
@@ -500,14 +516,14 @@ impl DngSpec {
(256, Val::Long(vec![self.width as u32])),
(257, Val::Long(vec![self.height as u32])),
(258, Val::Short(vec![self.bits; self.samples])),
- (262, Val::Short(vec![if self.samples == 1 { 32803 } else { 34892 }])),
+ (262, Val::Short(vec![if self.is_cfa() { 32803 } else { 34892 }])),
(277, Val::Short(vec![self.samples as u16])),
(284, Val::Short(vec![1])),
(50717, Val::Long(vec![self.white; self.samples])),
(50713, Val::Short(vec![self.black_repeat.0, self.black_repeat.1])),
(50714, Val::Long(self.black.clone())),
];
- if self.samples == 1 {
+ if self.is_cfa() {
raw.push((33421, Val::Short(vec![2, 2])));
raw.push((33422, Val::Byte(self.cfa.to_vec())));
raw.push((50710, Val::Byte(vec![0, 1, 2])));
@@ -725,6 +741,7 @@ impl DngSpec {
if let Some(m) = &self.profile_gain_table_map {
ifd0.push((52525, Val::Undefined(m.clone())));
}
+ ifd0.extend(self.ifd0_extra.iter().cloned());
let i0 = t.ifd(ifd0);
t.chain = vec![i0];
t.build()
diff --git a/crates/raw/tests/dng.rs b/crates/raw/tests/dng.rs
index 9b19d31b4..9dfab5dfd 100644
--- a/crates/raw/tests/dng.rs
+++ b/crates/raw/tests/dng.rs
@@ -1,7 +1,7 @@
//! Synthetic DNG files: every storage layout decodes to the exact sensor
//! samples, and development reproduces known colours.
-use photocraft_raw::testgen::{DngSpec, DngStorage, mosaic, scene};
+use photocraft_raw::testgen::{DngSpec, DngStorage, Val, mosaic, scene};
use photocraft_raw::*;
fn sensor(bytes: &[u8]) -> Sensor {
@@ -71,6 +71,132 @@ fn linear_raw_decodes_and_develops() {
assert!(d.info.cfa.is_none());
}
+/// A horizontal ramp from `lo` to `hi` (inclusive), the same in every row.
+fn ramp(w: usize, h: usize, lo: u16, hi: u16) -> Vec<u16> {
+ (0..w * h).map(|i| lo + ((u32::from(hi - lo) * (i % w) as u32) / (w as u32 - 1)) as u16).collect()
+}
+
+/// Developed RGB of a monochrome DNG: every pixel has R = G = B, and the first row's grey level
+/// rises with the ramp. Returns the first row's grey levels.
+fn assert_neutral_ramp(d: &Developed, name: &str) -> Vec<u16> {
+ let px = d.rgb.as_chunks::<3>().0;
+ assert!(px.iter().all(|p| p[0] == p[1] && p[1] == p[2]), "{name}: channels differ");
+ let row: Vec<u16> = px[..d.width as usize].iter().map(|p| p[0]).collect();
+ assert!(row.windows(2).all(|w| w[1] >= w[0]), "{name}: not monotonic: {row:?}");
+ assert!(row[row.len() - 1] > row[0] + 10_000, "{name}: flat: {row:?}");
+ row
+}
+
+/// #3497: a one-sample LinearRaw DNG (VueScan film scans, Leica Monochrom) was rejected as
+/// "LinearRaw data with 1 samples per pixel". It opens as neutral grey from every storage.
+#[test]
+fn monochrome_linear_raw_develops_to_neutral_grey() {
+ let (w, h) = (37, 23);
+ let cases: Vec<(&str, u16, DngStorage)> = vec![
+ ("16-bit strips", 16, DngStorage::Strips { rows: 5 }),
+ ("12-bit packed", 12, DngStorage::Strips { rows: 4 }),
+ ("8-bit", 8, DngStorage::Strips { rows: 23 }),
+ ("LJ92 strips", 14, DngStorage::Lj92Strips { rows: 6 }),
+ ("LJ92 tiles", 16, DngStorage::Lj92Tiles { width: 16, height: 8 }),
+ ("deflate predictor 2", 16, DngStorage::DeflateStrips { rows: 7, predictor: 2 }),
+ // One whole tile: a partial edge tile is a separate decoder limitation.
+ ("lossy JPEG tile", 16, DngStorage::LossyJpegTiles { width: 37, height: 23 }),
+ ];
+ for (name, bits, storage) in cases {
+ let white = ((1u32 << bits) - 1) as u16;
+ let data = ramp(w, h, 0, white);
+ let mut spec = DngSpec::monochrome(w, h, data.clone());
+ spec.bits = bits;
+ spec.white = u32::from(white);
+ spec.storage = storage;
+ let lossy = matches!(storage, DngStorage::LossyJpegTiles { .. });
+ let s = sensor(&spec.build());
+ assert_eq!((s.samples, s.cfa.is_none(), s.is_monochrome()), (1, true, true), "{name}");
+ if !lossy {
+ assert_eq!(s.data, data, "{name}");
+ }
+ let d = develop_sensor(&s, &DevelopOptions::default()).unwrap_or_else(|e| panic!("{name}: {e}"));
+ assert_eq!((d.width, d.height, d.rgb.len()), (37, 23, 37 * 23 * 3), "{name}");
+ assert!(d.info.cfa.is_none() && d.info.wb_multipliers == [1.0; 3], "{name}: {:?}", d.info);
+ assert!(d.warnings.iter().all(|w| !w.contains("colour") && !w.contains("white balance")), "{name}: {:?}", d.warnings);
+ let row = assert_neutral_ramp(&d, name);
+ if !lossy {
+ assert_eq!((row[0], row[row.len() - 1]), (0, 65535), "{name}");
+ }
+ }
+}
+
+/// Black and white levels of a monochrome DNG scale its one sample; the white-balance
+/// settings do not tint it.
+#[test]
+fn monochrome_linear_raw_levels_and_white_balance() {
+ let (w, h) = (32, 4);
+ let mut spec = DngSpec::monochrome(w, h, ramp(w, h, 1000, 60000));
+ spec.black = vec![1000];
+ spec.white = 60000;
+ let s = sensor(&spec.build());
+ for wb in [WhiteBalance::AsShot, WhiteBalance::Auto, WhiteBalance::Multipliers([2.0, 1.0, 1.5])] {
+ let d = develop_sensor(&s, &DevelopOptions { white_balance: wb, ..Default::default() }).unwrap();
+ let row = assert_neutral_ramp(&d, &format!("{wb:?}"));
+ assert_eq!((row[0], row[w - 1]), (0, 65535), "{wb:?}");
+ }
+ // Develop exposure still applies.
+ let dark = develop_sensor(&s, &DevelopOptions { exposure: -1.0, ..Default::default() }).unwrap();
+ let row = assert_neutral_ramp(&dark, "exposure -1");
+ assert!(row[w - 1] < 60000, "{row:?}");
+}
+
+/// Colour metadata a monochrome DNG may carry, well-formed or not (a 1×3 ColorMatrix, a
+/// one-value ColorMatrix or AsShotNeutral, BlackLevel counts that fit no repeat), is ignored
+/// or falls back; it never errors or indexes out of bounds.
+#[test]
+fn monochrome_linear_raw_odd_metadata_develops() {
+ let (w, h) = (16, 6);
+ let base = DngSpec::monochrome(w, h, ramp(w, h, 100, 4000));
+ let rat = |v: &[f64]| Val::SRational(v.iter().map(|x| ((x * 10000.0) as i32, 10000)).collect());
+ let variants: Vec<(&str, DngSpec)> = vec![
+ ("1x3 ColorMatrix", DngSpec { ifd0_extra: vec![(50721, rat(&[0.3, 0.6, 0.1])), (50778, Val::Short(vec![21]))], ..base.clone() }),
+ ("one-value ColorMatrix", DngSpec { ifd0_extra: vec![(50721, rat(&[1.0]))], ..base.clone() }),
+ ("one-value AsShotNeutral", DngSpec { ifd0_extra: vec![(50728, Val::Rational(vec![(1, 1)]))], ..base.clone() }),
+ ("two BlackLevels", DngSpec { black: vec![100, 120], ..base.clone() }),
+ ("three BlackLevels", DngSpec { black: vec![100, 110, 120], ..base.clone() }),
+ ("2x2 BlackLevel repeat", DngSpec { black: vec![100, 101, 102, 103], black_repeat: (2, 2), ..base.clone() }),
+ ("2x2 repeat, one value", DngSpec { black: vec![100], black_repeat: (2, 2), ..base.clone() }),
+ ("3x3 ColorMatrix", DngSpec { color_matrix1: Some((21, [3.2, -1.5, -0.5, -1.0, 1.9, 0.04, 0.06, -0.2, 1.06])), ..base.clone() }),
+ ("3-value AsShotNeutral", DngSpec { as_shot_neutral: Some([0.5, 1.0, 0.7]), ..base.clone() }),
+ ];
+ for (name, spec) in variants {
+ let d = develop(&spec.build(), &DevelopOptions::default()).unwrap_or_else(|e| panic!("{name}: {e}"));
+ assert_neutral_ramp(&d, name);
+ }
+}
+
+/// Broken monochrome DNGs fail with an error, not a panic.
+#[test]
+fn broken_monochrome_linear_raw_errors() {
+ let (w, h) = (16, 6);
+ let spec = DngSpec::monochrome(w, h, ramp(w, h, 100, 4000));
+ // Every truncation decodes to an error or develops; none panics, and a cut into the
+ // strip data is an error.
+ let b = spec.build();
+ for n in 0..b.len() {
+ if let Ok(s) = decode(&b[..n], &Limits::default()) {
+ let _ = develop_sensor(&s, &DevelopOptions::default());
+ }
+ }
+ let first: Vec<u8> = spec.data[..4].iter().flat_map(|v| v.to_le_bytes()).collect();
+ let strip = b.windows(first.len()).position(|win| win == first.as_slice()).expect("strip data");
+ assert!(decode(&b[..strip + w], &Limits::default()).is_err(), "truncated strip");
+ // Two samples per pixel is no LinearRaw layout.
+ let two = DngSpec { samples: 2, data: ramp(2 * w, h, 100, 4000), ..spec.clone() };
+ let err = decode(&two.build(), &Limits::default()).unwrap_err().to_string();
+ assert!(err.contains("2 samples per pixel"), "{err}");
+ // A monochrome sensor holding less data than its size.
+ let mut s = sensor(&spec.build());
+ s.data.truncate(10);
+ assert!(develop_sensor(&s, &DevelopOptions::default()).is_err());
+}
+
/// `spec`'s file with its Orientation entry (a SHORT `from`) rewritten as a LONG `to`.
fn with_long_orientation(spec: &DngSpec, from: u16, to: u32) -> Vec<u8> {
let mut b = spec.build();
diff --git a/crates/raw/tests/hostile.rs b/crates/raw/tests/hostile.rs
index 53e54015d..dabe9ffe9 100644
--- a/crates/raw/tests/hostile.rs
+++ b/crates/raw/tests/hostile.rs
@@ -39,6 +39,16 @@ fn samples() -> Vec<Vec<u8>> {
j.jxl_segments = vec![jxl_rgb16(&rgb, w, h)];
j.profile_gain_table_map = Some(vec![0; 32]);
out.push(j.build());
+ // Monochrome LinearRaw (one sample, no CFA, no colour matrix), as film scanners write it (#3497).
+ let grey: Vec<u16> = scene(w, h).iter().map(|p| 64 + (p[1] * 3900.0) as u16).collect();
+ let mut m = DngSpec::monochrome(w, h, grey);
+ m.bits = 12;
+ m.white = 4000;
+ m.black = vec![64];
+ m.storage = DngStorage::Lj92Tiles { width: 16, height: 8 };
+ out.push(m.build());
+ m.storage = DngStorage::DeflateStrips { rows: 5, predictor: 2 };
+ out.push(m.build());
let mut data = vec![600u16; 40 * 10];
for (i, v) in data.iter_mut().enumerate() {
*v = 600 + (i as u16 * 7) % 3000;