Skip to content
Permalink
Browse files

Use piston_image instead of stb_image for decoding JPEGs

Bump image to 0.7
  • Loading branch information...
kaksmet committed Feb 27, 2016
1 parent 62814f7 commit 8c07a1a3af7003d184c25af4160a4c1e0269777b
@@ -91,7 +91,7 @@ git = "https://github.com/servo/webrender"
app_units = {version = "0.2.1", features = ["plugins"]}
euclid = {version = "0.6.2", features = ["plugins"]}
gleam = "0.2"
image = "0.5.0"
image = "0.7"
log = "0.3"
num = "0.1.24"
serde = "0.6"
@@ -23,10 +23,9 @@ path = "../plugins"
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
image = "0.7"
log = "0.3"
serde = "0.6"
serde_macros = "0.6"
stb_image = "0.2"
url = {version = "0.5.5", features = ["heap_size"]}
websocket = "0.15.0"
@@ -4,9 +4,7 @@

use ipc_channel::ipc::IpcSharedMemory;
use piston_image::{self, DynamicImage, GenericImage, ImageFormat};
use stb_image::image as stb_image2;
use util::opts;
use util::vec::byte_swap;

pub use msg::constellation_msg::{Image, ImageMetadata, PixelFormat};

@@ -49,41 +47,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
debug!("{}", msg);
None
}
Ok(ImageFormat::JPEG) => {
// For JPEG images, we use stb_image because piston_image does not yet support progressive
// JPEG.

// Can't remember why we do this. Maybe it's what cairo wants
static FORCE_DEPTH: usize = 4;

match stb_image2::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
stb_image2::LoadResult::ImageU8(mut image) => {
assert!(image.depth == 4);
// handle gif separately because the alpha-channel has to be premultiplied
if is_gif(buffer) {
byte_swap_and_premultiply(&mut image.data);
} else {
byte_swap(&mut image.data);
}
Some(Image {
width: image.width as u32,
height: image.height as u32,
format: PixelFormat::RGBA8,
bytes: IpcSharedMemory::from_bytes(&image.data[..]),
id: None,
})
}
stb_image2::LoadResult::ImageF32(_image) => {
debug!("HDR images not implemented");
None
}
stb_image2::LoadResult::Error(e) => {
debug!("stb_image failed: {}", e);
None
}
}
}
_ => {
Ok(_) => {
match piston_image::load_from_memory(buffer) {
Ok(image) => {
let mut rgba = match image {
@@ -19,7 +19,6 @@ extern crate ipc_channel;
extern crate log;
extern crate msg;
extern crate serde;
extern crate stb_image;
extern crate url;
extern crate util;
extern crate websocket;
@@ -74,7 +74,7 @@ heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
html5ever = {version = "0.5.1", features = ["heap_size", "unstable"]}
hyper = { version = "0.7", features = [ "serde-serialization" ] }
image = "0.5.0"
image = "0.7"
libc = "0.2"
log = "0.3"
num = "0.1.24"

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -18,7 +18,7 @@ doc = false
bench = false

[dev-dependencies]
image = "0.5.0"
image = "0.7"

[dev-dependencies.gfx_tests]
path = "../../tests/unit/gfx"
@@ -26,7 +26,7 @@ git = "https://github.com/jgraham/webdriver-rust.git"
git = "https://github.com/servo/ipc-channel"

[dependencies]
image = "0.5.0"
image = "0.7"
log = "0.3"
hyper = "0.7"
rustc-serialize = "0.3.4"

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -13,7 +13,6 @@ euclid = {version = "0.6.2", features = ["plugins"]}
gleam = "0.2"
libc = "0.2"
log = "0.3"
stb_image = "0.2"
url = {version = "0.5.5", features = ["heap_size"]}

[dependencies.servo]
@@ -40,7 +40,6 @@ extern crate msg;
extern crate util;
extern crate style;
extern crate style_traits;
extern crate stb_image;

extern crate libc;
extern crate url as std_url;
Oops, something went wrong.

0 comments on commit 8c07a1a

Please sign in to comment.
You can’t perform that action at this time.