mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-11-10 20:46:24 +00:00
Changed all namespaces to file-scope
This commit is contained in:
1 parent
a0c6ccebea
commit
30624035f1
353 files changed
+35775
-36129
No files matched your search
@@ -1,34 +1,33 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Presets.Textures.Sampler
|
||||
namespace RGB.NET.Presets.Textures.Sampler;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a sampled that averages multiple byte-data entries.
|
||||
/// </summary>
|
||||
public class AverageByteSampler : ISampler<byte>
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a sampled that averages multiple byte-data entries.
|
||||
/// </summary>
|
||||
public class AverageByteSampler : ISampler<byte>
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Sample(in SamplerInfo<byte> info, in Span<byte> pixelData)
|
||||
{
|
||||
#region Methods
|
||||
int count = info.Width * info.Height;
|
||||
if (count == 0) return;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Sample(in SamplerInfo<byte> info, in Span<byte> pixelData)
|
||||
{
|
||||
int count = info.Width * info.Height;
|
||||
if (count == 0) return;
|
||||
ReadOnlySpan<byte> data = info.Data;
|
||||
|
||||
ReadOnlySpan<byte> data = info.Data;
|
||||
int dataLength = pixelData.Length;
|
||||
Span<uint> sums = stackalloc uint[dataLength];
|
||||
for (int i = 0; i < data.Length; i += dataLength)
|
||||
for (int j = 0; j < sums.Length; j++)
|
||||
sums[j] += data[i + j];
|
||||
|
||||
int dataLength = pixelData.Length;
|
||||
Span<uint> sums = stackalloc uint[dataLength];
|
||||
for (int i = 0; i < data.Length; i += dataLength)
|
||||
for (int j = 0; j < sums.Length; j++)
|
||||
sums[j] += data[i + j];
|
||||
|
||||
float divisor = count * byte.MaxValue;
|
||||
for (int i = 0; i < pixelData.Length; i++)
|
||||
pixelData[i] = (sums[i] / divisor).GetByteValueFromPercentage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
float divisor = count * byte.MaxValue;
|
||||
for (int i = 0; i < pixelData.Length; i++)
|
||||
pixelData[i] = (sums[i] / divisor).GetByteValueFromPercentage();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,33 +1,32 @@
|
||||
using System;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGB.NET.Presets.Textures.Sampler
|
||||
namespace RGB.NET.Presets.Textures.Sampler;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a sampled that averages multiple float-data entries.
|
||||
/// </summary>
|
||||
public class AverageFloatSampler : ISampler<float>
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a sampled that averages multiple float-data entries.
|
||||
/// </summary>
|
||||
public class AverageFloatSampler : ISampler<float>
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Sample(in SamplerInfo<float> info, in Span<float> pixelData)
|
||||
{
|
||||
#region Methods
|
||||
int count = info.Width * info.Height;
|
||||
if (count == 0) return;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Sample(in SamplerInfo<float> info, in Span<float> pixelData)
|
||||
{
|
||||
int count = info.Width * info.Height;
|
||||
if (count == 0) return;
|
||||
ReadOnlySpan<float> data = info.Data;
|
||||
|
||||
ReadOnlySpan<float> data = info.Data;
|
||||
int dataLength = pixelData.Length;
|
||||
Span<float> sums = stackalloc float[dataLength];
|
||||
for (int i = 0; i < data.Length; i += dataLength)
|
||||
for (int j = 0; j < sums.Length; j++)
|
||||
sums[j] += data[i + j];
|
||||
|
||||
int dataLength = pixelData.Length;
|
||||
Span<float> sums = stackalloc float[dataLength];
|
||||
for (int i = 0; i < data.Length; i += dataLength)
|
||||
for (int j = 0; j < sums.Length; j++)
|
||||
sums[j] += data[i + j];
|
||||
|
||||
for (int i = 0; i < pixelData.Length; i++)
|
||||
pixelData[i] = sums[i] / count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
for (int i = 0; i < pixelData.Length; i++)
|
||||
pixelData[i] = sums[i] / count;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user