Browse Source

Gray8 => L8

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

2
src/ImageSharp/Advanced/AotCompilerTools.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Advanced
Seed<Bgra5551>();
Seed<Byte4>();
Seed<Gray16>();
Seed<Gray8>();
Seed<L8>();
Seed<HalfSingle>();
Seed<HalfVector2>();
Seed<HalfVector4>();

4
src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs

@ -315,11 +315,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
private void Write8Bit<TPixel>(Stream stream, ImageFrame<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
bool isGray8 = typeof(TPixel) == typeof(Gray8);
bool isL8 = typeof(TPixel) == typeof(L8);
using (IMemoryOwner<byte> colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean))
{
Span<byte> colorPalette = colorPaletteBuffer.GetSpan();
if (isGray8)
if (isL8)
{
this.Write8BitGray(stream, image, colorPalette);
}

2
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
this.InitIccProfile();
this.InitDerivedMetadataProperties();
return this.ColorSpace == JpegColorSpace.Grayscale
? (Image)this.PostProcessIntoImage<Gray8>()
? (Image)this.PostProcessIntoImage<L8>()
: this.PostProcessIntoImage<Rgb24>();
}

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

@ -659,7 +659,7 @@ namespace SixLabors.ImageSharp.Formats.Png
rowSpan,
pngMetadata.HasTransparency,
pngMetadata.TransparentGray16.GetValueOrDefault(),
pngMetadata.TransparentGray8.GetValueOrDefault());
pngMetadata.TransparentL8.GetValueOrDefault());
break;
@ -743,7 +743,7 @@ namespace SixLabors.ImageSharp.Formats.Png
increment,
pngMetadata.HasTransparency,
pngMetadata.TransparentGray16.GetValueOrDefault(),
pngMetadata.TransparentGray8.GetValueOrDefault());
pngMetadata.TransparentL8.GetValueOrDefault());
break;
@ -841,7 +841,7 @@ namespace SixLabors.ImageSharp.Formats.Png
}
else
{
pngMetadata.TransparentGray8 = new Gray8(ReadByteLittleEndian(alpha, 0));
pngMetadata.TransparentL8 = new L8(ReadByteLittleEndian(alpha, 0));
}
pngMetadata.HasTransparency = true;

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

@ -218,7 +218,7 @@ namespace SixLabors.ImageSharp.Formats.Png
if (this.bitDepth == 8)
{
// 8 bit grayscale
PixelOperations<TPixel>.Instance.ToGray8Bytes(
PixelOperations<TPixel>.Instance.ToL8Bytes(
this.configuration,
rowSpan,
rawScanlineSpan,
@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Span<byte> tempSpan = temp.GetSpan();
// We need to first create an array of luminance bytes then scale them down to the correct bit depth.
PixelOperations<TPixel>.Instance.ToGray8Bytes(
PixelOperations<TPixel>.Instance.ToL8Bytes(
this.configuration,
rowSpan,
tempSpan,
@ -766,10 +766,10 @@ namespace SixLabors.ImageSharp.Formats.Png
BinaryPrimitives.WriteUInt16LittleEndian(alpha, pngMetadata.TransparentGray16.Value.PackedValue);
this.WriteChunk(stream, PngChunkType.Transparency, this.chunkDataBuffer, 0, 2);
}
else if (pngMetadata.TransparentGray8.HasValue)
else if (pngMetadata.TransparentL8.HasValue)
{
alpha.Clear();
alpha[1] = pngMetadata.TransparentGray8.Value.PackedValue;
alpha[1] = pngMetadata.TransparentL8.Value.PackedValue;
this.WriteChunk(stream, PngChunkType.Transparency, this.chunkDataBuffer, 0, 2);
}
}

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

@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.Gamma = other.Gamma;
this.InterlaceMethod = other.InterlaceMethod;
this.HasTransparency = other.HasTransparency;
this.TransparentGray8 = other.TransparentGray8;
this.TransparentL8 = other.TransparentL8;
this.TransparentGray16 = other.TransparentGray16;
this.TransparentRgb24 = other.TransparentRgb24;
this.TransparentRgb48 = other.TransparentRgb48;
@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// Gets or sets the 8 bit grayscale transparent color.
/// This represents any color in an 8 bit grayscale encoded png that should be transparent.
/// </summary>
public Gray8? TransparentGray8 { get; set; }
public L8? TransparentL8 { get; set; }
/// <summary>
/// Gets or sets the 16 bit grayscale transparent color.

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Formats.Png
Span<TPixel> rowSpan,
bool hasTrans,
Gray16 luminance16Trans,
Gray8 luminanceTrans)
L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel>
{
TPixel pixel = default;
@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Formats.Png
for (int x = 0; x < header.Width; x++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor);
pixel.FromGray8(new Gray8(luminance));
pixel.FromL8(new L8(luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
}
}
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Formats.Png
int increment,
bool hasTrans,
Gray16 luminance16Trans,
Gray8 luminanceTrans)
L8 luminanceTrans)
where TPixel : struct, IPixel<TPixel>
{
TPixel pixel = default;
@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.Formats.Png
for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++)
{
byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor);
pixel.FromGray8(new Gray8(luminance));
pixel.FromL8(new L8(luminance));
Unsafe.Add(ref rowSpanRef, x) = pixel;
}
}
@ -576,4 +576,4 @@ namespace SixLabors.ImageSharp.Formats.Png
}
}
}
}
}

6
src/ImageSharp/Formats/Tga/TgaDecoderCore.cs

@ -301,7 +301,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
switch (colorMapPixelSizeInBytes)
{
case 1:
color.FromGray8(Unsafe.As<byte, Gray8>(ref palette[bufferSpan[idx] * colorMapPixelSizeInBytes]));
color.FromL8(Unsafe.As<byte, L8>(ref palette[bufferSpan[idx] * colorMapPixelSizeInBytes]));
break;
case 2:
// Set alpha value to 1, to treat it as opaque for Bgra5551.
@ -341,7 +341,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
this.currentStream.Read(row);
int newY = Invert(y, height, inverted);
Span<TPixel> pixelSpan = pixels.GetRowSpan(newY);
PixelOperations<TPixel>.Instance.FromGray8Bytes(
PixelOperations<TPixel>.Instance.FromL8Bytes(
this.configuration,
row.GetSpan(),
pixelSpan,
@ -467,7 +467,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
switch (bytesPerPixel)
{
case 1:
color.FromGray8(Unsafe.As<byte, Gray8>(ref bufferSpan[idx]));
color.FromL8(Unsafe.As<byte, L8>(ref bufferSpan[idx]));
break;
case 2:
// Set alpha value to 1, to treat it as opaque for Bgra5551.

2
src/ImageSharp/Formats/Tga/TgaEncoderCore.cs

@ -251,7 +251,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
for (int y = pixels.Height - 1; y >= 0; y--)
{
Span<TPixel> pixelSpan = pixels.GetRowSpan(y);
PixelOperations<TPixel>.Instance.ToGray8Bytes(
PixelOperations<TPixel>.Instance.ToL8Bytes(
this.configuration,
pixelSpan,
row.GetSpan(),

8
src/ImageSharp/ImageSharp.csproj

@ -76,10 +76,10 @@
<AutoGen>True</AutoGen>
<DependentUpon>Bgra32.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Gray8.PixelOperations.Generated.cs">
<Compile Update="PixelFormats\PixelImplementations\Generated\L8.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Gray8.PixelOperations.Generated.tt</DependentUpon>
<DependentUpon>L8.PixelOperations.Generated.tt</DependentUpon>
</Compile>
<Compile Update="PixelFormats\PixelImplementations\Generated\Gray16.PixelOperations.Generated.cs">
<DesignTime>True</DesignTime>
@ -151,9 +151,9 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Bgra32.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Gray8.PixelOperations.Generated.tt">
<None Update="PixelFormats\PixelImplementations\Generated\L8.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Gray8.PixelOperations.Generated.cs</LastGenOutput>
<LastGenOutput>L8.PixelOperations.Generated.cs</LastGenOutput>
</None>
<None Update="PixelFormats\PixelImplementations\Generated\Gray16.PixelOperations.Generated.tt">
<Generator>TextTemplatingFileGenerator</Generator>

6
src/ImageSharp/PixelFormats/IPixel.cs

@ -80,10 +80,10 @@ namespace SixLabors.ImageSharp.PixelFormats
void FromBgra32(Bgra32 source);
/// <summary>
/// Initializes the pixel instance from an <see cref="Gray8"/> value.
/// Initializes the pixel instance from an <see cref="L8"/> value.
/// </summary>
/// <param name="source">The <see cref="Gray8"/> value.</param>
void FromGray8(Gray8 source);
/// <param name="source">The <see cref="L8"/> value.</param>
void FromL8(L8 source);
/// <summary>
/// Initializes the pixel instance from an <see cref="Gray16"/> value.

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

@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.PackedValue = byte.MaxValue;
public void FromL8(L8 source) => this.PackedValue = byte.MaxValue;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

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

@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

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

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -185,7 +185,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

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

@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

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

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

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

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

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

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

@ -97,18 +97,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<Gray8> destPixels)
internal override void ToL8(Configuration configuration, ReadOnlySpan<Gray16> sourcePixels, Span<L8> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
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 Gray8 dp = ref Unsafe.Add(ref destRef, i);
ref L8 dp = ref Unsafe.Add(ref destRef, i);
dp.FromGray16(sp);
}

76
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs → src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs

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

6
src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt → src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.tt

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

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

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

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

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

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

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

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

@ -97,18 +97,18 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <inheritdoc />
internal override void ToGray8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<Gray8> destPixels)
internal override void ToL8(Configuration configuration, ReadOnlySpan<Rgba64> sourcePixels, Span<L8> destPixels)
{
Guard.NotNull(configuration, nameof(configuration));
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray8 destRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray8 dp = ref Unsafe.Add(ref destRef, i);
ref L8 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", "Gray8", "Gray16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
static readonly string[] CommonPixelTypes = { "Argb32", "Bgr24", "Bgra32", "L8", "Gray16", "Rgb24", "Rgba32", "Rgb48", "Rgba64" };
static readonly string[] Optimized32BitTypes = { "Rgba32", "Argb32", "Bgra32" };

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

@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue);
public void FromL8(L8 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

34
src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs → src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -7,49 +7,49 @@ using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.PixelFormats
{
/// <summary>
/// Packed pixel type containing a single 8 bit normalized gray values.
/// Packed pixel type containing a single 8 bit normalized luminance value.
/// <para>
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para>
/// </summary>
public partial struct Gray8 : IPixel<Gray8>, IPackedVector<byte>
public partial struct L8 : IPixel<L8>, IPackedVector<byte>
{
private static readonly Vector4 MaxBytes = new Vector4(255F);
private static readonly Vector4 Half = new Vector4(0.5F);
/// <summary>
/// Initializes a new instance of the <see cref="Gray8"/> struct.
/// Initializes a new instance of the <see cref="L8"/> struct.
/// </summary>
/// <param name="luminance">The luminance component.</param>
public Gray8(byte luminance) => this.PackedValue = luminance;
public L8(byte luminance) => this.PackedValue = luminance;
/// <inheritdoc />
public byte PackedValue { get; set; }
/// <summary>
/// Compares two <see cref="Gray8"/> objects for equality.
/// Compares two <see cref="L8"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Gray8"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Gray8"/> on the right side of the operand.</param>
/// <param name="left">The <see cref="L8"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="L8"/> 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 ==(Gray8 left, Gray8 right) => left.Equals(right);
public static bool operator ==(L8 left, L8 right) => left.Equals(right);
/// <summary>
/// Compares two <see cref="Gray8"/> objects for equality.
/// Compares two <see cref="L8"/> objects for equality.
/// </summary>
/// <param name="left">The <see cref="Gray8"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="Gray8"/> on the right side of the operand.</param>
/// <param name="left">The <see cref="L8"/> on the left side of the operand.</param>
/// <param name="right">The <see cref="L8"/> 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 !=(Gray8 left, Gray8 right) => !left.Equals(right);
public static bool operator !=(L8 left, L8 right) => !left.Equals(right);
/// <inheritdoc />
public PixelOperations<Gray8> CreatePixelOperations() => new PixelOperations();
public PixelOperations<L8> CreatePixelOperations() => new PixelOperations();
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.PackedValue = source.PackedValue;
public void FromL8(L8 source) => this.PackedValue = source.PackedValue;
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -130,14 +130,14 @@ namespace SixLabors.ImageSharp.PixelFormats
ImageMaths.DownScaleFrom16BitTo8Bit(source.B));
/// <inheritdoc />
public override bool Equals(object obj) => obj is Gray8 other && this.Equals(other);
public override bool Equals(object obj) => obj is L8 other && this.Equals(other);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public bool Equals(Gray8 other) => this.PackedValue.Equals(other.PackedValue);
public bool Equals(L8 other) => this.PackedValue.Equals(other.PackedValue);
/// <inheritdoc />
public override string ToString() => $"Gray8({this.PackedValue})";
public override string ToString() => $"L8({this.PackedValue})";
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -118,7 +118,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

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

@ -132,7 +132,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue);
this.R = rgb;

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

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -307,7 +307,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
this.R = source.PackedValue;
this.G = source.PackedValue;

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

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source)
public void FromL8(L8 source)
{
ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue);
this.R = rgb;
@ -399,4 +399,4 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(InliningOptions.ShortMethod)]
public override int GetHashCode() => this.PackedValue.GetHashCode();
}
}
}

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

@ -46,17 +46,17 @@ namespace SixLabors.ImageSharp.PixelFormats
Vector4Converters.ApplyForwardConversionModifiers(destVectors, modifiers);
}
internal override void ToGray8(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<Gray8> destPixels)
internal override void ToL8(Configuration configuration, ReadOnlySpan<RgbaVector> sourcePixels, Span<L8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref Vector4 sourceBaseRef = ref Unsafe.As<RgbaVector, Vector4>(ref MemoryMarshal.GetReference(sourcePixels));
ref Gray8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref Vector4 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Gray8 dp = ref Unsafe.Add(ref destBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, i);
dp.ConvertFromRgbaScaledVector4(sp);
}

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

@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -122,7 +122,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4());
public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4());
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

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

@ -227,75 +227,75 @@ namespace SixLabors.ImageSharp.PixelFormats
}
/// <summary>
/// Converts all pixels in 'source` span of <see cref="Gray8"/> into a span of <typeparamref name="TPixel"/>-s.
/// Converts all pixels in 'source` span of <see cref="L8"/> 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="Gray8"/> data.</param>
/// <param name="source">The source <see cref="Span{T}"/> of <see cref="L8"/> data.</param>
/// <param name="destPixels">The <see cref="Span{T}"/> to the destination pixels.</param>
internal virtual void FromGray8(Configuration configuration, ReadOnlySpan<Gray8> source, Span<TPixel> destPixels)
internal virtual void FromL8(Configuration configuration, ReadOnlySpan<L8> source, Span<TPixel> destPixels)
{
Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels));
ref Gray8 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref L8 sourceBaseRef = ref MemoryMarshal.GetReference(source);
ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < source.Length; i++)
{
ref Gray8 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref L8 sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i);
dp.FromGray8(sp);
dp.FromL8(sp);
}
}
/// <summary>
/// A helper for <see cref="FromGray8(Configuration, ReadOnlySpan{Gray8}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="Gray8"/> layout.
/// A helper for <see cref="FromL8(Configuration, ReadOnlySpan{L8}, Span{TPixel})"/> that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with <see cref="L8"/> 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 FromGray8Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
internal void FromL8Bytes(Configuration configuration, ReadOnlySpan<byte> sourceBytes, Span<TPixel> destPixels, int count)
{
this.FromGray8(configuration, MemoryMarshal.Cast<byte, Gray8>(sourceBytes).Slice(0, count), destPixels);
this.FromL8(configuration, MemoryMarshal.Cast<byte, L8>(sourceBytes).Slice(0, count), destPixels);
}
/// <summary>
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="Gray8"/>-s.
/// Converts all pixels of the 'sourcePixels` span to a span of <see cref="L8"/>-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="Gray8"/> data.</param>
internal virtual void ToGray8(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<Gray8> destPixels)
/// <param name="destPixels">The destination span of <see cref="L8"/> data.</param>
internal virtual void ToL8(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<L8> destPixels)
{
Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels));
ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
ref Gray8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
ref L8 destBaseRef = ref MemoryMarshal.GetReference(destPixels);
for (int i = 0; i < sourcePixels.Length; i++)
{
ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
ref Gray8 dp = ref Unsafe.Add(ref destBaseRef, i);
ref L8 dp = ref Unsafe.Add(ref destBaseRef, i);
dp.FromScaledVector4(sp.ToScaledVector4());
}
}
/// <summary>
/// A helper for <see cref="ToGray8(Configuration, ReadOnlySpan{TPixel}, Span{Gray8})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="Gray8"/> layout.
/// A helper for <see cref="ToL8(Configuration, ReadOnlySpan{TPixel}, Span{L8})"/> that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with <see cref="L8"/> 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 ToGray8Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
internal void ToL8Bytes(Configuration configuration, ReadOnlySpan<TPixel> sourcePixels, Span<byte> destBytes, int count)
{
this.ToGray8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, Gray8>(destBytes));
this.ToL8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast<byte, L8>(destBytes));
}
/// <summary>

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

@ -118,8 +118,8 @@ namespace SixLabors.ImageSharp.PixelFormats
GenerateFromMethods("Bgra32");
GenerateToDestFormatMethods("Bgra32");
GenerateFromMethods("Gray8");
GenerateToDestFormatMethods("Gray8");
GenerateFromMethods("L8");
GenerateToDestFormatMethods("L8");
GenerateFromMethods("Gray16");
GenerateToDestFormatMethods("Gray16");

4
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
where TPixel : struct, IPixel<TPixel> => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true);
[Theory]
[WithFile(Bit8Gs, PixelTypes.Gray8, BmpBitsPerPixel.Pixel8)]
[WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)]
public void Encode_8BitGray_WithV3Header_Works<TPixel>(TestImageProvider<TPixel> provider, BmpBitsPerPixel bitsPerPixel)
where TPixel : struct, IPixel<TPixel> =>
TestBmpEncoderCore(
@ -176,7 +176,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
supportTransparency: false);
[Theory]
[WithFile(Bit8Gs, PixelTypes.Gray8, BmpBitsPerPixel.Pixel8)]
[WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)]
public void Encode_8BitGray_WithV4Header_Works<TPixel>(TestImageProvider<TPixel> provider, BmpBitsPerPixel bitsPerPixel)
where TPixel : struct, IPixel<TPixel> =>
TestBmpEncoderCore(

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

@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
TestImages.Png.GrayTrns16BitInterlaced
};
public static readonly string[] TestImagesGray8BitInterlaced =
public static readonly string[] TestImagesL8BitInterlaced =
{
TestImages.Png.GrayAlpha1BitInterlaced,
TestImages.Png.GrayAlpha2BitInterlaced,
@ -144,8 +144,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
}
[Theory]
[WithFileCollection(nameof(TestImagesGray8BitInterlaced), PixelTypes.Rgba32)]
public void Decoder_Gray8bitInterlaced<TPixel>(TestImageProvider<TPixel> provider)
[WithFileCollection(nameof(TestImagesL8BitInterlaced), PixelTypes.Rgba32)]
public void Decoder_L8bitInterlaced<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(new PngDecoder()))

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

@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
{ TestImages.Png.Gray1BitTrans, PngBitDepth.Bit1, PngColorType.Grayscale },
{ TestImages.Png.Gray2BitTrans, PngBitDepth.Bit2, PngColorType.Grayscale },
{ TestImages.Png.Gray4BitTrans, PngBitDepth.Bit4, PngColorType.Grayscale },
{ TestImages.Png.Gray8BitTrans, PngBitDepth.Bit8, PngColorType.Grayscale },
{ TestImages.Png.L8BitTrans, PngBitDepth.Bit8, PngColorType.Grayscale },
{ TestImages.Png.GrayTrns16BitInterlaced, PngBitDepth.Bit16, PngColorType.Grayscale },
{ TestImages.Png.Rgb24BppTrans, PngBitDepth.Bit8, PngColorType.Rgb },
{ TestImages.Png.Rgb48BppTrans, PngBitDepth.Bit16, PngColorType.Rgb }
@ -319,8 +319,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
}
else
{
Assert.True(outMeta.TransparentGray8.HasValue);
Assert.Equal(inMeta.TransparentGray8, outMeta.TransparentGray8);
Assert.True(outMeta.TransparentL8.HasValue);
Assert.Equal(inMeta.TransparentL8, outMeta.TransparentL8);
}
break;

2
tests/ImageSharp.Tests/Image/ImageTests.cs

@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests
configuration.MemoryAllocator = new TestMemoryAllocator(dirtyValue);
var metadata = new ImageMetadata();
using (Image<Gray8> image = Image.CreateUninitialized<Gray8>(configuration, 21, 22, metadata))
using (Image<L8> image = Image.CreateUninitialized<L8>(configuration, 21, 22, metadata))
{
Assert.Equal(21, image.Width);
Assert.Equal(22, image.Height);

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

@ -221,7 +221,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expected = ushort.MaxValue;
// act
bgr.FromGray8(new Gray8(byte.MaxValue));
bgr.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expected, bgr.PackedValue);

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

@ -204,7 +204,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expectedPackedValue = ushort.MaxValue;
// act
bgra.FromGray8(new Gray8(byte.MaxValue));
bgra.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expectedPackedValue, bgra.PackedValue);

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

@ -229,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
ushort expectedPackedValue = ushort.MaxValue;
// act
bgra.FromGray8(new Gray8(byte.MaxValue));
bgra.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expectedPackedValue, bgra.PackedValue);

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

@ -141,7 +141,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
uint expectedPackedValue = uint.MaxValue;
// act
byte4.FromGray8(new Gray8(byte.MaxValue));
byte4.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expectedPackedValue, byte4.PackedValue);

131
tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs → tests/ImageSharp.Tests/PixelFormats/L8Tests.cs

@ -9,65 +9,66 @@ using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.PixelFormats
{
public class Gray8Tests
public class L8Tests
{
public static readonly TheoryData<byte> LuminanceData = new TheoryData<byte>
{
0,
1,
2,
3,
5,
13,
31,
71,
73,
79,
83,
109,
127,
128,
131,
199,
250,
251,
254,
255
};
public static readonly TheoryData<byte> LuminanceData
= new TheoryData<byte>
{
0,
1,
2,
3,
5,
13,
31,
71,
73,
79,
83,
109,
127,
128,
131,
199,
250,
251,
254,
255
};
[Theory]
[InlineData(0)]
[InlineData(255)]
[InlineData(10)]
[InlineData(42)]
public void Gray8_PackedValue_EqualsInput(byte input)
=> Assert.Equal(input, new Gray8(input).PackedValue);
public void L8_PackedValue_EqualsInput(byte input)
=> Assert.Equal(input, new L8(input).PackedValue);
[Fact]
public void AreEqual()
{
var color1 = new Gray8(100);
var color2 = new Gray8(100);
var color1 = new L8(100);
var color2 = new L8(100);
Assert.Equal(color1, color2);
}
[Fact]
public void AreNotEqual()
{
var color1 = new Gray8(100);
var color2 = new Gray8(200);
var color1 = new L8(100);
var color2 = new L8(200);
Assert.NotEqual(color1, color2);
}
[Fact]
public void Gray8_FromScaledVector4()
public void L8_FromScaledVector4()
{
// Arrange
Gray8 gray = default;
L8 gray = default;
const byte expected = 128;
Vector4 scaled = new Gray8(expected).ToScaledVector4();
Vector4 scaled = new L8(expected).ToScaledVector4();
// Act
gray.FromScaledVector4(scaled);
@ -79,10 +80,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_ToScaledVector4(byte input)
public void L8_ToScaledVector4(byte input)
{
// Arrange
var gray = new Gray8(input);
var gray = new L8(input);
// Act
Vector4 actual = gray.ToScaledVector4();
@ -97,11 +98,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_FromVector4(byte luminance)
public void L8_FromVector4(byte luminance)
{
// Arrange
Gray8 gray = default;
var vector = new Gray8(luminance).ToVector4();
L8 gray = default;
var vector = new L8(luminance).ToVector4();
// Act
gray.FromVector4(vector);
@ -113,10 +114,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_ToVector4(byte input)
public void L8_ToVector4(byte input)
{
// Arrange
var gray = new Gray8(input);
var gray = new L8(input);
// Act
var actual = gray.ToVector4();
@ -131,10 +132,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_FromRgba32(byte rgb)
public void L8_FromRgba32(byte rgb)
{
// Arrange
Gray8 gray = default;
L8 gray = default;
byte expected = ImageMaths.Get8BitBT709Luminance(rgb, rgb, rgb);
// Act
@ -145,13 +146,13 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Assert.Equal(expected, actual);
}
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_ToRgba32(byte luminance)
public void L8_ToRgba32(byte luminance)
{
// Arrange
var gray = new Gray8(luminance);
var gray = new L8(luminance);
// Act
Rgba32 actual = default;
@ -165,10 +166,10 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
}
[Fact]
public void Gray8_FromBgra5551()
public void L8_FromBgra5551()
{
// arrange
var grey = default(Gray8);
var grey = default(L8);
byte expected = byte.MaxValue;
// act
@ -181,18 +182,18 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
public class Rgba32Compatibility
{
// ReSharper disable once MemberHidesStaticFromOuterClass
public static readonly TheoryData<byte> LuminanceData = Gray8Tests.LuminanceData;
public static readonly TheoryData<byte> LuminanceData = L8Tests.LuminanceData;
[Theory]
[MemberData(nameof(LuminanceData))]
public void Gray8_FromRgba32_IsInverseOf_ToRgba32(byte luminance)
public void L8_FromRgba32_IsInverseOf_ToRgba32(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
Gray8 mirror = default;
L8 mirror = default;
mirror.FromRgba32(rgba);
Assert.Equal(original, mirror);
@ -201,14 +202,14 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[Theory]
[MemberData(nameof(LuminanceData))]
public void Rgba32_ToGray8_IsInverseOf_Gray8_ToRgba32(byte luminance)
public void Rgba32_ToL8_IsInverseOf_L8_ToRgba32(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
Gray8 mirror = default;
L8 mirror = default;
mirror.FromRgba32(rgba);
Assert.Equal(original, mirror);
@ -218,29 +219,29 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[MemberData(nameof(LuminanceData))]
public void ToVector4_IsRgba32Compatible(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
var gray8Vector = original.ToVector4();
var L8Vector = original.ToVector4();
var rgbaVector = original.ToVector4();
Assert.Equal(gray8Vector, rgbaVector, new ApproximateFloatComparer(1e-5f));
Assert.Equal(L8Vector, rgbaVector, new ApproximateFloatComparer(1e-5f));
}
[Theory]
[MemberData(nameof(LuminanceData))]
public void FromVector4_IsRgba32Compatible(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
Vector4 rgbaVector = original.ToVector4();
Gray8 mirror = default;
L8 mirror = default;
mirror.FromVector4(rgbaVector);
Assert.Equal(original, mirror);
@ -250,29 +251,29 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
[MemberData(nameof(LuminanceData))]
public void ToScaledVector4_IsRgba32Compatible(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
Vector4 gray8Vector = original.ToScaledVector4();
Vector4 L8Vector = original.ToScaledVector4();
Vector4 rgbaVector = original.ToScaledVector4();
Assert.Equal(gray8Vector, rgbaVector, new ApproximateFloatComparer(1e-5f));
Assert.Equal(L8Vector, rgbaVector, new ApproximateFloatComparer(1e-5f));
}
[Theory]
[MemberData(nameof(LuminanceData))]
public void FromScaledVector4_IsRgba32Compatible(byte luminance)
{
var original = new Gray8(luminance);
var original = new L8(luminance);
Rgba32 rgba = default;
original.ToRgba32(ref rgba);
Vector4 rgbaVector = original.ToScaledVector4();
Gray8 mirror = default;
L8 mirror = default;
mirror.FromScaledVector4(rgbaVector);
Assert.Equal(original, mirror);

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

@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
byte4.FromGray8(new Gray8(byte.MaxValue));
byte4.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expected, byte4.ToScaledVector4());

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

@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
byte4.FromGray8(new Gray8(byte.MaxValue));
byte4.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expected, byte4.ToScaledVector4());

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

@ -69,7 +69,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
return;
}
// Gray8 and Gray16 are special implementations of IPixel in that they do not conform to the
// L8 and Gray16 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.
@ -87,14 +87,14 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
return;
}
if (typeof(TDestinationPixel) == typeof(Gray8))
if (typeof(TDestinationPixel) == typeof(L8))
{
ref Gray8 gray8Ref = ref MemoryMarshal.GetReference(
MemoryMarshal.Cast<TDestinationPixel, Gray8>(destinationPixels));
ref L8 L8Ref = ref MemoryMarshal.GetReference(
MemoryMarshal.Cast<TDestinationPixel, L8>(destinationPixels));
for (int i = 0; i < count; i++)
{
ref TSourcePixel sp = ref Unsafe.Add(ref sourceRef, i);
ref Gray8 dp = ref Unsafe.Add(ref gray8Ref, i);
ref L8 dp = ref Unsafe.Add(ref L8Ref, i);
dp.ConvertFromRgbaScaledVector4(sp.ToScaledVector4());
}

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

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

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

@ -284,7 +284,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
default(Rgba32),
default(Bgra32),
default(Rgb24),
default(Gray8),
default(L8),
default(Gray16),
default(Rgb48),
default(Rgba64)
@ -763,31 +763,31 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
[Theory]
[MemberData(nameof(ArraySizesData))]
public void FromGray8(int count)
public void FromL8(int count)
{
byte[] sourceBytes = CreateByteTestData(count);
Gray8[] source = sourceBytes.Select(b => new Gray8(b)).ToArray();
L8[] source = sourceBytes.Select(b => new L8(b)).ToArray();
var expected = new TPixel[count];
for (int i = 0; i < count; i++)
{
expected[i].FromGray8(source[i]);
expected[i].FromL8(source[i]);
}
TestOperation(
source,
expected,
(s, d) => Operations.FromGray8(this.Configuration, s, d.GetSpan())
(s, d) => Operations.FromL8(this.Configuration, s, d.GetSpan())
);
}
[Theory]
[MemberData(nameof(ArraySizesData))]
public void ToGray8(int count)
public void ToL8(int count)
{
TPixel[] source = CreatePixelTestData(count);
var expected = new Gray8[count];
var expected = new L8[count];
for (int i = 0; i < count; i++)
{
@ -797,7 +797,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
TestOperation(
source,
expected,
(s, d) => Operations.ToGray8(this.Configuration, s, d.GetSpan())
(s, d) => Operations.ToL8(this.Configuration, s, d.GetSpan())
);
}

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

@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
uint expectedPackedValue = uint.MaxValue;
// act
rgba.FromGray8(new Gray8(byte.MaxValue));
rgba.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expectedPackedValue, rgba.PackedValue);

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

@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
Vector4 expected = Vector4.One;
// act
rgba.FromGray8(new Gray8(byte.MaxValue));
rgba.FromL8(new L8(byte.MaxValue));
// assert
Assert.Equal(expected, rgba.ToScaledVector4());

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs

@ -132,7 +132,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
}
[Theory]
[WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32 | PixelTypes.Gray8)]
[WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32 | PixelTypes.L8)]
public void BokehBlurFilterProcessor_WorksWithAllPixelTypes<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{

2
tests/ImageSharp.Tests/TestFormat.cs

@ -252,7 +252,7 @@ namespace SixLabors.ImageSharp.Tests
public void FromBgra5551(Bgra5551 source) { }
public void FromBgr24(Bgr24 source) { }
public void FromBgra32(Bgra32 source) { }
public void FromGray8(Gray8 source) { }
public void FromL8(L8 source) { }
public void FromGray16(Gray16 source) { }
public void FromRgb24(Rgb24 source) { }
public void FromRgba32(Rgba32 source) { }

2
tests/ImageSharp.Tests/TestImages.cs

@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests
public const string Gray1BitTrans = "Png/gray-1-trns.png";
public const string Gray2BitTrans = "Png/gray-2-tRNS.png";
public const string Gray4BitTrans = "Png/gray-4-tRNS.png";
public const string Gray8BitTrans = "Png/gray-8-tRNS.png";
public const string L8BitTrans = "Png/gray-8-tRNS.png";
public const string LowColorVariance = "Png/low-variance.png";
public const string PngWithMetaData = "Png/PngWithMetaData.png";
public const string InvalidTextData = "Png/InvalidTextData.png";

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

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests
Bgra5551 = 1 << 22,
Gray8 = 1 << 23,
L8 = 1 << 23,
// TODO: Add multi-flag entries by rules defined in PackedPixelConverterHelper

Loading…
Cancel
Save