Vendor rawler 0.7.2 unmodified

The crate as crates.io publishes it, minus .cargo-ok, its Cargo.lock and
data/testdata (13 MB of sample files only its own tests read). Not yet
routed through [patch.crates-io]; the next commit is the patch.
This commit is contained in:
2026-09-27 17:33:19 -04:00
parent 0d9feb0556
commit 77a1925bac
940 changed files with 66954 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// The debug version
#[cfg(feature = "inspector")]
#[macro_export]
macro_rules! inspector {
($( $args:expr ),*) => { println!( $( $args ),* ); }
}
// Non-debug version
#[cfg(not(feature = "inspector"))]
#[macro_export]
macro_rules! inspector {
($( $args:expr ),*) => {};
}
+41
View File
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: LGPL-2.1
// Copyright 2021 Daniel Vogelbacher <daniel@chaospixel.com>
use std::{
fs::File,
io::{BufWriter, Write},
};
use byteorder::{LittleEndian, WriteBytesExt};
use image::{ImageBuffer, ImageFormat, Luma, Rgb};
pub(crate) mod inspector;
pub fn dump_image_u16(data: &[u16], width: usize, height: usize, path: impl AsRef<str>) {
let img = ImageBuffer::<Luma<u16>, Vec<u16>>::from_vec(width as u32, height as u32, data.to_vec()).unwrap();
img.save_with_format(path.as_ref(), ImageFormat::Tiff).unwrap();
}
pub fn dump_image_u16_rgb(data: &[u16], width: usize, height: usize, path: impl AsRef<str>) {
let img = ImageBuffer::<Rgb<u16>, Vec<u16>>::from_vec(width as u32, height as u32, data.to_vec()).unwrap();
img.save_with_format(path.as_ref(), ImageFormat::Tiff).unwrap();
}
pub fn dump_buf<T>(path: &str, buf: T)
where
T: AsRef<[u8]>,
{
let mut f = BufWriter::new(File::create(path).expect("Unable to create file"));
f.write_all(buf.as_ref()).expect("Failed to dump buffer to file");
f.flush().expect("Failed to flush file");
}
pub fn dump_buf_u16<T>(path: &str, buf: T)
where
T: AsRef<[u16]>,
{
let mut f = BufWriter::new(File::create(path).expect("Unable to create file"));
for v in buf.as_ref().iter() {
f.write_u16::<LittleEndian>(*v).expect("Failed to dump buffer to file");
}
f.flush().expect("Failed to flush file");
}