Cleanups, visibility fixes, add authors

This commit is contained in:
R.Chavignat committed 2018-06-17 15:45:00 +02:00
1 parent 71f1342236
commit 112492261f
5 files changed
+20 -15

No files matched your search

+8 -1
View File
@@ -1,7 +1,14 @@
[package]
name = "tiff"
version = "0.1.0"
authors = []
authors = [
"ccgn",
"bvssvni <bvssvni@gmail.com>",
"nwin",
"TyOverby <ty@pre-alpha.com>",
"HeroicKatora",
"Calum",
"CensoredUsername <cens.username@gmail.com>"]
[dependencies]
byteorder = "1.2.*"
+1 -1
View File
@@ -148,7 +148,7 @@ impl Entry {
)
}
pub fn val<R: Read + Seek>(&self, decoder: &mut super::TIFFDecoder<R>)
pub fn val<R: Read + Seek>(&self, decoder: &mut super::Decoder<R>)
-> TiffResult<Value> {
let bo = decoder.byte_order();
match (self.type_, self.count) {
+9 -9
View File
@@ -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<R> where R: Read + Seek {
pub struct Decoder<R> where R: Read + Seek {
reader: SmartReader<R>,
byte_order: ByteOrder,
next_ifd: Option<u32>,
@@ -147,10 +147,10 @@ fn rev_hpredict(image: DecodingResult, size: (u32, u32), color_type: ColorType)
})
}
impl<R: Read + Seek> TIFFDecoder<R> {
impl<R: Read + Seek> Decoder<R> {
/// Create a new decoder that decodes from the stream ```r```
pub fn new(r: R) -> TiffResult<TIFFDecoder<R>> {
TIFFDecoder {
pub fn new(r: R) -> TiffResult<Decoder<R>> {
Decoder {
reader: SmartReader::wrap(r, ByteOrder::LittleEndian),
byte_order: ByteOrder::LittleEndian,
next_ifd: None,
@@ -164,11 +164,11 @@ impl<R: Read + Seek> TIFFDecoder<R> {
}.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<ColorType> {
pub fn colortype(&mut self) -> TiffResult<ColorType> {
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<R: Read + Seek> TIFFDecoder<R> {
}
/// Initializes the decoder.
pub fn init(mut self) -> TiffResult<TIFFDecoder<R>> {
pub fn init(mut self) -> TiffResult<Decoder<R>> {
try!(self.read_header());
self.next_image()
}
@@ -217,7 +217,7 @@ impl<R: Read + Seek> TIFFDecoder<R> {
/// 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<TIFFDecoder<R>> {
pub fn next_image(mut self) -> TiffResult<Decoder<R>> {
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));
+1 -1
View File
@@ -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
+1 -3
View File
@@ -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};