Created
July 31, 2020 16:00
-
-
Save richardanaya/46d8ec5b4111ce2f5548ef7e5060b87b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn image_from_resource(path:&str) -> ImageSurface{ | |
| let pb = Pixbuf::from_resource(path).unwrap(); | |
| let mut pixels = unsafe { pb.get_pixels().to_owned() }; | |
| let pslice = pixels.as_mut_slice(); | |
| ImageSurface::create_for_data(pslice,if pb.get_has_alpha() { Format::ARgb32 } else { Format::Rgb24 },pb.get_width(),pb.get_height(),pb.get_width()).unwrap() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment