mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
add sp_bitmap_new_screen_sized
This commit is contained in:
parent
bcd65fb4f0
commit
52b1ce83d9
|
@ -47,6 +47,22 @@ pub unsafe extern "C" fn sp_bitmap_new(
|
||||||
NonNull::from(Box::leak(result))
|
NonNull::from(Box::leak(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new [SPBitmap] with a size matching the screen.
|
||||||
|
///
|
||||||
|
/// returns: [SPBitmap] initialized to all pixels off. Will never return NULL.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// The caller has to make sure that:
|
||||||
|
///
|
||||||
|
/// - the returned instance is freed in some way, either by using a consuming function or
|
||||||
|
/// by explicitly calling `sp_bitmap_free`.
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn sp_bitmap_new_screen_sized() -> NonNull<SPBitmap> {
|
||||||
|
let result = Box::new(SPBitmap(servicepoint::Bitmap::max_sized()));
|
||||||
|
NonNull::from(Box::leak(result))
|
||||||
|
}
|
||||||
|
|
||||||
/// Loads a [SPBitmap] with the specified dimensions from the provided data.
|
/// Loads a [SPBitmap] with the specified dimensions from the provided data.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
|
|
@ -37,6 +37,24 @@ namespace ServicePoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Bitmap(nuint width, nuint height) : this(sp_bitmap_new(width, height)) {}
|
public Bitmap(nuint width, nuint height) : this(sp_bitmap_new(width, height)) {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new [SPBitmap] with a size matching the screen.
|
||||||
|
///
|
||||||
|
/// returns: [SPBitmap] initialized to all pixels off. Will never return NULL.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// The caller has to make sure that:
|
||||||
|
///
|
||||||
|
/// - the returned instance is freed in some way, either by using a consuming function or
|
||||||
|
/// by explicitly calling `sp_bitmap_free`.
|
||||||
|
/// </summary>
|
||||||
|
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static Bitmap NewScreenSized()
|
||||||
|
{
|
||||||
|
return new Bitmap(Bitmap.sp_bitmap_new_screen_sized());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads a [SPBitmap] with the specified dimensions from the provided data.
|
/// Loads a [SPBitmap] with the specified dimensions from the provided data.
|
||||||
///
|
///
|
||||||
|
@ -286,6 +304,9 @@ namespace ServicePoint
|
||||||
[DllImport(__DllName, EntryPoint = "sp_bitmap_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_bitmap_new", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPBitmap* sp_bitmap_new(nuint width, nuint height);
|
private static extern SPBitmap* sp_bitmap_new(nuint width, nuint height);
|
||||||
|
|
||||||
|
[DllImport(__DllName, EntryPoint = "sp_bitmap_new_screen_sized", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
|
private static extern SPBitmap* sp_bitmap_new_screen_sized();
|
||||||
|
|
||||||
[DllImport(__DllName, EntryPoint = "sp_bitmap_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
[DllImport(__DllName, EntryPoint = "sp_bitmap_load", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||||
private static extern SPBitmap* sp_bitmap_load(nuint width, nuint height, byte* data, nuint data_length);
|
private static extern SPBitmap* sp_bitmap_load(nuint width, nuint height, byte* data, nuint data_length);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue