diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs index 5d172d93f7..60c1f4178a 100644 --- a/src/ImageSharp/Advanced/AotCompilerTools.cs +++ b/src/ImageSharp/Advanced/AotCompilerTools.cs @@ -40,7 +40,7 @@ static AotCompilerTools() /// private static void SeedEverything() { - Seed(); + Seed(); Seed(); Seed(); Seed(); @@ -48,8 +48,10 @@ private static void SeedEverything() Seed(); Seed(); Seed(); - Seed(); - Seed(); + Seed(); + Seed(); + Seed(); + Seed(); Seed(); Seed(); Seed(); diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index c51a54a40b..122952caeb 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -38,7 +38,7 @@ public static int GetBT709Luminance(ref Vector4 vector, int luminanceLevels) /// The . [MethodImpl(InliningOptions.ShortMethod)] public static byte Get8BitBT709Luminance(byte r, byte g, byte b) => - (byte)((r * .2126F) + (g * .7152F) + (b * .0722F) + 0.5f); + (byte)((r * .2126F) + (g * .7152F) + (b * .0722F) + 0.5F); /// /// Gets the luminance from the rgb components using the formula as specified by ITU-R Recommendation BT.709. @@ -49,7 +49,7 @@ public static byte Get8BitBT709Luminance(byte r, byte g, byte b) => /// The . [MethodImpl(InliningOptions.ShortMethod)] public static ushort Get16BitBT709Luminance(ushort r, ushort g, ushort b) => - (ushort)((r * .2126F) + (g * .7152F) + (b * .0722F)); + (ushort)((r * .2126F) + (g * .7152F) + (b * .0722F) + 0.5F); /// /// Gets the luminance from the rgb components using the formula as specified by ITU-R Recommendation BT.709. @@ -60,7 +60,7 @@ public static ushort Get16BitBT709Luminance(ushort r, ushort g, ushort b) => /// The . [MethodImpl(InliningOptions.ShortMethod)] public static ushort Get16BitBT709Luminance(float r, float g, float b) => - (ushort)((r * .2126F) + (g * .7152F) + (b * .0722F)); + (ushort)((r * .2126F) + (g * .7152F) + (b * .0722F) + 0.5F); /// /// Scales a value from a 16 bit to it's 8 bit equivalent. diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 03e082cce0..596710294a 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -1321,7 +1321,7 @@ private void ReadInfoHeader() this.metadata = meta; short bitsPerPixel = this.infoHeader.BitsPerPixel; - this.bmpMetadata = this.metadata.GetFormatMetadata(BmpFormat.Instance); + this.bmpMetadata = this.metadata.GetBmpMetadata(); this.bmpMetadata.InfoHeaderType = infoHeaderType; // We can only encode at these bit rates so far (1 bit and 4 bit are still missing). diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index a5e1ee5dbc..f7576bacbd 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -105,7 +105,7 @@ public void Encode(Image image, Stream stream) this.configuration = image.GetConfiguration(); ImageMetadata metadata = image.Metadata; - BmpMetadata bmpMetadata = metadata.GetFormatMetadata(BmpFormat.Instance); + BmpMetadata bmpMetadata = metadata.GetBmpMetadata(); this.bitsPerPixel = this.bitsPerPixel ?? bmpMetadata.BitsPerPixel; short bpp = (short)this.bitsPerPixel; @@ -315,11 +315,11 @@ private void Write16Bit(Stream stream, Buffer2D pixels) private void Write8Bit(Stream stream, ImageFrame image) where TPixel : struct, IPixel { - bool isGray8 = typeof(TPixel) == typeof(Gray8); + bool isL8 = typeof(TPixel) == typeof(L8); using (IMemoryOwner colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean)) { Span colorPalette = colorPaletteBuffer.GetSpan(); - if (isGray8) + if (isL8) { this.Write8BitGray(stream, image, colorPalette); } diff --git a/src/ImageSharp/Formats/Bmp/BmpMetaData.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs similarity index 100% rename from src/ImageSharp/Formats/Bmp/BmpMetaData.cs rename to src/ImageSharp/Formats/Bmp/BmpMetadata.cs diff --git a/src/ImageSharp/Formats/Bmp/MetadataExtensions.cs b/src/ImageSharp/Formats/Bmp/MetadataExtensions.cs new file mode 100644 index 0000000000..0315b3c768 --- /dev/null +++ b/src/ImageSharp/Formats/Bmp/MetadataExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Bmp; +using SixLabors.ImageSharp.Metadata; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods for the type. + /// + public static partial class MetadataExtensions + { + /// + /// Gets the bmp format specific metadata for the image. + /// + /// The metadata this method extends. + /// The . + public static BmpMetadata GetBmpMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(BmpFormat.Instance); + } +} diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index c11e93a93a..b4d92b15dd 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -553,7 +553,7 @@ private void RestoreToBackground(ImageFrame frame) [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SetFrameMetadata(ImageFrameMetadata meta) { - GifFrameMetadata gifMeta = meta.GetFormatMetadata(GifFormat.Instance); + GifFrameMetadata gifMeta = meta.GetGifMetadata(); if (this.graphicsControlExtension.DelayTime > 0) { gifMeta.FrameDelay = this.graphicsControlExtension.DelayTime; @@ -615,7 +615,7 @@ private void ReadLogicalScreenDescriptorAndGlobalColorTable(Stream stream) } this.metadata = meta; - this.gifMetadata = meta.GetFormatMetadata(GifFormat.Instance); + this.gifMetadata = meta.GetGifMetadata(); this.gifMetadata.ColorTableMode = this.logicalScreenDescriptor.GlobalColorTableFlag ? GifColorTableMode.Global : GifColorTableMode.Local; diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index c8fc448125..f8b40306b8 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -78,7 +78,7 @@ public void Encode(Image image, Stream stream) this.configuration = image.GetConfiguration(); ImageMetadata metadata = image.Metadata; - GifMetadata gifMetadata = metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata gifMetadata = metadata.GetGifMetadata(); this.colorTableMode = this.colorTableMode ?? gifMetadata.ColorTableMode; bool useGlobalTable = this.colorTableMode == GifColorTableMode.Global; @@ -136,7 +136,7 @@ private void EncodeGlobal(Image image, IQuantizedFrame q { ImageFrame frame = image.Frames[i]; ImageFrameMetadata metadata = frame.Metadata; - GifFrameMetadata frameMetadata = metadata.GetFormatMetadata(GifFormat.Instance); + GifFrameMetadata frameMetadata = metadata.GetGifMetadata(); this.WriteGraphicalControlExtension(frameMetadata, transparencyIndex, stream); this.WriteImageDescriptor(frame, false, stream); @@ -166,7 +166,7 @@ private void EncodeLocal(Image image, IQuantizedFrame qu foreach (ImageFrame frame in image.Frames) { ImageFrameMetadata metadata = frame.Metadata; - GifFrameMetadata frameMetadata = metadata.GetFormatMetadata(GifFormat.Instance); + GifFrameMetadata frameMetadata = metadata.GetGifMetadata(); if (quantized is null) { // Allow each frame to be encoded at whatever color depth the frame designates if set. diff --git a/src/ImageSharp/Formats/Gif/GifFrameMetaData.cs b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifFrameMetaData.cs rename to src/ImageSharp/Formats/Gif/GifFrameMetadata.cs diff --git a/src/ImageSharp/Formats/Gif/GifMetaData.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs similarity index 100% rename from src/ImageSharp/Formats/Gif/GifMetaData.cs rename to src/ImageSharp/Formats/Gif/GifMetadata.cs diff --git a/src/ImageSharp/Formats/Gif/MetadataExtensions.cs b/src/ImageSharp/Formats/Gif/MetadataExtensions.cs new file mode 100644 index 0000000000..7c432d26fe --- /dev/null +++ b/src/ImageSharp/Formats/Gif/MetadataExtensions.cs @@ -0,0 +1,28 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Gif; +using SixLabors.ImageSharp.Metadata; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods for the type. + /// + public static partial class MetadataExtensions + { + /// + /// Gets the gif format specific metadata for the image. + /// + /// The metadata this method extends. + /// The . + public static GifMetadata GetGifMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(GifFormat.Instance); + + /// + /// Gets the gif format specific metadata for the image frame. + /// + /// The metadata this method extends. + /// The . + public static GifFrameMetadata GetGifMetadata(this ImageFrameMetadata metadata) => metadata.GetFormatMetadata(GifFormat.Instance); + } +} diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs index 8dafdac795..e8e84de7d8 100644 --- a/src/ImageSharp/Formats/IImageDecoder.cs +++ b/src/ImageSharp/Formats/IImageDecoder.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.IO; @@ -17,17 +17,16 @@ public interface IImageDecoder /// The pixel format. /// The configuration for the image. /// The containing image data. - /// The decoded image of a given pixel type. + /// The . Image Decode(Configuration configuration, Stream stream) where TPixel : struct, IPixel; /// /// Decodes the image from the specified stream to an . - /// The decoder is free to choose the pixel type. /// /// The configuration for the image. /// The containing image data. - /// The decoded image of a pixel type chosen by the decoder. + /// The . Image Decode(Configuration configuration, Stream stream); } } diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index a1bf048521..4e1c0c1beb 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.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.IO; @@ -28,6 +28,10 @@ public Image Decode(Configuration configuration, Stream stream) } } + /// + public Image Decode(Configuration configuration, Stream stream) + => this.Decode(configuration, stream); + /// public IImageInfo Identify(Configuration configuration, Stream stream) { @@ -38,8 +42,5 @@ public IImageInfo Identify(Configuration configuration, Stream stream) return decoder.Identify(stream); } } - - /// - public Image Decode(Configuration configuration, Stream stream) => this.Decode(configuration, stream); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index c15fe5e274..60709ed00e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -649,48 +649,51 @@ private void ProcessDefineQuantizationTablesMarker(int remaining) switch (quantizationTableSpec >> 4) { case 0: + { + // 8 bit values + if (remaining < 64) { - // 8 bit values - if (remaining < 64) - { - done = true; - break; - } + done = true; + break; + } - this.InputStream.Read(this.temp, 0, 64); - remaining -= 64; + this.InputStream.Read(this.temp, 0, 64); + remaining -= 64; - ref Block8x8F table = ref this.QuantizationTables[tableIndex]; - for (int j = 0; j < 64; j++) - { - table[j] = this.temp[j]; - } + ref Block8x8F table = ref this.QuantizationTables[tableIndex]; + for (int j = 0; j < 64; j++) + { + table[j] = this.temp[j]; } + } - break; + break; case 1: + { + // 16 bit values + if (remaining < 128) { - // 16 bit values - if (remaining < 128) - { - done = true; - break; - } + done = true; + break; + } - this.InputStream.Read(this.temp, 0, 128); - remaining -= 128; + this.InputStream.Read(this.temp, 0, 128); + remaining -= 128; - ref Block8x8F table = ref this.QuantizationTables[tableIndex]; - for (int j = 0; j < 64; j++) - { - table[j] = (this.temp[2 * j] << 8) | this.temp[(2 * j) + 1]; - } + ref Block8x8F table = ref this.QuantizationTables[tableIndex]; + for (int j = 0; j < 64; j++) + { + table[j] = (this.temp[2 * j] << 8) | this.temp[(2 * j) + 1]; } + } + + break; - break; default: + { JpegThrowHelper.ThrowBadQuantizationTable(); break; + } } if (done) diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 0b9eeb609b..bc9bb9543e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -206,7 +206,7 @@ public void Encode(Image image, Stream stream) ImageMetadata metadata = image.Metadata; // System.Drawing produces identical output for jpegs with a quality parameter of 0 and 1. - int qlty = (this.quality ?? metadata.GetFormatMetadata(JpegFormat.Instance).Quality).Clamp(1, 100); + int qlty = (this.quality ?? metadata.GetJpegMetadata().Quality).Clamp(1, 100); this.subsample = this.subsample ?? (qlty >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); // Convert from a quality rating to a scaling factor. diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetaData.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs similarity index 100% rename from src/ImageSharp/Formats/Jpeg/JpegMetaData.cs rename to src/ImageSharp/Formats/Jpeg/JpegMetadata.cs diff --git a/src/ImageSharp/Formats/Jpeg/MetadataExtensions.cs b/src/ImageSharp/Formats/Jpeg/MetadataExtensions.cs new file mode 100644 index 0000000000..53a9d2a35d --- /dev/null +++ b/src/ImageSharp/Formats/Jpeg/MetadataExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Jpeg; +using SixLabors.ImageSharp.Metadata; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods for the type. + /// + public static partial class MetadataExtensions + { + /// + /// Gets the jpeg format specific metadata for the image. + /// + /// The metadata this method extends. + /// The . + public static JpegMetadata GetJpegMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(JpegFormat.Instance); + } +} diff --git a/src/ImageSharp/Formats/Png/MetadataExtensions.cs b/src/ImageSharp/Formats/Png/MetadataExtensions.cs new file mode 100644 index 0000000000..762a6c40cb --- /dev/null +++ b/src/ImageSharp/Formats/Png/MetadataExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Png; +using SixLabors.ImageSharp.Metadata; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods for the type. + /// + public static partial class MetadataExtensions + { + /// + /// Gets the png format specific metadata for the image. + /// + /// The metadata this method extends. + /// The . + public static PngMetadata GetPngMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(PngFormat.Instance); + } +} diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index b24a5eabda..0161797128 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -149,7 +149,7 @@ public Image Decode(Stream stream) where TPixel : struct, IPixel { var metadata = new ImageMetadata(); - PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance); + PngMetadata pngMetadata = metadata.GetPngMetadata(); this.currentStream = stream; this.currentStream.Skip(8); Image image = null; @@ -240,7 +240,7 @@ public Image Decode(Stream stream) public IImageInfo Identify(Stream stream) { var metadata = new ImageMetadata(); - PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance); + PngMetadata pngMetadata = metadata.GetPngMetadata(); this.currentStream = stream; this.currentStream.Skip(8); try @@ -658,8 +658,8 @@ private void ProcessDefilteredScanline(ReadOnlySpan defilteredScan scanlineSpan, rowSpan, pngMetadata.HasTransparency, - pngMetadata.TransparentGray16.GetValueOrDefault(), - pngMetadata.TransparentGray8.GetValueOrDefault()); + pngMetadata.TransparentL16.GetValueOrDefault(), + pngMetadata.TransparentL8.GetValueOrDefault()); break; @@ -742,8 +742,8 @@ private void ProcessInterlacedDefilteredScanline(ReadOnlySpan defi pixelOffset, increment, pngMetadata.HasTransparency, - pngMetadata.TransparentGray16.GetValueOrDefault(), - pngMetadata.TransparentGray8.GetValueOrDefault()); + pngMetadata.TransparentL16.GetValueOrDefault(), + pngMetadata.TransparentL8.GetValueOrDefault()); break; @@ -837,11 +837,11 @@ private void AssignTransparentMarkers(ReadOnlySpan alpha, PngMetadata pngM { 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 { - pngMetadata.TransparentGray8 = new Gray8(ReadByteLittleEndian(alpha, 0)); + pngMetadata.TransparentL8 = new L8(ReadByteLittleEndian(alpha, 0)); } pngMetadata.HasTransparency = true; diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 19c6af27f7..82796c5706 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -199,16 +199,16 @@ private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) if (this.use16Bit) { // 16 bit grayscale - using (IMemoryOwner luminanceBuffer = this.memoryAllocator.Allocate(rowSpan.Length)) + using (IMemoryOwner luminanceBuffer = this.memoryAllocator.Allocate(rowSpan.Length)) { - Span luminanceSpan = luminanceBuffer.GetSpan(); - ref Gray16 luminanceRef = ref MemoryMarshal.GetReference(luminanceSpan); - PixelOperations.Instance.ToGray16(this.configuration, rowSpan, luminanceSpan); + Span luminanceSpan = luminanceBuffer.GetSpan(); + ref L16 luminanceRef = ref MemoryMarshal.GetReference(luminanceSpan); + PixelOperations.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); } } @@ -218,7 +218,7 @@ private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) if (this.bitDepth == 8) { // 8 bit grayscale - PixelOperations.Instance.ToGray8Bytes( + PixelOperations.Instance.ToL8Bytes( this.configuration, rowSpan, rawScanlineSpan, @@ -235,7 +235,7 @@ private void CollectGrayscaleBytes(ReadOnlySpan rowSpan) Span tempSpan = temp.GetSpan(); // We need to first create an array of luminance bytes then scale them down to the correct bit depth. - PixelOperations.Instance.ToGray8Bytes( + PixelOperations.Instance.ToL8Bytes( this.configuration, rowSpan, tempSpan, @@ -761,15 +761,15 @@ private void WriteTransparencyChunk(Stream stream, PngMetadata pngMetadata) } 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.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); } } diff --git a/src/ImageSharp/Formats/Png/PngMetaData.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs similarity index 94% rename from src/ImageSharp/Formats/Png/PngMetaData.cs rename to src/ImageSharp/Formats/Png/PngMetadata.cs index ec8779a59a..87a2080f0f 100644 --- a/src/ImageSharp/Formats/Png/PngMetaData.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -29,8 +29,8 @@ private PngMetadata(PngMetadata other) this.Gamma = other.Gamma; this.InterlaceMethod = other.InterlaceMethod; this.HasTransparency = other.HasTransparency; - this.TransparentGray8 = other.TransparentGray8; - this.TransparentGray16 = other.TransparentGray16; + this.TransparentL8 = other.TransparentL8; + this.TransparentL16 = other.TransparentL16; this.TransparentRgb24 = other.TransparentRgb24; this.TransparentRgb48 = other.TransparentRgb48; @@ -77,13 +77,13 @@ private PngMetadata(PngMetadata other) /// Gets or sets the 8 bit grayscale transparent color. /// This represents any color in an 8 bit grayscale encoded png that should be transparent. /// - public Gray8? TransparentGray8 { get; set; } + public L8? TransparentL8 { get; set; } /// /// Gets or sets the 16 bit grayscale transparent color. /// This represents any color in a 16 bit grayscale encoded png that should be transparent. /// - public Gray16? TransparentGray16 { get; set; } + public L16? TransparentL16 { get; set; } /// /// Gets or sets a value indicating whether the image contains a transparency chunk and markers were decoded. diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index c23694951d..5f9d1de9c5 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/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; @@ -20,8 +20,8 @@ public static void ProcessGrayscaleScanline( ReadOnlySpan scanlineSpan, Span rowSpan, bool hasTrans, - Gray16 luminance16Trans, - Gray8 luminanceTrans) + L16 luminance16Trans, + L8 luminanceTrans) where TPixel : struct, IPixel { TPixel pixel = default; @@ -36,7 +36,7 @@ public static void ProcessGrayscaleScanline( 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(Unsafe.As(ref luminance)); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -45,7 +45,7 @@ public static void ProcessGrayscaleScanline( for (int x = 0; x < header.Width; x++) { byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); - pixel.FromGray8(new Gray8(luminance)); + pixel.FromL8(Unsafe.As(ref luminance)); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -55,32 +55,28 @@ public static void ProcessGrayscaleScanline( if (header.BitDepth == 16) { - Rgba64 rgba64 = default; + La32 source = default; for (int x = 0, o = 0; x < header.Width; x++, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); - rgba64.R = luminance; - rgba64.G = luminance; - rgba64.B = luminance; - rgba64.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; + source.L = luminance; + source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; - pixel.FromRgba64(rgba64); + pixel.FromLa32(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { + La16 source = default; byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); - Rgba32 rgba32 = default; for (int x = 0; x < header.Width; x++) { byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, x) * scaleFactor); - rgba32.R = luminance; - rgba32.G = luminance; - rgba32.B = luminance; - rgba32.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; + source.L = luminance; + source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; - pixel.FromRgba32(rgba32); + pixel.FromLa16(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -93,8 +89,8 @@ public static void ProcessInterlacedGrayscaleScanline( int pixelOffset, int increment, bool hasTrans, - Gray16 luminance16Trans, - Gray8 luminanceTrans) + L16 luminance16Trans, + L8 luminanceTrans) where TPixel : struct, IPixel { TPixel pixel = default; @@ -109,7 +105,7 @@ public static void ProcessInterlacedGrayscaleScanline( 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(Unsafe.As(ref luminance)); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -118,7 +114,7 @@ public static void ProcessInterlacedGrayscaleScanline( 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(Unsafe.As(ref luminance)); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -128,32 +124,28 @@ public static void ProcessInterlacedGrayscaleScanline( if (header.BitDepth == 16) { - Rgba64 rgba64 = default; + La32 source = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 2) { ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); - rgba64.R = luminance; - rgba64.G = luminance; - rgba64.B = luminance; - rgba64.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; + source.L = luminance; + source.A = luminance.Equals(luminance16Trans.PackedValue) ? ushort.MinValue : ushort.MaxValue; - pixel.FromRgba64(rgba64); + pixel.FromLa32(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { + La16 source = default; byte scaledLuminanceTrans = (byte)(luminanceTrans.PackedValue * scaleFactor); - Rgba32 rgba32 = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o++) { byte luminance = (byte)(Unsafe.Add(ref scanlineSpanRef, o) * scaleFactor); - rgba32.R = luminance; - rgba32.G = luminance; - rgba32.B = luminance; - rgba32.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; + source.L = luminance; + source.A = luminance.Equals(scaledLuminanceTrans) ? byte.MinValue : byte.MaxValue; - pixel.FromRgba32(rgba32); + pixel.FromLa16(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -173,35 +165,26 @@ public static void ProcessGrayscaleWithAlphaScanline( if (header.BitDepth == 16) { - Rgba64 rgba64 = default; + La32 source = default; for (int x = 0, o = 0; x < header.Width; x++, o += 4) { - ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); - ushort alpha = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - rgba64.R = luminance; - rgba64.G = luminance; - rgba64.B = luminance; - rgba64.A = alpha; + source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); + source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - pixel.FromRgba64(rgba64); + pixel.FromLa32(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - Rgba32 rgba32 = default; + La16 source = default; for (int x = 0; x < header.Width; x++) { int offset = x * bytesPerPixel; - byte luminance = Unsafe.Add(ref scanlineSpanRef, offset); - byte alpha = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); - - rgba32.R = luminance; - rgba32.G = luminance; - rgba32.B = luminance; - rgba32.A = alpha; + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); - pixel.FromRgba32(rgba32); + pixel.FromLa16(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } @@ -223,34 +206,26 @@ public static void ProcessInterlacedGrayscaleWithAlphaScanline( if (header.BitDepth == 16) { - Rgba64 rgba64 = default; + La32 source = default; for (int x = pixelOffset, o = 0; x < header.Width; x += increment, o += 4) { - ushort luminance = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); - ushort alpha = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - rgba64.R = luminance; - rgba64.G = luminance; - rgba64.B = luminance; - rgba64.A = alpha; + source.L = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); + source.A = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - pixel.FromRgba64(rgba64); + pixel.FromLa32(source); Unsafe.Add(ref rowSpanRef, x) = pixel; } } else { - Rgba32 rgba32 = default; int offset = 0; + La16 source = default; for (int x = pixelOffset; x < header.Width; x += increment) { - byte luminance = Unsafe.Add(ref scanlineSpanRef, offset); - byte alpha = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); - rgba32.R = luminance; - rgba32.G = luminance; - rgba32.B = luminance; - rgba32.A = alpha; + source.L = Unsafe.Add(ref scanlineSpanRef, offset); + source.A = Unsafe.Add(ref scanlineSpanRef, offset + bytesPerSample); - pixel.FromRgba32(rgba32); + pixel.FromLa16(source); Unsafe.Add(ref rowSpanRef, x) = pixel; offset += bytesPerPixel; } @@ -403,12 +378,12 @@ public static void ProcessRgbScanline( } else { + Rgba32 rgba32 = default; ReadOnlySpan rgb24Span = MemoryMarshal.Cast(scanlineSpan); ref Rgb24 rgb24SpanRef = ref MemoryMarshal.GetReference(rgb24Span); for (int x = 0; x < header.Width; x++) { ref readonly Rgb24 rgb24 = ref Unsafe.Add(ref rgb24SpanRef, x); - Rgba32 rgba32 = default; rgba32.Rgb = rgb24; rgba32.A = rgb24.Equals(rgb24Trans) ? byte.MinValue : byte.MaxValue; @@ -576,4 +551,4 @@ public static void ProcessInterlacedRgbaScanline( } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Formats/Tga/MetadataExtensions.cs b/src/ImageSharp/Formats/Tga/MetadataExtensions.cs new file mode 100644 index 0000000000..2b0e405e75 --- /dev/null +++ b/src/ImageSharp/Formats/Tga/MetadataExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Tga; +using SixLabors.ImageSharp.Metadata; + +namespace SixLabors.ImageSharp +{ + /// + /// Extension methods for the type. + /// + public static partial class MetadataExtensions + { + /// + /// Gets the tga format specific metadata for the image. + /// + /// The metadata this method extends. + /// The . + public static TgaMetadata GetTgaMetadata(this ImageMetadata metadata) => metadata.GetFormatMetadata(TgaFormat.Instance); + } +} diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index d861450e04..bfc69d1c8a 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -301,7 +301,7 @@ private void ReadPalettedRle(int width, int height, Buffer2D pix switch (colorMapPixelSizeInBytes) { case 1: - color.FromGray8(Unsafe.As(ref palette[bufferSpan[idx] * colorMapPixelSizeInBytes])); + color.FromL8(Unsafe.As(ref palette[bufferSpan[idx] * colorMapPixelSizeInBytes])); break; case 2: // Set alpha value to 1, to treat it as opaque for Bgra5551. @@ -341,7 +341,7 @@ private void ReadMonoChrome(int width, int height, Buffer2D pixe this.currentStream.Read(row); int newY = Invert(y, height, inverted); Span pixelSpan = pixels.GetRowSpan(newY); - PixelOperations.Instance.FromGray8Bytes( + PixelOperations.Instance.FromL8Bytes( this.configuration, row.GetSpan(), pixelSpan, @@ -467,7 +467,7 @@ private void ReadRle(int width, int height, Buffer2D pixels, int switch (bytesPerPixel) { case 1: - color.FromGray8(Unsafe.As(ref bufferSpan[idx])); + color.FromL8(Unsafe.As(ref bufferSpan[idx])); break; case 2: // Set alpha value to 1, to treat it as opaque for Bgra5551. @@ -573,7 +573,7 @@ private bool ReadFileHeader(Stream stream) this.currentStream.Read(buffer, 0, TgaFileHeader.Size); this.fileHeader = TgaFileHeader.Parse(buffer); this.metadata = new ImageMetadata(); - this.tgaMetadata = this.metadata.GetFormatMetadata(TgaFormat.Instance); + this.tgaMetadata = this.metadata.GetTgaMetadata(); this.tgaMetadata.BitsPerPixel = (TgaBitsPerPixel)this.fileHeader.PixelDepth; // Bit at position 5 of the descriptor indicates, that the origin is top left instead of bottom right. diff --git a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs index 28b87e9857..3f4fb8f934 100644 --- a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs @@ -71,7 +71,7 @@ public void Encode(Image image, Stream stream) this.configuration = image.GetConfiguration(); ImageMetadata metadata = image.Metadata; - TgaMetadata tgaMetadata = metadata.GetFormatMetadata(TgaFormat.Instance); + TgaMetadata tgaMetadata = metadata.GetTgaMetadata(); this.bitsPerPixel = this.bitsPerPixel ?? tgaMetadata.BitsPerPixel; TgaImageType imageType = this.compression is TgaCompression.RunLength ? TgaImageType.RleTrueColor : TgaImageType.TrueColor; @@ -251,7 +251,7 @@ private void Write8Bit(Stream stream, Buffer2D pixels) for (int y = pixels.Height - 1; y >= 0; y--) { Span pixelSpan = pixels.GetRowSpan(y); - PixelOperations.Instance.ToGray8Bytes( + PixelOperations.Instance.ToL8Bytes( this.configuration, pixelSpan, row.GetSpan(), diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 465139b2e5..178098b7fa 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -270,7 +270,7 @@ public static unsafe Image Load( /// /// The byte array containing image data. /// The detected format. - /// A new . + /// The . public static Image Load(byte[] data, out IImageFormat format) => Load(Configuration.Default, data, out format); @@ -279,24 +279,24 @@ public static Image Load(byte[] data, out IImageFormat format) => /// /// The byte array containing encoded image data. /// The decoder. - /// A new . + /// The . public static Image Load(byte[] data, IImageDecoder decoder) => Load(Configuration.Default, data, decoder); /// - /// Load a new instance of from the given encoded byte array. + /// Load a new instance of from the given encoded byte array. /// /// The config for the decoder. /// The byte array containing encoded image data. - /// A new . + /// The . public static Image Load(Configuration config, byte[] data) => Load(config, data, out _); /// - /// Load a new instance of from the given encoded byte array. + /// Load a new instance of from the given encoded byte array. /// /// The config for the decoder. /// The byte array containing image data. /// The decoder. - /// A new . + /// The . public static Image Load(Configuration config, byte[] data, IImageDecoder decoder) { using (var stream = new MemoryStream(data)) @@ -306,12 +306,12 @@ public static Image Load(Configuration config, byte[] data, IImageDecoder decode } /// - /// Load a new instance of from the given encoded byte array. + /// Load a new instance of from the given encoded byte array. /// /// The config for the decoder. /// The byte array containing image data. /// The mime type of the decoded image. - /// A new . + /// The . public static Image Load(Configuration config, byte[] data, out IImageFormat format) { using (var stream = new MemoryStream(data)) @@ -321,10 +321,10 @@ public static Image Load(Configuration config, byte[] data, out IImageFormat for } /// - /// Load a new instance of from the given encoded byte span. + /// Load a new instance of from the given encoded byte span. /// /// The byte span containing image data. - /// A new . + /// The . public static Image Load(ReadOnlySpan data) => Load(Configuration.Default, data); /// @@ -332,7 +332,7 @@ public static Image Load(Configuration config, byte[] data, out IImageFormat for /// /// The byte span containing image data. /// The decoder. - /// A new . + /// The . public static Image Load(ReadOnlySpan data, IImageDecoder decoder) => Load(Configuration.Default, data, decoder); @@ -341,7 +341,7 @@ public static Image Load(ReadOnlySpan data, IImageDecoder decoder) => /// /// The byte span containing image data. /// The detected format. - /// A new . + /// The . public static Image Load(ReadOnlySpan data, out IImageFormat format) => Load(Configuration.Default, data, out format); @@ -350,7 +350,7 @@ public static Image Load(ReadOnlySpan data, out IImageFormat format) => /// /// The configuration options. /// The byte span containing image data. - /// A new . + /// The . public static Image Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _); /// @@ -359,7 +359,7 @@ public static Image Load(ReadOnlySpan data, out IImageFormat format) => /// The Configuration. /// The byte span containing image data. /// The decoder. - /// A new . + /// The . public static unsafe Image Load( Configuration config, ReadOnlySpan data, @@ -380,7 +380,7 @@ public static unsafe Image Load( /// The configuration options. /// The byte span containing image data. /// The of the decoded image.> - /// A new . + /// The . public static unsafe Image Load( Configuration config, ReadOnlySpan data, diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index 08ed381c5a..95b4b9790e 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.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; @@ -39,17 +39,17 @@ public static IImageFormat DetectFormat(Configuration config, string filePath) } /// - /// Create a new instance of the class from the given file. + /// Create a new instance of the class from the given file. /// /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// - /// A new . + /// The . public static Image Load(string path) => Load(Configuration.Default, path); /// - /// Create a new instance of the class from the given file. + /// Create a new instance of the class from the given file. /// /// The file path to the image. /// The mime type of the decoded image. @@ -60,18 +60,18 @@ public static IImageFormat DetectFormat(Configuration config, string filePath) public static Image Load(string path, out IImageFormat format) => Load(Configuration.Default, path, out format); /// - /// Create a new instance of the class from the given file. + /// Create a new instance of the class from the given file. /// /// The config for the decoder. /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// - /// A new . + /// The . public static Image Load(Configuration config, string path) => Load(config, path, out _); /// - /// Create a new instance of the class from the given file. + /// Create a new instance of the class from the given file. /// /// The Configuration. /// The file path to the image. @@ -79,7 +79,7 @@ public static IImageFormat DetectFormat(Configuration config, string filePath) /// /// Thrown if the stream is not readable nor seekable. /// - /// A new . + /// The . public static Image Load(Configuration config, string path, IImageDecoder decoder) { using (Stream stream = config.FileSystem.OpenRead(path)) @@ -89,14 +89,14 @@ public static Image Load(Configuration config, string path, IImageDecoder decode } /// - /// Create a new instance of the class from the given file. + /// Create a new instance of the class from the given file. /// /// The file path to the image. /// The decoder. /// /// Thrown if the stream is not readable nor seekable. /// - /// A new . + /// The . public static Image Load(string path, IImageDecoder decoder) => Load(Configuration.Default, path, decoder); /// @@ -224,4 +224,4 @@ public static Image Load(Configuration config, string path, IIma } } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index 60db45f215..db2cc2fd19 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -80,7 +80,7 @@ public static IImageInfo Identify(Configuration config, Stream stream, out IImag /// The format type of the decoded image. /// Thrown if the stream is not readable. /// Image cannot be loaded. - /// A new .> + /// The . public static Image Load(Stream stream, out IImageFormat format) => Load(Configuration.Default, stream, out format); /// @@ -90,7 +90,7 @@ public static IImageInfo Identify(Configuration config, Stream stream, out IImag /// The stream containing image information. /// Thrown if the stream is not readable. /// Image cannot be loaded. - /// A new .> + /// The . public static Image Load(Stream stream) => Load(Configuration.Default, stream); /// @@ -101,7 +101,7 @@ public static IImageInfo Identify(Configuration config, Stream stream, out IImag /// The decoder. /// Thrown if the stream is not readable. /// Image cannot be loaded. - /// A new .> + /// The . public static Image Load(Stream stream, IImageDecoder decoder) => Load(Configuration.Default, stream, decoder); /// diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 86b0848663..c59f883964 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -1,4 +1,4 @@ - + @@ -76,15 +76,30 @@ True Bgra32.PixelOperations.Generated.tt - + True True - Gray8.PixelOperations.Generated.tt + Bgra5551.PixelOperations.Generated.tt - + True True - Gray16.PixelOperations.Generated.tt + L8.PixelOperations.Generated.tt + + + True + True + L16.PixelOperations.Generated.tt + + + True + True + La16.PixelOperations.Generated.tt + + + True + True + La32.PixelOperations.Generated.tt True @@ -151,13 +166,25 @@ TextTemplatingFileGenerator Bgra32.PixelOperations.Generated.cs - + + TextTemplatingFileGenerator + Bgra5551.PixelOperations.Generated.cs + + + TextTemplatingFileGenerator + L8.PixelOperations.Generated.cs + + + TextTemplatingFileGenerator + L16.PixelOperations.Generated.cs + + TextTemplatingFileGenerator - Gray8.PixelOperations.Generated.cs + La16.PixelOperations.Generated.cs - + TextTemplatingFileGenerator - Gray16.PixelOperations.Generated.cs + La32.PixelOperations.Generated.cs TextTemplatingFileGenerator diff --git a/src/ImageSharp/MetaData/FrameDecodingMode.cs b/src/ImageSharp/Metadata/FrameDecodingMode.cs similarity index 100% rename from src/ImageSharp/MetaData/FrameDecodingMode.cs rename to src/ImageSharp/Metadata/FrameDecodingMode.cs diff --git a/src/ImageSharp/MetaData/ImageFrameMetaData.cs b/src/ImageSharp/Metadata/ImageFrameMetadata.cs similarity index 100% rename from src/ImageSharp/MetaData/ImageFrameMetaData.cs rename to src/ImageSharp/Metadata/ImageFrameMetadata.cs diff --git a/src/ImageSharp/MetaData/ImageMetaData.cs b/src/ImageSharp/Metadata/ImageMetadata.cs similarity index 100% rename from src/ImageSharp/MetaData/ImageMetaData.cs rename to src/ImageSharp/Metadata/ImageMetadata.cs diff --git a/src/ImageSharp/MetaData/PixelResolutionUnit.cs b/src/ImageSharp/Metadata/PixelResolutionUnit.cs similarity index 100% rename from src/ImageSharp/MetaData/PixelResolutionUnit.cs rename to src/ImageSharp/Metadata/PixelResolutionUnit.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifConstants.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifDataType.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifDataType.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifParts.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifParts.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifParts.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifParts.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTag.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifTag.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifTag.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifTag.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifTagDescriptionAttribute.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifTagDescriptionAttribute.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifTagDescriptionAttribute.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifTags.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifTags.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifTags.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifTags.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifValue.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifValue.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/ExifWriter.cs rename to src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs diff --git a/src/ImageSharp/MetaData/Profiles/Exif/README.md b/src/ImageSharp/Metadata/Profiles/Exif/README.md similarity index 100% rename from src/ImageSharp/MetaData/Profiles/Exif/README.md rename to src/ImageSharp/Metadata/Profiles/Exif/README.md diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccCurveSegment.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccCurveSegment.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccCurveSegment.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccFormulaCurveElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccFormulaCurveElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccOneDimensionalCurve.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccOneDimensionalCurve.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccParametricCurve.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccParametricCurve.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccResponseCurve.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccResponseCurve.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccSampledCurveElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/Curves/IccSampledCurveElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Curves/IccSampledCurveElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Curves/IccSampledCurveElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Lut.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Matrix.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Curves.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Lut.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Primitives.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.cs rename to src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccClutDataType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccClutDataType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccClutDataType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccClutDataType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccColorSpaceType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccColorSpaceType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccColorSpaceType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccColorSpaceType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccColorantEncoding.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccColorantEncoding.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccColorantEncoding.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccColorantEncoding.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccCurveMeasurementEncodings.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccCurveMeasurementEncodings.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccCurveMeasurementEncodings.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccCurveMeasurementEncodings.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccCurveSegmentSignature.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccCurveSegmentSignature.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccCurveSegmentSignature.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccCurveSegmentSignature.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccDataType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccDataType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccDataType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccDataType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccDeviceAttribute.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccDeviceAttribute.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccDeviceAttribute.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccDeviceAttribute.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccFormulaCurveType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccFormulaCurveType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccFormulaCurveType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccMeasurementGeometry.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccMeasurementGeometry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccMeasurementGeometry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccMeasurementGeometry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccMultiProcessElementSignature.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccMultiProcessElementSignature.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccMultiProcessElementSignature.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccMultiProcessElementSignature.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccParametricCurveType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccParametricCurveType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccParametricCurveType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccParametricCurveType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccPrimaryPlatformType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccPrimaryPlatformType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccPrimaryPlatformType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccPrimaryPlatformType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileClass.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileClass.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileClass.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileClass.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileFlag.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileFlag.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileFlag.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileFlag.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileTag.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileTag.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccProfileTag.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccProfileTag.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccRenderingIntent.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccRenderingIntent.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccRenderingIntent.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccRenderingIntent.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccScreeningFlag.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccScreeningFlag.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccScreeningFlag.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccScreeningFlag.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccScreeningSpotType.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccScreeningSpotType.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccScreeningSpotType.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccScreeningSpotType.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccSignatureName.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccSignatureName.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccSignatureName.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccSignatureName.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccStandardIlluminant.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccStandardIlluminant.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccStandardIlluminant.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccStandardIlluminant.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccStandardObserver.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccStandardObserver.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccStandardObserver.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccStandardObserver.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Enums/IccTypeSignature.cs b/src/ImageSharp/Metadata/Profiles/ICC/Enums/IccTypeSignature.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Enums/IccTypeSignature.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Enums/IccTypeSignature.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs b/src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Exceptions/InvalidIccProfileException.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/IccProfile.cs rename to src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/IccProfileHeader.cs rename to src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs rename to src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/IccTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs rename to src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccBAcsProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccBAcsProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccBAcsProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccBAcsProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccClutProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccEAcsProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccEAcsProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccEAcsProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccEAcsProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccMatrixProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs rename to src/ImageSharp/Metadata/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccXyzTagDataEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccClut.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccColorantTableEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccColorantTableEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccLocalizedString.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccLocalizedString.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccLut.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccLut.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccNamedColor.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccNamedColor.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccPositionNumber.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccPositionNumber.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileDescription.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileDescription.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileId.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileId.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccResponseNumber.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccResponseNumber.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccScreeningChannel.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccScreeningChannel.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccTagTableEntry.cs diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccVersion.cs b/src/ImageSharp/Metadata/Profiles/ICC/Various/IccVersion.cs similarity index 100% rename from src/ImageSharp/MetaData/Profiles/ICC/Various/IccVersion.cs rename to src/ImageSharp/Metadata/Profiles/ICC/Various/IccVersion.cs diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs index 21ec2a3fdc..61adedb0d0 100644 --- a/src/ImageSharp/PixelFormats/IPixel.cs +++ b/src/ImageSharp/PixelFormats/IPixel.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; @@ -80,16 +80,28 @@ public interface IPixel void FromBgra32(Bgra32 source); /// - /// Initializes the pixel instance from an value. + /// Initializes the pixel instance from an value. /// - /// The value. - void FromGray8(Gray8 source); + /// The value. + void FromL8(L8 source); /// - /// Initializes the pixel instance from an value. + /// Initializes the pixel instance from an value. /// - /// The value. - void FromGray16(Gray16 source); + /// The value. + void FromL16(L16 source); + + /// + /// Initializes the pixel instance from an value. + /// + /// The value. + void FromLa16(La16 source); + + /// + /// Initializes the pixel instance from an value. + /// + /// The value. + void FromLa32(La32 source); /// /// Initializes the pixel instance from an value. @@ -121,4 +133,4 @@ public interface IPixel /// The value. void FromRgba64(Rgba64 source); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs similarity index 69% rename from src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/A8.cs index cd864b5455..cf55a22456 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Alpha8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.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; @@ -8,56 +8,56 @@ namespace SixLabors.ImageSharp.PixelFormats { /// - /// Packed pixel type containing a single 8 bit normalized W values. + /// Packed pixel type containing a single 8-bit normalized alpha value. /// /// Ranges from [0, 0, 0, 0] to [0, 0, 0, 1] in vector form. /// /// - public struct Alpha8 : IPixel, IPackedVector + public struct A8 : IPixel, IPackedVector { /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The alpha component. - public Alpha8(byte alpha) => this.PackedValue = alpha; + public A8(byte alpha) => this.PackedValue = alpha; /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The alpha component. - public Alpha8(float alpha) => this.PackedValue = Pack(alpha); + public A8(float alpha) => this.PackedValue = Pack(alpha); /// public byte PackedValue { get; set; } /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// /// - /// The on the left side of the operand. + /// The on the left side of the operand. /// /// - /// The on the right side of the operand. + /// The on the right side of the operand. /// /// /// True if the parameter is equal to the parameter; otherwise, false. /// [MethodImpl(InliningOptions.ShortMethod)] - public static bool operator ==(Alpha8 left, Alpha8 right) => left.Equals(right); + public static bool operator ==(A8 left, A8 right) => left.Equals(right); /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is not equal to the parameter; otherwise, false. /// [MethodImpl(InliningOptions.ShortMethod)] - public static bool operator !=(Alpha8 left, Alpha8 right) => !left.Equals(right); + public static bool operator !=(A8 left, A8 right) => !left.Equals(right); /// - public PixelOperations CreatePixelOperations() => new PixelOperations(); + public PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -93,11 +93,19 @@ public struct Alpha8 : IPixel, IPackedVector /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.PackedValue = byte.MaxValue; + public void FromL8(L8 source) => this.PackedValue = byte.MaxValue; /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.PackedValue = byte.MaxValue; + public void FromL16(L16 source) => this.PackedValue = byte.MaxValue; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.PackedValue = source.A; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -128,21 +136,21 @@ public void ToRgba32(ref Rgba32 dest) /// /// The object to compare. /// True if the object is equal to the packed vector. - public override bool Equals(object obj) => obj is Alpha8 other && this.Equals(other); + public override bool Equals(object obj) => obj is A8 other && this.Equals(other); /// - /// Compares another Alpha8 packed vector with the packed vector. + /// Compares another A8 packed vector with the packed vector. /// - /// The Alpha8 packed vector to compare. + /// The A8 packed vector to compare. /// True if the packed vectors are equal. [MethodImpl(InliningOptions.ShortMethod)] - public bool Equals(Alpha8 other) => this.PackedValue.Equals(other.PackedValue); + public bool Equals(A8 other) => this.PackedValue.Equals(other.PackedValue); /// /// Gets a string representation of the packed vector. /// /// A string representation of the packed vector. - public override string ToString() => $"Alpha8({this.PackedValue})"; + public override string ToString() => $"A8({this.PackedValue})"; /// [MethodImpl(InliningOptions.ShortMethod)] @@ -156,4 +164,4 @@ public void ToRgba32(ref Rgba32 dest) [MethodImpl(InliningOptions.ShortMethod)] private static byte Pack(float alpha) => (byte)Math.Round(alpha.Clamp(0, 1F) * 255F); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs index 8981c87458..4dc5c9fb56 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.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.Numerics; @@ -229,7 +229,7 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -239,7 +239,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; @@ -248,6 +248,27 @@ public void FromGray16(Gray16 source) this.A = byte.MaxValue; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) @@ -357,4 +378,4 @@ private void Pack(ref Vector4 vector) this.A = (byte)vector.W; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index a0b059dfce..1cd0b80274 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.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; @@ -140,7 +140,7 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -149,7 +149,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; @@ -157,6 +157,25 @@ public void FromGray16(Gray16 source) this.B = rgb; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) @@ -212,4 +231,4 @@ public void FromRgba64(Rgba64 source) [MethodImpl(InliningOptions.ShortMethod)] public override int GetHashCode() => HashCode.Combine(this.R, this.B, this.G); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index 9e42de388c..4a7bbded92 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.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; @@ -101,11 +101,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -172,4 +180,4 @@ private static ushort Pack(ref Vector3 vector) | ((int)Math.Round(vector.Z * 31F) & 0x1F)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs index ea7a961885..e4ae35c261 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.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.Numerics; @@ -185,7 +185,7 @@ public void FromBgr24(Bgr24 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -195,7 +195,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; @@ -204,6 +204,27 @@ public void FromGray16(Gray16 source) this.A = byte.MaxValue; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) @@ -283,4 +304,4 @@ private void Pack(ref Vector4 vector) this.A = (byte)vector.W; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index 6fcac62917..f4479603f5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.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; @@ -104,11 +104,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -161,4 +169,4 @@ private static ushort Pack(ref Vector4 vector) | ((int)Math.Round(vector.Z * 15F) & 0x0F)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index abb3eb19e5..b3d7015cfd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.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; @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form. /// /// - public struct Bgra5551 : IPixel, IPackedVector + public partial struct Bgra5551 : IPixel, IPackedVector { /// /// Initializes a new instance of the struct. @@ -62,7 +62,7 @@ public Bgra5551(float x, float y, float z, float w) public static bool operator !=(Bgra5551 left, Bgra5551 right) => !left.Equals(right); /// - public PixelOperations CreatePixelOperations() => new PixelOperations(); + public PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -105,11 +105,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -163,4 +171,4 @@ private static ushort Pack(ref Vector4 vector) | (((int)Math.Round(vector.W) & 0x1) << 15)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index ab8a13c166..6583670f1b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.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; @@ -101,11 +101,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -173,4 +181,4 @@ private static uint Pack(ref Vector4 vector) return byte4 | byte3 | byte2 | byte1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs index 5bacc6747d..6a599985f4 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Argb32.PixelOperations.Generated.cs @@ -134,36 +134,72 @@ internal override void ToBgr24(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromArgb32(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromArgb32(sp); } @@ -222,6 +258,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromArgb32(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs index 4b2b3a02e4..16ba364b83 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgr24.PixelOperations.Generated.cs @@ -91,36 +91,72 @@ internal override void ToBgra32(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgr24(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromBgr24(sp); } @@ -197,6 +233,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan dp.FromBgr24(sp); } } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgr24 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgr24(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs index 6074e19778..54d946880d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra32.PixelOperations.Generated.cs @@ -134,36 +134,72 @@ internal override void ToBgr24(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra32(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromBgra32(sp); } @@ -222,6 +258,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra32(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs new file mode 100644 index 0000000000..10abec075b --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.cs @@ -0,0 +1,254 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +// + +using SixLabors.ImageSharp.PixelFormats.Utils; +using System; +using System.Buffers; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + + + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct Bgra5551 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + /// + internal override void FromBgra5551(Configuration configuration, ReadOnlySpan source, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); + + source.CopyTo(destPixels); + } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + sourcePixels.CopyTo(destPixels); + } + + + /// + internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Argb32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L8 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref L8 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref L16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + + /// + internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Bgra5551 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Bgra5551 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromBgra5551(sp); + } + } + /// + internal override void From( + Configuration configuration, + ReadOnlySpan sourcePixels, + Span destinationPixels) + { + PixelOperations.Instance.ToBgra5551(configuration, sourcePixels, destinationPixels); + } + + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.tt new file mode 100644 index 0000000000..c4f2fc8bdd --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Bgra5551.PixelOperations.Generated.tt @@ -0,0 +1,19 @@ +<#@include file="_Common.ttinclude" #> +<#@ output extension=".cs" #> + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct Bgra5551 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + <# GenerateAllDefaultConversionMethods("Bgra5551"); #> + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs similarity index 52% rename from src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs index d37a253097..aaff5a23b7 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.cs @@ -16,15 +16,15 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Provides optimized overrides for bulk operations. /// - public partial struct Gray8 + public partial struct L16 { /// /// Provides optimized overrides for bulk operations. /// - internal class PixelOperations : PixelOperations + internal class PixelOperations : PixelOperations { /// - internal override void FromGray8(Configuration configuration, ReadOnlySpan source, Span destPixels) + internal override void FromL16(Configuration configuration, ReadOnlySpan source, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); @@ -33,7 +33,7 @@ internal override void FromGray8(Configuration configuration, ReadOnlySpan - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); @@ -43,155 +43,209 @@ internal override void ToGray8(Configuration configuration, ReadOnlySpan /// - internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); - ref Gray16 destRef = ref MemoryMarshal.GetReference(destPixels); + ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L8 destRef = ref MemoryMarshal.GetReference(destPixels); for (int i = 0; i < sourcePixels.Length; i++) { - ref Gray8 sp = ref Unsafe.Add(ref sourceRef, i); - ref Gray16 dp = ref Unsafe.Add(ref destRef, i); + ref L16 sp = ref Unsafe.Add(ref sourceRef, i); + ref L8 dp = ref Unsafe.Add(ref destRef, i); - dp.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L16 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL16(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L16 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL16(sp); + } + } + + /// + internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L16 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 L16 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); - dp.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); } } /// - internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray8 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 Gray8 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.FromGray8(sp); + dp.FromL16(sp); + } + } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL16(sp); } } /// internal override void From( Configuration configuration, ReadOnlySpan sourcePixels, - Span destinationPixels) + Span destinationPixels) { - PixelOperations.Instance.ToGray8(configuration, sourcePixels, destinationPixels); + PixelOperations.Instance.ToL16(configuration, sourcePixels, destinationPixels); } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt similarity index 68% rename from src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt rename to src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt index ffa15af9dc..937902346f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray8.PixelOperations.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L16.PixelOperations.Generated.tt @@ -6,14 +6,14 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Provides optimized overrides for bulk operations. /// - public partial struct Gray8 + public partial struct L16 { /// /// Provides optimized overrides for bulk operations. /// - internal class PixelOperations : PixelOperations + internal class PixelOperations : PixelOperations { - <# GenerateAllDefaultConversionMethods("Gray8"); #> + <# GenerateAllDefaultConversionMethods("L16"); #> } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs similarity index 52% rename from src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs index c30dfe0c02..30a338d484 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.cs @@ -16,15 +16,15 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Provides optimized overrides for bulk operations. /// - public partial struct Gray16 + public partial struct L8 { /// /// Provides optimized overrides for bulk operations. /// - internal class PixelOperations : PixelOperations + internal class PixelOperations : PixelOperations { /// - internal override void FromGray16(Configuration configuration, ReadOnlySpan source, Span destPixels) + internal override void FromL8(Configuration configuration, ReadOnlySpan source, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); @@ -33,7 +33,7 @@ internal override void FromGray16(Configuration configuration, ReadOnlySpan - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); @@ -43,155 +43,209 @@ internal override void ToGray16(Configuration configuration, ReadOnlySpan - internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L16 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 sp = ref Unsafe.Add(ref sourceRef, i); + ref L16 dp = ref Unsafe.Add(ref destRef, i); - dp.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L8 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL8(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L8 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL8(sp); + } + } + + /// + internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L8 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 L8 sp = ref Unsafe.Add(ref sourceRef, i); ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); - dp.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); } } /// - internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.NotNull(configuration, nameof(configuration)); Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); - ref Gray16 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 Gray16 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.FromGray16(sp); + dp.FromL8(sp); + } + } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref L8 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref L8 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromL8(sp); } } /// internal override void From( Configuration configuration, ReadOnlySpan sourcePixels, - Span destinationPixels) + Span destinationPixels) { - PixelOperations.Instance.ToGray16(configuration, sourcePixels, destinationPixels); + PixelOperations.Instance.ToL8(configuration, sourcePixels, destinationPixels); } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.tt similarity index 68% rename from src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt rename to src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.tt index ac484bdbc0..d2e802a190 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Gray16.PixelOperations.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/L8.PixelOperations.Generated.tt @@ -6,14 +6,14 @@ namespace SixLabors.ImageSharp.PixelFormats /// /// Provides optimized overrides for bulk operations. /// - public partial struct Gray16 + public partial struct L8 { /// /// Provides optimized overrides for bulk operations. /// - internal class PixelOperations : PixelOperations + internal class PixelOperations : PixelOperations { - <# GenerateAllDefaultConversionMethods("Gray16"); #> + <# GenerateAllDefaultConversionMethods("L8"); #> } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs new file mode 100644 index 0000000000..ee0641aa8c --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.cs @@ -0,0 +1,252 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +// + +using SixLabors.ImageSharp.PixelFormats.Utils; +using System; +using System.Buffers; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct La16 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + /// + internal override void FromLa16(Configuration configuration, ReadOnlySpan source, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); + + source.CopyTo(destPixels); + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + sourcePixels.CopyTo(destPixels); + } + + + /// + internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Argb32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L8 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref L8 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref L16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La16 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La16 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa16(sp); + } + } + /// + internal override void From( + Configuration configuration, + ReadOnlySpan sourcePixels, + Span destinationPixels) + { + PixelOperations.Instance.ToLa16(configuration, sourcePixels, destinationPixels); + } + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.tt new file mode 100644 index 0000000000..5d6661631d --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La16.PixelOperations.Generated.tt @@ -0,0 +1,19 @@ +<#@include file="_Common.ttinclude" #> +<#@ output extension=".cs" #> + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct La16 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + <# GenerateAllDefaultConversionMethods("La16"); #> + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs new file mode 100644 index 0000000000..a95fce7aac --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.cs @@ -0,0 +1,252 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +// + +using SixLabors.ImageSharp.PixelFormats.Utils; +using System; +using System.Buffers; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct La32 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + /// + internal override void FromLa32(Configuration configuration, ReadOnlySpan source, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); + + source.CopyTo(destPixels); + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + sourcePixels.CopyTo(destPixels); + } + + + /// + internal override void ToArgb32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Argb32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Argb32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToBgr24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgr24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgr24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToBgra32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L8 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref L8 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref L16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref L16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToRgb24(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb24 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb24 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToRgba32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba32 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToRgb48(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgb48 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgb48 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToRgba64(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Rgba64 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Rgba64 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref La32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromLa32(sp); + } + } + /// + internal override void From( + Configuration configuration, + ReadOnlySpan sourcePixels, + Span destinationPixels) + { + PixelOperations.Instance.ToLa32(configuration, sourcePixels, destinationPixels); + } + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.tt new file mode 100644 index 0000000000..e2fb4867a9 --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/La32.PixelOperations.Generated.tt @@ -0,0 +1,19 @@ +<#@include file="_Common.ttinclude" #> +<#@ output extension=".cs" #> + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Provides optimized overrides for bulk operations. + /// + public partial struct La32 + { + /// + /// Provides optimized overrides for bulk operations. + /// + internal class PixelOperations : PixelOperations + { + <# GenerateAllDefaultConversionMethods("La32"); #> + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs index e5f648fcb7..a6730428c2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb24.PixelOperations.Generated.cs @@ -108,36 +108,72 @@ internal override void ToBgra32(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgb24(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromRgb24(sp); } @@ -196,6 +232,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan dp.FromRgb24(sp); } } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb24 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgb24(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs index d3b2bc6f48..a80636b2cd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgb48.PixelOperations.Generated.cs @@ -97,36 +97,72 @@ internal override void ToBgra32(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgb48(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromRgb48(sp); } @@ -185,6 +221,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan dp.FromRgb48(sp); } } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgb48 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgb48 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgb48(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs index 0da2bf2449..c9f025335c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba32.PixelOperations.Generated.cs @@ -123,36 +123,72 @@ internal override void ToBgr24(Configuration configuration, ReadOnlySpan } /// - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgba32(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromRgba32(sp); } @@ -211,6 +247,24 @@ internal override void ToRgba64(Configuration configuration, ReadOnlySpan + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgba32(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs index 83f5cadd6d..f1545d6fcf 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/Rgba64.PixelOperations.Generated.cs @@ -97,36 +97,72 @@ internal override void ToBgra32(Configuration configuration, ReadOnlySpan - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); } } /// - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span 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); + } + } + + /// + internal override void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); + ref La16 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgba64(sp); + } + } + + /// + internal override void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La32 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); + ref La32 dp = ref Unsafe.Add(ref destRef, i); dp.FromRgba64(sp); } @@ -185,6 +221,24 @@ internal override void ToRgb48(Configuration configuration, ReadOnlySpan dp.FromRgba64(sp); } } + + /// + internal override void ToBgra5551(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.NotNull(configuration, nameof(configuration)); + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref Rgba64 sourceRef = ref MemoryMarshal.GetReference(sourcePixels); + ref Bgra5551 destRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref Rgba64 sp = ref Unsafe.Add(ref sourceRef, i); + ref Bgra5551 dp = ref Unsafe.Add(ref destRef, i); + + dp.FromRgba64(sp); + } + } /// internal override void From( Configuration configuration, diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude index 17e9469f31..8aeef3a663 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Generated/_Common.ttinclude @@ -1,4 +1,4 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> @@ -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", "L16", "La16", "La32", "Rgb24", "Rgba32", "Rgb48", "Rgba64", "Bgra5551" }; static readonly string[] Optimized32BitTypes = { "Rgba32", "Argb32", "Bgra32" }; diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 580cc5399b..4d6c4985a7 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.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; @@ -94,11 +94,19 @@ public Vector4 ToScaledVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -144,4 +152,4 @@ public void ToRgba32(ref Rgba32 dest) [MethodImpl(InliningOptions.ShortMethod)] public override int GetHashCode() => this.PackedValue.GetHashCode(); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs index 8854f16501..300458cb2b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs @@ -105,11 +105,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index 3b30ebd1e6..5ccc09e9f3 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.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; @@ -113,11 +113,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -175,4 +183,4 @@ private static ulong Pack(ref Vector4 vector) return num4 | num3 | num2 | num1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs similarity index 75% rename from src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index b5bd14d9f1..cbe34745c9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Gray16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -7,48 +7,48 @@ namespace SixLabors.ImageSharp.PixelFormats { /// - /// Packed pixel type containing a single 16 bit normalized gray values. + /// Packed pixel type containing a single 16-bit normalized luminance value. /// /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// /// - public partial struct Gray16 : IPixel, IPackedVector + public partial struct L16 : IPixel, IPackedVector { private const float Max = ushort.MaxValue; /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The luminance component - public Gray16(ushort luminance) => this.PackedValue = luminance; + public L16(ushort luminance) => this.PackedValue = luminance; /// public ushort PackedValue { get; set; } /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is equal to the parameter; otherwise, false. /// [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); /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is not equal to the parameter; otherwise, false. /// [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); /// - public PixelOperations CreatePixelOperations() => new PixelOperations(); + public PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -106,11 +106,19 @@ public void FromBgra32(Bgra32 source) /// [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); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.PackedValue = source.PackedValue; + public void FromL16(L16 source) => this = source; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.PackedValue = source.L; /// [MethodImpl(InliningOptions.ShortMethod)] @@ -152,14 +160,14 @@ public void ToRgba32(ref Rgba32 dest) public void FromRgba64(Rgba64 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); /// - 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); /// [MethodImpl(InliningOptions.ShortMethod)] - public bool Equals(Gray16 other) => this.PackedValue.Equals(other.PackedValue); + public bool Equals(L16 other) => this.PackedValue.Equals(other.PackedValue); /// - public override string ToString() => $"Gray16({this.PackedValue})"; + public override string ToString() => $"L16({this.PackedValue})"; /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs similarity index 73% rename from src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs rename to src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index ac67c9d170..b4911ec1c7 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Gray8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -7,49 +7,49 @@ namespace SixLabors.ImageSharp.PixelFormats { /// - /// Packed pixel type containing a single 8 bit normalized gray values. + /// Packed pixel type containing a single 8-bit normalized luminance value. /// /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// /// - public partial struct Gray8 : IPixel, IPackedVector + public partial struct L8 : IPixel, IPackedVector { private static readonly Vector4 MaxBytes = new Vector4(255F); private static readonly Vector4 Half = new Vector4(0.5F); /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The luminance component. - public Gray8(byte luminance) => this.PackedValue = luminance; + public L8(byte luminance) => this.PackedValue = luminance; /// public byte PackedValue { get; set; } /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is equal to the parameter; otherwise, false. /// [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); /// - /// Compares two objects for equality. + /// Compares two objects for equality. /// - /// The on the left side of the operand. - /// The on the right side of the operand. + /// The on the left side of the operand. + /// The on the right side of the operand. /// /// True if the parameter is not equal to the parameter; otherwise, false. /// [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); /// - public PixelOperations CreatePixelOperations() => new PixelOperations(); + public PixelOperations CreatePixelOperations() => new PixelOperations(); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -89,11 +89,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.PackedValue = source.PackedValue; + public void FromL8(L8 source) => this = source; /// [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); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.PackedValue = source.L; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -130,14 +138,14 @@ public void FromRgba64(Rgba64 source) ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); /// - 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); /// [MethodImpl(InliningOptions.ShortMethod)] - public bool Equals(Gray8 other) => this.PackedValue.Equals(other.PackedValue); + public bool Equals(L8 other) => this.PackedValue.Equals(other.PackedValue); /// - public override string ToString() => $"Gray8({this.PackedValue})"; + public override string ToString() => $"L8({this.PackedValue})"; /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs new file mode 100644 index 0000000000..2ab5da158e --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -0,0 +1,228 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Packed pixel type containing two 8-bit normalized values representing luminance and alpha. + /// + /// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form. + /// + /// + [StructLayout(LayoutKind.Explicit)] + public partial struct La16 : IPixel, IPackedVector + { + private static readonly Vector4 MaxBytes = new Vector4(255F); + private static readonly Vector4 Half = new Vector4(0.5F); + + /// + /// Gets or sets the luminance component. + /// + [FieldOffset(0)] + public byte L; + + /// + /// Gets or sets the alpha component. + /// + [FieldOffset(1)] + public byte A; + + /// + /// Initializes a new instance of the struct. + /// + /// The luminance component. + /// The alpha componant. + public La16(byte l, byte a) + { + this.L = l; + this.A = a; + } + + /// + public ushort PackedValue + { + get => Unsafe.As(ref this); + + set => Unsafe.As(ref this) = value; + } + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is equal to the parameter; otherwise, false. + /// + [MethodImpl(InliningOptions.ShortMethod)] + public static bool operator ==(La16 left, La16 right) => left.Equals(right); + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is not equal to the parameter; otherwise, false. + /// + [MethodImpl(InliningOptions.ShortMethod)] + public static bool operator !=(La16 left, La16 right) => !left.Equals(right); + + /// + public PixelOperations CreatePixelOperations() => new PixelOperations(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public bool Equals(La16 other) => this.PackedValue.Equals(other.PackedValue); + + /// + public override bool Equals(object obj) => obj is La16 other && this.Equals(other); + + /// + public override string ToString() => $"La16({this.L}, {this.A})"; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public override int GetHashCode() => this.PackedValue.GetHashCode(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromArgb32(Argb32 source) + { + this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgr24(Bgr24 source) + { + this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.A = byte.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgra32(Bgra32 source) + { + this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgra5551(Bgra5551 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromL16(L16 source) + { + this.L = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + this.A = byte.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromL8(L8 source) + { + this.L = source.PackedValue; + this.A = byte.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this = source; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + this.L = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgb24(Rgb24 source) + { + this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.A = byte.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgb48(Rgb48 source) + { + this.L = ImageMaths.Get8BitBT709Luminance( + ImageMaths.DownScaleFrom16BitTo8Bit(source.R), + ImageMaths.DownScaleFrom16BitTo8Bit(source.G), + ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + + this.A = byte.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgba32(Rgba32 source) + { + this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.A = source.A; + } + + /// + public void FromRgba64(Rgba64 source) + { + this.L = ImageMaths.Get8BitBT709Luminance( + ImageMaths.DownScaleFrom16BitTo8Bit(source.R), + ImageMaths.DownScaleFrom16BitTo8Bit(source.G), + ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + + this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromScaledVector4(Vector4 vector) => this.ConvertFromRgbaScaledVector4(vector); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromVector4(Vector4 vector) => this.ConvertFromRgbaScaledVector4(vector); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void ToRgba32(ref Rgba32 dest) + { + dest.R = this.L; + dest.G = this.L; + dest.B = this.L; + dest.A = this.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public Vector4 ToScaledVector4() => this.ToVector4(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public Vector4 ToVector4() + { + const float Max = 255F; + float rgb = this.L / Max; + return new Vector4(rgb, rgb, rgb, this.A / Max); + } + + [MethodImpl(InliningOptions.ShortMethod)] + internal void ConvertFromRgbaScaledVector4(Vector4 vector) + { + vector *= MaxBytes; + vector += Half; + vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes); + this.L = ImageMaths.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); + this.A = (byte)vector.W; + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs new file mode 100644 index 0000000000..b13c43827c --- /dev/null +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -0,0 +1,243 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace SixLabors.ImageSharp.PixelFormats +{ + /// + /// Packed pixel type containing two 16-bit normalized values representing luminance and alpha. + /// + /// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form. + /// + /// + [StructLayout(LayoutKind.Explicit)] + public partial struct La32 : IPixel, IPackedVector + { + private const float Max = ushort.MaxValue; + + /// + /// Gets or sets the luminance component. + /// + [FieldOffset(0)] + public ushort L; + + /// + /// Gets or sets the alpha component. + /// + [FieldOffset(2)] + public ushort A; + + /// + /// Initializes a new instance of the struct. + /// + /// The luminance component. + /// The alpha componant. + public La32(ushort l, ushort a) + { + this.L = l; + this.A = a; + } + + /// + public uint PackedValue + { + get => Unsafe.As(ref this); + + set => Unsafe.As(ref this) = value; + } + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is equal to the parameter; otherwise, false. + /// + [MethodImpl(InliningOptions.ShortMethod)] + public static bool operator ==(La32 left, La32 right) => left.Equals(right); + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is not equal to the parameter; otherwise, false. + /// + [MethodImpl(InliningOptions.ShortMethod)] + public static bool operator !=(La32 left, La32 right) => !left.Equals(right); + + /// + public PixelOperations CreatePixelOperations() => new PixelOperations(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public bool Equals(La32 other) => this.PackedValue.Equals(other.PackedValue); + + /// + public override bool Equals(object obj) => obj is La32 other && this.Equals(other); + + /// + public override string ToString() => $"La32({this.L}, {this.A})"; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public override int GetHashCode() => this.PackedValue.GetHashCode(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromArgb32(Argb32 source) + { + this.L = ImageMaths.Get16BitBT709Luminance( + ImageMaths.UpscaleFrom8BitTo16Bit(source.R), + ImageMaths.UpscaleFrom8BitTo16Bit(source.G), + ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + + this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgr24(Bgr24 source) + { + this.L = ImageMaths.Get16BitBT709Luminance( + ImageMaths.UpscaleFrom8BitTo16Bit(source.R), + ImageMaths.UpscaleFrom8BitTo16Bit(source.G), + ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + + this.A = ushort.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgra32(Bgra32 source) + { + this.L = ImageMaths.Get16BitBT709Luminance( + ImageMaths.UpscaleFrom8BitTo16Bit(source.R), + ImageMaths.UpscaleFrom8BitTo16Bit(source.G), + ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + + this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromBgra5551(Bgra5551 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromL16(L16 source) + { + this.L = source.PackedValue; + this.A = ushort.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromL8(L8 source) + { + this.L = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); + this.A = ushort.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.L = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this = source; + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgb24(Rgb24 source) + { + this.L = ImageMaths.Get16BitBT709Luminance( + ImageMaths.UpscaleFrom8BitTo16Bit(source.R), + ImageMaths.UpscaleFrom8BitTo16Bit(source.G), + ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + + this.A = ushort.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgb48(Rgb48 source) + { + this.L = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + this.A = ushort.MaxValue; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgba32(Rgba32 source) + { + this.L = ImageMaths.Get16BitBT709Luminance( + ImageMaths.UpscaleFrom8BitTo16Bit(source.R), + ImageMaths.UpscaleFrom8BitTo16Bit(source.G), + ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + + this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromRgba64(Rgba64 source) + { + this.L = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromScaledVector4(Vector4 vector) => this.ConvertFromRgbaScaledVector4(vector); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromVector4(Vector4 vector) => this.ConvertFromRgbaScaledVector4(vector); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void ToRgba32(ref Rgba32 dest) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(this.L); + dest.R = rgb; + dest.G = rgb; + dest.B = rgb; + dest.A = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public Vector4 ToScaledVector4() => this.ToVector4(); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public Vector4 ToVector4() + { + float scaled = this.L / Max; + return new Vector4(scaled, scaled, scaled, this.A / Max); + } + + [MethodImpl(InliningOptions.ShortMethod)] + internal void ConvertFromRgbaScaledVector4(Vector4 vector) + { + vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * Max; + this.L = ImageMaths.Get16BitBT709Luminance( + vector.X, + vector.Y, + vector.Z); + + this.A = (ushort)MathF.Round(vector.W); + } + } +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index a24e725692..d6362dacce 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -115,11 +115,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 73a3d32625..f6c5d25800 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.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; @@ -116,11 +116,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -176,4 +184,4 @@ private static uint Pack(ref Vector4 vector) return byte4 | byte3 | byte2 | byte1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index 3ede947139..989c03e22e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -111,11 +111,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index 453b1c1b7c..ed849a6c79 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.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; @@ -118,11 +118,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -180,4 +188,4 @@ private static ulong Pack(ref Vector4 vector) return word4 | word3 | word2 | word1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index 0411f8f3e9..a7385d5af5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.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; @@ -99,11 +99,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -161,4 +169,4 @@ private static uint Pack(Vector2 vector) return (uint)(((int)Math.Round(vector.X) & 0xFFFF) | (((int)Math.Round(vector.Y) & 0xFFFF) << 16)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index 469dbbad4a..65191e86f6 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -155,7 +155,7 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -164,7 +164,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; @@ -172,6 +172,25 @@ public void FromGray16(Gray16 source) this.B = rgb; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra5551(Bgra5551 source) => this.FromScaledVector4(source.ToScaledVector4()); @@ -242,4 +261,4 @@ private void Pack(ref Vector4 vector) this.B = (byte)vector.Z; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index f59036ec7d..c78219a484 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.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; @@ -132,7 +132,7 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); this.R = rgb; @@ -142,13 +142,32 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { this.R = source.PackedValue; this.G = source.PackedValue; this.B = source.PackedValue; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) @@ -195,4 +214,4 @@ public void ToRgba32(ref Rgba32 dest) [MethodImpl(InliningOptions.ShortMethod)] public override int GetHashCode() => HashCode.Combine(this.R, this.G, this.B); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index 38f61d56c1..330f5a8ee5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.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; @@ -105,11 +105,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -164,4 +172,4 @@ private static uint Pack(ref Vector4 vector) | (((int)Math.Round(vector.W) & 0x03) << 30)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index ba259ca8ed..10631e2cf9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.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; @@ -307,7 +307,7 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -317,7 +317,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; @@ -326,6 +326,27 @@ public void FromGray16(Gray16 source) this.A = byte.MaxValue; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + this.A = source.A; + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) @@ -483,4 +504,4 @@ private static string ToRgbaHex(string hex) return new string(new[] { r, r, g, g, b, b, a, a }); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs index 978d9b0156..56bc6f4559 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs +++ b/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 @@ public void FromBgra32(Bgra32 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) + public void FromL8(L8 source) { ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); this.R = rgb; @@ -267,7 +267,7 @@ public void FromGray8(Gray8 source) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) + public void FromL16(L16 source) { this.R = source.PackedValue; this.G = source.PackedValue; @@ -275,6 +275,27 @@ public void FromGray16(Gray16 source) this.A = ushort.MaxValue; } + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) + { + ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + this.R = rgb; + this.G = rgb; + this.B = rgb; + this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + } + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) + { + this.R = source.L; + this.G = source.L; + this.B = source.L; + this.A = source.A; + } + /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) @@ -399,4 +420,4 @@ public Bgr24 ToBgr24() [MethodImpl(InliningOptions.ShortMethod)] public override int GetHashCode() => this.PackedValue.GetHashCode(); } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs index b331dbd99f..5ced9e8a30 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.PixelOperations.cs @@ -46,33 +46,33 @@ internal override void ToVector4( Vector4Converters.ApplyForwardConversionModifiers(destVectors, modifiers); } - internal override void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); ref Vector4 sourceBaseRef = ref Unsafe.As(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); } } - internal override void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + internal override void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); ref Vector4 sourceBaseRef = ref Unsafe.As(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); } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs index 10c642300c..67f09f3a5d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs @@ -140,11 +140,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 14987e5829..1cc7d269c4 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -117,11 +117,19 @@ public void FromVector4(Vector4 vector) /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index c52b293476..433f49f153 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.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; @@ -122,11 +122,19 @@ public Vector4 ToVector4() /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray8(Gray8 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL8(L8 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromGray16(Gray16 source) => this.FromScaledVector4(source.ToScaledVector4()); + public void FromL16(L16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa16(La16 source) => this.FromScaledVector4(source.ToScaledVector4()); + + /// + [MethodImpl(InliningOptions.ShortMethod)] + public void FromLa32(La32 source) => this.FromScaledVector4(source.ToScaledVector4()); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -186,4 +194,4 @@ private static ulong Pack(ref Vector4 vector) return word4 | word3 | word2 | word1; } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs index 7002819928..1bc237100e 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.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. // @@ -13,7 +13,7 @@ public partial class PixelOperations /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromArgb32(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -36,7 +36,7 @@ internal virtual void FromArgb32(Configuration configuration, ReadOnlySpan that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -85,7 +85,7 @@ internal void ToArgb32Bytes(Configuration configuration, ReadOnlySpan so /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromBgr24(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -108,7 +108,7 @@ internal virtual void FromBgr24(Configuration configuration, ReadOnlySpan /// A helper for that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -157,7 +157,7 @@ internal void ToBgr24Bytes(Configuration configuration, ReadOnlySpan sou /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromBgra32(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -180,7 +180,7 @@ internal virtual void FromBgra32(Configuration configuration, ReadOnlySpan that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -227,153 +227,297 @@ internal void ToBgra32Bytes(Configuration configuration, ReadOnlySpan so } /// - /// Converts all pixels in 'source` span of into a span of -s. + /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations - /// The source of data. + /// A to configure internal operations. + /// The source of data. /// The to the destination pixels. - internal virtual void FromGray8(Configuration configuration, ReadOnlySpan source, Span destPixels) + internal virtual void FromL8(Configuration configuration, ReadOnlySpan source, Span 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); } } /// - /// A helper for that expects a byte span. - /// The layout of the data in 'sourceBytes' must be compatible with layout. + /// A helper for that expects a byte span. + /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void FromGray8Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) + internal void FromL8Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) { - this.FromGray8(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); + this.FromL8(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); } /// - /// Converts all pixels of the 'sourcePixels` span to a span of -s. + /// Converts all pixels of the 'sourcePixels` span to a span of -s. /// /// A to configure internal operations /// The span of source pixels - /// The destination span of data. - internal virtual void ToGray8(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + /// The destination span of data. + internal virtual void ToL8(Configuration configuration, ReadOnlySpan sourcePixels, Span 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()); } } /// - /// A helper for that expects a byte span as destination. - /// The layout of the data in 'destBytes' must be compatible with layout. + /// A helper for that expects a byte span as destination. + /// The layout of the data in 'destBytes' must be compatible with layout. /// /// A to configure internal operations /// The to the source pixels. /// The to the destination bytes. /// The number of pixels to convert. [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void ToGray8Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) + internal void ToL8Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) { - this.ToGray8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); + this.ToL8(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); + } + + /// + /// Converts all pixels in 'source` span of into a span of -s. + /// + /// A to configure internal operations. + /// The source of data. + /// The to the destination pixels. + internal virtual void FromL16(Configuration configuration, ReadOnlySpan source, Span destPixels) + { + Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); + + ref L16 sourceBaseRef = ref MemoryMarshal.GetReference(source); + ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < source.Length; i++) + { + ref L16 sp = ref Unsafe.Add(ref sourceBaseRef, i); + ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); + + dp.FromL16(sp); + } } /// - /// Converts all pixels in 'source` span of into a span of -s. + /// A helper for that expects a byte span. + /// The layout of the data in 'sourceBytes' must be compatible with layout. + /// + /// A to configure internal operations. + /// The to the source bytes. + /// The to the destination pixels. + /// The number of pixels to convert. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void FromL16Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) + { + this.FromL16(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); + } + + /// + /// Converts all pixels of the 'sourcePixels` span to a span of -s. /// /// A to configure internal operations - /// The source of data. + /// The span of source pixels + /// The destination span of data. + internal virtual void ToL16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); + 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 L16 dp = ref Unsafe.Add(ref destBaseRef, i); + + dp.FromScaledVector4(sp.ToScaledVector4()); + } + } + + /// + /// A helper for that expects a byte span as destination. + /// The layout of the data in 'destBytes' must be compatible with layout. + /// + /// A to configure internal operations + /// The to the source pixels. + /// The to the destination bytes. + /// The number of pixels to convert. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void ToL16Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) + { + this.ToL16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); + } + + /// + /// Converts all pixels in 'source` span of into a span of -s. + /// + /// A to configure internal operations. + /// The source of data. /// The to the destination pixels. - internal virtual void FromGray16(Configuration configuration, ReadOnlySpan source, Span destPixels) + internal virtual void FromLa16(Configuration configuration, ReadOnlySpan source, Span destPixels) { Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); - ref Gray16 sourceBaseRef = ref MemoryMarshal.GetReference(source); + ref La16 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 La16 sp = ref Unsafe.Add(ref sourceBaseRef, i); ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); - dp.FromGray16(sp); + dp.FromLa16(sp); + } + } + + /// + /// A helper for that expects a byte span. + /// The layout of the data in 'sourceBytes' must be compatible with layout. + /// + /// A to configure internal operations. + /// The to the source bytes. + /// The to the destination pixels. + /// The number of pixels to convert. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void FromLa16Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) + { + this.FromLa16(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); + } + + /// + /// Converts all pixels of the 'sourcePixels` span to a span of -s. + /// + /// A to configure internal operations + /// The span of source pixels + /// The destination span of data. + internal virtual void ToLa16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + { + Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); + + ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); + ref La16 destBaseRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < sourcePixels.Length; i++) + { + ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i); + ref La16 dp = ref Unsafe.Add(ref destBaseRef, i); + + dp.FromScaledVector4(sp.ToScaledVector4()); } } /// - /// A helper for that expects a byte span. - /// The layout of the data in 'sourceBytes' must be compatible with layout. + /// A helper for that expects a byte span as destination. + /// The layout of the data in 'destBytes' must be compatible with layout. /// /// A to configure internal operations + /// The to the source pixels. + /// The to the destination bytes. + /// The number of pixels to convert. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void ToLa16Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) + { + this.ToLa16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); + } + + /// + /// Converts all pixels in 'source` span of into a span of -s. + /// + /// A to configure internal operations. + /// The source of data. + /// The to the destination pixels. + internal virtual void FromLa32(Configuration configuration, ReadOnlySpan source, Span destPixels) + { + Guard.DestinationShouldNotBeTooShort(source, destPixels, nameof(destPixels)); + + ref La32 sourceBaseRef = ref MemoryMarshal.GetReference(source); + ref TPixel destBaseRef = ref MemoryMarshal.GetReference(destPixels); + + for (int i = 0; i < source.Length; i++) + { + ref La32 sp = ref Unsafe.Add(ref sourceBaseRef, i); + ref TPixel dp = ref Unsafe.Add(ref destBaseRef, i); + + dp.FromLa32(sp); + } + } + + /// + /// A helper for that expects a byte span. + /// The layout of the data in 'sourceBytes' must be compatible with layout. + /// + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void FromGray16Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) + internal void FromLa32Bytes(Configuration configuration, ReadOnlySpan sourceBytes, Span destPixels, int count) { - this.FromGray16(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); + this.FromLa32(configuration, MemoryMarshal.Cast(sourceBytes).Slice(0, count), destPixels); } /// - /// Converts all pixels of the 'sourcePixels` span to a span of -s. + /// Converts all pixels of the 'sourcePixels` span to a span of -s. /// /// A to configure internal operations /// The span of source pixels - /// The destination span of data. - internal virtual void ToGray16(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) + /// The destination span of data. + internal virtual void ToLa32(Configuration configuration, ReadOnlySpan sourcePixels, Span destPixels) { Guard.DestinationShouldNotBeTooShort(sourcePixels, destPixels, nameof(destPixels)); ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels); - ref Gray16 destBaseRef = ref MemoryMarshal.GetReference(destPixels); + ref La32 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 La32 dp = ref Unsafe.Add(ref destBaseRef, i); dp.FromScaledVector4(sp.ToScaledVector4()); } } /// - /// A helper for that expects a byte span as destination. - /// The layout of the data in 'destBytes' must be compatible with layout. + /// A helper for that expects a byte span as destination. + /// The layout of the data in 'destBytes' must be compatible with layout. /// /// A to configure internal operations /// The to the source pixels. /// The to the destination bytes. /// The number of pixels to convert. [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void ToGray16Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) + internal void ToLa32Bytes(Configuration configuration, ReadOnlySpan sourcePixels, Span destBytes, int count) { - this.ToGray16(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); + this.ToLa32(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); } /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromRgb24(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -396,7 +540,7 @@ internal virtual void FromRgb24(Configuration configuration, ReadOnlySpan /// A helper for that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -445,7 +589,7 @@ internal void ToRgb24Bytes(Configuration configuration, ReadOnlySpan sou /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromRgba32(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -468,7 +612,7 @@ internal virtual void FromRgba32(Configuration configuration, ReadOnlySpan that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -517,7 +661,7 @@ internal void ToRgba32Bytes(Configuration configuration, ReadOnlySpan so /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromRgb48(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -540,7 +684,7 @@ internal virtual void FromRgb48(Configuration configuration, ReadOnlySpan /// A helper for that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -589,7 +733,7 @@ internal void ToRgb48Bytes(Configuration configuration, ReadOnlySpan sou /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromRgba64(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -612,7 +756,7 @@ internal virtual void FromRgba64(Configuration configuration, ReadOnlySpan that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -661,7 +805,7 @@ internal void ToRgba64Bytes(Configuration configuration, ReadOnlySpan so /// /// Converts all pixels in 'source` span of into a span of -s. /// - /// A to configure internal operations + /// A to configure internal operations. /// The source of data. /// The to the destination pixels. internal virtual void FromBgra5551(Configuration configuration, ReadOnlySpan source, Span destPixels) @@ -684,7 +828,7 @@ internal virtual void FromBgra5551(Configuration configuration, ReadOnlySpan that expects a byte span. /// The layout of the data in 'sourceBytes' must be compatible with layout. /// - /// A to configure internal operations + /// A to configure internal operations. /// The to the source bytes. /// The to the destination pixels. /// The number of pixels to convert. @@ -730,4 +874,4 @@ internal void ToBgra5551Bytes(Configuration configuration, ReadOnlySpan this.ToBgra5551(configuration, sourcePixels.Slice(0, count), MemoryMarshal.Cast(destBytes)); } } -} \ No newline at end of file +} diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt index 459924c318..a9fe3ea20b 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.Generated.tt @@ -1,4 +1,4 @@ -<# +<# // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. #> @@ -118,11 +118,17 @@ namespace SixLabors.ImageSharp.PixelFormats GenerateFromMethods("Bgra32"); GenerateToDestFormatMethods("Bgra32"); - GenerateFromMethods("Gray8"); - GenerateToDestFormatMethods("Gray8"); + GenerateFromMethods("L8"); + GenerateToDestFormatMethods("L8"); + + GenerateFromMethods("L16"); + GenerateToDestFormatMethods("L16"); + + GenerateFromMethods("La16"); + GenerateToDestFormatMethods("La16"); - GenerateFromMethods("Gray16"); - GenerateToDestFormatMethods("Gray16"); + GenerateFromMethods("La32"); + GenerateToDestFormatMethods("La32"); GenerateFromMethods("Rgb24"); GenerateToDestFormatMethods("Rgb24"); @@ -140,4 +146,4 @@ namespace SixLabors.ImageSharp.PixelFormats GenerateToDestFormatMethods("Bgra5551"); #> } -} \ No newline at end of file +} diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs index 0124575488..c59e77b10c 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs @@ -39,7 +39,7 @@ protected override void OnFrameApply(ImageFrame source) IErrorDiffuser diffuser = this.definition.Diffuser; byte threshold = (byte)MathF.Round(this.definition.Threshold * 255F); - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs index e0aae0279f..d750c9f077 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs @@ -38,7 +38,7 @@ protected override void OnFrameApply(ImageFrame source) TPixel upperColor = this.definition.UpperColor.ToPixel(); TPixel lowerColor = this.definition.LowerColor.ToPixel(); - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); int startY = interest.Y; diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index 7208fc3cd5..20a22fba3f 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -47,7 +47,7 @@ protected override void OnFrameApply(ImageFrame source) int startX = interest.X; int endX = interest.Right; - bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8); + bool isAlphaOnly = typeof(TPixel) == typeof(A8); var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 7412f70a11..fd9f50a294 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -89,7 +89,7 @@ public void Encode_PreserveBitsPerPixel(string imagePath, BmpBitsPerPixel bmpBit memStream.Position = 0; using (var output = Image.Load(memStream)) { - BmpMetadata meta = output.Metadata.GetFormatMetadata(BmpFormat.Instance); + BmpMetadata meta = output.Metadata.GetBmpMetadata(); Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel); } @@ -167,7 +167,7 @@ public void Encode_8Bit_WithV4Header_Works(TestImageProvider pro where TPixel : struct, IPixel => TestBmpEncoderCore(provider, bitsPerPixel, supportTransparency: true); [Theory] - [WithFile(Bit8Gs, PixelTypes.Gray8, BmpBitsPerPixel.Pixel8)] + [WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)] public void Encode_8BitGray_WithV3Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) where TPixel : struct, IPixel => TestBmpEncoderCore( @@ -176,7 +176,7 @@ public void Encode_8BitGray_WithV3Header_Works(TestImageProvider supportTransparency: false); [Theory] - [WithFile(Bit8Gs, PixelTypes.Gray8, BmpBitsPerPixel.Pixel8)] + [WithFile(Bit8Gs, PixelTypes.L8, BmpBitsPerPixel.Pixel8)] public void Encode_8BitGray_WithV4Header_Works(TestImageProvider provider, BmpBitsPerPixel bitsPerPixel) where TPixel : struct, IPixel => TestBmpEncoderCore( diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetadataTests.cs similarity index 86% rename from tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs rename to tests/ImageSharp.Tests/Formats/Bmp/BmpMetadataTests.cs index 7045d64508..4eac337307 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpMetadataTests.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp { using static TestImages.Bmp; - public class BmpMetaDataTests + public class BmpMetadataTests { [Fact] public void CloneIsDeep() @@ -41,9 +41,9 @@ public void Identify_DetectsCorrectBitmapInfoHeaderType(string imagePath, BmpInf { IImageInfo imageInfo = Image.Identify(stream); Assert.NotNull(imageInfo); - BmpMetadata bitmapMetaData = imageInfo.Metadata.GetFormatMetadata(BmpFormat.Instance); - Assert.NotNull(bitmapMetaData); - Assert.Equal(expectedInfoHeaderType, bitmapMetaData.InfoHeaderType); + BmpMetadata bitmapMetadata = imageInfo.Metadata.GetBmpMetadata(); + Assert.NotNull(bitmapMetadata); + Assert.Equal(expectedInfoHeaderType, bitmapMetadata.InfoHeaderType); } } } diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index d6d58eae7a..eb39c28479 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -92,7 +92,7 @@ public void Encode_IgnoreMetadataIsFalse_CommentsAreWritten() memStream.Position = 0; using (var output = Image.Load(memStream)) { - GifMetadata metadata = output.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metadata = output.Metadata.GetGifMetadata(); Assert.Equal(1, metadata.Comments.Count); Assert.Equal("ImageSharp", metadata.Comments[0]); } @@ -135,13 +135,13 @@ public void NonMutatingEncodePreservesPaletteCount() inStream.Position = 0; var image = Image.Load(inStream); - GifMetadata metaData = image.Metadata.GetFormatMetadata(GifFormat.Instance); - GifFrameMetadata frameMetaData = image.Frames.RootFrame.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metaData = image.Metadata.GetGifMetadata(); + GifFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetGifMetadata(); GifColorTableMode colorMode = metaData.ColorTableMode; var encoder = new GifEncoder { ColorTableMode = colorMode, - Quantizer = new OctreeQuantizer(frameMetaData.ColorTableLength) + Quantizer = new OctreeQuantizer(frameMetadata.ColorTableLength) }; image.Save(outStream, encoder); @@ -150,16 +150,16 @@ public void NonMutatingEncodePreservesPaletteCount() outStream.Position = 0; var clone = Image.Load(outStream); - GifMetadata cloneMetaData = clone.Metadata.GetFormatMetadata(GifFormat.Instance); - Assert.Equal(metaData.ColorTableMode, cloneMetaData.ColorTableMode); + GifMetadata cloneMetadata = clone.Metadata.GetGifMetadata(); + Assert.Equal(metaData.ColorTableMode, cloneMetadata.ColorTableMode); // Gifiddle and Cyotek GifInfo say this image has 64 colors. - Assert.Equal(64, frameMetaData.ColorTableLength); + Assert.Equal(64, frameMetadata.ColorTableLength); for (int i = 0; i < image.Frames.Count; i++) { - GifFrameMetadata ifm = image.Frames[i].Metadata.GetFormatMetadata(GifFormat.Instance); - GifFrameMetadata cifm = clone.Frames[i].Metadata.GetFormatMetadata(GifFormat.Instance); + GifFrameMetadata ifm = image.Frames[i].Metadata.GetGifMetadata(); + GifFrameMetadata cifm = clone.Frames[i].Metadata.GetGifMetadata(); Assert.Equal(ifm.ColorTableLength, cifm.ColorTableLength); Assert.Equal(ifm.FrameDelay, cifm.FrameDelay); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetadataTests.cs similarity index 95% rename from tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs rename to tests/ImageSharp.Tests/Formats/Gif/GifFrameMetadataTests.cs index b891c8ed20..a3bc5d45c4 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifFrameMetadataTests.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif { - public class GifFrameMetaDataTests + public class GifFrameMetadataTests { [Fact] public void CloneIsDeep() diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs similarity index 93% rename from tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs rename to tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs index 8cb61235e3..7f1acf71e1 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif { - public class GifMetaDataTests + public class GifMetadataTests { public static readonly TheoryData RatioFiles = new TheoryData @@ -59,7 +59,7 @@ public void Decode_IgnoreMetadataIsFalse_CommentsAreRead() using (Image image = testFile.CreateRgba32Image(options)) { - GifMetadata metadata = image.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(1, metadata.Comments.Count); Assert.Equal("ImageSharp", metadata.Comments[0]); } @@ -77,7 +77,7 @@ public void Decode_IgnoreMetadataIsTrue_CommentsAreIgnored() using (Image image = testFile.CreateRgba32Image(options)) { - GifMetadata metadata = image.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(0, metadata.Comments.Count); } } @@ -90,7 +90,7 @@ public void Decode_CanDecodeLargeTextComment() using (Image image = testFile.CreateRgba32Image(options)) { - GifMetadata metadata = image.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); Assert.Equal(new string('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); @@ -111,7 +111,7 @@ public void Encode_PreservesTextData() using (Image image = decoder.Decode(Configuration.Default, memoryStream)) { - GifMetadata metadata = image.Metadata.GetFormatMetadata(GifFormat.Instance); + GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); Assert.Equal(new string('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs similarity index 95% rename from tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs rename to tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index 1d5c3e27a4..4b845c2cbb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -21,7 +21,7 @@ public partial class JpegDecoderTests { // TODO: A JPEGsnoop & metadata expert should review if the Exif/Icc expectations are correct. // I'm seeing several entries with Exif-related names in images where we do not decode an exif profile. (- Anton) - public static readonly TheoryData MetaDataTestData = + public static readonly TheoryData MetadataTestData = new TheoryData { { false, TestImages.Jpeg.Progressive.Progress, 24, false, false }, @@ -58,15 +58,15 @@ public partial class JpegDecoderTests }; [Theory] - [MemberData(nameof(MetaDataTestData))] - public void MetaDataIsParsedCorrectly( + [MemberData(nameof(MetadataTestData))] + public void MetadataIsParsedCorrectly( bool useIdentify, string imagePath, int expectedPixelSize, bool exifProfilePresent, bool iccProfilePresent) { - TestMetaDataImpl( + TestMetadataImpl( useIdentify, JpegDecoder, imagePath, @@ -118,7 +118,7 @@ public void Identify_VerifyQuality(string imagePath, int quality) { var decoder = new JpegDecoder(); IImageInfo image = decoder.Identify(Configuration.Default, stream); - JpegMetadata meta = image.Metadata.GetFormatMetadata(JpegFormat.Instance); + JpegMetadata meta = image.Metadata.GetJpegMetadata(); Assert.Equal(quality, meta.Quality); } } @@ -133,7 +133,7 @@ public void Decode_VerifyQuality(string imagePath, int quality) var decoder = new JpegDecoder(); using (Image image = decoder.Decode(Configuration.Default, stream)) { - JpegMetadata meta = image.Metadata.GetFormatMetadata(JpegFormat.Instance); + JpegMetadata meta = image.Metadata.GetJpegMetadata(); Assert.Equal(quality, meta.Quality); } } @@ -152,7 +152,7 @@ private static void TestImageInfo(string imagePath, IImageDecoder decoder, bool } } - private static void TestMetaDataImpl( + private static void TestMetadataImpl( bool useIdentify, IImageDecoder decoder, string imagePath, @@ -209,16 +209,16 @@ private static void TestMetaDataImpl( [Theory] [InlineData(false)] [InlineData(true)] - public void IgnoreMetaData_ControlsWhetherMetaDataIsParsed(bool ignoreMetaData) + public void IgnoreMetadata_ControlsWhetherMetadataIsParsed(bool ignoreMetadata) { - var decoder = new JpegDecoder { IgnoreMetadata = ignoreMetaData }; + var decoder = new JpegDecoder { IgnoreMetadata = ignoreMetadata }; // Snake.jpg has both Exif and ICC profiles defined: var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake); using (Image image = testFile.CreateRgba32Image(decoder)) { - if (ignoreMetaData) + if (ignoreMetadata) { Assert.Null(image.Metadata.ExifProfile); Assert.Null(image.Metadata.IccProfile); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index 639ec520ec..ccfde3b465 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -57,7 +57,7 @@ public void Encode_PreserveQuality(string imagePath, int quality) memStream.Position = 0; using (var output = Image.Load(memStream)) { - JpegMetadata meta = output.Metadata.GetFormatMetadata(JpegFormat.Instance); + JpegMetadata meta = output.Metadata.GetJpegMetadata(); Assert.Equal(quality, meta.Quality); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs similarity index 93% rename from tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs rename to tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs index 59ad571f49..50a2a44163 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs @@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { - public class JpegMetaDataTests + public class JpegMetadataTests { [Fact] public void CloneIsDeep() diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index bdd84038e3..3b05b00ce0 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -37,7 +37,7 @@ public partial class PngDecoderTests TestImages.Png.VimImage2, TestImages.Png.Rgb24BppTrans, - TestImages.Png.GrayAlpha8Bit, + TestImages.Png.GrayA8Bit, TestImages.Png.Gray1BitTrans, TestImages.Png.Bad.ZlibOverflow, TestImages.Png.Bad.ZlibOverflow2, @@ -57,9 +57,9 @@ public partial class PngDecoderTests TestImages.Png.Rgb48BppTrans }; - public static readonly string[] TestImagesGray16Bit = + public static readonly string[] TestImagesL16Bit = { - TestImages.Png.Gray16Bit, + TestImages.Png.L16Bit, }; public static readonly string[] TestImagesGrayAlpha16Bit = @@ -68,12 +68,12 @@ public partial class PngDecoderTests TestImages.Png.GrayTrns16BitInterlaced }; - public static readonly string[] TestImagesGray8BitInterlaced = + public static readonly string[] TestImagesL8BitInterlaced = { TestImages.Png.GrayAlpha1BitInterlaced, TestImages.Png.GrayAlpha2BitInterlaced, TestImages.Png.Gray4BitInterlaced, - TestImages.Png.GrayAlpha8BitInterlaced + TestImages.Png.GrayA8BitInterlaced }; public static readonly string[] TestImagesIssue1014 = @@ -144,8 +144,8 @@ public void Decode_64Bpp(TestImageProvider provider) } [Theory] - [WithFileCollection(nameof(TestImagesGray8BitInterlaced), PixelTypes.Rgba32)] - public void Decoder_Gray8bitInterlaced(TestImageProvider provider) + [WithFileCollection(nameof(TestImagesL8BitInterlaced), PixelTypes.Rgba32)] + public void Decoder_L8bitInterlaced(TestImageProvider provider) where TPixel : struct, IPixel { using (Image image = provider.GetImage(new PngDecoder())) @@ -156,8 +156,8 @@ public void Decoder_Gray8bitInterlaced(TestImageProvider provide } [Theory] - [WithFileCollection(nameof(TestImagesGray16Bit), PixelTypes.Rgb48)] - public void Decode_Gray16Bit(TestImageProvider provider) + [WithFileCollection(nameof(TestImagesL16Bit), PixelTypes.Rgb48)] + public void Decode_L16Bit(TestImageProvider provider) where TPixel : struct, IPixel { using (Image image = provider.GetImage(new PngDecoder())) @@ -180,7 +180,7 @@ public void Decode_GrayAlpha16Bit(TestImageProvider provider) } [Theory] - [WithFile(TestImages.Png.GrayAlpha8BitInterlaced, PixelTypes)] + [WithFile(TestImages.Png.GrayA8BitInterlaced, PixelTypes)] public void Decoder_CanDecodeGrey8bitWithAlpha(TestImageProvider provider) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 8a0cdbfbaf..d3e675b907 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -31,7 +31,7 @@ public class PngEncoderTests { 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 } @@ -280,7 +280,7 @@ public void Encode_PreserveBits(string imagePath, PngBitDepth pngBitDepth) memStream.Position = 0; using (var output = Image.Load(memStream)) { - PngMetadata meta = output.Metadata.GetFormatMetadata(PngFormat.Instance); + PngMetadata meta = output.Metadata.GetPngMetadata(); Assert.Equal(pngBitDepth, meta.BitDepth); } @@ -297,7 +297,7 @@ public void Encode_PreserveTrns(string imagePath, PngBitDepth pngBitDepth, PngCo var testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - PngMetadata inMeta = input.Metadata.GetFormatMetadata(PngFormat.Instance); + PngMetadata inMeta = input.Metadata.GetPngMetadata(); Assert.True(inMeta.HasTransparency); using (var memStream = new MemoryStream()) @@ -306,7 +306,7 @@ public void Encode_PreserveTrns(string imagePath, PngBitDepth pngBitDepth, PngCo memStream.Position = 0; using (var output = Image.Load(memStream)) { - PngMetadata outMeta = output.Metadata.GetFormatMetadata(PngFormat.Instance); + PngMetadata outMeta = output.Metadata.GetPngMetadata(); Assert.True(outMeta.HasTransparency); switch (pngColorType) @@ -314,13 +314,13 @@ public void Encode_PreserveTrns(string imagePath, PngBitDepth pngBitDepth, PngCo 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 { - Assert.True(outMeta.TransparentGray8.HasValue); - Assert.Equal(inMeta.TransparentGray8, outMeta.TransparentGray8); + Assert.True(outMeta.TransparentL8.HasValue); + Assert.Equal(inMeta.TransparentL8, outMeta.TransparentL8); } break; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs similarity index 98% rename from tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs rename to tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index dfa7fd2922..4b11ad3e27 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png { - public class PngMetaDataTests + public class PngMetadataTests { public static readonly TheoryData RatioFiles = new TheoryData @@ -49,7 +49,7 @@ public void CloneIsDeep() } [Theory] - [WithFile(TestImages.Png.PngWithMetaData, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Decoder_CanReadTextData(TestImageProvider provider) where TPixel : struct, IPixel { @@ -71,7 +71,7 @@ public void Decoder_CanReadTextData(TestImageProvider provider) } [Theory] - [WithFile(TestImages.Png.PngWithMetaData, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Encoder_PreservesTextData(TestImageProvider provider) where TPixel : struct, IPixel { @@ -118,7 +118,7 @@ public void Decoder_IgnoresInvalidTextData(TestImageProvider pro } [Theory] - [WithFile(TestImages.Png.PngWithMetaData, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Encode_UseCompression_WhenTextIsGreaterThenThreshold_Works(TestImageProvider provider) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index e26aaf8e65..1f8147ea95 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -65,7 +65,7 @@ public void GeneralTest(TestImageProvider provider) // using (Image source = provider.GetImage()) // using (MemoryStream ms = new MemoryStream()) // { - // source.MetaData.Quality = 256; + // source.Metadata.Quality = 256; // source.Save(ms, new PngEncoder(), new PngEncoderOptions { // Threshold = 200 // }); diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs index e946729a15..9d34684f7a 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs @@ -47,7 +47,7 @@ public void Encode_PreserveBitsPerPixel(string imagePath, TgaBitsPerPixel bmpBit memStream.Position = 0; using (Image output = Image.Load(memStream)) { - TgaMetadata meta = output.Metadata.GetFormatMetadata(TgaFormat.Instance); + TgaMetadata meta = output.Metadata.GetTgaMetadata(); Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel); } } @@ -72,7 +72,7 @@ public void Encode_WithCompression_PreserveBitsPerPixel(string imagePath, TgaBit memStream.Position = 0; using (Image output = Image.Load(memStream)) { - TgaMetadata meta = output.Metadata.GetFormatMetadata(TgaFormat.Instance); + TgaMetadata meta = output.Metadata.GetTgaMetadata(); Assert.Equal(bmpBitsPerPixel, meta.BitsPerPixel); } } diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index e972012e29..e41bb4c176 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -312,8 +312,8 @@ private static void CompareGifMetadata(ImageFrame a, ImageFrame b) { // TODO: all metadata classes should be equatable! - GifFrameMetadata aData = a.Metadata.GetFormatMetadata(GifFormat.Instance); - GifFrameMetadata bData = b.Metadata.GetFormatMetadata(GifFormat.Instance); + GifFrameMetadata aData = a.Metadata.GetGifMetadata(); + GifFrameMetadata bData = b.Metadata.GetGifMetadata(); Assert.Equal(aData.DisposalMethod, bData.DisposalMethod); Assert.Equal(aData.FrameDelay, bData.FrameDelay); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.cs b/tests/ImageSharp.Tests/Image/ImageTests.cs index 60384c0578..1e48f14c86 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.cs @@ -74,7 +74,7 @@ public void CreateUninitialized() configuration.MemoryAllocator = new TestMemoryAllocator(dirtyValue); var metadata = new ImageMetadata(); - using (Image image = Image.CreateUninitialized(configuration, 21, 22, metadata)) + using (Image image = Image.CreateUninitialized(configuration, 21, 22, metadata)) { Assert.Equal(21, image.Width); Assert.Equal(22, image.Height); diff --git a/tests/ImageSharp.Tests/MetaData/ImageFrameMetaDataTests.cs b/tests/ImageSharp.Tests/MetaData/ImageFrameMetaDataTests.cs deleted file mode 100644 index bafb117f75..0000000000 --- a/tests/ImageSharp.Tests/MetaData/ImageFrameMetaDataTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Six Labors and contributors. -// Licensed under the Apache License, Version 2.0. - -using SixLabors.ImageSharp.Formats.Gif; -using SixLabors.ImageSharp.Metadata; -using Xunit; - -namespace SixLabors.ImageSharp.Tests -{ - /// - /// Tests the class. - /// - public class ImageFrameMetaDataTests - { - [Fact] - public void ConstructorImageFrameMetaData() - { - const int frameDelay = 42; - const int colorTableLength = 128; - const GifDisposalMethod disposalMethod = GifDisposalMethod.RestoreToBackground; - - var metaData = new ImageFrameMetadata(); - GifFrameMetadata gifFrameMetaData = metaData.GetFormatMetadata(GifFormat.Instance); - gifFrameMetaData.FrameDelay = frameDelay; - gifFrameMetaData.ColorTableLength = colorTableLength; - gifFrameMetaData.DisposalMethod = disposalMethod; - - var clone = new ImageFrameMetadata(metaData); - GifFrameMetadata cloneGifFrameMetaData = clone.GetFormatMetadata(GifFormat.Instance); - - Assert.Equal(frameDelay, cloneGifFrameMetaData.FrameDelay); - Assert.Equal(colorTableLength, cloneGifFrameMetaData.ColorTableLength); - Assert.Equal(disposalMethod, cloneGifFrameMetaData.DisposalMethod); - } - - [Fact] - public void CloneIsDeep() - { - var metaData = new ImageFrameMetadata(); - ImageFrameMetadata clone = metaData.DeepClone(); - Assert.False(metaData.GetFormatMetadata(GifFormat.Instance).Equals(clone.GetFormatMetadata(GifFormat.Instance))); - } - } -} diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs new file mode 100644 index 0000000000..746c0f3c72 --- /dev/null +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -0,0 +1,44 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.Formats.Gif; +using SixLabors.ImageSharp.Metadata; +using Xunit; + +namespace SixLabors.ImageSharp.Tests +{ + /// + /// Tests the class. + /// + public class ImageFrameMetadataTests + { + [Fact] + public void ConstructorImageFrameMetadata() + { + const int frameDelay = 42; + const int colorTableLength = 128; + const GifDisposalMethod disposalMethod = GifDisposalMethod.RestoreToBackground; + + var metaData = new ImageFrameMetadata(); + GifFrameMetadata gifFrameMetadata = metaData.GetGifMetadata(); + gifFrameMetadata.FrameDelay = frameDelay; + gifFrameMetadata.ColorTableLength = colorTableLength; + gifFrameMetadata.DisposalMethod = disposalMethod; + + var clone = new ImageFrameMetadata(metaData); + GifFrameMetadata cloneGifFrameMetadata = clone.GetGifMetadata(); + + Assert.Equal(frameDelay, cloneGifFrameMetadata.FrameDelay); + Assert.Equal(colorTableLength, cloneGifFrameMetadata.ColorTableLength); + Assert.Equal(disposalMethod, cloneGifFrameMetadata.DisposalMethod); + } + + [Fact] + public void CloneIsDeep() + { + var metaData = new ImageFrameMetadata(); + ImageFrameMetadata clone = metaData.DeepClone(); + Assert.False(metaData.GetGifMetadata().Equals(clone.GetGifMetadata())); + } + } +} diff --git a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs similarity index 96% rename from tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs rename to tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs index 39135d0037..bdca87ef7e 100644 --- a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs @@ -8,15 +8,15 @@ using Xunit; -namespace SixLabors.ImageSharp.Tests.MetaData +namespace SixLabors.ImageSharp.Tests.Metadata { /// /// Tests the class. /// - public class ImageMetaDataTests + public class ImageMetadataTests { [Fact] - public void ConstructorImageMetaData() + public void ConstructorImageMetadata() { var metaData = new ImageMetadata(); diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifReaderTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifTagDescriptionAttributeTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifValueTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifValueTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.CurvesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.LutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.LutTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.LutTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.LutTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.MatrixTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElementTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitivesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.PrimitivesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntryTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataReader/IccDataReaderTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.CurvesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.LutTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MatrixTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.MultiProcessElementTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitivesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.PrimitivesTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntryTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/DataWriter/IccDataWriterTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccProfileTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccReaderTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccReaderTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/IccWriterTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs similarity index 100% rename from tests/ImageSharp.Tests/MetaData/Profiles/ICC/Various/IccProfileIdTests.cs rename to tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs diff --git a/tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs similarity index 61% rename from tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs rename to tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index b6e87626b6..6b542badff 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Alpha8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -7,42 +7,42 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { - public class Alpha8Tests + public class A8Tests { [Fact] - public void Alpha8_Constructor() + public void A8_Constructor() { // Test the limits. - Assert.Equal(byte.MinValue, new Alpha8(0F).PackedValue); - Assert.Equal(byte.MaxValue, new Alpha8(1F).PackedValue); + Assert.Equal(byte.MinValue, new A8(0F).PackedValue); + Assert.Equal(byte.MaxValue, new A8(1F).PackedValue); // Test clamping. - Assert.Equal(byte.MinValue, new Alpha8(-1234F).PackedValue); - Assert.Equal(byte.MaxValue, new Alpha8(1234F).PackedValue); + Assert.Equal(byte.MinValue, new A8(-1234F).PackedValue); + Assert.Equal(byte.MaxValue, new A8(1234F).PackedValue); // Test ordering - Assert.Equal(124, new Alpha8(124F / byte.MaxValue).PackedValue); - Assert.Equal(26, new Alpha8(0.1F).PackedValue); + Assert.Equal(124, new A8(124F / byte.MaxValue).PackedValue); + Assert.Equal(26, new A8(0.1F).PackedValue); } [Fact] - public void Alpha8_Equality() + public void A8_Equality() { - var left = new Alpha8(16); - var right = new Alpha8(32); + var left = new A8(16); + var right = new A8(32); - Assert.True(left == new Alpha8(16)); + Assert.True(left == new A8(16)); Assert.True(left != right); - Assert.Equal(left, (object)new Alpha8(16)); + Assert.Equal(left, (object)new A8(16)); } [Fact] - public void Alpha8_FromScaledVector4() + public void A8_FromScaledVector4() { // Arrange - Alpha8 alpha = default; + A8 alpha = default; int expected = 128; - Vector4 scaled = new Alpha8(.5F).ToScaledVector4(); + Vector4 scaled = new A8(.5F).ToScaledVector4(); // Act alpha.FromScaledVector4(scaled); @@ -53,10 +53,10 @@ public void Alpha8_FromScaledVector4() } [Fact] - public void Alpha8_ToScaledVector4() + public void A8_ToScaledVector4() { // Arrange - var alpha = new Alpha8(.5F); + var alpha = new A8(.5F); // Act Vector4 actual = alpha.ToScaledVector4(); @@ -69,10 +69,10 @@ public void Alpha8_ToScaledVector4() } [Fact] - public void Alpha8_ToVector4() + public void A8_ToVector4() { // Arrange - var alpha = new Alpha8(.5F); + var alpha = new A8(.5F); // Act var actual = alpha.ToVector4(); @@ -85,9 +85,9 @@ public void Alpha8_ToVector4() } [Fact] - public void Alpha8_ToRgba32() + public void A8_ToRgba32() { - var input = new Alpha8(128); + var input = new A8(128); var expected = new Rgba32(0, 0, 0, 128); Rgba32 actual = default; @@ -96,10 +96,10 @@ public void Alpha8_ToRgba32() } [Fact] - public void Alpha8_FromBgra5551() + public void A8_FromBgra5551() { // arrange - var alpha = default(Alpha8); + var alpha = default(A8); byte expected = byte.MaxValue; // act diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs index ccefa85c1e..3043626cab 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs @@ -221,7 +221,7 @@ public void Bgr565_FromGrey8() ushort expected = ushort.MaxValue; // act - bgr.FromGray8(new Gray8(byte.MaxValue)); + bgr.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -235,7 +235,7 @@ public void Bgr565_FromGrey16() ushort expected = ushort.MaxValue; // act - bgr.FromGray16(new Gray16(ushort.MaxValue)); + bgr.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs index d4c9986252..b979eebdec 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs @@ -190,7 +190,7 @@ public void Bgra4444_FromGrey16() ushort expectedPackedValue = ushort.MaxValue; // act - bgra.FromGray16(new Gray16(ushort.MaxValue)); + bgra.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgra.PackedValue); @@ -204,7 +204,7 @@ public void Bgra4444_FromGrey8() ushort expectedPackedValue = ushort.MaxValue; // act - bgra.FromGray8(new Gray8(byte.MaxValue)); + bgra.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs index 7751d7ab93..41ebfc9550 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs @@ -215,7 +215,7 @@ public void Bgra5551_FromGrey16() ushort expectedPackedValue = ushort.MaxValue; // act - bgra.FromGray16(new Gray16(ushort.MaxValue)); + bgra.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgra.PackedValue); @@ -229,7 +229,7 @@ public void Bgra5551_FromGrey8() ushort expectedPackedValue = ushort.MaxValue; // act - bgra.FromGray8(new Gray8(byte.MaxValue)); + bgra.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs index 2dff656ac8..2eb5553d7c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs @@ -141,7 +141,7 @@ public void Byte4_FromGrey8() uint expectedPackedValue = uint.MaxValue; // act - byte4.FromGray8(new Gray8(byte.MaxValue)); + byte4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, byte4.PackedValue); @@ -155,7 +155,7 @@ public void Byte4_FromGrey16() uint expectedPackedValue = uint.MaxValue; // act - byte4.FromGray16(new Gray16(ushort.MaxValue)); + byte4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, byte4.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Gray16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs similarity index 75% rename from tests/ImageSharp.Tests/PixelFormats/Gray16Tests.cs rename to tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 8a0bd62c19..179ba12b2d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Gray16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -7,13 +7,13 @@ 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 @@ public void AreEqual() [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 @@ public void AreNotEqual() [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 @@ public void Gray16_FromScaledVector4() [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 @@ public void Gray16_ToScaledVector4(ushort input) } [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 @@ public void Gray16_FromVector4() [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 @@ public void Gray16_ToVector4(ushort input) } [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 @@ public void Gray16_FromRgba32() [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 @@ public void Gray16_ToRgba32(ushort input) } [Fact] - public void Gray16_FromBgra5551() + public void L16_FromBgra5551() { // arrange - var gray = default(Gray16); + var gray = default(L16); ushort expected = ushort.MaxValue; // act diff --git a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs similarity index 58% rename from tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs rename to tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index d7b50ee1e2..13999ee3b2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Gray8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -9,65 +9,66 @@ // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.PixelFormats { - public class Gray8Tests + public class L8Tests { - public static readonly TheoryData LuminanceData = new TheoryData - { - 0, - 1, - 2, - 3, - 5, - 13, - 31, - 71, - 73, - 79, - 83, - 109, - 127, - 128, - 131, - 199, - 250, - 251, - 254, - 255 - }; + public static readonly TheoryData LuminanceData + = new TheoryData + { + 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 @@ public void Gray8_FromScaledVector4() [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 @@ public void Gray8_ToScaledVector4(byte input) [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 @@ public void Gray8_FromVector4(byte luminance) [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 @@ public void Gray8_ToVector4(byte input) [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 @@ public void Gray8_FromRgba32(byte rgb) 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 @@ public void Gray8_ToRgba32(byte luminance) } [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 @@ public void Gray8_FromBgra5551() public class Rgba32Compatibility { // ReSharper disable once MemberHidesStaticFromOuterClass - public static readonly TheoryData LuminanceData = Gray8Tests.LuminanceData; + public static readonly TheoryData 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 @@ public void Gray8_FromRgba32_IsInverseOf_ToRgba32(byte luminance) [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 @@ public void Rgba32_ToGray8_IsInverseOf_Gray8_ToRgba32(byte luminance) [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 @@ public void FromVector4_IsRgba32Compatible(byte luminance) [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); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs new file mode 100644 index 0000000000..3663350067 --- /dev/null +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -0,0 +1,287 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; + +using SixLabors.ImageSharp.PixelFormats; +using Xunit; + +// ReSharper disable InconsistentNaming +namespace SixLabors.ImageSharp.Tests.PixelFormats +{ + public class La16Tests + { + public static readonly TheoryData LuminanceData + = new TheoryData + { + 0, + 1, + 2, + 3, + 5, + 13, + 31, + 71, + 73, + 79, + 83, + 109, + 127, + 128, + 131, + 199, + 250, + 251, + 254, + 255 + }; + + [Theory] + [InlineData(0, 0)] + [InlineData(255, 65535)] + [InlineData(10, 2570)] + [InlineData(42, 10794)] + public void La16_PackedValue_EqualsPackedInput(byte input, ushort packed) + => Assert.Equal(packed, new La16(input, input).PackedValue); + + [Fact] + public void AreEqual() + { + var color1 = new La16(100, 50); + var color2 = new La16(100, 50); + + Assert.Equal(color1, color2); + } + + [Fact] + public void AreNotEqual() + { + var color1 = new La16(100, 50); + var color2 = new La16(200, 50); + + Assert.NotEqual(color1, color2); + } + + [Fact] + public void La16_FromScaledVector4() + { + // Arrange + La16 gray = default; + const ushort expected = 32896; + Vector4 scaled = new La16(128, 128).ToScaledVector4(); + + // Act + gray.FromScaledVector4(scaled); + ushort actual = gray.PackedValue; + + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_ToScaledVector4(byte input) + { + // Arrange + var gray = new La16(input, input); + + // Act + Vector4 actual = gray.ToScaledVector4(); + + // Assert + float scaledInput = input / 255F; + Assert.Equal(scaledInput, actual.X); + Assert.Equal(scaledInput, actual.Y); + Assert.Equal(scaledInput, actual.Z); + Assert.Equal(scaledInput, actual.W); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_FromVector4(byte luminance) + { + // Arrange + La16 gray = default; + var vector = new La16(luminance, luminance).ToVector4(); + + // Act + gray.FromVector4(vector); + byte actualL = gray.L; + byte actualA = gray.A; + + // Assert + Assert.Equal(luminance, actualL); + Assert.Equal(luminance, actualA); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_ToVector4(byte input) + { + // Arrange + var gray = new La16(input, input); + + // Act + var actual = gray.ToVector4(); + + // Assert + float scaledInput = input / 255F; + Assert.Equal(scaledInput, actual.X); + Assert.Equal(scaledInput, actual.Y); + Assert.Equal(scaledInput, actual.Z); + Assert.Equal(scaledInput, actual.W); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_FromRgba32(byte rgb) + { + // Arrange + La16 gray = default; + byte expected = ImageMaths.Get8BitBT709Luminance(rgb, rgb, rgb); + + // Act + gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); + byte actual = gray.L; + + // Assert + Assert.Equal(expected, actual); + Assert.Equal(255, gray.A); + } + + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_ToRgba32(byte luminance) + { + // Arrange + var gray = new La16(luminance, luminance); + + // Act + Rgba32 actual = default; + gray.ToRgba32(ref actual); + + // Assert + Assert.Equal(luminance, actual.R); + Assert.Equal(luminance, actual.G); + Assert.Equal(luminance, actual.B); + Assert.Equal(luminance, actual.A); + } + + [Fact] + public void La16_FromBgra5551() + { + // arrange + var grey = default(La16); + byte expected = byte.MaxValue; + + // act + grey.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + + // assert + Assert.Equal(expected, grey.L); + Assert.Equal(expected, grey.A); + } + + public class Rgba32Compatibility + { + // ReSharper disable once MemberHidesStaticFromOuterClass + public static readonly TheoryData LuminanceData = La16Tests.LuminanceData; + + [Theory] + [MemberData(nameof(LuminanceData))] + public void La16_FromRgba32_IsInverseOf_ToRgba32(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + La16 mirror = default; + mirror.FromRgba32(rgba); + + Assert.Equal(original, mirror); + } + + + [Theory] + [MemberData(nameof(LuminanceData))] + public void Rgba32_ToLa16_IsInverseOf_La16_ToRgba32(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + La16 mirror = default; + mirror.FromRgba32(rgba); + + Assert.Equal(original, mirror); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void ToVector4_IsRgba32Compatible(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + var La16Vector = original.ToVector4(); + var rgbaVector = original.ToVector4(); + + Assert.Equal(La16Vector, rgbaVector, new ApproximateFloatComparer(1e-5f)); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void FromVector4_IsRgba32Compatible(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + var rgbaVector = original.ToVector4(); + + La16 mirror = default; + mirror.FromVector4(rgbaVector); + + Assert.Equal(original, mirror); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void ToScaledVector4_IsRgba32Compatible(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + Vector4 La16Vector = original.ToScaledVector4(); + Vector4 rgbaVector = original.ToScaledVector4(); + + Assert.Equal(La16Vector, rgbaVector, new ApproximateFloatComparer(1e-5f)); + } + + [Theory] + [MemberData(nameof(LuminanceData))] + public void FromScaledVector4_IsRgba32Compatible(byte luminance) + { + var original = new La16(luminance, luminance); + + Rgba32 rgba = default; + original.ToRgba32(ref rgba); + + Vector4 rgbaVector = original.ToScaledVector4(); + + La16 mirror = default; + mirror.FromScaledVector4(rgbaVector); + + Assert.Equal(original, mirror); + } + } + } +} diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs new file mode 100644 index 0000000000..40739c69a2 --- /dev/null +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -0,0 +1,168 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System.Numerics; +using SixLabors.ImageSharp.PixelFormats; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.PixelFormats +{ + public class La32Tests + { + [Fact] + public void AreEqual() + { + var color1 = new La32(3000, 100); + var color2 = new La32(3000, 100); + + Assert.Equal(color1, color2); + } + + [Fact] + public void AreNotEqual() + { + var color1 = new La32(12345, 100); + var color2 = new La32(54321, 100); + + Assert.NotEqual(color1, color2); + } + + [Theory] + [InlineData(0, 0)] + [InlineData(65535, 4294967295)] + [InlineData(32767, 2147450879)] + [InlineData(42, 2752554)] + public void La32_PackedValue_EqualsInput(ushort input, uint packed) + => Assert.Equal(packed, new La32(input, input).PackedValue); + + [Fact] + public void La32_FromScaledVector4() + { + // Arrange + La32 gray = default; + const ushort expected = 32767; + Vector4 scaled = new La32(expected, expected).ToScaledVector4(); + + // Act + gray.FromScaledVector4(scaled); + ushort actual = gray.L; + ushort actualA = gray.A; + + // Assert + Assert.Equal(expected, actual); + Assert.Equal(expected, actualA); + } + + [Theory] + [InlineData(0)] + [InlineData(65535)] + [InlineData(32767)] + public void La32_ToScaledVector4(ushort input) + { + // Arrange + var gray = new La32(input, input); + + // Act + Vector4 actual = gray.ToScaledVector4(); + + // Assert + float vectorInput = input / 65535F; + Assert.Equal(vectorInput, actual.X); + Assert.Equal(vectorInput, actual.Y); + Assert.Equal(vectorInput, actual.Z); + Assert.Equal(vectorInput, actual.W); + } + + [Fact] + public void La32_FromVector4() + { + // Arrange + La32 gray = default; + const ushort expected = 32767; + var vector = new La32(expected, expected).ToVector4(); + + // Act + gray.FromVector4(vector); + ushort actual = gray.L; + ushort actualA = gray.A; + + // Assert + Assert.Equal(expected, actual); + Assert.Equal(expected, actualA); + } + + [Theory] + [InlineData(0)] + [InlineData(65535)] + [InlineData(32767)] + public void La32_ToVector4(ushort input) + { + // Arrange + var gray = new La32(input, input); + + // Act + var actual = gray.ToVector4(); + + // Assert + float vectorInput = input / 65535F; + Assert.Equal(vectorInput, actual.X); + Assert.Equal(vectorInput, actual.Y); + Assert.Equal(vectorInput, actual.Z); + Assert.Equal(vectorInput, actual.W); + } + + [Fact] + public void La32_FromRgba32() + { + // Arrange + La32 gray = default; + const byte rgb = 128; + ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb); + ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); + + // Act + gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); + ushort actual = gray.L; + + // Assert + Assert.Equal(expected, actual); + Assert.Equal(ushort.MaxValue, gray.A); + } + + [Theory] + [InlineData(0)] + [InlineData(65535)] + [InlineData(8100)] + public void La32_ToRgba32(ushort input) + { + // Arrange + ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input); + var gray = new La32(input, ushort.MaxValue); + + // Act + Rgba32 actual = default; + gray.ToRgba32(ref actual); + + // Assert + Assert.Equal(expected, actual.R); + Assert.Equal(expected, actual.G); + Assert.Equal(expected, actual.B); + Assert.Equal(byte.MaxValue, actual.A); + } + + [Fact] + public void La32_FromBgra5551() + { + // arrange + var gray = default(La32); + ushort expected = ushort.MaxValue; + + // act + gray.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + + // assert + Assert.Equal(expected, gray.L); + Assert.Equal(expected, gray.A); + } + } +} diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs index 7687a7777c..7f02493b47 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs @@ -127,7 +127,7 @@ public void NormalizedByte4_FromGrey8() Vector4 expected = Vector4.One; // act - byte4.FromGray8(new Gray8(byte.MaxValue)); + byte4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, byte4.ToScaledVector4()); @@ -141,7 +141,7 @@ public void NormalizedByte4_FromGrey16() Vector4 expected = Vector4.One; // act - byte4.FromGray16(new Gray16(ushort.MaxValue)); + byte4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, byte4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs index b872e58b68..834bae685c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs @@ -128,7 +128,7 @@ public void NormalizedShort4_FromGrey8() Vector4 expected = Vector4.One; // act - byte4.FromGray8(new Gray8(byte.MaxValue)); + byte4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, byte4.ToScaledVector4()); @@ -142,7 +142,7 @@ public void NormalizedShort4_FromGrey16() Vector4 expected = Vector4.One; // act - byte4.FromGray16(new Gray16(ushort.MaxValue)); + byte4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, byte4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs index d03cfeee22..6a678abc7f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelConverterTests.ReferenceImplementations.cs @@ -69,32 +69,32 @@ internal static void To( return; } - // Gray8 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(destinationPixels)); + ref L16 L16Ref = ref MemoryMarshal.GetReference( + MemoryMarshal.Cast(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()); } return; } - if (typeof(TDestinationPixel) == typeof(Gray8)) + if (typeof(TDestinationPixel) == typeof(L8)) { - ref Gray8 gray8Ref = ref MemoryMarshal.GetReference( - MemoryMarshal.Cast(destinationPixels)); + ref L8 L8Ref = ref MemoryMarshal.GetReference( + MemoryMarshal.Cast(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()); } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray8OperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L16OperationsTests.cs similarity index 70% rename from tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray8OperationsTests.cs rename to tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L16OperationsTests.cs index 24b20eecab..ddcdc30bfd 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray8OperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L16OperationsTests.cs @@ -10,15 +10,16 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations { public partial class PixelOperationsTests { - public class Gray8OperationsTests : PixelOperationsTests + public class L16OperationsTests : PixelOperationsTests { - public Gray8OperationsTests(ITestOutputHelper output) + public L16OperationsTests(ITestOutputHelper output) : base(output) { } [Fact] - public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); + public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); + } } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray16OperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L8OperationsTests.cs similarity index 69% rename from tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray16OperationsTests.cs rename to tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L8OperationsTests.cs index ffb1a0b027..b2a1a2dc3a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.Gray16OperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.L8OperationsTests.cs @@ -10,16 +10,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations { public partial class PixelOperationsTests { - public class Gray16OperationsTests : PixelOperationsTests + public class L8OperationsTests : PixelOperationsTests { - public Gray16OperationsTests(ITestOutputHelper output) + public L8OperationsTests(ITestOutputHelper output) : base(output) { } [Fact] - public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); - + public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); } } } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La16OperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La16OperationsTests.cs new file mode 100644 index 0000000000..f03aa5587f --- /dev/null +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La16OperationsTests.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +using Xunit; +using Xunit.Abstractions; + +namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations +{ + public partial class PixelOperationsTests + { + public class La16OperationsTests : PixelOperationsTests + { + public La16OperationsTests(ITestOutputHelper output) + : base(output) + { + } + + [Fact] + public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); + + } + } +} diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La32OperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La32OperationsTests.cs new file mode 100644 index 0000000000..2112a2fea3 --- /dev/null +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.La32OperationsTests.cs @@ -0,0 +1,25 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.PixelFormats; + +using Xunit; +using Xunit.Abstractions; + +namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations +{ + public partial class PixelOperationsTests + { + public class La32OperationsTests : PixelOperationsTests + { + public La32OperationsTests(ITestOutputHelper output) + : base(output) + { + } + + [Fact] + public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance); + + } + } +} diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 682da89fcc..ef2531060e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -280,15 +280,15 @@ public void ToVector4(int count) public static readonly TheoryData Generic_To_Data = new TheoryData - { - default(Rgba32), - default(Bgra32), - default(Rgb24), - default(Gray8), - default(Gray16), - default(Rgb48), - default(Rgba64) - }; + { + default(Rgba32), + default(Bgra32), + default(Rgb24), + default(L8), + default(L16), + default(Rgb48), + default(Rgba64) + }; [Theory] [MemberData(nameof(Generic_To_Data))] @@ -569,6 +569,236 @@ public void ToBgra32Bytes(int count) ); } + [Theory] + [MemberData(nameof(ArraySizesData))] + public void FromBgra5551Bytes(int count) + { + int size = Unsafe.SizeOf(); + byte[] source = CreateByteTestData(count * size); + var expected = new TPixel[count]; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + + Bgra5551 bgra = MemoryMarshal.Cast(source.AsSpan().Slice(offset, size))[0]; + expected[i].FromBgra5551(bgra); + } + + TestOperation( + source, + expected, + (s, d) => Operations.FromBgra5551Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToBgra5551Bytes(int count) + { + int size = Unsafe.SizeOf(); + TPixel[] source = CreatePixelTestData(count); + var expected = new byte[count * size]; + Bgra5551 bgra = default; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + bgra.FromScaledVector4(source[i].ToScaledVector4()); + OctetBytes bytes = Unsafe.As(ref bgra); + expected[offset] = bytes[0]; + expected[offset + 1] = bytes[1]; + } + + TestOperation( + source, + expected, + (s, d) => Operations.ToBgra5551Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void FromL8(int count) + { + byte[] sourceBytes = CreateByteTestData(count); + L8[] source = sourceBytes.Select(b => new L8(b)).ToArray(); + var expected = new TPixel[count]; + + + for (int i = 0; i < count; i++) + { + expected[i].FromL8(source[i]); + } + + TestOperation( + source, + expected, + (s, d) => Operations.FromL8(this.Configuration, s, d.GetSpan()) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToL8(int count) + { + TPixel[] source = CreatePixelTestData(count); + var expected = new L8[count]; + + for (int i = 0; i < count; i++) + { + expected[i].FromScaledVector4(source[i].ToScaledVector4()); + } + + TestOperation( + source, + expected, + (s, d) => Operations.ToL8(this.Configuration, s, d.GetSpan()) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void FromL16(int count) + { + L16[] source = CreateVector4TestData(count).Select(v => + { + L16 g = default; + g.FromVector4(v); + return g; + }).ToArray(); + + var expected = new TPixel[count]; + + for (int i = 0; i < count; i++) + { + expected[i].FromL16(source[i]); + } + + TestOperation( + source, + expected, + (s, d) => Operations.FromL16(this.Configuration, s, d.GetSpan()) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToL16(int count) + { + TPixel[] source = CreatePixelTestData(count); + var expected = new L16[count]; + + for (int i = 0; i < count; i++) + { + expected[i].FromScaledVector4(source[i].ToScaledVector4()); + } + + TestOperation( + source, + expected, + (s, d) => Operations.ToL16(this.Configuration, s, d.GetSpan()) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void FromLa16Bytes(int count) + { + int size = Unsafe.SizeOf(); + byte[] source = CreateByteTestData(count * size); + var expected = new TPixel[count]; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + + La16 la = MemoryMarshal.Cast(source.AsSpan().Slice(offset, size))[0]; + expected[i].FromLa16(la); + } + + TestOperation( + source, + expected, + (s, d) => Operations.FromLa16Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToLa16Bytes(int count) + { + int size = Unsafe.SizeOf(); + TPixel[] source = CreatePixelTestData(count); + var expected = new byte[count * size]; + La16 la = default; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + la.FromScaledVector4(source[i].ToScaledVector4()); + OctetBytes bytes = Unsafe.As(ref la); + expected[offset] = bytes[0]; + expected[offset + 1] = bytes[1]; + } + + TestOperation( + source, + expected, + (s, d) => Operations.ToLa16Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void FromLa32Bytes(int count) + { + int size = Unsafe.SizeOf(); + byte[] source = CreateByteTestData(count * size); + var expected = new TPixel[count]; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + + La32 la = MemoryMarshal.Cast(source.AsSpan().Slice(offset, size))[0]; + expected[i].FromLa32(la); + } + + TestOperation( + source, + expected, + (s, d) => Operations.FromLa32Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToLa32Bytes(int count) + { + var size = Unsafe.SizeOf(); + TPixel[] source = CreatePixelTestData(count); + var expected = new byte[count * size]; + La32 la = default; + + for (int i = 0; i < count; i++) + { + int offset = i * size; + la.FromScaledVector4(source[i].ToScaledVector4()); + OctetBytes bytes = Unsafe.As(ref la); + expected[offset] = bytes[0]; + expected[offset + 1] = bytes[1]; + expected[offset + 2] = bytes[2]; + expected[offset + 3] = bytes[3]; + } + + TestOperation( + source, + expected, + (s, d) => Operations.ToLa32Bytes(this.Configuration, s, d.GetSpan(), count) + ); + } + [Theory] [MemberData(nameof(ArraySizesData))] public void FromRgb24Bytes(int count) @@ -760,91 +990,6 @@ public void ToRgba64Bytes(int count) ); } - - [Theory] - [MemberData(nameof(ArraySizesData))] - public void FromGray8(int count) - { - byte[] sourceBytes = CreateByteTestData(count); - Gray8[] source = sourceBytes.Select(b => new Gray8(b)).ToArray(); - var expected = new TPixel[count]; - - - for (int i = 0; i < count; i++) - { - expected[i].FromGray8(source[i]); - } - - TestOperation( - source, - expected, - (s, d) => Operations.FromGray8(this.Configuration, s, d.GetSpan()) - ); - } - - [Theory] - [MemberData(nameof(ArraySizesData))] - public void ToGray8(int count) - { - TPixel[] source = CreatePixelTestData(count); - var expected = new Gray8[count]; - - for (int i = 0; i < count; i++) - { - expected[i].FromScaledVector4(source[i].ToScaledVector4()); - } - - TestOperation( - source, - expected, - (s, d) => Operations.ToGray8(this.Configuration, s, d.GetSpan()) - ); - } - - [Theory] - [MemberData(nameof(ArraySizesData))] - public void FromGray16(int count) - { - Gray16[] source = CreateVector4TestData(count).Select(v => - { - Gray16 g = default; - g.FromVector4(v); - return g; - }).ToArray(); - - var expected = new TPixel[count]; - - for (int i = 0; i < count; i++) - { - expected[i].FromGray16(source[i]); - } - - TestOperation( - source, - expected, - (s, d) => Operations.FromGray16(this.Configuration, s, d.GetSpan()) - ); - } - - [Theory] - [MemberData(nameof(ArraySizesData))] - public void ToGray16(int count) - { - TPixel[] source = CreatePixelTestData(count); - var expected = new Gray16[count]; - - for (int i = 0; i < count; i++) - { - expected[i].FromScaledVector4(source[i].ToScaledVector4()); - } - - TestOperation( - source, - expected, - (s, d) => Operations.ToGray16(this.Configuration, s, d.GetSpan()) - ); - } - public delegate void RefAction(ref T1 arg1); internal static Vector4[] CreateExpectedVector4Data(TPixel[] source, RefAction vectorModifier = null) @@ -1016,18 +1161,6 @@ public void Verify() // ReSharper restore PossibleNullReferenceException } } - else if (typeof(TDest) == typeof(Gray16)) - { - // Minor difference is tolerated for 16 bit pixel values - Span expected = MemoryMarshal.Cast(this.ExpectedDestBuffer.AsSpan()); - Span actual = MemoryMarshal.Cast(this.ActualDestBuffer.GetSpan()); - - for (int i = 0; i < count; i++) - { - int difference = expected[i].PackedValue - actual[i].PackedValue; - Assert.True(Math.Abs(difference) < 2); - } - } else { Span expected = this.ExpectedDestBuffer.AsSpan(); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs index 3a28c82b7b..56cb526a4d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs @@ -162,7 +162,7 @@ public void Rgba1010102_FromGrey8() uint expectedPackedValue = uint.MaxValue; // act - rgba.FromGray8(new Gray8(byte.MaxValue)); + rgba.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -176,7 +176,7 @@ public void Rgba1010102_FromGrey16() uint expectedPackedValue = uint.MaxValue; // act - rgba.FromGray16(new Gray16(ushort.MaxValue)); + rgba.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs index fe2f8394ff..3a2841bb3b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs @@ -169,7 +169,7 @@ public void RgbaVector_FromGrey16() Vector4 expected = Vector4.One; // act - rgba.FromGray16(new Gray16(ushort.MaxValue)); + rgba.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); @@ -183,7 +183,7 @@ public void RgbaVector_FromGrey8() Vector4 expected = Vector4.One; // act - rgba.FromGray8(new Gray8(byte.MaxValue)); + rgba.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index 296b8d1d7f..6bd8c9b2f5 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -132,7 +132,9 @@ public void BokehBlurFilterProcessor(TestImageProvider provider, } [Theory] - [WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32 | PixelTypes.Gray8)] + // TODO: Re-enable L8 when we update the reference images. + // [WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32 | PixelTypes.L8)] + [WithTestPatternImages(200, 200, PixelTypes.Bgr24 | PixelTypes.Bgra32)] public void BokehBlurFilterProcessor_WorksWithAllPixelTypes(TestImageProvider provider) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs index 3ac9af960b..19226b3071 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs @@ -15,7 +15,7 @@ public void HelperCanChangeExifDataType() { int xy = 1; - using (var img = new Image(xy, xy)) + using (var img = new Image(xy, xy)) { var profile = new ExifProfile(); img.Metadata.ExifProfile = profile; diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 0a56110560..0f44b8e1cc 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -252,8 +252,10 @@ public void FromArgb32(Argb32 source) { } public void FromBgra5551(Bgra5551 source) { } public void FromBgr24(Bgr24 source) { } public void FromBgra32(Bgra32 source) { } - public void FromGray8(Gray8 source) { } - public void FromGray16(Gray16 source) { } + public void FromL8(L8 source) { } + public void FromL16(L16 source) { } + public void FromLa16(La16 source) { } + public void FromLa32(La32 source) { } public void FromRgb24(Rgb24 source) { } public void FromRgba32(Rgba32 source) { } public void ToRgba32(ref Rgba32 dest) { } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 8f1eca4829..8389d85351 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -27,9 +27,9 @@ public static class Png 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 GrayAlpha8Bit = "Png/gray-alpha-8.png"; - public const string GrayAlpha8BitInterlaced = "Png/rollsroyce.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"; public const string GrayAlpha2BitInterlaced = "Png/iftbbn0g02.png"; public const string Gray4BitInterlaced = "Png/iftbbn0g04.png"; @@ -52,9 +52,9 @@ public static class Png 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 PngWithMetadata = "Png/PngWithMetaData.png"; public const string InvalidTextData = "Png/InvalidTextData.png"; // Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 78431f31aa..0c7334d007 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -14,7 +14,7 @@ public enum PixelTypes { Undefined = 0, - Alpha8 = 1 << 0, + A8 = 1 << 0, Argb32 = 1 << 1, @@ -60,7 +60,7 @@ public enum PixelTypes Bgra5551 = 1 << 22, - Gray8 = 1 << 23, + L8 = 1 << 23, // TODO: Add multi-flag entries by rules defined in PackedPixelConverterHelper diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index b56ce05171..a6ca008995 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -39,8 +39,8 @@ static TestUtils() ClrTypes2PixelTypes[defaultPixelFormatType] = PixelTypes.Rgba32; // Add PixelFormat types - string nameSpace = typeof(Alpha8).FullName; - nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Alpha8).Name.Length - 1); + string nameSpace = typeof(A8).FullName; + nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(A8).Name.Length - 1); foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.Rgba32)) { string typeName = $"{nameSpace}.{pt}"; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs index b60439b488..3b4097820a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs @@ -58,7 +58,7 @@ public void MagickDecode_8BitDepthImage_IsEquivalentTo_SystemDrawingResult(TestImageProvider dummyProvider, string testImage) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 738465a6ed..416f4034f4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -170,7 +170,7 @@ public void NoOutputSubfolderIsPresentByDefault(TestImageProvider(TestImageProvider provider, PixelTypes expected) where TPixel : struct, IPixel => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 301d0cebe6..64b217a028 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -99,13 +99,13 @@ private static void AssertContainsPixelType( [Fact] public void ExpandAllTypes_1() { - PixelTypes pixelTypes = PixelTypes.Alpha8 | PixelTypes.Bgr565 | PixelTypes.HalfVector2 | PixelTypes.Rgba32; + PixelTypes pixelTypes = PixelTypes.A8 | PixelTypes.Bgr565 | PixelTypes.HalfVector2 | PixelTypes.Rgba32; IEnumerable> expanded = pixelTypes.ExpandAllTypes(); Assert.Equal(4, expanded.Count()); - AssertContainsPixelType(PixelTypes.Alpha8, expanded); + AssertContainsPixelType(PixelTypes.A8, expanded); AssertContainsPixelType(PixelTypes.Bgr565, expanded); AssertContainsPixelType(PixelTypes.HalfVector2, expanded); AssertContainsPixelType(PixelTypes.Rgba32, expanded);