Skip to content

Commit 9f1de91

Browse files
committed
Make an explicit 'fax' feature
1 parent 4a68fea commit 9f1de91

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ exclude = ["tests/images/*", "tests/fuzz_images/*"]
2020
half = { version = "2.4.1" }
2121
quick-error = "2.0.1"
2222

23-
fax = { version = "0.2.4", optional = true }
23+
# Rename to avoid confusion with the feature name.
24+
fax34 = { package = "fax", version = "0.2.4", optional = true }
2425
flate2 = { version = "1.0.20", optional = true }
2526
weezl = { version = "0.1.10", optional = true }
2627
zstd = { version = "0.13", optional = true }
@@ -36,6 +37,7 @@ default = ["deflate", "jpeg", "lzw"]
3637

3738
# Compression algorithms
3839
deflate = ["dep:flate2"]
40+
fax = ["dep:fax34"]
3941
jpeg = ["dep:zune-jpeg"]
4042
lzw = ["dep:weezl"]
4143
zstd = ["dep:zstd"]

src/decoder/stream.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl<R: Read> Read for PackBitsReader<R> {
277277

278278
#[cfg(feature = "fax")]
279279
pub struct Group4Reader<R: Read> {
280-
decoder: fax::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>,
280+
decoder: fax34::decoder::Group4Decoder<io::Bytes<io::BufReader<io::Take<R>>>>,
281281
line_buf: io::Cursor<Vec<u8>>,
282282
height: u16,
283283
width: u16,
@@ -295,7 +295,7 @@ impl<R: Read> Group4Reader<R> {
295295
let height = u16::try_from(dimensions.1)?;
296296

297297
Ok(Self {
298-
decoder: fax::decoder::Group4Decoder::new(
298+
decoder: fax34::decoder::Group4Decoder::new(
299299
io::BufReader::new(reader.take(compressed_length)).bytes(),
300300
width,
301301
)?,
@@ -317,21 +317,21 @@ impl<R: Read> Read for Group4Reader<R> {
317317
let next = self.decoder.advance().map_err(std::io::Error::other)?;
318318

319319
match next {
320-
fax::decoder::DecodeStatus::End => (),
321-
fax::decoder::DecodeStatus::Incomplete => {
320+
fax34::decoder::DecodeStatus::End => (),
321+
fax34::decoder::DecodeStatus::Incomplete => {
322322
self.y += 1;
323323

324324
// We known `transitions` yields exactly `self.width` items (per doc).
325-
let transitions = fax::decoder::pels(self.decoder.transition(), self.width);
325+
let transitions = fax34::decoder::pels(self.decoder.transition(), self.width);
326326

327327
let buffer = self.line_buf.get_mut();
328328
buffer.resize(usize::from(self.width).div_ceil(8), 0u8);
329329

330330
let target = &mut buffer[..];
331331

332332
let mut bits = transitions.map(|c| match c {
333-
fax::Color::Black => true,
334-
fax::Color::White => false,
333+
fax34::Color::Black => true,
334+
fax34::Color::White => false,
335335
});
336336

337337
// Assemble bits in MSB as per our library representation for buffer.

0 commit comments

Comments
 (0)