mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
pass through real types to c#
This commit is contained in:
parent
db98709ca7
commit
55aa7ecf4c
|
@ -4,11 +4,11 @@ namespace ServicePoint;
|
||||||
|
|
||||||
public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
||||||
{
|
{
|
||||||
public static BitVec New(int size)
|
public static BitVec New(nuint size)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new BitVec(NativeMethods.sp_bitvec_new((nuint)size));
|
return new BitVec(NativeMethods.sp_bitvec_new(size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,20 +31,20 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool this[int index]
|
public bool this[nuint index]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return NativeMethods.sp_bitvec_get(Instance, (nuint)index);
|
return NativeMethods.sp_bitvec_get(Instance, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
NativeMethods.sp_bitvec_set(Instance, (nuint)index, value);
|
NativeMethods.sp_bitvec_set(Instance, index, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,13 +57,13 @@ public sealed class BitVec : SpNativeInstance<BindGen.BitVec>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Length
|
public nuint Length
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return (int)NativeMethods.sp_bitvec_len(Instance);
|
return NativeMethods.sp_bitvec_len(Instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,21 @@ namespace ServicePoint;
|
||||||
|
|
||||||
public sealed class Bitmap : SpNativeInstance<BindGen.Bitmap>
|
public sealed class Bitmap : SpNativeInstance<BindGen.Bitmap>
|
||||||
{
|
{
|
||||||
public static Bitmap New(int width, int height)
|
public static Bitmap New(nuint width, nuint height)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Bitmap(NativeMethods.sp_bitmap_new((nuint)width, (nuint)height));
|
return new Bitmap(NativeMethods.sp_bitmap_new(width, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap Load(int width, int height, Span<byte> bytes)
|
public static Bitmap Load(nuint width, nuint height, Span<byte> bytes)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (byte* bytesPtr = bytes)
|
fixed (byte* bytesPtr = bytes)
|
||||||
{
|
{
|
||||||
return new Bitmap(NativeMethods.sp_bitmap_load((nuint)width, (nuint)height, bytesPtr,
|
return new Bitmap(NativeMethods.sp_bitmap_load(width, height, bytesPtr,
|
||||||
(nuint)bytes.Length));
|
(nuint)bytes.Length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,20 @@ public sealed class Bitmap : SpNativeInstance<BindGen.Bitmap>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool this[int x, int y]
|
public bool this[nuint x, nuint y]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return NativeMethods.sp_bitmap_get(Instance, (nuint)x, (nuint)y);
|
return NativeMethods.sp_bitmap_get(Instance, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
NativeMethods.sp_bitmap_set(Instance, (nuint)x, (nuint)y, value);
|
NativeMethods.sp_bitmap_set(Instance, x, y, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,24 +58,24 @@ public sealed class Bitmap : SpNativeInstance<BindGen.Bitmap>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Width
|
public nuint Width
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return (int)NativeMethods.sp_bitmap_width(Instance);
|
return NativeMethods.sp_bitmap_width(Instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Height
|
public nuint Height
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return (int)NativeMethods.sp_bitmap_height(Instance);
|
return NativeMethods.sp_bitmap_height(Instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,21 @@ namespace ServicePoint;
|
||||||
|
|
||||||
public sealed class BrightnessGrid : SpNativeInstance<BindGen.BrightnessGrid>
|
public sealed class BrightnessGrid : SpNativeInstance<BindGen.BrightnessGrid>
|
||||||
{
|
{
|
||||||
public static BrightnessGrid New(int width, int height)
|
public static BrightnessGrid New(nuint width, nuint height)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new BrightnessGrid(NativeMethods.sp_brightness_grid_new((nuint)width, (nuint)height));
|
return new BrightnessGrid(NativeMethods.sp_brightness_grid_new(width, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BrightnessGrid Load(int width, int height, Span<byte> bytes)
|
public static BrightnessGrid Load(nuint width, nuint height, Span<byte> bytes)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (byte* bytesPtr = bytes)
|
fixed (byte* bytesPtr = bytes)
|
||||||
{
|
{
|
||||||
return new BrightnessGrid(NativeMethods.sp_brightness_grid_load((nuint)width, (nuint)height, bytesPtr,
|
return new BrightnessGrid(NativeMethods.sp_brightness_grid_load(width, height, bytesPtr,
|
||||||
(nuint)bytes.Length));
|
(nuint)bytes.Length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,20 +32,20 @@ public sealed class BrightnessGrid : SpNativeInstance<BindGen.BrightnessGrid>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte this[int x, int y]
|
public byte this[nuint x, nuint y]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return NativeMethods.sp_brightness_grid_get(Instance, (nuint)x, (nuint)y);
|
return NativeMethods.sp_brightness_grid_get(Instance, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
NativeMethods.sp_brightness_grid_set(Instance, (nuint)x, (nuint)y, value);
|
NativeMethods.sp_brightness_grid_set(Instance, x, y, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,24 +58,24 @@ public sealed class BrightnessGrid : SpNativeInstance<BindGen.BrightnessGrid>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Width
|
public nuint Width
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return (int)NativeMethods.sp_brightness_grid_width(Instance);
|
return NativeMethods.sp_brightness_grid_width(Instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Height
|
public nuint Height
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return (int)NativeMethods.sp_brightness_grid_height(Instance);
|
return NativeMethods.sp_brightness_grid_height(Instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,63 +61,63 @@ public sealed class Command : SpNativeInstance<BindGen.Command>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command CharBrightness(int x, int y, BrightnessGrid grid)
|
public static Command CharBrightness(ushort x, ushort y, BrightnessGrid grid)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(NativeMethods.sp_command_char_brightness((ushort)x, (ushort)y, grid.Into()));
|
return new Command(NativeMethods.sp_command_char_brightness(x, y, grid.Into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command BitmapLinear(int offset, BitVec bitVec, CompressionCode compressionCode)
|
public static Command BitmapLinear(ushort offset, BitVec bitVec, CompressionCode compressionCode)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(
|
return new Command(
|
||||||
NativeMethods.sp_command_bitmap_linear((ushort)offset, bitVec.Into(), compressionCode));
|
NativeMethods.sp_command_bitmap_linear(offset, bitVec.Into(), compressionCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command BitmapLinearAnd(int offset, BitVec bitVec, CompressionCode compressionCode)
|
public static Command BitmapLinearAnd(ushort offset, BitVec bitVec, CompressionCode compressionCode)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(
|
return new Command(
|
||||||
NativeMethods.sp_command_bitmap_linear_and((ushort)offset, bitVec.Into(), compressionCode));
|
NativeMethods.sp_command_bitmap_linear_and(offset, bitVec.Into(), compressionCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command BitmapLinearOr(int offset, BitVec bitVec, CompressionCode compressionCode)
|
public static Command BitmapLinearOr(ushort offset, BitVec bitVec, CompressionCode compressionCode)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(
|
return new Command(
|
||||||
NativeMethods.sp_command_bitmap_linear_or((ushort)offset, bitVec.Into(), compressionCode));
|
NativeMethods.sp_command_bitmap_linear_or(offset, bitVec.Into(), compressionCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command BitmapLinearXor(int offset, BitVec bitVec, CompressionCode compressionCode)
|
public static Command BitmapLinearXor(ushort offset, BitVec bitVec, CompressionCode compressionCode)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(
|
return new Command(
|
||||||
NativeMethods.sp_command_bitmap_linear_xor((ushort)offset, bitVec.Into(), compressionCode));
|
NativeMethods.sp_command_bitmap_linear_xor(offset, bitVec.Into(), compressionCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command BitmapLinearWin(int x, int y, Bitmap bitmap, CompressionCode compression)
|
public static Command BitmapLinearWin(ushort x, ushort y, Bitmap bitmap, CompressionCode compression)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(NativeMethods.sp_command_bitmap_linear_win((ushort)x, (ushort)y, bitmap.Into(), compression));
|
return new Command(NativeMethods.sp_command_bitmap_linear_win(x, y, bitmap.Into(), compression));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Command Cp437Data(int x, int y, Cp437Grid byteGrid)
|
public static Command Cp437Data(ushort x, ushort y, Cp437Grid byteGrid)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
return new Command(NativeMethods.sp_command_cp437_data((ushort)x, (ushort)y, byteGrid.Into()));
|
return new Command(NativeMethods.sp_command_cp437_data(x, y, byteGrid.Into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ connection.Send(Command.Brightness(128).IntoPacket());
|
||||||
|
|
||||||
using var pixels = Bitmap.New(Constants.PixelWidth, Constants.PixelHeight);
|
using var pixels = Bitmap.New(Constants.PixelWidth, Constants.PixelHeight);
|
||||||
|
|
||||||
for (var offset = 0; offset < int.MaxValue; offset++)
|
for (nuint offset = 0; offset < nuint.MaxValue; offset++)
|
||||||
{
|
{
|
||||||
pixels.Fill(false);
|
pixels.Fill(false);
|
||||||
|
|
||||||
for (var y = 0; y < pixels.Height; y++)
|
for (nuint y = 0; y < pixels.Height; y++)
|
||||||
pixels[(y + offset) % Constants.PixelWidth, y] = true;
|
pixels[(y + offset) % Constants.PixelWidth, y] = true;
|
||||||
|
|
||||||
connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone(), CompressionCode.Lzma).IntoPacket());
|
connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone(), CompressionCode.Lzma).IntoPacket());
|
||||||
|
|
Loading…
Reference in a new issue