Skip to content

Commit

Permalink
Merge pull request #990 from HeroicKatora/update-png
Browse files Browse the repository at this point in the history
Update png to newly release 0.15
  • Loading branch information
HeroicKatora committed Jul 18, 2019
2 parents 7c5873c + 9876c55 commit 0b43c30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -45,7 +45,7 @@ default-features = false
optional = true

[dependencies.png]
version = "0.14"
version = "0.15"
optional = true

[dependencies.scoped_threadpool]
Expand Down
9 changes: 4 additions & 5 deletions src/png.rs
Expand Up @@ -8,9 +8,6 @@

extern crate png;

use self::png::HasParameters;

use std;
use std::io::{self, Read, Write};

use color::ColorType;
Expand Down Expand Up @@ -101,7 +98,7 @@ impl<R: Read> PNGDecoder<R> {
/// Creates a new decoder that decodes from the stream ```r```
pub fn new(r: R) -> ImageResult<PNGDecoder<R>> {
let limits = png::Limits {
pixels: std::u64::MAX,
bytes: usize::max_value(),
};
let decoder = png::Decoder::new_with_limits(r, limits);
let (_, mut reader) = decoder.read_info()?;
Expand Down Expand Up @@ -157,7 +154,8 @@ impl<W: Write> PNGEncoder<W> {
pub fn encode(self, data: &[u8], width: u32, height: u32, color: ColorType) -> io::Result<()> {
let (ct, bits) = color.into();
let mut encoder = png::Encoder::new(self.w, width, height);
encoder.set(ct).set(bits);
encoder.set_color(ct);
encoder.set_depth(bits);
let mut writer = try!(encoder.write_header());
writer.write_image_data(data).map_err(|e| e.into())
}
Expand Down Expand Up @@ -205,6 +203,7 @@ impl From<png::DecodingError> for ImageError {
CorruptFlateStream => {
ImageError::FormatError("compressed data stream corrupted".into())
}
LimitsExceeded => ImageError::InsufficientMemory,
}
}
}

0 comments on commit 0b43c30

Please sign in to comment.