How to load a image from a path #819
-
Hello, I have recently started using Skia and was curious about how I could do this. let image = image::io::Reader::open("/home/arthex/Pictures/test.png")
.unwrap()
.decode()
.unwrap();
let image = image.into_bytes();
let data = skia_safe::Image::from_encoded(unsafe { skia_safe::Data::new_bytes(&image) }).unwrap(); I tried this, but it doesn't seem to work. Thats all, thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
pragmatrix
Jul 11, 2023
Replies: 1 comment
-
Looks to me like this decodes the image twice, first the image library and then passes the raw bytes to skia-safe (which attempts to decode again), try to read the encoded image with Rust's fs:: functions. See here for an example that uses include_bytes: rust-skia/skia-org/src/main.rs Lines 159 to 163 in 143f937 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Arthex1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks to me like this decodes the image twice, first the image library and then passes the raw bytes to skia-safe (which attempts to decode again), try to read the encoded image with Rust's fs:: functions. See here for an example that uses include_bytes:
rust-skia/skia-org/src/main.rs
Lines 159 to 163 in 143f937