Browse Source

Gray16 => L16

af/merge-core
James Jackson-South 6 years ago
parent
commit
895c7f584b
  1. 2
      src/ImageSharp/Advanced/AotCompilerTools.cs
  2. 6
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  3. 14
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  4. 4
      src/ImageSharp/Formats/Png/PngMetaData.cs
  5. 8
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  6. 8
      src/ImageSharp/ImageSharp.csproj
  7. 6
      src/ImageSharp/PixelFormats/IPixel.cs
  8. 2
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  9. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  10. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  11. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs
  12. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  13. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs
  14. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs
  15. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs
  16. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs
  17. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs
  18. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs
  19. 76
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs
  20. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt
  21. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs
  22. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs
  23. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs
  24. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs
  25. 6
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs
  26. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude
  27. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs
  28. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs
  29. 2
      src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs
  30. 34
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  31. 2
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  32. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs
  33. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs
  34. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs
  35. 2
      src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs
  36. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs
  37. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  38. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  39. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs
  40. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  41. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  42. 6
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs
  43. 2
      src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs
  44. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs
  45. 2
      src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs
  46. 38
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs
  47. 4
      src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt
  48. 8
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  49. 4
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
  50. 2
      tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs
  51. 2
      tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs
  52. 2
      tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs
  53. 2
      tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs
  54. 46
      tests/ImageSharp.Tests/PixelFormats/L16Tests.cs
  55. 2
      tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs
  56. 2
      tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs
  57. 10
      tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs
  58. 6
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray16OperationsTests.cs
  59. 24
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  60. 2
      tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs
  61. 2
      tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs
  62. 2
      tests/ImageSharp.Tests/TestFormat.cs
  63. 2
      tests/ImageSharp.Tests/TestImages.cs
  64. 2
      tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs

2
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Advanced
Seed<Bgra4444>();
Seed<Bgra5551>();
Seed<Byte4>();
Seed<Gray16>();
Seed<L16>();
Seed<L8>();
Seed<HalfSingle>();
Seed<HalfVector2>();

6
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -658,7 +658,7 @@ namespace SixLabors.ImageSharp.Formats.Png
scanlineSpan,
rowSpan,
pngMetadata.HasTransparency,
pngMetadata.TransparentGray16.GetValueOrDefault(),
pngMetadata.TransparentL16.GetValueOrDefault(),
pngMetadata.TransparentL8.GetValueOrDefault());
break;
@ -742,7 +742,7 @@ namespace SixLabors.ImageSharp.Formats.Png
pixelOffset,
increment,
pngMetadata.HasTransparency,
pngMetadata.TransparentGray16.GetValueOrDefault(),
pngMetadata.TransparentL16.GetValueOrDefault(),
pngMetadata.TransparentL8.GetValueOrDefault());
break;
@ -837,7 +837,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{
if (this.header.BitDepth == 16)
{
pngMetadata.TransparentGray16 = new Gray16(BinaryPrimitives.ReadUInt16LittleEndian(alpha.Slice(0, 2)));
pngMetadata.TransparentL16 = new L16(BinaryPrimitives.ReadUInt16LittleEndian(alpha.Slice(0, 2)));
}
else
{

14
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -199,16 +199,16 @@ namespace SixLabors.ImageSharp.Formats.Png
if (this.use16Bit)
{
// 16 bit grayscale
using (IMemoryOwner<Gray16> luminanceBuffer = this.memoryAllocator.Allocate<Gray16>(rowSpan.Length))
using (IMemoryOwner<L16> luminanceBuffer = this.memoryAllocator.Allocate<L16>(rowSpan.Length))
{
Span<Gray16> luminanceSpan = luminanceBuffer.GetSpan();
ref Gray16 luminanceRef = ref MemoryMarshal.GetReference(luminanceSpan);
PixelOperations<TPixel>.Instance.ToGray16(this.configuration, rowSpan, luminanceSpan);
Span<L16> luminanceSpan = luminanceBuffer.GetSpan();
ref L16 luminanceRef = ref MemoryMarshal.GetReference(luminanceSpan);
PixelOperations<TPixel>.Instance.ToL16(this.configuration, rowSpan, luminanceSpan);
// Can't map directly to byte array as it's big-endian.
for (int x = 0, o = 0; x < luminanceSpan.Length; x++, o += 2)
{
Gray16 luminance = Unsafe.Add(ref luminanceRef, x);
L16 luminance = Unsafe.Add(ref luminanceRef, x);
BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), luminance.PackedValue);
}
}
@ -761,9 +761,9 @@ namespace SixLabors.ImageSharp.Formats.Png
}
else if (pngMetadata.ColorType == PngColorType.Grayscale)
{
if (pngMetadata.TransparentGray16.HasValue && this.use16Bit)
if (pngMetadata.TransparentL16.HasValue && this.use16Bit)
{
BinaryPrimitives.WriteUInt16LittleEndian(alpha, pngMetadata.TransparentGray16.Value.PackedValue);
BinaryPrimitives.WriteUInt16LittleEndian(alpha, pngMetadata.TransparentL16.Value.PackedValue);
this.WriteChunk(stream, PngChunkType.Transparency, this.chunkDataBuffer, 0, 2);
}
else if (pngMetadata.TransparentL8.HasValue)

4
src/ImageSharp/Formats/Png/PngMetaData.cs

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.InterlaceMethod = other.InterlaceMethod;
this.HasTransparency = other.HasTransparency;
this.TransparentL8 = other.TransparentL8;
this.TransparentGray16 = other.TransparentGray16;
this.TransparentL16 = other.TransparentL16;
this.TransparentRgb24 = other.TransparentRgb24;
this.TransparentRgb48 = other.TransparentRgb48;
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// Gets or sets the 16 bit grayscale transparent color.
/// This represents any color in a 16 bit grayscale encoded png that should be transparent.
/// </summary>
public Gray16? TransparentGray16 { get; set; }
public L16? TransparentL16 { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the image contains a transparency chunk and markers were decoded.

8
src/ImageSharp/Formats/Png/PngScanlineProcessor.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Png
ReadOnlySpan<byte> scanlineSpan,
Span<TPixel> rowSpan,
bool hasTrans,
Gray16 luminance16Trans,
L16 luminance16Trans,
L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel>
{
@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Formats.Png
for (int x = 0, o = 0; x < header.Width; x++, o += 2)
{
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromGray16(new Gray16(luminance));
pixel.FromL16(new L16(luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
}
}
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Formats.Png
int pixelOffset,
int increment,
bool hasTrans,
Gray16 luminance16Trans,
L16 luminance16Trans,
L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel>
{
@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.Formats.Png
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2)
{
ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2));
pixel.FromGray16(new Gray16(luminance));
pixel.FromL16(new L16(luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
}
}

8
src/ImageSharp/ImageSharp.csproj

@ -81,10 +81,10 @@
<AutoGen>True</AutoGen>
<DependentUpon>L8.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Gray16.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\Generated\L16.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Gray16.PixelOperations.Generated.tt</DependentUpon>
<DependentUpon>L16.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Rgb24.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
@ -155,9 +155,9 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>L8.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Gray16.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\Generated\L16.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Gray16.PixelOperations.Generated.cs</LastGenOutput>
<LastGenOutput>L16.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Rgb24.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>

6
src/ImageSharp/PixelFormats/IPixel.cs

@ -86,10 +86,10 @@ namespace SixLabors.ImageSharp.PixelFormats
void FromL8(L8 source);
/// <summary>
/// Initializes the pixel instance from an <see cref="Gray16"/> value.
/// Initializes the pixel instance from an <see cref="L16"/> value.
/// </summary>
/// <param name="source">The <see cref="Gray16"/> value.</param>
void FromGray16(Gray16 source);
/// <param name="source">The <see cref="L16"/> value.</param>
void FromL16(L16 source);
/// <summary>
/// Initializes the pixel instance from an <see cref="Rgb24"/> value.

2
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.PackedValue = byte.MaxValue;
public void FromL16(L16 source) => this.PackedValue = byte.MaxValue;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
this.R = rgb;

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

@ -149,7 +149,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
this.R = rgb;

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
this.R = rgb;

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs

@ -152,18 +152,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Argb32> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromArgb32(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs

@ -109,18 +109,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Bgr24> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromBgr24(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs

@ -152,18 +152,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Bgra32> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromBgra32(sp);
}

76
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs

@ -16,15 +16,15 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray16
public partial struct L16
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray16>
internal class PixelOperations : PixelOperations<L16>
{
/// <inheritdoc />
internal override void FromGray16(Configuration configuration, ReadOnlySpan<Gray16> source, Span<Gray16> destPixels)
internal override void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
@ -43,155 +43,155 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Argb32> destPixels)
internal override void ToArgb32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Argb32> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgr24> destPixels)
internal override void ToBgr24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgr24> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgr24 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Bgra32> destPixels)
internal override void ToBgra32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Bgra32> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Bgra32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToL8(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<L8> destPixels)
internal override void ToL8(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<L8> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb24> destPixels)
internal override void ToRgb24(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb24> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb24 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba32> destPixels)
internal override void ToRgba32(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba32> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgb48> destPixels)
internal override void ToRgb48(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgb48> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgb48 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Rgba64> destPixels)
internal override void ToRgba64(Configuration configuration, ReadOnlySpan<L16> sourcePixels, Span<Rgba64> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceRef, i);
ref Rgba64 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <inheritdoc />
internal override void From<TSourcePixel>(
Configuration configuration,
ReadOnlySpan<TSourcePixel> sourcePixels,
Span<Gray16> destinationPixels)
Span<L16> destinationPixels)
{
PixelOperations<TSourcePixel>.Instance.ToGray16(configuration, sourcePixels, destinationPixels);
PixelOperations<TSourcePixel>.Instance.ToL16(configuration, sourcePixels, destinationPixels);
}
}
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt

@ -6,14 +6,14 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <content>
/// Provides optimized overrides for bulk operations.
/// </content>
public partial struct Gray16
public partial struct L16
{
/// <summary>
/// Provides optimized overrides for bulk operations.
/// </summary>
internal class PixelOperations : PixelOperations<Gray16>
internal class PixelOperations : PixelOperations<L16>
{
<# GenerateAllDefaultConversionMethods("Gray16"); #>
<# GenerateAllDefaultConversionMethods("L16"); #>
}
}
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs

@ -97,18 +97,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<L8> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref L8 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromL8(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs

@ -126,18 +126,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgb24> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgb24(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs

@ -115,18 +115,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgb48> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgb48(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs

@ -141,18 +141,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgba32> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba32(sp);
}

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs

@ -115,18 +115,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L16> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destRef, i);
ref L16 dp = ref Unsafe.Add(ref destRef, i);
dp.FromRgba64(sp);
}

2
src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude

@ -15,7 +15,7 @@ using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
<#+
static readonly string[] CommonPixelTypes = { "Argb32", "Bgr24", "Bgra32", "L8", "Gray16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
static readonly string[] CommonPixelTypes = { "Argb32", "Bgr24", "Bgra32", "L8", "L16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
static readonly string[] Optimized32BitTypes = { "Rgba32", "Argb32", "Bgra32" };

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs

@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs

@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

34
src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs → src/ImageSharp/PixelFormats/PixelImplementations/L16.cs

@ -7,48 +7,48 @@ using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <summary>
/// Packed pixel type containing a single 16 bit normalized gray values.
/// Packed pixel type containing a single 16 bit normalized luminance value.
/// <para>
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public partial struct Gray16 : IPixel<Gray16>, IPackedVector<ushort>
public partial struct L16 : IPixel<L16>, IPackedVector<ushort>
{
private const float Max = ushort.MaxValue;
/// <summary>
/// Initializes a new instance of the <see cref="Gray16"/> struct.
/// Initializes a new instance of the <see cref="L16"/> struct.
/// </summary>
/// <param name="luminance">The luminance component</param>
public Gray16(ushort luminance) => this.PackedValue = luminance;
public L16(ushort luminance) => this.PackedValue = luminance;
/// <inheritdoc />
public ushort PackedValue { get; set; }
/// <summary>
/// Compares two <see cref="Gray16"/> objects for equality.
/// Compares two <see cref="L16"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Gray16"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Gray16"/> on the right side of the operand.</param>
/// <param name="left">The <see cref="L16"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="L16"/> on the right side of the operand.</param>
/// <returns>
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator ==(Gray16 left, Gray16 right) => left.Equals(right);
public static bool operator ==(L16 left, L16 right) => left.Equals(right);
/// <summary>
/// Compares two <see cref="Gray16"/> objects for equality.
/// Compares two <see cref="L16"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Gray16"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Gray16"/> on the right side of the operand.</param>
/// <param name="left">The <see cref="L16"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="L16"/> on the right side of the operand.</param>
/// <returns>
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static bool operator !=(Gray16 left, Gray16 right) => !left.Equals(right);
public static bool operator !=(L16 left, L16 right) => !left.Equals(right);
/// <inheritdoc />
public PixelOperations<Gray16> CreatePixelOperations() => new PixelOperations();
public PixelOperations<L16> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.PackedValue = source.PackedValue;
public void FromL16(L16 source) => this.PackedValue = source.PackedValue;
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -152,14 +152,14 @@ namespace SixLabors.ImageSharp.PixelFormats
public void FromRgba64(Rgba64 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B);
/// <inheritdoc />
public override bool Equals(object obj) => obj is Gray16 other && this.Equals(other);
public override bool Equals(object obj) => obj is L16 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Gray16 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(L16 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override string ToString() => $"Gray16({this.PackedValue})";
public override string ToString() => $"L16({this.PackedValue})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
public void FromL16(L16 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs

@ -119,7 +119,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs

@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs

@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs

@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs

@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs

@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
this.R = rgb;

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs

@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs

@ -109,7 +109,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs

@ -317,7 +317,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue);
this.R = rgb;

2
src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs

@ -267,7 +267,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source)
public void FromL16(L16 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

6
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs

@ -62,17 +62,17 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
internal override void ToGray16(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<Gray16> destPixels)
internal override void ToL16(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref Gray16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, i);
dp.ConvertFromRgbaScaledVector4(sp);
}

2
src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs

@ -144,7 +144,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs

@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs

@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

38
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs

@ -299,75 +299,75 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Gray16"/> into a span of <typeparamref name="TPixel"/>-s.
/// Converts all pixels in 'source` span of <see cref="L16"/> into a span of <typeparamref name="TPixel"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="Gray16"/> data.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="L16"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromGray16(Configuration configuration, ReadOnlySpan<Gray16> source, Span<TPixel> destPixels)
internal virtual void FromL16(Configuration configuration, ReadOnlySpan<L16> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
ref Gray16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < source.Length; i++)
{
ref Gray16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
dp.FromGray16(sp);
dp.FromL16(sp);
}
}
/// <summary>
/// A helper for <see cref="FromGray16(Configuration, ReadOnlySpan{Gray16}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Gray16"/> layout.
/// A helper for <see cref="FromL16(Configuration, ReadOnlySpan{L16}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="L16"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourceBytes">The <see cref="ReadOnlySpan{T}"/> to the source bytes.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void FromGray16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromL16Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromGray16(configuration, MemoryMarshal.Cast<byte, Gray16>(sourceBytes).Slice(0, count), destPixels);
this.FromL16(configuration, MemoryMarshal.Cast<byte, L16>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Gray16"/>-s.
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="L16"/>-s.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The span of source pixels</param>
/// <param name="destPixels">The destination span of <see cref="Gray16"/> data.</param>
internal virtual void ToGray16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Gray16> destPixels)
/// <param name="destPixels">The destination span of <see cref="L16"/> data.</param>
internal virtual void ToL16(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L16> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L16 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Gray16 dp = ref Unsafe.Add(ref destBaseRef, i);
ref L16 dp = ref Unsafe.Add(ref destBaseRef, i);
dp.FromScaledVector4(sp.ToScaledVector4());
}
}
/// <summary>
/// A helper for <see cref="ToGray16(Configuration, ReadOnlySpan{TPixel}, Span{Gray16})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Gray16"/> layout.
/// A helper for <see cref="ToL16(Configuration, ReadOnlySpan{TPixel}, Span{L16})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="L16"/> layout.
/// </summary>
/// <param name="configuration">A <see cref="Configuration"/> to configure internal operations</param>
/// <param name="sourcePixels">The <see cref="Span{T}"/> to the source pixels.</param>
/// <param name="destBytes">The <see cref="Span{T}"/> to the destination bytes.</param>
/// <param name="count">The number of pixels to convert.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToGray16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToL16Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToGray16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray16>(destBytes));
this.ToL16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, L16>(destBytes));
}
/// <summary>

4
src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt

@ -121,8 +121,8 @@ namespace SixLabors.ImageSharp.PixelFormats
GenerateFromMethods("L8");
GenerateToDestFormatMethods("L8");
GenerateFromMethods("Gray16");
GenerateToDestFormatMethods("Gray16");
GenerateFromMethods("L16");
GenerateToDestFormatMethods("L16");
GenerateFromMethods("Rgb24");
GenerateToDestFormatMethods("Rgb24");

8
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -57,9 +57,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
TestImages.Png.Rgb48BppTrans
};
public static readonly string[] TestImagesGray16Bit =
public static readonly string[] TestImagesL16Bit =
{
TestImages.Png.Gray16Bit,
TestImages.Png.L16Bit,
};
public static readonly string[] TestImagesGrayAlpha16Bit =
@ -156,8 +156,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
}
[Theory]
[WithFileCollection(nameof(TestImagesGray16Bit), PixelTypes.Rgb48)]
public void Decode_Gray16Bit<TPixel>(TestImageProvider<TPixel> provider)
[WithFileCollection(nameof(TestImagesL16Bit), PixelTypes.Rgb48)]
public void Decode_L16Bit<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(new PngDecoder()))

4
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -314,8 +314,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
case PngColorType.Grayscale:
if (pngBitDepth.Equals(PngBitDepth.Bit16))
{
Assert.True(outMeta.TransparentGray16.HasValue);
Assert.Equal(inMeta.TransparentGray16, outMeta.TransparentGray16);
Assert.True(outMeta.TransparentL16.HasValue);
Assert.Equal(inMeta.TransparentL16, outMeta.TransparentL16);
}
else
{

2
tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs

@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expected = ushort.MaxValue;
// act
bgr.FromGray16(new Gray16(ushort.MaxValue));
bgr.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expected, bgr.PackedValue);

2
tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs

@ -190,7 +190,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expectedPackedValue = ushort.MaxValue;
// act
bgra.FromGray16(new Gray16(ushort.MaxValue));
bgra.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expectedPackedValue, bgra.PackedValue);

2
tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs

@ -215,7 +215,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expectedPackedValue = ushort.MaxValue;
// act
bgra.FromGray16(new Gray16(ushort.MaxValue));
bgra.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expectedPackedValue, bgra.PackedValue);

2
tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs

@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
uint expectedPackedValue = uint.MaxValue;
// act
byte4.FromGray16(new Gray16(ushort.MaxValue));
byte4.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expectedPackedValue, byte4.PackedValue);

46
tests/ImageSharp.Tests/PixelFormats/Gray16Tests.cs → tests/ImageSharp.Tests/PixelFormats/L16Tests.cs

@ -7,13 +7,13 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.PixelFormats
{
public class Gray16Tests
public class L16Tests
{
[Fact]
public void AreEqual()
{
var color1 = new Gray16(3000);
var color2 = new Gray16(3000);
var color1 = new L16(3000);
var color2 = new L16(3000);
Assert.Equal(color1, color2);
}
@ -21,8 +21,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Fact]
public void AreNotEqual()
{
var color1 = new Gray16(12345);
var color2 = new Gray16(54321);
var color1 = new L16(12345);
var color2 = new L16(54321);
Assert.NotEqual(color1, color2);
}
@ -32,16 +32,16 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[InlineData(65535)]
[InlineData(32767)]
[InlineData(42)]
public void Gray16_PackedValue_EqualsInput(ushort input)
=> Assert.Equal(input, new Gray16(input).PackedValue);
public void L16_PackedValue_EqualsInput(ushort input)
=> Assert.Equal(input, new L16(input).PackedValue);
[Fact]
public void Gray16_FromScaledVector4()
public void L16_FromScaledVector4()
{
// Arrange
Gray16 gray = default;
L16 gray = default;
const ushort expected = 32767;
Vector4 scaled = new Gray16(expected).ToScaledVector4();
Vector4 scaled = new L16(expected).ToScaledVector4();
// Act
gray.FromScaledVector4(scaled);
@ -55,10 +55,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[InlineData(0)]
[InlineData(65535)]
[InlineData(32767)]
public void Gray16_ToScaledVector4(ushort input)
public void L16_ToScaledVector4(ushort input)
{
// Arrange
var gray = new Gray16(input);
var gray = new L16(input);
// Act
Vector4 actual = gray.ToScaledVector4();
@ -72,12 +72,12 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
[Fact]
public void Gray16_FromVector4()
public void L16_FromVector4()
{
// Arrange
Gray16 gray = default;
L16 gray = default;
const ushort expected = 32767;
var vector = new Gray16(expected).ToVector4();
var vector = new L16(expected).ToVector4();
// Act
gray.FromVector4(vector);
@ -91,10 +91,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[InlineData(0)]
[InlineData(65535)]
[InlineData(32767)]
public void Gray16_ToVector4(ushort input)
public void L16_ToVector4(ushort input)
{
// Arrange
var gray = new Gray16(input);
var gray = new L16(input);
// Act
var actual = gray.ToVector4();
@ -108,10 +108,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
[Fact]
public void Gray16_FromRgba32()
public void L16_FromRgba32()
{
// Arrange
Gray16 gray = default;
L16 gray = default;
const byte rgb = 128;
ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb);
ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb);
@ -128,11 +128,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[InlineData(0)]
[InlineData(65535)]
[InlineData(8100)]
public void Gray16_ToRgba32(ushort input)
public void L16_ToRgba32(ushort input)
{
// Arrange
ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input);
var gray = new Gray16(input);
var gray = new L16(input);
// Act
Rgba32 actual = default;
@ -146,10 +146,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
[Fact]
public void Gray16_FromBgra5551()
public void L16_FromBgra5551()
{
// arrange
var gray = default(Gray16);
var gray = default(L16);
ushort expected = ushort.MaxValue;
// act

2
tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs

@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
byte4.FromGray16(new Gray16(ushort.MaxValue));
byte4.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expected, byte4.ToScaledVector4());

2
tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs

@ -142,7 +142,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
byte4.FromGray16(new Gray16(ushort.MaxValue));
byte4.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expected, byte4.ToScaledVector4());

10
tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs

@ -69,18 +69,18 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
return;
}
// L8 and Gray16 are special implementations of IPixel in that they do not conform to the
// L8 and L16 are special implementations of IPixel in that they do not conform to the
// standard RGBA colorspace format and must be converted from RGBA using the special ITU BT709 algorithm.
// One of the requirements of FromScaledVector4/ToScaledVector4 is that it unaware of this and
// packs/unpacks the pixel without and conversion so we employ custom methods do do this.
if (typeof(TDestinationPixel) == typeof(Gray16))
if (typeof(TDestinationPixel) == typeof(L16))
{
ref Gray16 gray16Ref = ref MemoryMarshal.GetReference(
MemoryMarshal.Cast<TDestinationPixel, Gray16>(destinationPixels));
ref L16 L16Ref = ref MemoryMarshal.GetReference(
MemoryMarshal.Cast<TDestinationPixel, L16>(destinationPixels));
for (int i = 0; i < count; i++)
{
ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray16 dp = ref Unsafe.Add(ref gray16Ref, i);
ref L16 dp = ref Unsafe.Add(ref L16Ref, i);
dp.ConvertFromRgbaScaledVector4(sp.ToScaledVector4());
}

6
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray16OperationsTests.cs

@ -10,15 +10,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
{
public partial class PixelOperationsTests
{
public class Gray16OperationsTests : PixelOperationsTests<Gray16>
public class L16OperationsTests : PixelOperationsTests<L16>
{
public Gray16OperationsTests(ITestOutputHelper output)
public L16OperationsTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void IsSpecialImplementation() => Assert.IsType<Gray16.PixelOperations>(PixelOperations<Gray16>.Instance);
public void IsSpecialImplementation() => Assert.IsType<L16.PixelOperations>(PixelOperations<L16>.Instance);
}
}

24
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs

@ -285,7 +285,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
default(Bgra32),
default(Rgb24),
default(L8),
default(Gray16),
default(L16),
default(Rgb48),
default(Rgba64)
};
@ -803,11 +803,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
[Theory]
[MemberData(nameof(ArraySizesData))]
public void FromGray16(int count)
public void FromL16(int count)
{
Gray16[] source = CreateVector4TestData(count).Select(v =>
L16[] source = CreateVector4TestData(count).Select(v =>
{
Gray16 g = default;
L16 g = default;
g.FromVector4(v);
return g;
}).ToArray();
@ -816,22 +816,22 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
for (int i = 0; i < count; i++)
{
expected[i].FromGray16(source[i]);
expected[i].FromL16(source[i]);
}
TestOperation(
source,
expected,
(s, d) => Operations.FromGray16(this.Configuration, s, d.GetSpan())
(s, d) => Operations.FromL16(this.Configuration, s, d.GetSpan())
);
}
[Theory]
[MemberData(nameof(ArraySizesData))]
public void ToGray16(int count)
public void ToL16(int count)
{
TPixel[] source = CreatePixelTestData(count);
var expected = new Gray16[count];
var expected = new L16[count];
for (int i = 0; i < count; i++)
{
@ -841,7 +841,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
TestOperation(
source,
expected,
(s, d) => Operations.ToGray16(this.Configuration, s, d.GetSpan())
(s, d) => Operations.ToL16(this.Configuration, s, d.GetSpan())
);
}
@ -1016,11 +1016,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
// ReSharper restore PossibleNullReferenceException
}
}
else if (typeof(TDest) == typeof(Gray16))
else if (typeof(TDest) == typeof(L16))
{
// Minor difference is tolerated for 16 bit pixel values
Span<Gray16> expected = MemoryMarshal.Cast<TDest, Gray16>(this.ExpectedDestBuffer.AsSpan());
Span<Gray16> actual = MemoryMarshal.Cast<TDest, Gray16>(this.ActualDestBuffer.GetSpan());
Span<L16> expected = MemoryMarshal.Cast<TDest, L16>(this.ExpectedDestBuffer.AsSpan());
Span<L16> actual = MemoryMarshal.Cast<TDest, L16>(this.ActualDestBuffer.GetSpan());
for (int i = 0; i < count; i++)
{

2
tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs

@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
uint expectedPackedValue = uint.MaxValue;
// act
rgba.FromGray16(new Gray16(ushort.MaxValue));
rgba.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expectedPackedValue, rgba.PackedValue);

2
tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs

@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
rgba.FromGray16(new Gray16(ushort.MaxValue));
rgba.FromL16(new L16(ushort.MaxValue));
// assert
Assert.Equal(expected, rgba.ToScaledVector4());

2
tests/ImageSharp.Tests/TestFormat.cs

@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp.Tests
public void FromBgr24(Bgr24 source) { }
public void FromBgra32(Bgra32 source) { }
public void FromL8(L8 source) { }
public void FromGray16(Gray16 source) { }
public void FromL16(L16 source) { }
public void FromRgb24(Rgb24 source) { }
public void FromRgba32(Rgba32 source) { }
public void ToRgba32(ref Rgba32 dest) { }

2
tests/ImageSharp.Tests/TestImages.cs

@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests
public const string Palette8Bpp = "Png/palette-8bpp.png";
public const string Bpp1 = "Png/bpp1.png";
public const string Gray4Bpp = "Png/gray_4bpp.png";
public const string Gray16Bit = "Png/gray-16.png";
public const string L16Bit = "Png/gray-16.png";
public const string GrayA8Bit = "Png/gray-alpha-8.png";
public const string GrayA8BitInterlaced = "Png/rollsroyce.png";
public const string GrayAlpha1BitInterlaced = "Png/iftbbn0g01.png";

2
tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs

@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
[WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.Rgb48Bpp)]
[WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.Rgb48BppInterlaced)]
[WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.Rgb48BppTrans)]
[WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.Gray16Bit)]
[WithBlankImages(1, 1, PixelTypesToTest48, TestImages.Png.L16Bit)]
public void MagickDecode_16BitDepthImage_IsApproximatelyEquivalentTo_SystemDrawingResult<TPixel>(TestImageProvider<TPixel> dummyProvider, string testImage)
where TPixel : struct, IPixel<TPixel>
{

Loading…
Cancel
Save