diff --git a/Cargo.toml b/Cargo.toml index 6d51c6b..67b6b1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,6 @@ authors = [ [dependencies] byteorder = "1.2.*" -enum_primitive = "0.1.*" lzw = "0.10.*" +num-derive = "0.2.*" num-traits = "0.2.*" diff --git a/src/decoder/ifd.rs b/src/decoder/ifd.rs index 1cf5a3c..8ac9cab 100644 --- a/src/decoder/ifd.rs +++ b/src/decoder/ifd.rs @@ -75,8 +75,7 @@ tags!{ Predictor 317; } -enum_from_primitive! { -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, FromPrimitive)] pub enum Type { BYTE = 1, ASCII = 2, @@ -84,7 +83,6 @@ pub enum Type { LONG = 4, RATIONAL = 5, } -} #[allow(unused_qualifications)] diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 2d66a30..3f512d5 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -35,8 +35,7 @@ enum DecodingBuffer<'a> { U16(&'a mut [u16]) } -enum_from_primitive! { -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, FromPrimitive)] enum PhotometricInterpretation { WhiteIsZero = 0, BlackIsZero = 1, @@ -47,10 +46,8 @@ enum PhotometricInterpretation { YCbCr = 6, CIELab = 8, } -} -enum_from_primitive! { -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, FromPrimitive)] enum CompressionMethod { None = 1, Huffman = 2, @@ -60,23 +57,18 @@ enum CompressionMethod { JPEG = 6, PackBits = 0x8005 } -} -enum_from_primitive! { -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, FromPrimitive)] enum PlanarConfiguration { Chunky = 1, Planar = 2 } -} -enum_from_primitive! { -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, FromPrimitive)] enum Predictor { None = 1, Horizontal = 2 } -} /// The representation of a TIFF decoder /// @@ -179,7 +171,7 @@ impl Decoder { if self.bits_per_sample.len() == 1 => Ok(ColorType::Gray(self.bits_per_sample[0])), _ => Err(TiffError::UnsupportedError(format!( - "{:?} with {:?} bits per sample is unsupported", self.bits_per_sample, self.photometric_interpretation + "{:?} with {:?} bits per sample is unsupported", self.photometric_interpretation, self.bits_per_sample ))) // TODO: this is bad we should not fail at this point} } } diff --git a/src/lib.rs b/src/lib.rs index 5ecdafb..2f74a6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,8 +8,8 @@ extern crate byteorder; extern crate lzw; +#[macro_use] extern crate num_derive; extern crate num_traits; -#[macro_use] extern crate enum_primitive; pub mod decoder; mod error; diff --git a/tests/decode_images.rs b/tests/decode_images.rs index 4da271a..f8e3a25 100644 --- a/tests/decode_images.rs +++ b/tests/decode_images.rs @@ -54,4 +54,4 @@ fn test_rgb_u16() //assert_eq!(decoder.colortype().unwrap(), ColorType::GrayA(8)); //let img_res = decoder.read_image(); //assert!(img_res.is_ok()); -} +//}