🐛 Fix problem with images

This commit is contained in:
alonso.torres 2025-02-20 17:57:36 +01:00
parent 9143187efd
commit 8c1e18b1cd
3 changed files with 10 additions and 13 deletions

View file

@ -221,8 +221,7 @@
(aget buffer 0) (aget buffer 0)
(aget buffer 1) (aget buffer 1)
(aget buffer 2) (aget buffer 2)
(aget buffer 3) (aget buffer 3))
image-size)
true)))))) true))))))
(defn set-shape-fills (defn set-shape-fills

View file

@ -332,21 +332,19 @@ pub extern "C" fn store_font(family_name_size: u32, font_size: u32) {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn store_image(a: u32, b: u32, c: u32, d: u32, size: u32) { pub extern "C" fn store_image(a: u32, b: u32, c: u32, d: u32) {
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer"); let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
let id = uuid_from_u32_quartet(a, b, c, d); let id = uuid_from_u32_quartet(a, b, c, d);
let image_bytes = mem::bytes();
unsafe {
let image_bytes =
Vec::<u8>::from_raw_parts(mem::buffer_ptr(), size as usize, size as usize);
match state.render_state().add_image(id, &image_bytes) { match state.render_state().add_image(id, &image_bytes) {
Err(msg) => { Err(msg) => {
eprintln!("{}", msg); eprintln!("{}", msg);
} }
_ => {} _ => {}
} }
mem::free_bytes(); mem::free_bytes();
}
} }
#[no_mangle] #[no_mangle]

View file

@ -577,7 +577,7 @@ mod tests {
assert_eq!(r.width(), 20.0); assert_eq!(r.width(), 20.0);
assert_eq!(r.height(), 20.0); assert_eq!(r.height(), 20.0);
} }
_ => assert!(false) _ => assert!(false),
} }
} }
} }