add sp_bitmap_into_bitvec
This commit is contained in:
parent
f483b5a2d5
commit
c797bb6894
|
@ -411,6 +411,11 @@ bool sp_bitmap_get(Bitmap */*notnull*/ bitmap, size_t x, size_t y);
|
||||||
*/
|
*/
|
||||||
size_t sp_bitmap_height(Bitmap */*notnull*/ bitmap);
|
size_t sp_bitmap_height(Bitmap */*notnull*/ bitmap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consumes the Bitmap and returns the contained BitVec
|
||||||
|
*/
|
||||||
|
SPBitVec */*notnull*/ sp_bitmap_into_bitvec(Bitmap */*notnull*/ bitmap);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a [Bitmap] with the specified dimensions from the provided data.
|
* Loads a [Bitmap] with the specified dimensions from the provided data.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::byte_slice::ByteSlice;
|
use crate::byte_slice::ByteSlice;
|
||||||
use crate::{heap_drop, heap_move, heap_move_nonnull};
|
use crate::{heap_drop, heap_move, heap_move_nonnull, SPBitVec};
|
||||||
use servicepoint::{Bitmap, DataRef, Grid};
|
use servicepoint::{Bitmap, DataRef, Grid};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
|
@ -172,3 +172,12 @@ pub unsafe extern "C" fn sp_bitmap_unsafe_data_ref(
|
||||||
) -> ByteSlice {
|
) -> ByteSlice {
|
||||||
unsafe { ByteSlice::from_slice(bitmap.as_mut().data_ref_mut()) }
|
unsafe { ByteSlice::from_slice(bitmap.as_mut().data_ref_mut()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Consumes the Bitmap and returns the contained BitVec
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn sp_bitmap_into_bitvec(
|
||||||
|
bitmap: NonNull<Bitmap>,
|
||||||
|
) -> NonNull<SPBitVec> {
|
||||||
|
let bitmap = unsafe { *Box::from_raw(bitmap.as_ptr()) };
|
||||||
|
heap_move_nonnull(SPBitVec(bitmap.into()))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue