Make an explicit 'fax' feature
This commit is contained in:
1 parent
4a68feab5a
commit
9f1de91880
2 files changed
+10
-8
No files matched your search
+3
-1
@@ -20,7 +20,8 @@ exclude = ["tests/images/*", "tests/fuzz_images/*"]
|
||||
half = { version = "2.4.1" }
|
||||
quick-error = "2.0.1"
|
||||
|
||||
fax = { version = "0.2.4", optional = true }
|
||||
# Rename to avoid confusion with the feature name.
|
||||
fax34 = { package = "fax", version = "0.2.4", optional = true }
|
||||
flate2 = { version = "1.0.20", optional = true }
|
||||
weezl = { version = "0.1.10", optional = true }
|
||||
zstd = { version = "0.13", optional = true }
|
||||
@@ -36,6 +37,7 @@ default = ["deflate", "jpeg", "lzw"]
|
||||
|
||||
# Compression algorithms
|
||||
deflate = ["dep:flate2"]
|
||||
fax = ["dep:fax34"]
|
||||
jpeg = ["dep:zune-jpeg"]
|
||||
lzw = ["dep:weezl"]
|
||||
zstd = ["dep:zstd"]
|
||||
|
||||
@@ -277,7 +277,7 @@ impl<R: Read> Read for PackBitsReader<R> {
|
||||
|
||||
#[cfg(feature = "fax")]
|
||||
pub struct Group4Reader<R: Read> {
|
||||
decoder: fax::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>,
|
||||
decoder: fax34::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>,
|
||||
line_buf: io::Cursor<Vec<u8>>,
|
||||
height: u16,
|
||||
width: u16,
|
||||
@@ -295,7 +295,7 @@ impl<R: Read> Group4Reader<R> {
|
||||
let height = u16::try_from(dimensions.1)?;
|
||||
|
||||
Ok(Self {
|
||||
decoder: fax::decoder::Group4Decoder::new(
|
||||
decoder: fax34::decoder::Group4Decoder::new(
|
||||
io::BufReader::new(reader.take(compressed_length)).bytes(),
|
||||
width,
|
||||
)?,
|
||||
@@ -317,12 +317,12 @@ impl<R: Read> Read for Group4Reader<R> {
|
||||
let next = self.decoder.advance().map_err(std::io::Error::other)?;
|
||||
|
||||
match next {
|
||||
fax::decoder::DecodeStatus::End => (),
|
||||
fax::decoder::DecodeStatus::Incomplete => {
|
||||
fax34::decoder::DecodeStatus::End => (),
|
||||
fax34::decoder::DecodeStatus::Incomplete => {
|
||||
self.y += 1;
|
||||
|
||||
// We known `transitions` yields exactly `self.width` items (per doc).
|
||||
let transitions = fax::decoder::pels(self.decoder.transition(), self.width);
|
||||
let transitions = fax34::decoder::pels(self.decoder.transition(), self.width);
|
||||
|
||||
let buffer = self.line_buf.get_mut();
|
||||
buffer.resize(usize::from(self.width).div_ceil(8), 0u8);
|
||||
@@ -330,8 +330,8 @@ impl<R: Read> Read for Group4Reader<R> {
|
||||
let target = &mut buffer[..];
|
||||
|
||||
let mut bits = transitions.map(|c| match c {
|
||||
fax::Color::Black => true,
|
||||
fax::Color::White => false,
|
||||
fax34::Color::Black => true,
|
||||
fax34::Color::White => false,
|
||||
});
|
||||
|
||||
// Assemble bits in MSB as per our library representation for buffer.
|
||||
|
||||
Reference in new issue
Block a user