2024-06-23 16:30:45 +02:00
|
|
|
using ServicePoint.BindGen;
|
|
|
|
|
|
|
|
namespace ServicePoint;
|
|
|
|
|
2024-08-29 21:40:33 +02:00
|
|
|
public sealed class BrightnessGrid : SpNativeInstance<BindGen.BrightnessGrid>
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
public static BrightnessGrid New(nuint width, nuint height)
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
return new BrightnessGrid(NativeMethods.sp_brightness_grid_new(width, height));
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:56:55 +02:00
|
|
|
public static BrightnessGrid Load(nuint width, nuint height, Span<byte> bytes)
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
|
|
|
fixed (byte* bytesPtr = bytes)
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
return new BrightnessGrid(NativeMethods.sp_brightness_grid_load(width, height, bytesPtr,
|
2024-06-23 16:30:45 +02:00
|
|
|
(nuint)bytes.Length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public BrightnessGrid Clone()
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
|
|
|
return new BrightnessGrid(NativeMethods.sp_brightness_grid_clone(Instance));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:56:55 +02:00
|
|
|
public byte this[nuint x, nuint y]
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
return NativeMethods.sp_brightness_grid_get(Instance, x, y);
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
NativeMethods.sp_brightness_grid_set(Instance, x, y, value);
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Fill(byte value)
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
|
|
|
NativeMethods.sp_brightness_grid_fill(Instance, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:56:55 +02:00
|
|
|
public nuint Width
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
return NativeMethods.sp_brightness_grid_width(Instance);
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-16 20:56:55 +02:00
|
|
|
public nuint Height
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
2024-10-16 20:56:55 +02:00
|
|
|
return NativeMethods.sp_brightness_grid_height(Instance);
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Span<byte> Data
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
unsafe
|
|
|
|
{
|
|
|
|
var slice = NativeMethods.sp_brightness_grid_unsafe_data_ref(Instance);
|
|
|
|
return new Span<byte>(slice.start, (int)slice.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-29 21:40:33 +02:00
|
|
|
private unsafe BrightnessGrid(BindGen.BrightnessGrid* instance) : base(instance)
|
2024-06-23 16:30:45 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-09-07 14:11:15 +02:00
|
|
|
private protected override unsafe void Free() => NativeMethods.sp_brightness_grid_free(Instance);
|
2024-06-23 16:30:45 +02:00
|
|
|
}
|