diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index c8a61cc..8fd1da6 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -1,4 +1,6 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global + +using System; using System.Runtime.CompilerServices; namespace RGB.NET.Core; @@ -12,9 +14,21 @@ public abstract class PixelTexture : ITexture where T : unmanaged { #region Properties & Fields + + /// + /// Gets the underlying pixel data. + /// + protected abstract ReadOnlySpan Data { get; } - private readonly int _dataPerPixel; - private readonly int _stride; + /// + /// Gets the amount of data-entries per pixel. + /// + protected readonly int DataPerPixel; + + /// + /// Gets the stride of the data. + /// + protected readonly int Stride; /// /// Gets or sets the sampler used to get the color of a region. @@ -24,11 +38,6 @@ public abstract class PixelTexture : ITexture /// public Size Size { get; } - /// - /// Gets the underlying pixel data. - /// - protected abstract ReadOnlySpan Data { get; } - /// public virtual Color this[in Point point] { @@ -78,9 +87,9 @@ public abstract class PixelTexture : ITexture if ((width == 0) || (height == 0)) return Color.Transparent; if ((width == 1) && (height == 1)) return GetColor(GetPixelData(x, y)); - SamplerInfo samplerInfo = new(x, y, width, height, _stride, _dataPerPixel, Data); + SamplerInfo samplerInfo = new(x, y, width, height, Stride, DataPerPixel, Data); - Span pixelData = stackalloc T[_dataPerPixel]; + Span pixelData = stackalloc T[DataPerPixel]; Sampler.Sample(samplerInfo, pixelData); return GetColor(pixelData); @@ -101,8 +110,8 @@ public abstract class PixelTexture : ITexture /// The stride of the data or -1 if the width should be used. public PixelTexture(int with, int height, int dataPerPixel, ISampler sampler, int stride = -1) { - this._stride = stride == -1 ? with : stride; - this._dataPerPixel = dataPerPixel; + this.Stride = stride == -1 ? with : stride; + this.DataPerPixel = dataPerPixel; this.Sampler = sampler; Size = new Size(with, height); @@ -126,7 +135,7 @@ public abstract class PixelTexture : ITexture /// The y-location. /// The pixel-data on the specified location. [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * _stride) + x, _dataPerPixel); + private ReadOnlySpan GetPixelData(int x, int y) => Data.Slice((y * Stride) + x, DataPerPixel); #endregion }