diff --git a/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs b/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs index 8bb2d43..9afdb28 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BitVec.cs @@ -2,6 +2,17 @@ namespace ServicePoint; public sealed partial class BitVec { + public static BitVec Load(Span bytes) + { + unsafe + { + fixed (byte* bytesPtr = bytes) + { + return Load(bytesPtr, (nuint)bytes.Length); + } + } + } + public bool this[nuint index] { get => Get(index); diff --git a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs index 27be715..07f63d8 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Bitmap.cs @@ -2,6 +2,17 @@ namespace ServicePoint; public sealed partial class Bitmap { + public static Bitmap Load(nuint width, nuint height, Span bytes) + { + unsafe + { + fixed (byte* bytesPtr = bytes) + { + return Load(width, height, bytesPtr, (nuint)bytes.Length); + } + } + } + public bool this[nuint x, nuint y] { get => Get(x, y); diff --git a/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs b/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs index c6590e6..fdca652 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs @@ -2,6 +2,17 @@ namespace ServicePoint; public sealed partial class BrightnessGrid { + public static BrightnessGrid Load(nuint width, nuint height, Span bytes) + { + unsafe + { + fixed (byte* bytesPtr = bytes) + { + return Load(width, height, bytesPtr, (nuint)bytes.Length); + } + } + } + public byte this[nuint x, nuint y] { get => Get(x, y); diff --git a/crates/servicepoint_binding_cs/ServicePoint/ByteSlice.cs b/crates/servicepoint_binding_cs/ServicePoint/ByteSlice.cs index 29e8a82..c05f5bc 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/ByteSlice.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/ByteSlice.cs @@ -2,5 +2,5 @@ namespace ServicePoint; public partial struct SPByteSlice { - public unsafe Span AsSpan() => new Span(start, (int)length); + public unsafe Span AsSpan() => new (start, (int)length); } diff --git a/crates/servicepoint_binding_cs/ServicePoint/Cp437Grid.cs b/crates/servicepoint_binding_cs/ServicePoint/Cp437Grid.cs index a3c6ba7..16a70e2 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Cp437Grid.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Cp437Grid.cs @@ -4,6 +4,17 @@ namespace ServicePoint; public sealed partial class Cp437Grid { + public static Cp437Grid Load(nuint width, nuint height, Span bytes) + { + unsafe + { + fixed (byte* bytesPtr = bytes) + { + return Load(width, height, bytesPtr, (nuint)bytes.Length); + } + } + } + public byte this[nuint x, nuint y] { get => Get(x, y); diff --git a/crates/servicepoint_binding_cs/ServicePoint/Packet.cs b/crates/servicepoint_binding_cs/ServicePoint/Packet.cs index e03b6f3..7946921 100644 --- a/crates/servicepoint_binding_cs/ServicePoint/Packet.cs +++ b/crates/servicepoint_binding_cs/ServicePoint/Packet.cs @@ -4,7 +4,7 @@ namespace ServicePoint; public sealed partial class Packet { - public static bool TryFromBytes(Span bytes, [MaybeNullWhen(false)] out Packet packet) + public static bool TryLoad(Span bytes, [MaybeNullWhen(false)] out Packet packet) { unsafe {