diff --git a/Cargo.toml b/Cargo.toml index c873aec..b922ce7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,14 @@ [package] name = "tiff" version = "0.1.0" -authors = [] +authors = [ + "ccgn", + "bvssvni ", + "nwin", + "TyOverby ", + "HeroicKatora", + "Calum", + "CensoredUsername "] [dependencies] byteorder = "1.2.*" diff --git a/src/decoder/ifd.rs b/src/decoder/ifd.rs index ceb9431..1cf5a3c 100644 --- a/src/decoder/ifd.rs +++ b/src/decoder/ifd.rs @@ -148,7 +148,7 @@ impl Entry { ) } - pub fn val(&self, decoder: &mut super::TIFFDecoder) + pub fn val(&self, decoder: &mut super::Decoder) -> TiffResult { let bo = decoder.byte_order(); match (self.type_, self.count) { diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 2e1386b..2d66a30 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -28,7 +28,7 @@ pub enum DecodingResult { } // A buffer for image decoding -pub enum DecodingBuffer<'a> { +enum DecodingBuffer<'a> { /// A slice of unsigned bytes U8(&'a mut [u8]), /// A slice of unsigned words @@ -82,7 +82,7 @@ enum Predictor { /// /// Currently does not support decoding of interlaced images #[derive(Debug)] -pub struct TIFFDecoder where R: Read + Seek { +pub struct Decoder where R: Read + Seek { reader: SmartReader, byte_order: ByteOrder, next_ifd: Option, @@ -147,10 +147,10 @@ fn rev_hpredict(image: DecodingResult, size: (u32, u32), color_type: ColorType) }) } -impl TIFFDecoder { +impl Decoder { /// Create a new decoder that decodes from the stream ```r``` - pub fn new(r: R) -> TiffResult> { - TIFFDecoder { + pub fn new(r: R) -> TiffResult> { + Decoder { reader: SmartReader::wrap(r, ByteOrder::LittleEndian), byte_order: ByteOrder::LittleEndian, next_ifd: None, @@ -164,11 +164,11 @@ impl TIFFDecoder { }.init() } - fn dimensions(&mut self) -> TiffResult<(u32, u32)> { + pub fn dimensions(&mut self) -> TiffResult<(u32, u32)> { Ok((self.width, self.height)) } - fn colortype(&mut self) -> TiffResult { + pub fn colortype(&mut self) -> TiffResult { match self.photometric_interpretation { // TODO: catch also [ 8, 8, 8, _] this does not work due to a bug in rust atm PhotometricInterpretation::RGB if self.bits_per_sample == [8, 8, 8, 8] => Ok(ColorType::RGBA(8)), @@ -209,7 +209,7 @@ impl TIFFDecoder { } /// Initializes the decoder. - pub fn init(mut self) -> TiffResult> { + pub fn init(mut self) -> TiffResult> { try!(self.read_header()); self.next_image() } @@ -217,7 +217,7 @@ impl TIFFDecoder { /// Reads in the next image. /// If there is no further image in the TIFF file a format error is returned. /// To determine whether there are more images call `TIFFDecoder::more_images` instead. - pub fn next_image(mut self) -> TiffResult> { + pub fn next_image(mut self) -> TiffResult> { self.ifd = Some(try!(self.read_ifd())); self.width = try!(self.get_tag_u32(ifd::Tag::ImageWidth)); self.height = try!(self.get_tag_u32(ifd::Tag::ImageLength)); diff --git a/src/error.rs b/src/error.rs index 330c985..bc6bf70 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use std::error::Error; use std::fmt; use std::io; -/// An enumeration of Tiff errors +/// Tiff error kinds. #[derive(Debug)] pub enum TiffError { /// The Image is not formatted properly diff --git a/src/lib.rs b/src/lib.rs index f9547dc..5ecdafb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,9 +11,7 @@ extern crate lzw; extern crate num_traits; #[macro_use] extern crate enum_primitive; -pub use self::decoder::TIFFDecoder; - -mod decoder; +pub mod decoder; mod error; pub use self::error::{TiffError, TiffResult};