Skip to content
Merged
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
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ publish = false
include = ["src", "tests/reference.rs"]

[features]
default = ["ora", "pcx", "xbm", "xpm"]
default = ["ora", "otb", "pcx", "xbm", "xpm", "wbmp"]

# Each feature below is the file extention for the file format decoder it
# enables.
ora = ["image/png", "dep:zip", "dep:ouroboros"]
otb = []
pcx = ["dep:pcx"]
wbmp = ["dep:wbmp"]
xbm = []
xpm = []


[dependencies]
image = { version = "0.25.8", default-features = false }

# Optional dependencies
ouroboros = { version = "0.18.5", optional = true }
pcx = { version = "0.2.4", optional = true }
wbmp = { version = "0.1.2", optional = true }
zip = { version = "5.1.1", default-features = false, features = ["deflate"], optional = true }

[dev-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Decoding support for additional image formats beyond those provided by the
| --------- | -------------------- |
| ORA | [Specification](https://www.openraster.org) |
| PCX | [Wikipedia](https://en.wikipedia.org/wiki/PCX#PCX_file_format) |
| WBMP | [Specification](https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf) |
| OTB | [Specification](https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf) |
| XBM | [Specification](https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html#Manipulating_Bitmaps) |
| XPM | [Specification](https://www.x.org/docs/XPM/xpm.pdf) |

Expand Down
24 changes: 21 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@

#![forbid(unsafe_code)]

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

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

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

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

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

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

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

#[allow(unused_imports)]
use image::hooks::{register_decoding_hook, register_format_detection_hook};

Expand All @@ -50,6 +56,12 @@ pub fn register() {
}),
);

#[cfg(feature = "otb")]
image::hooks::register_decoding_hook(
"otb".into(),
Box::new(|r| Ok(Box::new(otb::OtbDecoder::new(r)?))),
);

#[cfg(feature = "pcx")]
if register_decoding_hook(
"pcx".into(),
Expand All @@ -58,6 +70,12 @@ pub fn register() {
register_format_detection_hook("pcx".into(), &[0x0a, 0x0], Some(b"\xFF\xF8"));
}

#[cfg(feature = "wbmp")]
image::hooks::register_decoding_hook(
"wbmp".into(),
Box::new(|r| Ok(Box::new(wbmp::WbmpDecoder::new(r)?))),
);

#[cfg(feature = "xbm")]
{
register_decoding_hook(
Expand Down
Loading
Loading