diff --git a/crates/servicepoint_binding_c/src/bitmap.rs b/crates/servicepoint_binding_c/src/bitmap.rs index 433e61e..3f73ffc 100644 --- a/crates/servicepoint_binding_c/src/bitmap.rs +++ b/crates/servicepoint_binding_c/src/bitmap.rs @@ -47,6 +47,22 @@ pub unsafe extern "C" fn sp_bitmap_new( 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 { + 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. /// /// # Arguments diff --git a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.g.cs b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.g.cs index 6f9e81b..38a4f6a 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.g.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.g.cs @@ -37,6 +37,24 @@ namespace ServicePoint /// public Bitmap(nuint width, nuint height) : this(sp_bitmap_new(width, height)) {} + /// + /// 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`. + /// + [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + public static Bitmap NewScreenSized() + { + return new Bitmap(Bitmap.sp_bitmap_new_screen_sized()); + } + /// /// 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)] 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)] private static extern SPBitmap* sp_bitmap_load(nuint width, nuint height, byte* data, nuint data_length);