servicepoint/crates/servicepoint_binding_cs/ServicePoint/BrightnessGrid.cs

100 lines
1.9 KiB
C#
Raw Normal View History

2024-06-23 16:30:45 +02:00
using ServicePoint.BindGen;
namespace ServicePoint;
2024-10-16 22:46:34 +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 21:59:35 +02:00
return new BrightnessGrid(BrightnessGridNative.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 21:59:35 +02:00
return new BrightnessGrid(BrightnessGridNative.sp_brightness_grid_load(width, height, bytesPtr,
2024-06-23 16:30:45 +02:00
(nuint)bytes.Length));
}
}
}
public BrightnessGrid Clone()
{
unsafe
{
2024-10-16 22:46:34 +02:00
return new BrightnessGrid(Instance->Clone());
2024-06-23 16:30:45 +02:00
}
}
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 22:46:34 +02:00
return Instance->Get(x, y);
2024-06-23 16:30:45 +02:00
}
}
set
{
unsafe
{
2024-10-16 22:46:34 +02:00
Instance->Set(x, y, value);
2024-06-23 16:30:45 +02:00
}
}
}
public void Fill(byte value)
{
unsafe
{
2024-10-16 22:46:34 +02:00
Instance->Fill(value);
2024-06-23 16:30:45 +02:00
}
}
2024-10-16 20:56:55 +02:00
public nuint Width
2024-06-23 16:30:45 +02:00
{
get
{
unsafe
{
2024-10-16 22:46:34 +02:00
return Instance->Width();
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 22:46:34 +02:00
return Instance->Height();
2024-06-23 16:30:45 +02:00
}
}
}
public Span<byte> Data
{
get
{
unsafe
{
2024-10-16 22:46:34 +02:00
return Instance->UnsafeDataRef().AsSpan();
2024-06-23 16:30:45 +02:00
}
}
}
2024-10-16 22:46:34 +02:00
private unsafe BrightnessGrid(BindGen.BrightnessGrid* instance) : base(instance)
2024-06-23 16:30:45 +02:00
{
}
2024-10-16 22:46:34 +02:00
private protected override unsafe void Free() => Instance->Free();
2024-06-23 16:30:45 +02:00
}