--- a/servo/src/servo/image/base.rs
+++ b/servo/src/servo/image/base.rs
@@ -17,17 +17,21 @@ pub fn Image(width: uint, height: uint,
const TEST_IMAGE: [u8 * 4962] = #include_bin("test.jpeg");
fn test_image_bin() -> ~[u8] {
return vec::from_fn(4962, |i| TEST_IMAGE[i]);
}
pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
- do stb_image::load_from_memory(buffer).map |image| {
+
+ // Can't remember why we do this. Maybe it's what cairo wants
+ const FORCE_DEPTH: uint = 4;
+
+ do stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH).map |image| {
assert image.depth == 4;
// Do color space conversion :(
let data = do vec::from_fn(image.width * image.height * 4) |i| {
let color = i % 4;
let pixel = i / 4;
match color {
0 => image.data[pixel * 4 + 2],