Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ publish = false
include = ["src", "tests/reference.rs"]

[features]
default = ["pcx"]
default = ["pcx", "wbmp", "otb"]
pcx = ["dep:pcx"]
wbmp = ["dep:wbmp"]
otb = []

[dependencies]
image = { version = "0.25.5", default-features = false }
pcx = { version = "0.2.4", optional = true }
wbmp = { version = "0.1.2", optional = true }

[dev-dependencies]
image = { version = "0.25.5", default-features = false, features = ["png"] }
walkdir = "2.5.0"

[patch.crates-io]
image = { git = "https://github.com/fintelia/image", branch = "decoding-hooks" }
#image = { git = "https://github.com/fintelia/image", branch = "decoding-hooks" }
image = { git = "https://github.com/reshane/image", branch = "decoding-hooks" }
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Decoding support for additional image formats beyond those provided by the [`ima
| Extension | File Format Description |
| --------- | -------------------- |
| PCX | [Wikipedia](https://en.wikipedia.org/wiki/PCX#PCX_file_format) |
| WBMP | [Wikipedia](https://en.wikipedia.org/wiki/Wireless_Application_Protocol_Bitmap_Format) |
| OTB | [Wikipedia](https://en.wikipedia.org/wiki/OTA_bitmap) |

## New Formats

Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,26 @@
#[cfg(feature = "pcx")]
pub mod pcx;

#[cfg(feature = "wbmp")]
pub mod wbmp;

#[cfg(feature = "otb")]
pub mod otb;

/// Register all enabled extra formats with the image crate.
pub fn register() {
image::hooks::register_decoding_hook(
image::ImageFormat::Pcx,
Box::new(|r| Ok(Box::new(pcx::PCXDecoder::new(r)?))),
);
#[cfg(feature = "wbmp")]
image::hooks::register_decoding_hook(
image::ImageFormat::Wbmp,
Box::new(|r| Ok(Box::new(wbmp::WbmpDecoder::new(r)?))),
);
#[cfg(feature = "otb")]
image::hooks::register_decoding_hook(
image::ImageFormat::Otb,
Box::new(|r| Ok(Box::new(otb::OtbDecoder::new(r)?))),
);
}
Loading