using System;
using RGB.NET.Core;
using RGB.NET.Presets.Textures.Sampler;
using SkiaSharp;
namespace Artemis.Core
{
///
/// Represents a SkiaSharp-based RGB.NET PixelTexture
///
public sealed class SKTexture : PixelTexture, IDisposable
{
#region Constructors
internal SKTexture(SKBitmap bitmap)
: base(bitmap.Width, bitmap.Height, 4, new AverageByteSampler())
{
Bitmap = bitmap;
}
#endregion
#region Methods
///
protected override Color GetColor(in ReadOnlySpan pixel)
{
return new(pixel[0], pixel[1], pixel[2]);
}
#endregion
#region Properties & Fields
///
/// Gets the SKBitmap backing this texture
///
public SKBitmap Bitmap { get; }
///
/// Gets the color data in RGB format
///
protected override ReadOnlySpan Data => Bitmap.GetPixelSpan();
///
public void Dispose()
{
Bitmap.Dispose();
}
#endregion
}
}