diff --git a/data/wikipedia_logo.svg b/data/wikipedia_logo.svg new file mode 100644 index 0000000..dc32f98 --- /dev/null +++ b/data/wikipedia_logo.svg @@ -0,0 +1 @@ +]>Wikipedia logo version 2 \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 6a7e5b8..ec3f9f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -300,7 +300,7 @@ pub fn decode_pixbuf( 8, width, height, - 4 * height, + 4 * width, ); Ok(buffer) } @@ -371,7 +371,7 @@ mod tests { #[cfg(feature = "gdk-pixbuf")] fn decode_blurhash_pixbuf() { use std::convert::TryInto; - let img = gdk_pixbuf::Pixbuf::from_file("data/octocat.png").unwrap(); + let img = gdk_pixbuf::Pixbuf::from_file("data/wikipedia_logo.svg").unwrap(); let blurhash = encode_pixbuf(4, 3, &img).unwrap(); let img = decode_pixbuf( @@ -382,6 +382,8 @@ mod tests { ) .unwrap(); - assert_eq!(img.read_pixel_bytes()[0..5], [1, 1, 1, 255, 1]); + let bytes = img.save_to_bufferv("png", &[]).unwrap(); + + assert_eq!(bytes[1000..1005], [77, 210, 4, 80, 15]); } }