(img: &mut liq_image, importance_map: *mut u8, buffer_size: usize, ownership: liq_ownership)
| 368 | #[no_mangle] |
| 369 | #[inline(never)] |
| 370 | pub unsafe extern "C" fn liq_image_set_importance_map(img: &mut liq_image, importance_map: *mut u8, buffer_size: usize, ownership: liq_ownership) -> liq_error { |
| 371 | if bad_object!(img, LIQ_IMAGE_MAGIC) { return Error::InvalidPointer; } |
| 372 | let free_fn = img.c_api_free; |
| 373 | let img = &mut img.inner; |
| 374 | |
| 375 | if buffer_size == 0 || liq_received_invalid_pointer(importance_map) { return Error::InvalidPointer; } |
| 376 | let required_size = img.width() * img.height(); |
| 377 | if buffer_size < required_size { |
| 378 | return Error::BufferTooSmall; |
| 379 | } |
| 380 | |
| 381 | let importance_map_slice = std::slice::from_raw_parts(importance_map, required_size); |
| 382 | if ownership == liq_ownership::LIQ_COPY_PIXELS { |
| 383 | img.set_importance_map(importance_map_slice).err().unwrap_or(LIQ_OK) |
| 384 | } else if ownership == liq_ownership::LIQ_OWN_PIXELS { |
| 385 | let copy: Box<[u8]> = importance_map_slice.into(); |
| 386 | free_fn(importance_map.cast()); |
| 387 | img.set_importance_map(copy).err().unwrap_or(LIQ_OK); |
| 388 | LIQ_OK |
| 389 | } else { |
| 390 | Error::Unsupported |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | #[no_mangle] |
| 395 | #[inline(never)] |
nothing calls this directly
no test coverage detected