Skip to content

Commit bf20247

Browse files
reshanefintelia
andauthored
Add Wbmp & Otb Encoding / Decoding (#2)
Co-authored-by: Jonathan Behrens <[email protected]>
1 parent 0b74489 commit bf20247

File tree

13 files changed

+675
-4
lines changed

13 files changed

+675
-4
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,25 @@ publish = false
88
include = ["src", "tests/reference.rs"]
99

1010
[features]
11-
default = ["ora", "pcx", "xbm", "xpm"]
11+
default = ["ora", "otb", "pcx", "xbm", "xpm", "wbmp"]
1212

1313
# Each feature below is the file extention for the file format decoder it
1414
# enables.
1515
ora = ["image/png", "dep:zip", "dep:ouroboros"]
16+
otb = []
1617
pcx = ["dep:pcx"]
18+
wbmp = ["dep:wbmp"]
1719
xbm = []
1820
xpm = []
1921

22+
2023
[dependencies]
2124
image = { version = "0.25.8", default-features = false }
2225

2326
# Optional dependencies
2427
ouroboros = { version = "0.18.5", optional = true }
2528
pcx = { version = "0.2.4", optional = true }
29+
wbmp = { version = "0.1.2", optional = true }
2630
zip = { version = "5.1.1", default-features = false, features = ["deflate"], optional = true }
2731

2832
[dev-dependencies]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Decoding support for additional image formats beyond those provided by the
99
| --------- | -------------------- |
1010
| ORA | [Specification](https://www.openraster.org) |
1111
| PCX | [Wikipedia](https://en.wikipedia.org/wiki/PCX#PCX_file_format) |
12+
| WBMP | [Specification](https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf) |
13+
| OTB | [Specification](https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf) |
1214
| XBM | [Specification](https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html#Manipulating_Bitmaps) |
1315
| XPM | [Specification](https://www.x.org/docs/XPM/xpm.pdf) |
1416

src/lib.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,24 @@
1717
1818
#![forbid(unsafe_code)]
1919

20+
#[cfg(feature = "ora")]
21+
pub mod ora;
22+
23+
#[cfg(feature = "otb")]
24+
pub mod otb;
25+
2026
#[cfg(feature = "pcx")]
2127
pub mod pcx;
2228

29+
#[cfg(feature = "wbmp")]
30+
pub mod wbmp;
31+
2332
#[cfg(feature = "xbm")]
2433
pub mod xbm;
2534

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

29-
#[cfg(feature = "ora")]
30-
pub mod ora;
31-
3238
#[allow(unused_imports)]
3339
use image::hooks::{register_decoding_hook, register_format_detection_hook};
3440

@@ -50,6 +56,12 @@ pub fn register() {
5056
}),
5157
);
5258

59+
#[cfg(feature = "otb")]
60+
image::hooks::register_decoding_hook(
61+
"otb".into(),
62+
Box::new(|r| Ok(Box::new(otb::OtbDecoder::new(r)?))),
63+
);
64+
5365
#[cfg(feature = "pcx")]
5466
if register_decoding_hook(
5567
"pcx".into(),
@@ -58,6 +70,12 @@ pub fn register() {
5870
register_format_detection_hook("pcx".into(), &[0x0a, 0x0], Some(b"\xFF\xF8"));
5971
}
6072

73+
#[cfg(feature = "wbmp")]
74+
image::hooks::register_decoding_hook(
75+
"wbmp".into(),
76+
Box::new(|r| Ok(Box::new(wbmp::WbmpDecoder::new(r)?))),
77+
);
78+
6179
#[cfg(feature = "xbm")]
6280
{
6381
register_decoding_hook(

0 commit comments

Comments
 (0)