From f6259616c8b6cf95b27d299b32f6096ba8156c5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:33:48 +0000 Subject: [PATCH 001/112] Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index cd22fe5e5..985b3aefb 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -81,7 +81,7 @@ jobs: path: tests/Images/ActualOutput/ - name: Codecov Update - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors') with: flags: unittests From 09818324ba3cea651c14a802c75b11883a7a2831 Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Fri, 6 Jun 2025 18:34:43 +0400 Subject: [PATCH 002/112] Reduce the number of memory allocations in lossless WebP encoder --- .../Webp/Lossless/BackwardReferenceEncoder.cs | 31 ++++++----- .../Formats/Webp/Lossless/CostModel.cs | 4 +- .../Formats/Webp/Lossless/HistogramEncoder.cs | 6 +-- .../Formats/Webp/Lossless/PixOrCopy.cs | 45 ++++++---------- .../Formats/Webp/Lossless/Vp8LBackwardRefs.cs | 30 +++++++---- .../Formats/Webp/Lossless/Vp8LEncoder.cs | 54 +++++++++---------- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 4 +- .../Formats/WebP/Vp8LHistogramTests.cs | 12 ++--- 8 files changed, 86 insertions(+), 100 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 2e7dd722f..7a2679173 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -149,9 +149,9 @@ internal static class BackwardReferenceEncoder } // Find the cacheBits giving the lowest entropy. - for (int idx = 0; idx < refs.Refs.Count; idx++) + for (int idx = 0; idx < refs.Count; idx++) { - PixOrCopy v = refs.Refs[idx]; + PixOrCopy v = refs[idx]; if (v.IsLiteral()) { uint pix = bgra[pos++]; @@ -387,7 +387,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - backwardRefs.Refs.Clear(); + backwardRefs.Clear(); for (int ix = 0; ix < chosenPathSize; ix++) { int len = chosenPath[ix]; @@ -479,7 +479,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - refs.Refs.Clear(); + refs.Clear(); for (int i = 0; i < pixCount;) { // Alternative #1: Code the pixels starting at 'i' using backward reference. @@ -734,7 +734,7 @@ internal static class BackwardReferenceEncoder colorCache = new ColorCache(cacheBits); } - refs.Refs.Clear(); + refs.Clear(); // Add first pixel as literal. AddSingleLiteral(bgra[0], useColorCache, colorCache, refs); @@ -779,10 +779,10 @@ internal static class BackwardReferenceEncoder private static void BackwardRefsWithLocalCache(ReadOnlySpan bgra, int cacheBits, Vp8LBackwardRefs refs) { int pixelIndex = 0; - ColorCache colorCache = new ColorCache(cacheBits); - for (int idx = 0; idx < refs.Refs.Count; idx++) + ColorCache colorCache = new(cacheBits); + for (int idx = 0; idx < refs.Count; idx++) { - PixOrCopy v = refs.Refs[idx]; + PixOrCopy v = refs[idx]; if (v.IsLiteral()) { uint bgraLiteral = v.BgraOrDistance; @@ -790,9 +790,7 @@ internal static class BackwardReferenceEncoder if (ix >= 0) { // Color cache contains bgraLiteral - v.Mode = PixOrCopyMode.CacheIdx; - v.BgraOrDistance = (uint)ix; - v.Len = 1; + refs[idx] = PixOrCopy.CreateCacheIdx(ix); } else { @@ -814,14 +812,15 @@ internal static class BackwardReferenceEncoder private static void BackwardReferences2DLocality(int xSize, Vp8LBackwardRefs refs) { - using List.Enumerator c = refs.Refs.GetEnumerator(); - while (c.MoveNext()) + for (int idx = 0; idx < refs.Count; idx++) { - if (c.Current.IsCopy()) + PixOrCopy v = refs[idx]; + + if (v.IsCopy()) { - int dist = (int)c.Current.BgraOrDistance; + int dist = (int)v.BgraOrDistance; int transformedDist = DistanceToPlaneCode(xSize, dist); - c.Current.BgraOrDistance = (uint)transformedDist; + refs[idx] = PixOrCopy.CreateCopy((uint)transformedDist, v.Len); } } } diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs index beebc48ab..15b0f4222 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs @@ -40,9 +40,9 @@ internal class CostModel using OwnedVp8LHistogram histogram = OwnedVp8LHistogram.Create(this.memoryAllocator, cacheBits); // The following code is similar to HistogramCreate but converts the distance to plane code. - for (int i = 0; i < backwardRefs.Refs.Count; i++) + for (int i = 0; i < backwardRefs.Count; i++) { - histogram.AddSinglePixOrCopy(backwardRefs.Refs[i], true, xSize); + histogram.AddSinglePixOrCopy(backwardRefs[i], true, xSize); } ConvertPopulationCountTableToBitEstimates(histogram.NumCodes(), histogram.Literal, this.Literal); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index 3a96362cf..c5d1aa145 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -109,10 +109,10 @@ internal static class HistogramEncoder { int x = 0, y = 0; int histoXSize = LosslessUtils.SubSampleSize(xSize, histoBits); - using List.Enumerator backwardRefsEnumerator = backwardRefs.Refs.GetEnumerator(); - while (backwardRefsEnumerator.MoveNext()) + + for (int i = 0; i < backwardRefs.Count; i++) { - PixOrCopy v = backwardRefsEnumerator.Current; + PixOrCopy v = backwardRefs[i]; int ix = ((y >> histoBits) * histoXSize) + (x >> histoBits); histograms[ix].AddSinglePixOrCopy(v, false); x += v.Len; diff --git a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs index d6b10ada5..bb8ce18aa 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs @@ -6,37 +6,24 @@ using System.Diagnostics; namespace SixLabors.ImageSharp.Formats.Webp.Lossless; [DebuggerDisplay("Mode: {Mode}, Len: {Len}, BgraOrDistance: {BgraOrDistance}")] -internal sealed class PixOrCopy +internal readonly struct PixOrCopy { - public PixOrCopyMode Mode { get; set; } - - public ushort Len { get; set; } - - public uint BgraOrDistance { get; set; } - - public static PixOrCopy CreateCacheIdx(int idx) => - new PixOrCopy - { - Mode = PixOrCopyMode.CacheIdx, - BgraOrDistance = (uint)idx, - Len = 1 - }; - - public static PixOrCopy CreateLiteral(uint bgra) => - new PixOrCopy - { - Mode = PixOrCopyMode.Literal, - BgraOrDistance = bgra, - Len = 1 - }; - - public static PixOrCopy CreateCopy(uint distance, ushort len) => - new PixOrCopy + public readonly PixOrCopyMode Mode; + public readonly ushort Len; + public readonly uint BgraOrDistance; + + private PixOrCopy(PixOrCopyMode mode, ushort len, uint bgraOrDistance) { - Mode = PixOrCopyMode.Copy, - BgraOrDistance = distance, - Len = len - }; + this.Mode = mode; + this.Len = len; + this.BgraOrDistance = bgraOrDistance; + } + + public static PixOrCopy CreateCacheIdx(int idx) => new(PixOrCopyMode.CacheIdx, 1, (uint)idx); + + public static PixOrCopy CreateLiteral(uint bgra) => new(PixOrCopyMode.Literal, 1, bgra); + + public static PixOrCopy CreateCopy(uint distance, ushort len) => new(PixOrCopyMode.Copy, len, distance); public int Literal(int component) => (int)(this.BgraOrDistance >> (component * 8)) & 0xFF; diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index ace9d6227..6a2869995 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -1,21 +1,29 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Buffers; +using SixLabors.ImageSharp.Memory; + namespace SixLabors.ImageSharp.Formats.Webp.Lossless; -internal class Vp8LBackwardRefs +internal class Vp8LBackwardRefs : IDisposable { - public Vp8LBackwardRefs(int pixels) => this.Refs = new List(pixels); + private readonly IMemoryOwner refs; + + public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels) + { + this.refs = memoryAllocator.Allocate(pixels); + this.Count = 0; + } + + public int Count { get; private set; } + + public ref PixOrCopy this[int index] => ref this.refs.Memory.Span[index]; - /// - /// Gets or sets the common block-size. - /// - public int BlockSize { get; set; } + public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.Count++] = pixOrCopy; - /// - /// Gets the backward references. - /// - public List Refs { get; } + public void Clear() => this.Count = 0; - public void Add(PixOrCopy pixOrCopy) => this.Refs.Add(pixOrCopy); + /// + public void Dispose() => this.refs.Dispose(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index 1864e539c..e19126fff 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -26,9 +26,9 @@ internal class Vp8LEncoder : IDisposable /// private ScratchBuffer scratch; // mutable struct, don't make readonly - private readonly int[][] histoArgb = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] histoArgb = [new int[256], new int[256], new int[256], new int[256]]; - private readonly int[][] bestHisto = { new int[256], new int[256], new int[256], new int[256] }; + private readonly int[][] bestHisto = [new int[256], new int[256], new int[256], new int[256]]; /// /// The to use for buffer allocations. @@ -45,11 +45,6 @@ internal class Vp8LEncoder : IDisposable /// private const int MaxRefsBlockPerImage = 16; - /// - /// Minimum block size for backward references. - /// - private const int MinBlockSize = 256; - /// /// A bit writer for writing lossless webp streams. /// @@ -136,14 +131,9 @@ internal class Vp8LEncoder : IDisposable this.Refs = new Vp8LBackwardRefs[3]; this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); - // We round the block size up, so we're guaranteed to have at most MaxRefsBlockPerImage blocks used: - int refsBlockSize = ((pixelCount - 1) / MaxRefsBlockPerImage) + 1; for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new Vp8LBackwardRefs(pixelCount) - { - BlockSize = refsBlockSize < MinBlockSize ? MinBlockSize : refsBlockSize - }; + this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount); } } @@ -151,10 +141,10 @@ internal class Vp8LEncoder : IDisposable // This sequence is tuned from that, but more weighted for lower symbol count, // and more spiking histograms. // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan StorageOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + private static ReadOnlySpan StorageOrder => [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Order => new byte[] { 1, 2, 0, 3 }; + private static ReadOnlySpan Order => [1, 2, 0, 3]; /// /// Gets the memory for the image data as packed bgra values. @@ -547,7 +537,7 @@ internal class Vp8LEncoder : IDisposable EntropyIx entropyIdx = this.AnalyzeEntropy(bgra, width, height, usePalette, this.PaletteSize, this.TransformBits, out redAndBlueAlwaysZero); bool doNotCache = false; - List crunchConfigs = new(); + List crunchConfigs = []; if (this.method == WebpEncodingMethod.BestQuality && this.quality == 100) { @@ -593,7 +583,7 @@ internal class Vp8LEncoder : IDisposable } } - return crunchConfigs.ToArray(); + return [.. crunchConfigs]; } private void EncodeImage(int width, int height, bool useCache, CrunchConfig config, int cacheBits, bool lowEffort) @@ -1068,9 +1058,9 @@ internal class Vp8LEncoder : IDisposable int histogramIx = histogramSymbols[0]; Span codes = huffmanCodes.AsSpan(5 * histogramIx); - for (int i = 0; i < backwardRefs.Refs.Count; i++) + for (int i = 0; i < backwardRefs.Count; i++) { - PixOrCopy v = backwardRefs.Refs[i]; + PixOrCopy v = backwardRefs[i]; if (tileX != (x & tileMask) || tileY != (y & tileMask)) { tileX = x & tileMask; @@ -1265,13 +1255,13 @@ internal class Vp8LEncoder : IDisposable // non-zero red and blue values. If all are zero, we can later skip // the cross color optimization. byte[][] histoPairs = - { - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue }, - new[] { (byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred }, - new[] { (byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen }, - new[] { (byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen }, - new[] { (byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue } - }; + [ + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue], + [(byte)HistoIx.HistoRedPred, (byte)HistoIx.HistoBluePred], + [(byte)HistoIx.HistoRedSubGreen, (byte)HistoIx.HistoBlueSubGreen], + [(byte)HistoIx.HistoRedPredSubGreen, (byte)HistoIx.HistoBluePredSubGreen], + [(byte)HistoIx.HistoRed, (byte)HistoIx.HistoBlue] + ]; Span redHisto = histo[(256 * histoPairs[(int)minEntropyIx][0])..]; Span blueHisto = histo[(256 * histoPairs[(int)minEntropyIx][1])..]; for (int i = 1; i < 256; i++) @@ -1325,7 +1315,7 @@ internal class Vp8LEncoder : IDisposable /// The number of palette entries. private static int GetColorPalette(ReadOnlySpan bgra, int width, int height, Span palette) { - HashSet colors = new(); + HashSet colors = []; for (int y = 0; y < height; y++) { ReadOnlySpan bgraRow = bgra.Slice(y * width, width); @@ -1904,9 +1894,9 @@ internal class Vp8LEncoder : IDisposable /// public void ClearRefs() { - foreach (Vp8LBackwardRefs t in this.Refs) + foreach (Vp8LBackwardRefs refs in this.Refs) { - t.Refs.Clear(); + refs.Clear(); } } @@ -1918,6 +1908,12 @@ internal class Vp8LEncoder : IDisposable this.BgraScratch?.Dispose(); this.Palette.Dispose(); this.TransformData?.Dispose(); + + foreach (Vp8LBackwardRefs refs in this.Refs) + { + refs.Dispose(); + } + this.HashChain.Dispose(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index f47397790..ee03499cf 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -138,9 +138,9 @@ internal abstract unsafe class Vp8LHistogram /// The backward references. public void StoreRefs(Vp8LBackwardRefs refs) { - for (int i = 0; i < refs.Refs.Count; i++) + for (int i = 0; i < refs.Count; i++) { - this.AddSinglePixOrCopy(refs.Refs[i], false); + this.AddSinglePixOrCopy(refs[i], false); } } diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs index cfe79e49e..7777c6108 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs @@ -66,18 +66,14 @@ public class Vp8LHistogramTests // All remaining values are expected to be zero. literals.AsSpan().CopyTo(expectedLiterals); - Vp8LBackwardRefs backwardRefs = new(pixelData.Length); + MemoryAllocator memoryAllocator = Configuration.Default.MemoryAllocator; + + using Vp8LBackwardRefs backwardRefs = new(memoryAllocator, pixelData.Length); for (int i = 0; i < pixelData.Length; i++) { - backwardRefs.Add(new PixOrCopy() - { - BgraOrDistance = pixelData[i], - Len = 1, - Mode = PixOrCopyMode.Literal - }); + backwardRefs.Add(PixOrCopy.CreateLiteral(pixelData[i])); } - MemoryAllocator memoryAllocator = Configuration.Default.MemoryAllocator; using OwnedVp8LHistogram histogram0 = OwnedVp8LHistogram.Create(memoryAllocator, backwardRefs, 3); using OwnedVp8LHistogram histogram1 = OwnedVp8LHistogram.Create(memoryAllocator, backwardRefs, 3); for (int i = 0; i < 5; i++) From ff9d3a6223c72ca1c5931593e404ce0070db9d9c Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Fri, 6 Jun 2025 19:01:01 +0400 Subject: [PATCH 003/112] Replace indexed span iteration with foreach (+performance) --- .../Webp/Lossless/BackwardReferenceEncoder.cs | 14 +++++--------- src/ImageSharp/Formats/Webp/Lossless/CostModel.cs | 4 ++-- .../Formats/Webp/Lossless/HistogramEncoder.cs | 9 ++++----- .../Formats/Webp/Lossless/Vp8LBackwardRefs.cs | 11 +++++------ .../Formats/Webp/Lossless/Vp8LEncoder.cs | 3 +-- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 4 ++-- 6 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 7a2679173..274d4426f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -149,9 +149,8 @@ internal static class BackwardReferenceEncoder } // Find the cacheBits giving the lowest entropy. - for (int idx = 0; idx < refs.Count; idx++) + foreach (PixOrCopy v in refs) { - PixOrCopy v = refs[idx]; if (v.IsLiteral()) { uint pix = bgra[pos++]; @@ -780,9 +779,8 @@ internal static class BackwardReferenceEncoder { int pixelIndex = 0; ColorCache colorCache = new(cacheBits); - for (int idx = 0; idx < refs.Count; idx++) + foreach (ref PixOrCopy v in refs) { - PixOrCopy v = refs[idx]; if (v.IsLiteral()) { uint bgraLiteral = v.BgraOrDistance; @@ -790,7 +788,7 @@ internal static class BackwardReferenceEncoder if (ix >= 0) { // Color cache contains bgraLiteral - refs[idx] = PixOrCopy.CreateCacheIdx(ix); + v = PixOrCopy.CreateCacheIdx(ix); } else { @@ -812,15 +810,13 @@ internal static class BackwardReferenceEncoder private static void BackwardReferences2DLocality(int xSize, Vp8LBackwardRefs refs) { - for (int idx = 0; idx < refs.Count; idx++) + foreach (ref PixOrCopy v in refs) { - PixOrCopy v = refs[idx]; - if (v.IsCopy()) { int dist = (int)v.BgraOrDistance; int transformedDist = DistanceToPlaneCode(xSize, dist); - refs[idx] = PixOrCopy.CreateCopy((uint)transformedDist, v.Len); + v = PixOrCopy.CreateCopy((uint)transformedDist, v.Len); } } } diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs index 15b0f4222..56a5bb7f5 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs @@ -40,9 +40,9 @@ internal class CostModel using OwnedVp8LHistogram histogram = OwnedVp8LHistogram.Create(this.memoryAllocator, cacheBits); // The following code is similar to HistogramCreate but converts the distance to plane code. - for (int i = 0; i < backwardRefs.Count; i++) + foreach (PixOrCopy v in backwardRefs) { - histogram.AddSinglePixOrCopy(backwardRefs[i], true, xSize); + histogram.AddSinglePixOrCopy(v, true, xSize); } ConvertPopulationCountTableToBitEstimates(histogram.NumCodes(), histogram.Literal, this.Literal); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index c5d1aa145..b60663fb6 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -110,9 +110,8 @@ internal static class HistogramEncoder int x = 0, y = 0; int histoXSize = LosslessUtils.SubSampleSize(xSize, histoBits); - for (int i = 0; i < backwardRefs.Count; i++) + foreach (PixOrCopy v in backwardRefs) { - PixOrCopy v = backwardRefs[i]; int ix = ((y >> histoBits) * histoXSize) + (x >> histoBits); histograms[ix].AddSinglePixOrCopy(v, false); x += v.Len; @@ -217,7 +216,7 @@ internal static class HistogramEncoder clusterMappings[idx] = (ushort)idx; } - List indicesToRemove = new(); + List indicesToRemove = []; Vp8LStreaks stats = new(); Vp8LBitEntropy bitsEntropy = new(); for (int idx = 0; idx < histograms.Count; idx++) @@ -345,7 +344,7 @@ internal static class HistogramEncoder // Priority list of histogram pairs. Its size impacts the quality of the compression and the speed: // the smaller the faster but the worse for the compression. - List histoPriorityList = new(); + List histoPriorityList = []; const int maxSize = 9; // Fill the initial mapping. @@ -480,7 +479,7 @@ internal static class HistogramEncoder int histoSize = histograms.Count(h => h != null); // Priority list of histogram pairs. - List histoPriorityList = new(); + List histoPriorityList = []; int maxSize = histoSize * histoSize; Vp8LStreaks stats = new(); Vp8LBitEntropy bitsEntropy = new(); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index 6a2869995..634fac5e8 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -9,20 +9,19 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal class Vp8LBackwardRefs : IDisposable { private readonly IMemoryOwner refs; + private int count; public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels) { this.refs = memoryAllocator.Allocate(pixels); - this.Count = 0; + this.count = 0; } - public int Count { get; private set; } + public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.count++] = pixOrCopy; - public ref PixOrCopy this[int index] => ref this.refs.Memory.Span[index]; + public void Clear() => this.count = 0; - public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.Count++] = pixOrCopy; - - public void Clear() => this.Count = 0; + public Span.Enumerator GetEnumerator() => this.refs.Slice(0, this.count).GetEnumerator(); /// public void Dispose() => this.refs.Dispose(); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index e19126fff..b398554eb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -1058,9 +1058,8 @@ internal class Vp8LEncoder : IDisposable int histogramIx = histogramSymbols[0]; Span codes = huffmanCodes.AsSpan(5 * histogramIx); - for (int i = 0; i < backwardRefs.Count; i++) + foreach (PixOrCopy v in backwardRefs) { - PixOrCopy v = backwardRefs[i]; if (tileX != (x & tileMask) || tileY != (y & tileMask)) { tileX = x & tileMask; diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index ee03499cf..399af7661 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -138,9 +138,9 @@ internal abstract unsafe class Vp8LHistogram /// The backward references. public void StoreRefs(Vp8LBackwardRefs refs) { - for (int i = 0; i < refs.Count; i++) + foreach (PixOrCopy v in refs) { - this.AddSinglePixOrCopy(refs[i], false); + this.AddSinglePixOrCopy(v, false); } } From 0faf614b0743b430a8513679be53c9c67537fd04 Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Tue, 10 Jun 2025 17:14:42 +0400 Subject: [PATCH 004/112] Change AddSinglePixOrCopy to accept 'in PixOrCopy' --- src/ImageSharp/Formats/Webp/Lossless/CostModel.cs | 2 +- src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs | 2 +- src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs index 56a5bb7f5..c6131bc2a 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostModel.cs @@ -42,7 +42,7 @@ internal class CostModel // The following code is similar to HistogramCreate but converts the distance to plane code. foreach (PixOrCopy v in backwardRefs) { - histogram.AddSinglePixOrCopy(v, true, xSize); + histogram.AddSinglePixOrCopy(in v, true, xSize); } ConvertPopulationCountTableToBitEstimates(histogram.NumCodes(), histogram.Literal, this.Literal); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index b60663fb6..0b610302f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -113,7 +113,7 @@ internal static class HistogramEncoder foreach (PixOrCopy v in backwardRefs) { int ix = ((y >> histoBits) * histoXSize) + (x >> histoBits); - histograms[ix].AddSinglePixOrCopy(v, false); + histograms[ix].AddSinglePixOrCopy(in v, false); x += v.Len; while (x >= xSize) { diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 399af7661..03bedfe67 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -140,7 +140,7 @@ internal abstract unsafe class Vp8LHistogram { foreach (PixOrCopy v in refs) { - this.AddSinglePixOrCopy(v, false); + this.AddSinglePixOrCopy(in v, false); } } @@ -150,7 +150,7 @@ internal abstract unsafe class Vp8LHistogram /// The token to add. /// Indicates whether to use the distance modifier. /// xSize is only used when useDistanceModifier is true. - public void AddSinglePixOrCopy(PixOrCopy v, bool useDistanceModifier, int xSize = 0) + public void AddSinglePixOrCopy(in PixOrCopy v, bool useDistanceModifier, int xSize = 0) { if (v.IsLiteral()) { From b240679c71db329f8977545a4835f8a452771b02 Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Tue, 10 Jun 2025 17:51:12 +0400 Subject: [PATCH 005/112] Pin the refs for faster access --- .../Formats/Webp/Lossless/Vp8LBackwardRefs.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index 634fac5e8..3b7dc99ff 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -8,21 +8,33 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal class Vp8LBackwardRefs : IDisposable { - private readonly IMemoryOwner refs; + private readonly IMemoryOwner owner; + private readonly MemoryHandle handle; private int count; public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels) { - this.refs = memoryAllocator.Allocate(pixels); + this.owner = memoryAllocator.Allocate(pixels); + this.handle = this.owner.Memory.Pin(); this.count = 0; } - public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.count++] = pixOrCopy; + public void Add(PixOrCopy pixOrCopy) + { + unsafe + { + ((PixOrCopy*)this.handle.Pointer)[this.count++] = pixOrCopy; + } + } public void Clear() => this.count = 0; - public Span.Enumerator GetEnumerator() => this.refs.Slice(0, this.count).GetEnumerator(); + public Span.Enumerator GetEnumerator() => this.owner.Slice(0, this.count).GetEnumerator(); /// - public void Dispose() => this.refs.Dispose(); + public void Dispose() + { + this.handle.Dispose(); + this.owner.Dispose(); + } } From 909e06be69ddfbbe8880fd6a766b7ef67a08b248 Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Tue, 10 Jun 2025 18:44:51 +0400 Subject: [PATCH 006/112] Revert "Pin the refs for faster access" --- .../Formats/Webp/Lossless/Vp8LBackwardRefs.cs | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs index 3b7dc99ff..634fac5e8 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LBackwardRefs.cs @@ -8,33 +8,21 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal class Vp8LBackwardRefs : IDisposable { - private readonly IMemoryOwner owner; - private readonly MemoryHandle handle; + private readonly IMemoryOwner refs; private int count; public Vp8LBackwardRefs(MemoryAllocator memoryAllocator, int pixels) { - this.owner = memoryAllocator.Allocate(pixels); - this.handle = this.owner.Memory.Pin(); + this.refs = memoryAllocator.Allocate(pixels); this.count = 0; } - public void Add(PixOrCopy pixOrCopy) - { - unsafe - { - ((PixOrCopy*)this.handle.Pointer)[this.count++] = pixOrCopy; - } - } + public void Add(PixOrCopy pixOrCopy) => this.refs.Memory.Span[this.count++] = pixOrCopy; public void Clear() => this.count = 0; - public Span.Enumerator GetEnumerator() => this.owner.Slice(0, this.count).GetEnumerator(); + public Span.Enumerator GetEnumerator() => this.refs.Slice(0, this.count).GetEnumerator(); /// - public void Dispose() - { - this.handle.Dispose(); - this.owner.Dispose(); - } + public void Dispose() => this.refs.Dispose(); } From 17fc6dbce95f58f3dc2059250ea649ed1dc61f74 Mon Sep 17 00:00:00 2001 From: Maxim Shipko Date: Wed, 11 Jun 2025 03:57:36 +0400 Subject: [PATCH 007/112] Remove list search in HistoListUpdateHead, we always know pair index at call site --- .../Formats/Webp/Lossless/HistogramEncoder.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs index 0b610302f..e0d854bb0 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HistogramEncoder.cs @@ -464,7 +464,7 @@ internal static class HistogramEncoder } } - HistoListUpdateHead(histoPriorityList, p); + HistoListUpdateHead(histoPriorityList, p, j); j++; } @@ -524,7 +524,7 @@ internal static class HistogramEncoder } else { - HistoListUpdateHead(histoPriorityList, p); + HistoListUpdateHead(histoPriorityList, p, i); i++; } } @@ -646,7 +646,7 @@ internal static class HistogramEncoder histoList.Add(pair); - HistoListUpdateHead(histoList, pair); + HistoListUpdateHead(histoList, pair, histoList.Count - 1); return pair.CostDiff; } @@ -673,13 +673,11 @@ internal static class HistogramEncoder /// /// Check whether a pair in the list should be updated as head or not. /// - private static void HistoListUpdateHead(List histoList, HistogramPair pair) + private static void HistoListUpdateHead(List histoList, HistogramPair pair, int idx) { if (pair.CostDiff < histoList[0].CostDiff) { - // Replace the best pair. - int oldIdx = histoList.IndexOf(pair); - histoList[oldIdx] = histoList[0]; + histoList[idx] = histoList[0]; histoList[0] = pair; } } From 07cc9f79a58a1c93a9f70bd40cafede82f96f206 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 11 Jun 2025 14:03:56 +1000 Subject: [PATCH 008/112] Allow additional and undefined extra samples --- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 20 ++++++++++--------- .../Formats/Tiff/TiffExtraSampleType.cs | 8 +++++++- .../Formats/Tiff/TiffDecoderTests.cs | 5 +++++ tests/ImageSharp.Tests/TestImages.cs | 1 + .../Tiff/Issues/ExtraSamplesUnspecified.tif | 3 +++ 5 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 tests/Images/Input/Tiff/Issues/ExtraSamplesUnspecified.tif diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index ed9175546..7519871b7 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -25,20 +25,22 @@ internal static class TiffDecoderOptionsParser /// True, if the image uses tiles. Otherwise the images has strip's. public static bool VerifyAndParse(this TiffDecoderCore options, ExifProfile exifProfile, TiffFrameMetadata frameMetadata) { - IExifValue extraSamplesExifValue = exifProfile.GetValueInternal(ExifTag.ExtraSamples); - if (extraSamplesExifValue is not null) + if (exifProfile.TryGetValue(ExifTag.ExtraSamples, out IExifValue samples)) { - short[] extraSamples = (short[])extraSamplesExifValue.GetValue(); - if (extraSamples.Length != 1) + // We only support a single sample pertaining to alpha data. + // Other information is discarded. + TiffExtraSampleType sampleType = (TiffExtraSampleType)samples.Value[0]; + if (sampleType is TiffExtraSampleType.CorelDrawUnassociatedAlphaData) { - TiffThrowHelper.ThrowNotSupported("ExtraSamples is only supported with one extra sample for alpha data."); + // According to libtiff, this CorelDRAW-specific value indicates unassociated alpha. + // Patch required for compatibility with malformed CorelDRAW-generated TIFFs. + // https://libtiff.gitlab.io/libtiff/releases/v3.9.0beta.html + sampleType = TiffExtraSampleType.UnassociatedAlphaData; } - TiffExtraSampleType extraSamplesType = (TiffExtraSampleType)extraSamples[0]; - options.ExtraSamplesType = extraSamplesType; - if (extraSamplesType is not (TiffExtraSampleType.UnassociatedAlphaData or TiffExtraSampleType.AssociatedAlphaData)) + if (sampleType is (TiffExtraSampleType.UnassociatedAlphaData or TiffExtraSampleType.AssociatedAlphaData)) { - TiffThrowHelper.ThrowNotSupported("Decoding Tiff images with ExtraSamples is not supported with UnspecifiedData."); + options.ExtraSamplesType = sampleType; } } diff --git a/src/ImageSharp/Formats/Tiff/TiffExtraSampleType.cs b/src/ImageSharp/Formats/Tiff/TiffExtraSampleType.cs index 484fc993b..cb7582764 100644 --- a/src/ImageSharp/Formats/Tiff/TiffExtraSampleType.cs +++ b/src/ImageSharp/Formats/Tiff/TiffExtraSampleType.cs @@ -22,5 +22,11 @@ internal enum TiffExtraSampleType /// The extra data is unassociated alpha data is transparency information that logically exists independent of an image; /// it is commonly called a soft matte. /// - UnassociatedAlphaData = 2 + UnassociatedAlphaData = 2, + + /// + /// A CorelDRAW-specific value observed in damaged files, indicating unassociated alpha. + /// Not part of the official TIFF specification; patched in ImageSharp for compatibility. + /// + CorelDrawUnassociatedAlphaData = 999, } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index cf27e561f..a16b26f9e 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -828,4 +828,9 @@ public class TiffDecoderTests : TiffDecoderBaseTester testOutputDetails: details, appendPixelTypeToFileName: false); } + + [Theory] + [WithFile(ExtraSamplesUnspecified, PixelTypes.Rgba32)] + public void TiffDecoder_CanDecode_ExtraSamplesUnspecified(TestImageProvider provider) + where TPixel : unmanaged, IPixel => TestTiffDecoder(provider); } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 0908e6e6b..9b73e60cf 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1136,6 +1136,7 @@ public static class TestImages public const string Issues2679 = "Tiff/Issues/Issue2679.tiff"; public const string JpegCompressedGray0000539558 = "Tiff/Issues/JpegCompressedGray-0000539558.tiff"; public const string Tiled0000023664 = "Tiff/Issues/tiled-0000023664.tiff"; + public const string ExtraSamplesUnspecified = "Tiff/Issues/ExtraSamplesUnspecified.tif"; public const string SmallRgbDeflate = "Tiff/rgb_small_deflate.tiff"; public const string SmallRgbLzw = "Tiff/rgb_small_lzw.tiff"; diff --git a/tests/Images/Input/Tiff/Issues/ExtraSamplesUnspecified.tif b/tests/Images/Input/Tiff/Issues/ExtraSamplesUnspecified.tif new file mode 100644 index 000000000..b5835c1ed --- /dev/null +++ b/tests/Images/Input/Tiff/Issues/ExtraSamplesUnspecified.tif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71d28f17d2d56481faa4d241fae882eae4f8303c70f85bc3759f6a0c2074979e +size 1426558 From 3c60117362b336cb17442c54beaf7081f921a1ac Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 11 Jun 2025 19:30:17 +1000 Subject: [PATCH 009/112] Use EXIF byte order for EXIF encoded strings. --- .../Formats/Tiff/Ifd/EntryReader.cs | 8 +- .../Metadata/Profiles/Exif/ExifDataType.cs | 2 +- .../Profiles/Exif/ExifEncodedStringHelpers.cs | 61 +- .../Metadata/Profiles/Exif/ExifProfile.cs | 21 +- .../Metadata/Profiles/Exif/ExifReader.cs | 37 +- .../Metadata/Profiles/Exif/ExifWriter.cs | 8 +- .../Metadata/Profiles/Exif/Tags/ExifTag.cs | 8 +- .../Exif/Values/ExifArrayValue{TValueType}.cs | 2 +- .../Metadata/Profiles/Exif/Values/ExifByte.cs | 2 +- .../Profiles/Exif/Values/ExifByteArray.cs | 4 +- .../Profiles/Exif/Values/ExifEncodedString.cs | 7 +- .../Profiles/Exif/Values/ExifLong8Array.cs | 26 +- .../Profiles/Exif/Values/ExifNumberArray.cs | 14 +- .../Profiles/Exif/Values/ExifRationalArray.cs | 4 +- .../Profiles/Exif/Values/ExifShort.cs | 2 +- .../Profiles/Exif/Values/ExifShortArray.cs | 12 +- .../Profiles/Exif/Values/ExifSignedByte.cs | 2 +- .../Profiles/Exif/Values/ExifSignedShort.cs | 2 +- .../Exif/Values/ExifSignedShortArray.cs | 8 +- .../Profiles/Exif/Values/ExifValues.cs | 840 ++++++------------ .../Profiles/Exif/Values/IExifValue.cs | 24 +- .../Formats/WebP/WebpDecoderTests.cs | 19 + tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/Webp/issues/Issue2906.webp | 3 + 24 files changed, 440 insertions(+), 677 deletions(-) create mode 100644 tests/Images/Input/Webp/issues/Issue2906.webp diff --git a/src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs b/src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs index 4496de6fb..49e43e49c 100644 --- a/src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs +++ b/src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs @@ -14,7 +14,7 @@ internal class EntryReader : BaseExifReader : base(stream, allocator) => this.IsBigEndian = byteOrder == ByteOrder.BigEndian; - public List Values { get; } = new(); + public List Values { get; } = []; public ulong NextIfdOffset { get; private set; } @@ -31,8 +31,6 @@ internal class EntryReader : BaseExifReader { this.ReadValues64(this.Values, ifdOffset); this.NextIfdOffset = this.ReadUInt64(); - - //// this.ReadSubIfd64(this.Values); } } @@ -62,9 +60,9 @@ internal class HeaderReader : BaseExifReader { this.IsBigTiff = true; - ushort bytesize = this.ReadUInt16(); + ushort byteSize = this.ReadUInt16(); ushort reserve = this.ReadUInt16(); - if (bytesize == TiffConstants.BigTiffByteSize && reserve == 0) + if (byteSize == TiffConstants.BigTiffByteSize && reserve == 0) { this.FirstIfdOffset = this.ReadUInt64(); return; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs index 90a5d15b7..e0b549362 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifDataType.cs @@ -4,7 +4,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; /// -/// Specifies exif data types. +/// Specifies Exif data types. /// public enum ExifDataType { diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index e9f46731c..c8725db81 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -16,13 +16,13 @@ internal static class ExifEncodedStringHelpers private const ulong UnicodeCode = 0x_45_44_4F_43_49_4E_55; private const ulong UndefinedCode = 0x_00_00_00_00_00_00_00_00; - private static ReadOnlySpan AsciiCodeBytes => new byte[] { 0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0 }; + private static ReadOnlySpan AsciiCodeBytes => [0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0]; - private static ReadOnlySpan JISCodeBytes => new byte[] { 0x4A, 0x49, 0x53, 0, 0, 0, 0, 0 }; + private static ReadOnlySpan JISCodeBytes => [0x4A, 0x49, 0x53, 0, 0, 0, 0, 0]; - private static ReadOnlySpan UnicodeCodeBytes => new byte[] { 0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0 }; + private static ReadOnlySpan UnicodeCodeBytes => [0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0]; - private static ReadOnlySpan UndefinedCodeBytes => new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + private static ReadOnlySpan UndefinedCodeBytes => [0, 0, 0, 0, 0, 0, 0, 0]; // 20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) // https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-6.0 @@ -50,37 +50,66 @@ internal static class ExifEncodedStringHelpers _ => UndefinedCodeBytes }; - public static Encoding GetEncoding(CharacterCode code) => code switch + public static Encoding GetEncoding(CharacterCode code, ByteOrder order) => code switch { CharacterCode.ASCII => Encoding.ASCII, CharacterCode.JIS => JIS0208Encoding, - CharacterCode.Unicode => Encoding.Unicode, + CharacterCode.Unicode => order is ByteOrder.BigEndian ? Encoding.BigEndianUnicode : Encoding.Unicode, CharacterCode.Undefined => Encoding.UTF8, _ => Encoding.UTF8 }; - public static bool TryParse(ReadOnlySpan buffer, out EncodedString encodedString) + public static bool TryParse(ReadOnlySpan buffer, ByteOrder order, out EncodedString encodedString) { if (TryDetect(buffer, out CharacterCode code)) { - string text = GetEncoding(code).GetString(buffer[CharacterCodeBytesLength..]); - encodedString = new EncodedString(code, text); - return true; + ReadOnlySpan textBuffer = buffer[CharacterCodeBytesLength..]; + if (code == CharacterCode.Unicode && textBuffer.Length >= 2) + { + // Check BOM + if (textBuffer[0] == 0xFF && textBuffer[1] == 0xFE) + { + // Little-endian BOM + string text = Encoding.Unicode.GetString(textBuffer[2..]); + encodedString = new EncodedString(code, text); + return true; + } + else if (textBuffer[0] == 0xFE && textBuffer[1] == 0xFF) + { + // Big-endian BOM + string text = Encoding.BigEndianUnicode.GetString(textBuffer[2..]); + encodedString = new EncodedString(code, text); + return true; + } + else + { + // No BOM, use EXIF byte order + string text = GetEncoding(code, order).GetString(textBuffer); + encodedString = new EncodedString(code, text); + return true; + } + } + else + { + string text = GetEncoding(code, order).GetString(textBuffer); + encodedString = new EncodedString(code, text); + return true; + } } encodedString = default; return false; } - public static uint GetDataLength(EncodedString encodedString) => - (uint)GetEncoding(encodedString.Code).GetByteCount(encodedString.Text) + CharacterCodeBytesLength; + public static uint GetDataLength(EncodedString encodedString, ByteOrder order) => + (uint)GetEncoding(encodedString.Code, order).GetByteCount(encodedString.Text) + CharacterCodeBytesLength; public static int Write(EncodedString encodedString, Span destination) { GetCodeBytes(encodedString.Code).CopyTo(destination); string text = encodedString.Text; - int count = Write(GetEncoding(encodedString.Code), text, destination[CharacterCodeBytesLength..]); + int count = Write(GetEncoding(encodedString.Code, ByteOrder.LittleEndian), text, destination[CharacterCodeBytesLength..]); return CharacterCodeBytesLength + count; } @@ -92,8 +121,7 @@ internal static class ExifEncodedStringHelpers { if (buffer.Length >= CharacterCodeBytesLength) { - ulong test = BinaryPrimitives.ReadUInt64LittleEndian(buffer); - switch (test) + switch (BinaryPrimitives.ReadUInt64LittleEndian(buffer)) { case AsciiCode: code = CharacterCode.ASCII; @@ -108,7 +136,8 @@ internal static class ExifEncodedStringHelpers code = CharacterCode.Undefined; return true; default: - break; + code = default; + return false; } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index e91a69444..aa987bbe7 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -3,7 +3,6 @@ using System.Diagnostics.CodeAnalysis; using SixLabors.ImageSharp.PixelFormats; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; @@ -48,7 +47,7 @@ public sealed class ExifProfile : IDeepCloneable { this.Parts = ExifParts.All; this.data = data; - this.InvalidTags = Array.Empty(); + this.InvalidTags = []; } /// @@ -171,7 +170,7 @@ public sealed class ExifProfile : IDeepCloneable /// /// Returns the value with the specified tag. /// - /// The tag of the exif value. + /// The tag of the Exif value. /// The value with the specified tag. /// True when found, otherwise false /// The data type of the tag. @@ -215,7 +214,7 @@ public sealed class ExifProfile : IDeepCloneable /// /// Sets the value of the specified tag. /// - /// The tag of the exif value. + /// The tag of the Exif value. /// The value. /// The data type of the tag. public void SetValue(ExifTag tag, TValueType value) @@ -234,7 +233,7 @@ public sealed class ExifProfile : IDeepCloneable if (this.values.Count == 0) { - return Array.Empty(); + return []; } ExifWriter writer = new(this.values, this.Parts); @@ -247,7 +246,7 @@ public sealed class ExifProfile : IDeepCloneable /// /// Returns the value with the specified tag. /// - /// The tag of the exif value. + /// The tag of the Exif value. /// The value with the specified tag. internal IExifValue? GetValueInternal(ExifTag tag) { @@ -265,7 +264,7 @@ public sealed class ExifProfile : IDeepCloneable /// /// Sets the value of the specified tag. /// - /// The tag of the exif value. + /// The tag of the Exif value. /// The value. /// Newly created value is null. internal void SetValueInternal(ExifTag tag, object? value) @@ -279,11 +278,7 @@ public sealed class ExifProfile : IDeepCloneable } } - ExifValue? newExifValue = ExifValues.Create(tag); - if (newExifValue is null) - { - throw new NotSupportedException($"Newly created value for tag {tag} is null."); - } + ExifValue? newExifValue = ExifValues.Create(tag) ?? throw new NotSupportedException($"Newly created value for tag {tag} is null."); newExifValue.TrySetValue(value); this.values.Add(newExifValue); @@ -349,7 +344,7 @@ public sealed class ExifProfile : IDeepCloneable if (this.data is null) { - this.values = new List(); + this.values = []; return; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index 3af4eb3c3..4cd4b4aac 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -34,7 +34,7 @@ internal class ExifReader : BaseExifReader /// public List ReadValues() { - List values = new(); + List values = []; // II == 0x4949 this.IsBigEndian = this.ReadUInt16() != 0x4949; @@ -64,7 +64,7 @@ internal class ExifReader : BaseExifReader return; } - List values = new(); + List values = []; this.ReadValues(values, offset); for (int i = 0; i < values.Count; i++) @@ -90,8 +90,8 @@ internal abstract class BaseExifReader private readonly MemoryAllocator? allocator; private readonly Stream data; private List? invalidTags; - private List? subIfds; + private bool isBigEndian; protected BaseExifReader(Stream stream, MemoryAllocator? allocator) { @@ -104,7 +104,7 @@ internal abstract class BaseExifReader /// /// Gets the invalid tags. /// - public IReadOnlyList InvalidTags => this.invalidTags ?? (IReadOnlyList)Array.Empty(); + public IReadOnlyList InvalidTags => this.invalidTags ?? (IReadOnlyList)[]; /// /// Gets or sets the thumbnail length in the byte stream. @@ -116,9 +116,19 @@ internal abstract class BaseExifReader /// public uint ThumbnailOffset { get; protected set; } - public bool IsBigEndian { get; protected set; } + public bool IsBigEndian + { + get => this.isBigEndian; + protected set + { + this.isBigEndian = value; + this.ByteOrder = value ? ByteOrder.BigEndian : ByteOrder.LittleEndian; + } + } + + protected ByteOrder ByteOrder { get; private set; } - public List<(ulong Offset, ExifDataType DataType, ulong NumberOfComponents, ExifValue Exif)> BigValues { get; } = new(); + public List<(ulong Offset, ExifDataType DataType, ulong NumberOfComponents, ExifValue Exif)> BigValues { get; } = []; protected void ReadBigValues(List values) { @@ -486,14 +496,21 @@ internal abstract class BaseExifReader private void Add(IList values, ExifValue exif, object? value) { - if (!exif.TrySetValue(value)) + if (exif is ExifEncodedString encodedString) + { + if (!encodedString.TrySetValue(value, this.ByteOrder)) + { + return; + } + } + else if (!exif.TrySetValue(value)) { return; } foreach (IExifValue val in values) { - // to skip duplicates must be used Equals method, + // To skip duplicates must be used Equals method, // == operator not defined for ExifValue and IExifValue if (exif.Equals(val)) { @@ -517,10 +534,10 @@ internal abstract class BaseExifReader } private void AddInvalidTag(ExifTag tag) - => (this.invalidTags ??= new List()).Add(tag); + => (this.invalidTags ??= []).Add(tag); private void AddSubIfd(object? val) - => (this.subIfds ??= new List()).Add(Convert.ToUInt64(val, CultureInfo.InvariantCulture)); + => (this.subIfds ??= []).Add(Convert.ToUInt64(val, CultureInfo.InvariantCulture)); private void Seek(ulong pos) => this.data.Seek((long)pos, SeekOrigin.Begin); diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs index cf4a421b4..14120ed49 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs @@ -55,7 +55,7 @@ internal sealed class ExifWriter if (length == 0) { - return Array.Empty(); + return []; } // two bytes for the byte Order marker 'II' or 'MM', followed by the number 42 (0x2A) and a 0, making 4 bytes total @@ -197,7 +197,7 @@ internal sealed class ExifWriter private List GetPartValues(ExifParts part) { - List result = new(); + List result = []; if (!EnumUtils.HasFlag(this.allowedParts, part)) { @@ -281,7 +281,7 @@ internal sealed class ExifWriter if (value is EncodedString encodedString) { - return ExifEncodedStringHelpers.GetDataLength(encodedString); + return ExifEncodedStringHelpers.GetDataLength(encodedString, ByteOrder.LittleEndian); } if (exifValue.DataType == ExifDataType.Ascii) @@ -332,7 +332,7 @@ internal sealed class ExifWriter private int WriteHeaders(List values, Span destination, int offset) { - this.dataOffsets = new List(); + this.dataOffsets = []; int newOffset = WriteUInt16((ushort)values.Count, destination, offset); diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs index ea0b8060d..26edb4b15 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs @@ -4,7 +4,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; /// -/// Class that represents an exif tag from the Exif standard 2.31. +/// Class that represents an Exif tag from the Exif standard 2.31. /// public abstract partial class ExifTag : IEquatable { @@ -16,21 +16,21 @@ public abstract partial class ExifTag : IEquatable /// Converts the specified to a . /// /// The to convert. - public static explicit operator ushort(ExifTag tag) => tag?.value ?? (ushort)ExifTagValue.Unknown; + public static explicit operator ushort(ExifTag? tag) => tag?.value ?? (ushort)ExifTagValue.Unknown; /// /// Determines whether the specified instances are considered equal. /// /// The first to compare. /// The second to compare. - public static bool operator ==(ExifTag left, ExifTag right) => Equals(left, right); + public static bool operator ==(ExifTag? left, ExifTag? right) => left?.Equals(right) == true; /// /// Determines whether the specified instances are not considered equal. /// /// The first to compare. /// The second to compare. - public static bool operator !=(ExifTag left, ExifTag right) => !Equals(left, right); + public static bool operator !=(ExifTag left, ExifTag right) => !(left == right); /// public override bool Equals(object? obj) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs index 64b8d2313..630709bec 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifArrayValue{TValueType}.cs @@ -43,7 +43,7 @@ internal abstract class ExifArrayValue : ExifValue, IExifValue switch (value) { case int intValue: - if (intValue >= byte.MinValue && intValue <= byte.MaxValue) + if (intValue is >= byte.MinValue and <= byte.MaxValue) { this.Value = (byte)intValue; return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs index 6811fc6f9..c0bbb5bee 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifByteArray.cs @@ -30,9 +30,9 @@ internal sealed class ExifByteArray : ExifArrayValue if (value is int intValue) { - if (intValue >= byte.MinValue && intValue <= byte.MaxValue) + if (intValue is >= byte.MinValue and <= byte.MaxValue) { - this.Value = new byte[] { (byte)intValue }; + this.Value = [(byte)intValue]; } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs index cce7cf3e8..14b097f81 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs @@ -24,7 +24,7 @@ internal sealed class ExifEncodedString : ExifValue protected override string StringValue => this.Value.Text; - public override bool TrySetValue(object? value) + public bool TrySetValue(object? value, ByteOrder order) { if (base.TrySetValue(value)) { @@ -38,7 +38,7 @@ internal sealed class ExifEncodedString : ExifValue } else if (value is byte[] buffer) { - if (ExifEncodedStringHelpers.TryParse(buffer, out EncodedString encodedString)) + if (ExifEncodedStringHelpers.TryParse(buffer, order, out EncodedString encodedString)) { this.Value = encodedString; return true; @@ -48,5 +48,8 @@ internal sealed class ExifEncodedString : ExifValue return false; } + public override bool TrySetValue(object? value) + => this.TrySetValue(value, ByteOrder.LittleEndian); + public override IExifValue DeepClone() => new ExifEncodedString(this); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs index b7756e62b..3266e538a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifLong8Array.cs @@ -47,46 +47,40 @@ internal sealed class ExifLong8Array : ExifArrayValue return this.SetSingle((ulong)Numerics.Clamp(val, 0, int.MaxValue)); case uint val: - return this.SetSingle((ulong)val); + return this.SetSingle(val); case short val: return this.SetSingle((ulong)Numerics.Clamp(val, 0, short.MaxValue)); case ushort val: - return this.SetSingle((ulong)val); + return this.SetSingle(val); case long val: return this.SetSingle((ulong)Numerics.Clamp(val, 0, long.MaxValue)); case long[] array: - { if (value.GetType() == typeof(ulong[])) { return this.SetArray((ulong[])value); } return this.SetArray(array); - } case int[] array: - { if (value.GetType() == typeof(uint[])) { return this.SetArray((uint[])value); } return this.SetArray(array); - } case short[] array: - { if (value.GetType() == typeof(ushort[])) { return this.SetArray((ushort[])value); } return this.SetArray(array); - } } return false; @@ -96,13 +90,13 @@ internal sealed class ExifLong8Array : ExifArrayValue private bool SetSingle(ulong value) { - this.Value = new[] { value }; + this.Value = [value]; return true; } private bool SetArray(long[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)(values[i] < 0 ? 0 : values[i]); @@ -120,7 +114,7 @@ internal sealed class ExifLong8Array : ExifArrayValue private bool SetArray(int[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)Numerics.Clamp(values[i], 0, int.MaxValue); @@ -132,10 +126,10 @@ internal sealed class ExifLong8Array : ExifArrayValue private bool SetArray(uint[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { - numbers[i] = (ulong)values[i]; + numbers[i] = values[i]; } this.Value = numbers; @@ -144,7 +138,7 @@ internal sealed class ExifLong8Array : ExifArrayValue private bool SetArray(short[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = (ulong)Numerics.Clamp(values[i], 0, short.MaxValue); @@ -156,10 +150,10 @@ internal sealed class ExifLong8Array : ExifArrayValue private bool SetArray(ushort[] values) { - var numbers = new ulong[values.Length]; + ulong[] numbers = new ulong[values.Length]; for (int i = 0; i < values.Length; i++) { - numbers[i] = (ulong)values[i]; + numbers[i] = values[i]; } this.Value = numbers; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs index 1162c25ea..3c8e4fc33 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs @@ -52,7 +52,6 @@ internal sealed class ExifNumberArray : ExifArrayValue case ushort val: return this.SetSingle(val); case int[] array: - { // workaround for inconsistent covariance of value-typed arrays if (value.GetType() == typeof(uint[])) { @@ -60,17 +59,14 @@ internal sealed class ExifNumberArray : ExifArrayValue } return this.SetArray(array); - } case short[] array: - { if (value.GetType() == typeof(ushort[])) { return this.SetArray((ushort[])value); } return this.SetArray(array); - } } return false; @@ -80,13 +76,13 @@ internal sealed class ExifNumberArray : ExifArrayValue private bool SetSingle(Number value) { - this.Value = new[] { value }; + this.Value = [value]; return true; } private bool SetArray(int[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -98,7 +94,7 @@ internal sealed class ExifNumberArray : ExifArrayValue private bool SetArray(uint[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -110,7 +106,7 @@ internal sealed class ExifNumberArray : ExifArrayValue private bool SetArray(short[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; @@ -122,7 +118,7 @@ internal sealed class ExifNumberArray : ExifArrayValue private bool SetArray(ushort[] values) { - var numbers = new Number[values.Length]; + Number[] numbers = new Number[values.Length]; for (int i = 0; i < values.Length; i++) { numbers[i] = values[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs index ac6453edc..e8b2006df 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs @@ -38,7 +38,7 @@ internal sealed class ExifRationalArray : ExifArrayValue { if (signed.Numerator >= 0 && signed.Denominator >= 0) { - this.Value = new[] { new Rational((uint)signed.Numerator, (uint)signed.Denominator) }; + this.Value = [new Rational((uint)signed.Numerator, (uint)signed.Denominator)]; } return true; @@ -56,7 +56,7 @@ internal sealed class ExifRationalArray : ExifArrayValue return false; } - var unsigned = new Rational[signed.Length]; + Rational[] unsigned = new Rational[signed.Length]; for (int i = 0; i < signed.Length; i++) { SignedRational s = signed[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShort.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShort.cs index d35b21422..7dfd7aed1 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShort.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShort.cs @@ -36,7 +36,7 @@ internal sealed class ExifShort : ExifValue switch (value) { case int intValue: - if (intValue >= ushort.MinValue && intValue <= ushort.MaxValue) + if (intValue is >= ushort.MinValue and <= ushort.MaxValue) { this.Value = (ushort)intValue; return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs index a205e77de..18ab5a162 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifShortArray.cs @@ -41,9 +41,9 @@ internal sealed class ExifShortArray : ExifArrayValue if (value is int signedInt) { - if (signedInt >= ushort.MinValue && signedInt <= ushort.MaxValue) + if (signedInt is >= ushort.MinValue and <= ushort.MaxValue) { - this.Value = new ushort[] { (ushort)signedInt }; + this.Value = [(ushort)signedInt]; } return true; @@ -53,7 +53,7 @@ internal sealed class ExifShortArray : ExifArrayValue { if (signedShort >= ushort.MinValue) { - this.Value = new ushort[] { (ushort)signedShort }; + this.Value = [(ushort)signedShort]; } return true; @@ -66,12 +66,12 @@ internal sealed class ExifShortArray : ExifArrayValue private bool TrySetSignedIntArray(int[] signed) { - if (Array.FindIndex(signed, x => x < ushort.MinValue || x > ushort.MaxValue) > -1) + if (Array.FindIndex(signed, x => x is < ushort.MinValue or > ushort.MaxValue) > -1) { return false; } - var unsigned = new ushort[signed.Length]; + ushort[] unsigned = new ushort[signed.Length]; for (int i = 0; i < signed.Length; i++) { int s = signed[i]; @@ -89,7 +89,7 @@ internal sealed class ExifShortArray : ExifArrayValue return false; } - var unsigned = new ushort[signed.Length]; + ushort[] unsigned = new ushort[signed.Length]; for (int i = 0; i < signed.Length; i++) { short s = signed[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedByte.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedByte.cs index 95a239b70..206f8bd41 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedByte.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedByte.cs @@ -31,7 +31,7 @@ internal sealed class ExifSignedByte : ExifValue switch (value) { case int intValue: - if (intValue >= sbyte.MinValue && intValue <= sbyte.MaxValue) + if (intValue is >= sbyte.MinValue and <= sbyte.MaxValue) { this.Value = (sbyte)intValue; return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShort.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShort.cs index 6726febef..5b008ea4a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShort.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShort.cs @@ -31,7 +31,7 @@ internal sealed class ExifSignedShort : ExifValue switch (value) { case int intValue: - if (intValue >= short.MinValue && intValue <= short.MaxValue) + if (intValue is >= short.MinValue and <= short.MaxValue) { this.Value = (short)intValue; return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs index 206417f66..d3993ac0d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifSignedShortArray.cs @@ -36,9 +36,9 @@ internal sealed class ExifSignedShortArray : ExifArrayValue if (value is int intValue) { - if (intValue >= short.MinValue && intValue <= short.MaxValue) + if (intValue is >= short.MinValue and <= short.MaxValue) { - this.Value = new short[] { (short)intValue }; + this.Value = [(short)intValue]; } return true; @@ -51,12 +51,12 @@ internal sealed class ExifSignedShortArray : ExifArrayValue private bool TrySetSignedArray(int[] intArray) { - if (Array.FindIndex(intArray, x => x < short.MinValue || x > short.MaxValue) > -1) + if (Array.FindIndex(intArray, x => x is < short.MinValue or > short.MaxValue) > -1) { return false; } - var value = new short[intArray.Length]; + short[] value = new short[intArray.Length]; for (int i = 0; i < intArray.Length; i++) { int s = intArray[i]; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs index 93f67d46a..1c054fcba 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValues.cs @@ -3,7 +3,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; -internal static partial class ExifValues +internal static class ExifValues { public static ExifValue? Create(ExifTagValue tag) => (ExifValue?)CreateValue(tag); @@ -12,573 +12,281 @@ internal static partial class ExifValues public static ExifValue? Create(ExifTagValue tag, ExifDataType dataType, ulong numberOfComponents) => Create(tag, dataType, numberOfComponents != 1); public static ExifValue? Create(ExifTagValue tag, ExifDataType dataType, bool isArray) - { - switch (dataType) + => dataType switch { - case ExifDataType.Byte: - return isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); - case ExifDataType.DoubleFloat: - return isArray ? new ExifDoubleArray(tag) : new ExifDouble(tag); - case ExifDataType.SingleFloat: - return isArray ? new ExifFloatArray(tag) : new ExifFloat(tag); - case ExifDataType.Long: - return isArray ? new ExifLongArray(tag) : new ExifLong(tag); - case ExifDataType.Long8: - return isArray ? new ExifLong8Array(tag) : new ExifLong8(tag); - case ExifDataType.Rational: - return isArray ? new ExifRationalArray(tag) : new ExifRational(tag); - case ExifDataType.Short: - return isArray ? new ExifShortArray(tag) : new ExifShort(tag); - case ExifDataType.SignedByte: - return isArray ? new ExifSignedByteArray(tag) : new ExifSignedByte(tag); - case ExifDataType.SignedLong: - return isArray ? new ExifSignedLongArray(tag) : new ExifSignedLong(tag); - case ExifDataType.SignedLong8: - return isArray ? new ExifSignedLong8Array(tag) : new ExifSignedLong8(tag); - case ExifDataType.SignedRational: - return isArray ? new ExifSignedRationalArray(tag) : new ExifSignedRational(tag); - case ExifDataType.SignedShort: - return isArray ? new ExifSignedShortArray(tag) : new ExifSignedShort(tag); - case ExifDataType.Ascii: - return new ExifString(tag); - case ExifDataType.Undefined: - return isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType); - default: - return null; - } - } + ExifDataType.Byte => isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType), + ExifDataType.DoubleFloat => isArray ? new ExifDoubleArray(tag) : new ExifDouble(tag), + ExifDataType.SingleFloat => isArray ? new ExifFloatArray(tag) : new ExifFloat(tag), + ExifDataType.Long => isArray ? new ExifLongArray(tag) : new ExifLong(tag), + ExifDataType.Long8 => isArray ? new ExifLong8Array(tag) : new ExifLong8(tag), + ExifDataType.Rational => isArray ? new ExifRationalArray(tag) : new ExifRational(tag), + ExifDataType.Short => isArray ? new ExifShortArray(tag) : new ExifShort(tag), + ExifDataType.SignedByte => isArray ? new ExifSignedByteArray(tag) : new ExifSignedByte(tag), + ExifDataType.SignedLong => isArray ? new ExifSignedLongArray(tag) : new ExifSignedLong(tag), + ExifDataType.SignedLong8 => isArray ? new ExifSignedLong8Array(tag) : new ExifSignedLong8(tag), + ExifDataType.SignedRational => isArray ? new ExifSignedRationalArray(tag) : new ExifSignedRational(tag), + ExifDataType.SignedShort => isArray ? new ExifSignedShortArray(tag) : new ExifSignedShort(tag), + ExifDataType.Ascii => new ExifString(tag), + ExifDataType.Undefined => isArray ? new ExifByteArray(tag, dataType) : new ExifByte(tag, dataType), + _ => null, + }; private static object? CreateValue(ExifTagValue tag) - { - switch (tag) + => tag switch { - case ExifTagValue.FaxProfile: - return new ExifByte(ExifTag.FaxProfile, ExifDataType.Byte); - case ExifTagValue.ModeNumber: - return new ExifByte(ExifTag.ModeNumber, ExifDataType.Byte); - case ExifTagValue.GPSAltitudeRef: - return new ExifByte(ExifTag.GPSAltitudeRef, ExifDataType.Byte); - - case ExifTagValue.ClipPath: - return new ExifByteArray(ExifTag.ClipPath, ExifDataType.Byte); - case ExifTagValue.VersionYear: - return new ExifByteArray(ExifTag.VersionYear, ExifDataType.Byte); - case ExifTagValue.XMP: - return new ExifByteArray(ExifTag.XMP, ExifDataType.Byte); - case ExifTagValue.CFAPattern2: - return new ExifByteArray(ExifTag.CFAPattern2, ExifDataType.Byte); - case ExifTagValue.TIFFEPStandardID: - return new ExifByteArray(ExifTag.TIFFEPStandardID, ExifDataType.Byte); - case ExifTagValue.GPSVersionID: - return new ExifByteArray(ExifTag.GPSVersionID, ExifDataType.Byte); - - case ExifTagValue.PixelScale: - return new ExifDoubleArray(ExifTag.PixelScale); - case ExifTagValue.IntergraphMatrix: - return new ExifDoubleArray(ExifTag.IntergraphMatrix); - case ExifTagValue.ModelTiePoint: - return new ExifDoubleArray(ExifTag.ModelTiePoint); - case ExifTagValue.ModelTransform: - return new ExifDoubleArray(ExifTag.ModelTransform); - - case ExifTagValue.SubfileType: - return new ExifLong(ExifTag.SubfileType); - case ExifTagValue.SubIFDOffset: - return new ExifLong(ExifTag.SubIFDOffset); - case ExifTagValue.GPSIFDOffset: - return new ExifLong(ExifTag.GPSIFDOffset); - case ExifTagValue.T4Options: - return new ExifLong(ExifTag.T4Options); - case ExifTagValue.T6Options: - return new ExifLong(ExifTag.T6Options); - case ExifTagValue.XClipPathUnits: - return new ExifLong(ExifTag.XClipPathUnits); - case ExifTagValue.YClipPathUnits: - return new ExifLong(ExifTag.YClipPathUnits); - case ExifTagValue.ProfileType: - return new ExifLong(ExifTag.ProfileType); - case ExifTagValue.CodingMethods: - return new ExifLong(ExifTag.CodingMethods); - case ExifTagValue.T82ptions: - return new ExifLong(ExifTag.T82ptions); - case ExifTagValue.JPEGInterchangeFormat: - return new ExifLong(ExifTag.JPEGInterchangeFormat); - case ExifTagValue.JPEGInterchangeFormatLength: - return new ExifLong(ExifTag.JPEGInterchangeFormatLength); - case ExifTagValue.MDFileTag: - return new ExifLong(ExifTag.MDFileTag); - case ExifTagValue.StandardOutputSensitivity: - return new ExifLong(ExifTag.StandardOutputSensitivity); - case ExifTagValue.RecommendedExposureIndex: - return new ExifLong(ExifTag.RecommendedExposureIndex); - case ExifTagValue.ISOSpeed: - return new ExifLong(ExifTag.ISOSpeed); - case ExifTagValue.ISOSpeedLatitudeyyy: - return new ExifLong(ExifTag.ISOSpeedLatitudeyyy); - case ExifTagValue.ISOSpeedLatitudezzz: - return new ExifLong(ExifTag.ISOSpeedLatitudezzz); - case ExifTagValue.FaxRecvParams: - return new ExifLong(ExifTag.FaxRecvParams); - case ExifTagValue.FaxRecvTime: - return new ExifLong(ExifTag.FaxRecvTime); - case ExifTagValue.ImageNumber: - return new ExifLong(ExifTag.ImageNumber); - - case ExifTagValue.FreeOffsets: - return new ExifLongArray(ExifTag.FreeOffsets); - case ExifTagValue.FreeByteCounts: - return new ExifLongArray(ExifTag.FreeByteCounts); - case ExifTagValue.ColorResponseUnit: - return new ExifLongArray(ExifTag.ColorResponseUnit); - case ExifTagValue.SMinSampleValue: - return new ExifLongArray(ExifTag.SMinSampleValue); - case ExifTagValue.SMaxSampleValue: - return new ExifLongArray(ExifTag.SMaxSampleValue); - case ExifTagValue.JPEGQTables: - return new ExifLongArray(ExifTag.JPEGQTables); - case ExifTagValue.JPEGDCTables: - return new ExifLongArray(ExifTag.JPEGDCTables); - case ExifTagValue.JPEGACTables: - return new ExifLongArray(ExifTag.JPEGACTables); - case ExifTagValue.StripRowCounts: - return new ExifLongArray(ExifTag.StripRowCounts); - case ExifTagValue.IntergraphRegisters: - return new ExifLongArray(ExifTag.IntergraphRegisters); - case ExifTagValue.SubIFDs: - return new ExifLongArray(ExifTag.SubIFDs); - - case ExifTagValue.ImageWidth: - return new ExifNumber(ExifTag.ImageWidth); - case ExifTagValue.ImageLength: - return new ExifNumber(ExifTag.ImageLength); - case ExifTagValue.RowsPerStrip: - return new ExifNumber(ExifTag.RowsPerStrip); - case ExifTagValue.TileWidth: - return new ExifNumber(ExifTag.TileWidth); - case ExifTagValue.TileLength: - return new ExifNumber(ExifTag.TileLength); - case ExifTagValue.BadFaxLines: - return new ExifNumber(ExifTag.BadFaxLines); - case ExifTagValue.ConsecutiveBadFaxLines: - return new ExifNumber(ExifTag.ConsecutiveBadFaxLines); - case ExifTagValue.PixelXDimension: - return new ExifNumber(ExifTag.PixelXDimension); - case ExifTagValue.PixelYDimension: - return new ExifNumber(ExifTag.PixelYDimension); - - case ExifTagValue.StripByteCounts: - return new ExifNumberArray(ExifTag.StripByteCounts); - case ExifTagValue.StripOffsets: - return new ExifNumberArray(ExifTag.StripOffsets); - case ExifTagValue.TileByteCounts: - return new ExifNumberArray(ExifTag.TileByteCounts); - case ExifTagValue.TileOffsets: - return new ExifNumberArray(ExifTag.TileOffsets); - case ExifTagValue.ImageLayer: - return new ExifNumberArray(ExifTag.ImageLayer); - - case ExifTagValue.XPosition: - return new ExifRational(ExifTag.XPosition); - case ExifTagValue.YPosition: - return new ExifRational(ExifTag.YPosition); - case ExifTagValue.XResolution: - return new ExifRational(ExifTag.XResolution); - case ExifTagValue.YResolution: - return new ExifRational(ExifTag.YResolution); - case ExifTagValue.BatteryLevel: - return new ExifRational(ExifTag.BatteryLevel); - case ExifTagValue.ExposureTime: - return new ExifRational(ExifTag.ExposureTime); - case ExifTagValue.FNumber: - return new ExifRational(ExifTag.FNumber); - case ExifTagValue.MDScalePixel: - return new ExifRational(ExifTag.MDScalePixel); - case ExifTagValue.CompressedBitsPerPixel: - return new ExifRational(ExifTag.CompressedBitsPerPixel); - case ExifTagValue.ApertureValue: - return new ExifRational(ExifTag.ApertureValue); - case ExifTagValue.MaxApertureValue: - return new ExifRational(ExifTag.MaxApertureValue); - case ExifTagValue.SubjectDistance: - return new ExifRational(ExifTag.SubjectDistance); - case ExifTagValue.FocalLength: - return new ExifRational(ExifTag.FocalLength); - case ExifTagValue.FlashEnergy2: - return new ExifRational(ExifTag.FlashEnergy2); - case ExifTagValue.FocalPlaneXResolution2: - return new ExifRational(ExifTag.FocalPlaneXResolution2); - case ExifTagValue.FocalPlaneYResolution2: - return new ExifRational(ExifTag.FocalPlaneYResolution2); - case ExifTagValue.ExposureIndex2: - return new ExifRational(ExifTag.ExposureIndex2); - case ExifTagValue.Humidity: - return new ExifRational(ExifTag.Humidity); - case ExifTagValue.Pressure: - return new ExifRational(ExifTag.Pressure); - case ExifTagValue.Acceleration: - return new ExifRational(ExifTag.Acceleration); - case ExifTagValue.FlashEnergy: - return new ExifRational(ExifTag.FlashEnergy); - case ExifTagValue.FocalPlaneXResolution: - return new ExifRational(ExifTag.FocalPlaneXResolution); - case ExifTagValue.FocalPlaneYResolution: - return new ExifRational(ExifTag.FocalPlaneYResolution); - case ExifTagValue.ExposureIndex: - return new ExifRational(ExifTag.ExposureIndex); - case ExifTagValue.DigitalZoomRatio: - return new ExifRational(ExifTag.DigitalZoomRatio); - case ExifTagValue.GPSAltitude: - return new ExifRational(ExifTag.GPSAltitude); - case ExifTagValue.GPSDOP: - return new ExifRational(ExifTag.GPSDOP); - case ExifTagValue.GPSSpeed: - return new ExifRational(ExifTag.GPSSpeed); - case ExifTagValue.GPSTrack: - return new ExifRational(ExifTag.GPSTrack); - case ExifTagValue.GPSImgDirection: - return new ExifRational(ExifTag.GPSImgDirection); - case ExifTagValue.GPSDestBearing: - return new ExifRational(ExifTag.GPSDestBearing); - case ExifTagValue.GPSDestDistance: - return new ExifRational(ExifTag.GPSDestDistance); - case ExifTagValue.GPSHPositioningError: - return new ExifRational(ExifTag.GPSHPositioningError); - - case ExifTagValue.WhitePoint: - return new ExifRationalArray(ExifTag.WhitePoint); - case ExifTagValue.PrimaryChromaticities: - return new ExifRationalArray(ExifTag.PrimaryChromaticities); - case ExifTagValue.YCbCrCoefficients: - return new ExifRationalArray(ExifTag.YCbCrCoefficients); - case ExifTagValue.ReferenceBlackWhite: - return new ExifRationalArray(ExifTag.ReferenceBlackWhite); - case ExifTagValue.GPSLatitude: - return new ExifRationalArray(ExifTag.GPSLatitude); - case ExifTagValue.GPSLongitude: - return new ExifRationalArray(ExifTag.GPSLongitude); - case ExifTagValue.GPSTimestamp: - return new ExifRationalArray(ExifTag.GPSTimestamp); - case ExifTagValue.GPSDestLatitude: - return new ExifRationalArray(ExifTag.GPSDestLatitude); - case ExifTagValue.GPSDestLongitude: - return new ExifRationalArray(ExifTag.GPSDestLongitude); - case ExifTagValue.LensSpecification: - return new ExifRationalArray(ExifTag.LensSpecification); - - case ExifTagValue.OldSubfileType: - return new ExifShort(ExifTag.OldSubfileType); - case ExifTagValue.Compression: - return new ExifShort(ExifTag.Compression); - case ExifTagValue.PhotometricInterpretation: - return new ExifShort(ExifTag.PhotometricInterpretation); - case ExifTagValue.Thresholding: - return new ExifShort(ExifTag.Thresholding); - case ExifTagValue.CellWidth: - return new ExifShort(ExifTag.CellWidth); - case ExifTagValue.CellLength: - return new ExifShort(ExifTag.CellLength); - case ExifTagValue.FillOrder: - return new ExifShort(ExifTag.FillOrder); - case ExifTagValue.Orientation: - return new ExifShort(ExifTag.Orientation); - case ExifTagValue.SamplesPerPixel: - return new ExifShort(ExifTag.SamplesPerPixel); - case ExifTagValue.PlanarConfiguration: - return new ExifShort(ExifTag.PlanarConfiguration); - case ExifTagValue.Predictor: - return new ExifShort(ExifTag.Predictor); - case ExifTagValue.GrayResponseUnit: - return new ExifShort(ExifTag.GrayResponseUnit); - case ExifTagValue.ResolutionUnit: - return new ExifShort(ExifTag.ResolutionUnit); - case ExifTagValue.CleanFaxData: - return new ExifShort(ExifTag.CleanFaxData); - case ExifTagValue.InkSet: - return new ExifShort(ExifTag.InkSet); - case ExifTagValue.NumberOfInks: - return new ExifShort(ExifTag.NumberOfInks); - case ExifTagValue.DotRange: - return new ExifShort(ExifTag.DotRange); - case ExifTagValue.Indexed: - return new ExifShort(ExifTag.Indexed); - case ExifTagValue.OPIProxy: - return new ExifShort(ExifTag.OPIProxy); - case ExifTagValue.JPEGProc: - return new ExifShort(ExifTag.JPEGProc); - case ExifTagValue.JPEGRestartInterval: - return new ExifShort(ExifTag.JPEGRestartInterval); - case ExifTagValue.YCbCrPositioning: - return new ExifShort(ExifTag.YCbCrPositioning); - case ExifTagValue.Rating: - return new ExifShort(ExifTag.Rating); - case ExifTagValue.RatingPercent: - return new ExifShort(ExifTag.RatingPercent); - case ExifTagValue.ExposureProgram: - return new ExifShort(ExifTag.ExposureProgram); - case ExifTagValue.Interlace: - return new ExifShort(ExifTag.Interlace); - case ExifTagValue.SelfTimerMode: - return new ExifShort(ExifTag.SelfTimerMode); - case ExifTagValue.SensitivityType: - return new ExifShort(ExifTag.SensitivityType); - case ExifTagValue.MeteringMode: - return new ExifShort(ExifTag.MeteringMode); - case ExifTagValue.LightSource: - return new ExifShort(ExifTag.LightSource); - case ExifTagValue.FocalPlaneResolutionUnit2: - return new ExifShort(ExifTag.FocalPlaneResolutionUnit2); - case ExifTagValue.SensingMethod2: - return new ExifShort(ExifTag.SensingMethod2); - case ExifTagValue.Flash: - return new ExifShort(ExifTag.Flash); - case ExifTagValue.ColorSpace: - return new ExifShort(ExifTag.ColorSpace); - case ExifTagValue.FocalPlaneResolutionUnit: - return new ExifShort(ExifTag.FocalPlaneResolutionUnit); - case ExifTagValue.SensingMethod: - return new ExifShort(ExifTag.SensingMethod); - case ExifTagValue.CustomRendered: - return new ExifShort(ExifTag.CustomRendered); - case ExifTagValue.ExposureMode: - return new ExifShort(ExifTag.ExposureMode); - case ExifTagValue.WhiteBalance: - return new ExifShort(ExifTag.WhiteBalance); - case ExifTagValue.FocalLengthIn35mmFilm: - return new ExifShort(ExifTag.FocalLengthIn35mmFilm); - case ExifTagValue.SceneCaptureType: - return new ExifShort(ExifTag.SceneCaptureType); - case ExifTagValue.GainControl: - return new ExifShort(ExifTag.GainControl); - case ExifTagValue.Contrast: - return new ExifShort(ExifTag.Contrast); - case ExifTagValue.Saturation: - return new ExifShort(ExifTag.Saturation); - case ExifTagValue.Sharpness: - return new ExifShort(ExifTag.Sharpness); - case ExifTagValue.SubjectDistanceRange: - return new ExifShort(ExifTag.SubjectDistanceRange); - case ExifTagValue.GPSDifferential: - return new ExifShort(ExifTag.GPSDifferential); - - case ExifTagValue.BitsPerSample: - return new ExifShortArray(ExifTag.BitsPerSample); - case ExifTagValue.MinSampleValue: - return new ExifShortArray(ExifTag.MinSampleValue); - case ExifTagValue.MaxSampleValue: - return new ExifShortArray(ExifTag.MaxSampleValue); - case ExifTagValue.GrayResponseCurve: - return new ExifShortArray(ExifTag.GrayResponseCurve); - case ExifTagValue.ColorMap: - return new ExifShortArray(ExifTag.ColorMap); - case ExifTagValue.ExtraSamples: - return new ExifShortArray(ExifTag.ExtraSamples); - case ExifTagValue.PageNumber: - return new ExifShortArray(ExifTag.PageNumber); - case ExifTagValue.TransferFunction: - return new ExifShortArray(ExifTag.TransferFunction); - case ExifTagValue.HalftoneHints: - return new ExifShortArray(ExifTag.HalftoneHints); - case ExifTagValue.SampleFormat: - return new ExifShortArray(ExifTag.SampleFormat); - case ExifTagValue.TransferRange: - return new ExifShortArray(ExifTag.TransferRange); - case ExifTagValue.DefaultImageColor: - return new ExifShortArray(ExifTag.DefaultImageColor); - case ExifTagValue.JPEGLosslessPredictors: - return new ExifShortArray(ExifTag.JPEGLosslessPredictors); - case ExifTagValue.JPEGPointTransforms: - return new ExifShortArray(ExifTag.JPEGPointTransforms); - case ExifTagValue.YCbCrSubsampling: - return new ExifShortArray(ExifTag.YCbCrSubsampling); - case ExifTagValue.CFARepeatPatternDim: - return new ExifShortArray(ExifTag.CFARepeatPatternDim); - case ExifTagValue.IntergraphPacketData: - return new ExifShortArray(ExifTag.IntergraphPacketData); - case ExifTagValue.ISOSpeedRatings: - return new ExifShortArray(ExifTag.ISOSpeedRatings); - case ExifTagValue.SubjectArea: - return new ExifShortArray(ExifTag.SubjectArea); - case ExifTagValue.SubjectLocation: - return new ExifShortArray(ExifTag.SubjectLocation); - - case ExifTagValue.ShutterSpeedValue: - return new ExifSignedRational(ExifTag.ShutterSpeedValue); - case ExifTagValue.BrightnessValue: - return new ExifSignedRational(ExifTag.BrightnessValue); - case ExifTagValue.ExposureBiasValue: - return new ExifSignedRational(ExifTag.ExposureBiasValue); - case ExifTagValue.AmbientTemperature: - return new ExifSignedRational(ExifTag.AmbientTemperature); - case ExifTagValue.WaterDepth: - return new ExifSignedRational(ExifTag.WaterDepth); - case ExifTagValue.CameraElevationAngle: - return new ExifSignedRational(ExifTag.CameraElevationAngle); - - case ExifTagValue.Decode: - return new ExifSignedRationalArray(ExifTag.Decode); - - case ExifTagValue.TimeZoneOffset: - return new ExifSignedShortArray(ExifTag.TimeZoneOffset); - - case ExifTagValue.ImageDescription: - return new ExifString(ExifTag.ImageDescription); - case ExifTagValue.Make: - return new ExifString(ExifTag.Make); - case ExifTagValue.Model: - return new ExifString(ExifTag.Model); - case ExifTagValue.Software: - return new ExifString(ExifTag.Software); - case ExifTagValue.DateTime: - return new ExifString(ExifTag.DateTime); - case ExifTagValue.Artist: - return new ExifString(ExifTag.Artist); - case ExifTagValue.HostComputer: - return new ExifString(ExifTag.HostComputer); - case ExifTagValue.Copyright: - return new ExifString(ExifTag.Copyright); - case ExifTagValue.DocumentName: - return new ExifString(ExifTag.DocumentName); - case ExifTagValue.PageName: - return new ExifString(ExifTag.PageName); - case ExifTagValue.InkNames: - return new ExifString(ExifTag.InkNames); - case ExifTagValue.TargetPrinter: - return new ExifString(ExifTag.TargetPrinter); - case ExifTagValue.ImageID: - return new ExifString(ExifTag.ImageID); - case ExifTagValue.MDLabName: - return new ExifString(ExifTag.MDLabName); - case ExifTagValue.MDSampleInfo: - return new ExifString(ExifTag.MDSampleInfo); - case ExifTagValue.MDPrepDate: - return new ExifString(ExifTag.MDPrepDate); - case ExifTagValue.MDPrepTime: - return new ExifString(ExifTag.MDPrepTime); - case ExifTagValue.MDFileUnits: - return new ExifString(ExifTag.MDFileUnits); - case ExifTagValue.SEMInfo: - return new ExifString(ExifTag.SEMInfo); - case ExifTagValue.SpectralSensitivity: - return new ExifString(ExifTag.SpectralSensitivity); - case ExifTagValue.DateTimeOriginal: - return new ExifString(ExifTag.DateTimeOriginal); - case ExifTagValue.DateTimeDigitized: - return new ExifString(ExifTag.DateTimeDigitized); - case ExifTagValue.SubsecTime: - return new ExifString(ExifTag.SubsecTime); - case ExifTagValue.SubsecTimeOriginal: - return new ExifString(ExifTag.SubsecTimeOriginal); - case ExifTagValue.SubsecTimeDigitized: - return new ExifString(ExifTag.SubsecTimeDigitized); - case ExifTagValue.RelatedSoundFile: - return new ExifString(ExifTag.RelatedSoundFile); - case ExifTagValue.FaxSubaddress: - return new ExifString(ExifTag.FaxSubaddress); - case ExifTagValue.OffsetTime: - return new ExifString(ExifTag.OffsetTime); - case ExifTagValue.OffsetTimeOriginal: - return new ExifString(ExifTag.OffsetTimeOriginal); - case ExifTagValue.OffsetTimeDigitized: - return new ExifString(ExifTag.OffsetTimeDigitized); - case ExifTagValue.SecurityClassification: - return new ExifString(ExifTag.SecurityClassification); - case ExifTagValue.ImageHistory: - return new ExifString(ExifTag.ImageHistory); - case ExifTagValue.ImageUniqueID: - return new ExifString(ExifTag.ImageUniqueID); - case ExifTagValue.OwnerName: - return new ExifString(ExifTag.OwnerName); - case ExifTagValue.SerialNumber: - return new ExifString(ExifTag.SerialNumber); - case ExifTagValue.LensMake: - return new ExifString(ExifTag.LensMake); - case ExifTagValue.LensModel: - return new ExifString(ExifTag.LensModel); - case ExifTagValue.LensSerialNumber: - return new ExifString(ExifTag.LensSerialNumber); - case ExifTagValue.GDALMetadata: - return new ExifString(ExifTag.GDALMetadata); - case ExifTagValue.GDALNoData: - return new ExifString(ExifTag.GDALNoData); - case ExifTagValue.GPSLatitudeRef: - return new ExifString(ExifTag.GPSLatitudeRef); - case ExifTagValue.GPSLongitudeRef: - return new ExifString(ExifTag.GPSLongitudeRef); - case ExifTagValue.GPSSatellites: - return new ExifString(ExifTag.GPSSatellites); - case ExifTagValue.GPSStatus: - return new ExifString(ExifTag.GPSStatus); - case ExifTagValue.GPSMeasureMode: - return new ExifString(ExifTag.GPSMeasureMode); - case ExifTagValue.GPSSpeedRef: - return new ExifString(ExifTag.GPSSpeedRef); - case ExifTagValue.GPSTrackRef: - return new ExifString(ExifTag.GPSTrackRef); - case ExifTagValue.GPSImgDirectionRef: - return new ExifString(ExifTag.GPSImgDirectionRef); - case ExifTagValue.GPSMapDatum: - return new ExifString(ExifTag.GPSMapDatum); - case ExifTagValue.GPSDestLatitudeRef: - return new ExifString(ExifTag.GPSDestLatitudeRef); - case ExifTagValue.GPSDestLongitudeRef: - return new ExifString(ExifTag.GPSDestLongitudeRef); - case ExifTagValue.GPSDestBearingRef: - return new ExifString(ExifTag.GPSDestBearingRef); - case ExifTagValue.GPSDestDistanceRef: - return new ExifString(ExifTag.GPSDestDistanceRef); - case ExifTagValue.GPSDateStamp: - return new ExifString(ExifTag.GPSDateStamp); - - case ExifTagValue.FileSource: - return new ExifByte(ExifTag.FileSource, ExifDataType.Undefined); - case ExifTagValue.SceneType: - return new ExifByte(ExifTag.SceneType, ExifDataType.Undefined); - - case ExifTagValue.JPEGTables: - return new ExifByteArray(ExifTag.JPEGTables, ExifDataType.Undefined); - case ExifTagValue.OECF: - return new ExifByteArray(ExifTag.OECF, ExifDataType.Undefined); - case ExifTagValue.ExifVersion: - return new ExifByteArray(ExifTag.ExifVersion, ExifDataType.Undefined); - case ExifTagValue.ComponentsConfiguration: - return new ExifByteArray(ExifTag.ComponentsConfiguration, ExifDataType.Undefined); - case ExifTagValue.MakerNote: - return new ExifByteArray(ExifTag.MakerNote, ExifDataType.Undefined); - case ExifTagValue.FlashpixVersion: - return new ExifByteArray(ExifTag.FlashpixVersion, ExifDataType.Undefined); - case ExifTagValue.SpatialFrequencyResponse: - return new ExifByteArray(ExifTag.SpatialFrequencyResponse, ExifDataType.Undefined); - case ExifTagValue.SpatialFrequencyResponse2: - return new ExifByteArray(ExifTag.SpatialFrequencyResponse2, ExifDataType.Undefined); - case ExifTagValue.Noise: - return new ExifByteArray(ExifTag.Noise, ExifDataType.Undefined); - case ExifTagValue.CFAPattern: - return new ExifByteArray(ExifTag.CFAPattern, ExifDataType.Undefined); - case ExifTagValue.DeviceSettingDescription: - return new ExifByteArray(ExifTag.DeviceSettingDescription, ExifDataType.Undefined); - case ExifTagValue.ImageSourceData: - return new ExifByteArray(ExifTag.ImageSourceData, ExifDataType.Undefined); - - case ExifTagValue.XPTitle: - return new ExifUcs2String(ExifTag.XPTitle); - case ExifTagValue.XPComment: - return new ExifUcs2String(ExifTag.XPComment); - case ExifTagValue.XPAuthor: - return new ExifUcs2String(ExifTag.XPAuthor); - case ExifTagValue.XPKeywords: - return new ExifUcs2String(ExifTag.XPKeywords); - case ExifTagValue.XPSubject: - return new ExifUcs2String(ExifTag.XPSubject); - - case ExifTagValue.UserComment: - return new ExifEncodedString(ExifTag.UserComment); - case ExifTagValue.GPSProcessingMethod: - return new ExifEncodedString(ExifTag.GPSProcessingMethod); - case ExifTagValue.GPSAreaInformation: - return new ExifEncodedString(ExifTag.GPSAreaInformation); - - default: - return null; - } - } + ExifTagValue.FaxProfile => new ExifByte(ExifTag.FaxProfile, ExifDataType.Byte), + ExifTagValue.ModeNumber => new ExifByte(ExifTag.ModeNumber, ExifDataType.Byte), + ExifTagValue.GPSAltitudeRef => new ExifByte(ExifTag.GPSAltitudeRef, ExifDataType.Byte), + ExifTagValue.ClipPath => new ExifByteArray(ExifTag.ClipPath, ExifDataType.Byte), + ExifTagValue.VersionYear => new ExifByteArray(ExifTag.VersionYear, ExifDataType.Byte), + ExifTagValue.XMP => new ExifByteArray(ExifTag.XMP, ExifDataType.Byte), + ExifTagValue.CFAPattern2 => new ExifByteArray(ExifTag.CFAPattern2, ExifDataType.Byte), + ExifTagValue.TIFFEPStandardID => new ExifByteArray(ExifTag.TIFFEPStandardID, ExifDataType.Byte), + ExifTagValue.GPSVersionID => new ExifByteArray(ExifTag.GPSVersionID, ExifDataType.Byte), + ExifTagValue.PixelScale => new ExifDoubleArray(ExifTag.PixelScale), + ExifTagValue.IntergraphMatrix => new ExifDoubleArray(ExifTag.IntergraphMatrix), + ExifTagValue.ModelTiePoint => new ExifDoubleArray(ExifTag.ModelTiePoint), + ExifTagValue.ModelTransform => new ExifDoubleArray(ExifTag.ModelTransform), + ExifTagValue.SubfileType => new ExifLong(ExifTag.SubfileType), + ExifTagValue.SubIFDOffset => new ExifLong(ExifTag.SubIFDOffset), + ExifTagValue.GPSIFDOffset => new ExifLong(ExifTag.GPSIFDOffset), + ExifTagValue.T4Options => new ExifLong(ExifTag.T4Options), + ExifTagValue.T6Options => new ExifLong(ExifTag.T6Options), + ExifTagValue.XClipPathUnits => new ExifLong(ExifTag.XClipPathUnits), + ExifTagValue.YClipPathUnits => new ExifLong(ExifTag.YClipPathUnits), + ExifTagValue.ProfileType => new ExifLong(ExifTag.ProfileType), + ExifTagValue.CodingMethods => new ExifLong(ExifTag.CodingMethods), + ExifTagValue.T82ptions => new ExifLong(ExifTag.T82ptions), + ExifTagValue.JPEGInterchangeFormat => new ExifLong(ExifTag.JPEGInterchangeFormat), + ExifTagValue.JPEGInterchangeFormatLength => new ExifLong(ExifTag.JPEGInterchangeFormatLength), + ExifTagValue.MDFileTag => new ExifLong(ExifTag.MDFileTag), + ExifTagValue.StandardOutputSensitivity => new ExifLong(ExifTag.StandardOutputSensitivity), + ExifTagValue.RecommendedExposureIndex => new ExifLong(ExifTag.RecommendedExposureIndex), + ExifTagValue.ISOSpeed => new ExifLong(ExifTag.ISOSpeed), + ExifTagValue.ISOSpeedLatitudeyyy => new ExifLong(ExifTag.ISOSpeedLatitudeyyy), + ExifTagValue.ISOSpeedLatitudezzz => new ExifLong(ExifTag.ISOSpeedLatitudezzz), + ExifTagValue.FaxRecvParams => new ExifLong(ExifTag.FaxRecvParams), + ExifTagValue.FaxRecvTime => new ExifLong(ExifTag.FaxRecvTime), + ExifTagValue.ImageNumber => new ExifLong(ExifTag.ImageNumber), + ExifTagValue.FreeOffsets => new ExifLongArray(ExifTag.FreeOffsets), + ExifTagValue.FreeByteCounts => new ExifLongArray(ExifTag.FreeByteCounts), + ExifTagValue.ColorResponseUnit => new ExifLongArray(ExifTag.ColorResponseUnit), + ExifTagValue.SMinSampleValue => new ExifLongArray(ExifTag.SMinSampleValue), + ExifTagValue.SMaxSampleValue => new ExifLongArray(ExifTag.SMaxSampleValue), + ExifTagValue.JPEGQTables => new ExifLongArray(ExifTag.JPEGQTables), + ExifTagValue.JPEGDCTables => new ExifLongArray(ExifTag.JPEGDCTables), + ExifTagValue.JPEGACTables => new ExifLongArray(ExifTag.JPEGACTables), + ExifTagValue.StripRowCounts => new ExifLongArray(ExifTag.StripRowCounts), + ExifTagValue.IntergraphRegisters => new ExifLongArray(ExifTag.IntergraphRegisters), + ExifTagValue.SubIFDs => new ExifLongArray(ExifTag.SubIFDs), + ExifTagValue.ImageWidth => new ExifNumber(ExifTag.ImageWidth), + ExifTagValue.ImageLength => new ExifNumber(ExifTag.ImageLength), + ExifTagValue.RowsPerStrip => new ExifNumber(ExifTag.RowsPerStrip), + ExifTagValue.TileWidth => new ExifNumber(ExifTag.TileWidth), + ExifTagValue.TileLength => new ExifNumber(ExifTag.TileLength), + ExifTagValue.BadFaxLines => new ExifNumber(ExifTag.BadFaxLines), + ExifTagValue.ConsecutiveBadFaxLines => new ExifNumber(ExifTag.ConsecutiveBadFaxLines), + ExifTagValue.PixelXDimension => new ExifNumber(ExifTag.PixelXDimension), + ExifTagValue.PixelYDimension => new ExifNumber(ExifTag.PixelYDimension), + ExifTagValue.StripByteCounts => new ExifNumberArray(ExifTag.StripByteCounts), + ExifTagValue.StripOffsets => new ExifNumberArray(ExifTag.StripOffsets), + ExifTagValue.TileByteCounts => new ExifNumberArray(ExifTag.TileByteCounts), + ExifTagValue.TileOffsets => new ExifNumberArray(ExifTag.TileOffsets), + ExifTagValue.ImageLayer => new ExifNumberArray(ExifTag.ImageLayer), + ExifTagValue.XPosition => new ExifRational(ExifTag.XPosition), + ExifTagValue.YPosition => new ExifRational(ExifTag.YPosition), + ExifTagValue.XResolution => new ExifRational(ExifTag.XResolution), + ExifTagValue.YResolution => new ExifRational(ExifTag.YResolution), + ExifTagValue.BatteryLevel => new ExifRational(ExifTag.BatteryLevel), + ExifTagValue.ExposureTime => new ExifRational(ExifTag.ExposureTime), + ExifTagValue.FNumber => new ExifRational(ExifTag.FNumber), + ExifTagValue.MDScalePixel => new ExifRational(ExifTag.MDScalePixel), + ExifTagValue.CompressedBitsPerPixel => new ExifRational(ExifTag.CompressedBitsPerPixel), + ExifTagValue.ApertureValue => new ExifRational(ExifTag.ApertureValue), + ExifTagValue.MaxApertureValue => new ExifRational(ExifTag.MaxApertureValue), + ExifTagValue.SubjectDistance => new ExifRational(ExifTag.SubjectDistance), + ExifTagValue.FocalLength => new ExifRational(ExifTag.FocalLength), + ExifTagValue.FlashEnergy2 => new ExifRational(ExifTag.FlashEnergy2), + ExifTagValue.FocalPlaneXResolution2 => new ExifRational(ExifTag.FocalPlaneXResolution2), + ExifTagValue.FocalPlaneYResolution2 => new ExifRational(ExifTag.FocalPlaneYResolution2), + ExifTagValue.ExposureIndex2 => new ExifRational(ExifTag.ExposureIndex2), + ExifTagValue.Humidity => new ExifRational(ExifTag.Humidity), + ExifTagValue.Pressure => new ExifRational(ExifTag.Pressure), + ExifTagValue.Acceleration => new ExifRational(ExifTag.Acceleration), + ExifTagValue.FlashEnergy => new ExifRational(ExifTag.FlashEnergy), + ExifTagValue.FocalPlaneXResolution => new ExifRational(ExifTag.FocalPlaneXResolution), + ExifTagValue.FocalPlaneYResolution => new ExifRational(ExifTag.FocalPlaneYResolution), + ExifTagValue.ExposureIndex => new ExifRational(ExifTag.ExposureIndex), + ExifTagValue.DigitalZoomRatio => new ExifRational(ExifTag.DigitalZoomRatio), + ExifTagValue.GPSAltitude => new ExifRational(ExifTag.GPSAltitude), + ExifTagValue.GPSDOP => new ExifRational(ExifTag.GPSDOP), + ExifTagValue.GPSSpeed => new ExifRational(ExifTag.GPSSpeed), + ExifTagValue.GPSTrack => new ExifRational(ExifTag.GPSTrack), + ExifTagValue.GPSImgDirection => new ExifRational(ExifTag.GPSImgDirection), + ExifTagValue.GPSDestBearing => new ExifRational(ExifTag.GPSDestBearing), + ExifTagValue.GPSDestDistance => new ExifRational(ExifTag.GPSDestDistance), + ExifTagValue.GPSHPositioningError => new ExifRational(ExifTag.GPSHPositioningError), + ExifTagValue.WhitePoint => new ExifRationalArray(ExifTag.WhitePoint), + ExifTagValue.PrimaryChromaticities => new ExifRationalArray(ExifTag.PrimaryChromaticities), + ExifTagValue.YCbCrCoefficients => new ExifRationalArray(ExifTag.YCbCrCoefficients), + ExifTagValue.ReferenceBlackWhite => new ExifRationalArray(ExifTag.ReferenceBlackWhite), + ExifTagValue.GPSLatitude => new ExifRationalArray(ExifTag.GPSLatitude), + ExifTagValue.GPSLongitude => new ExifRationalArray(ExifTag.GPSLongitude), + ExifTagValue.GPSTimestamp => new ExifRationalArray(ExifTag.GPSTimestamp), + ExifTagValue.GPSDestLatitude => new ExifRationalArray(ExifTag.GPSDestLatitude), + ExifTagValue.GPSDestLongitude => new ExifRationalArray(ExifTag.GPSDestLongitude), + ExifTagValue.LensSpecification => new ExifRationalArray(ExifTag.LensSpecification), + ExifTagValue.OldSubfileType => new ExifShort(ExifTag.OldSubfileType), + ExifTagValue.Compression => new ExifShort(ExifTag.Compression), + ExifTagValue.PhotometricInterpretation => new ExifShort(ExifTag.PhotometricInterpretation), + ExifTagValue.Thresholding => new ExifShort(ExifTag.Thresholding), + ExifTagValue.CellWidth => new ExifShort(ExifTag.CellWidth), + ExifTagValue.CellLength => new ExifShort(ExifTag.CellLength), + ExifTagValue.FillOrder => new ExifShort(ExifTag.FillOrder), + ExifTagValue.Orientation => new ExifShort(ExifTag.Orientation), + ExifTagValue.SamplesPerPixel => new ExifShort(ExifTag.SamplesPerPixel), + ExifTagValue.PlanarConfiguration => new ExifShort(ExifTag.PlanarConfiguration), + ExifTagValue.Predictor => new ExifShort(ExifTag.Predictor), + ExifTagValue.GrayResponseUnit => new ExifShort(ExifTag.GrayResponseUnit), + ExifTagValue.ResolutionUnit => new ExifShort(ExifTag.ResolutionUnit), + ExifTagValue.CleanFaxData => new ExifShort(ExifTag.CleanFaxData), + ExifTagValue.InkSet => new ExifShort(ExifTag.InkSet), + ExifTagValue.NumberOfInks => new ExifShort(ExifTag.NumberOfInks), + ExifTagValue.DotRange => new ExifShort(ExifTag.DotRange), + ExifTagValue.Indexed => new ExifShort(ExifTag.Indexed), + ExifTagValue.OPIProxy => new ExifShort(ExifTag.OPIProxy), + ExifTagValue.JPEGProc => new ExifShort(ExifTag.JPEGProc), + ExifTagValue.JPEGRestartInterval => new ExifShort(ExifTag.JPEGRestartInterval), + ExifTagValue.YCbCrPositioning => new ExifShort(ExifTag.YCbCrPositioning), + ExifTagValue.Rating => new ExifShort(ExifTag.Rating), + ExifTagValue.RatingPercent => new ExifShort(ExifTag.RatingPercent), + ExifTagValue.ExposureProgram => new ExifShort(ExifTag.ExposureProgram), + ExifTagValue.Interlace => new ExifShort(ExifTag.Interlace), + ExifTagValue.SelfTimerMode => new ExifShort(ExifTag.SelfTimerMode), + ExifTagValue.SensitivityType => new ExifShort(ExifTag.SensitivityType), + ExifTagValue.MeteringMode => new ExifShort(ExifTag.MeteringMode), + ExifTagValue.LightSource => new ExifShort(ExifTag.LightSource), + ExifTagValue.FocalPlaneResolutionUnit2 => new ExifShort(ExifTag.FocalPlaneResolutionUnit2), + ExifTagValue.SensingMethod2 => new ExifShort(ExifTag.SensingMethod2), + ExifTagValue.Flash => new ExifShort(ExifTag.Flash), + ExifTagValue.ColorSpace => new ExifShort(ExifTag.ColorSpace), + ExifTagValue.FocalPlaneResolutionUnit => new ExifShort(ExifTag.FocalPlaneResolutionUnit), + ExifTagValue.SensingMethod => new ExifShort(ExifTag.SensingMethod), + ExifTagValue.CustomRendered => new ExifShort(ExifTag.CustomRendered), + ExifTagValue.ExposureMode => new ExifShort(ExifTag.ExposureMode), + ExifTagValue.WhiteBalance => new ExifShort(ExifTag.WhiteBalance), + ExifTagValue.FocalLengthIn35mmFilm => new ExifShort(ExifTag.FocalLengthIn35mmFilm), + ExifTagValue.SceneCaptureType => new ExifShort(ExifTag.SceneCaptureType), + ExifTagValue.GainControl => new ExifShort(ExifTag.GainControl), + ExifTagValue.Contrast => new ExifShort(ExifTag.Contrast), + ExifTagValue.Saturation => new ExifShort(ExifTag.Saturation), + ExifTagValue.Sharpness => new ExifShort(ExifTag.Sharpness), + ExifTagValue.SubjectDistanceRange => new ExifShort(ExifTag.SubjectDistanceRange), + ExifTagValue.GPSDifferential => new ExifShort(ExifTag.GPSDifferential), + ExifTagValue.BitsPerSample => new ExifShortArray(ExifTag.BitsPerSample), + ExifTagValue.MinSampleValue => new ExifShortArray(ExifTag.MinSampleValue), + ExifTagValue.MaxSampleValue => new ExifShortArray(ExifTag.MaxSampleValue), + ExifTagValue.GrayResponseCurve => new ExifShortArray(ExifTag.GrayResponseCurve), + ExifTagValue.ColorMap => new ExifShortArray(ExifTag.ColorMap), + ExifTagValue.ExtraSamples => new ExifShortArray(ExifTag.ExtraSamples), + ExifTagValue.PageNumber => new ExifShortArray(ExifTag.PageNumber), + ExifTagValue.TransferFunction => new ExifShortArray(ExifTag.TransferFunction), + ExifTagValue.HalftoneHints => new ExifShortArray(ExifTag.HalftoneHints), + ExifTagValue.SampleFormat => new ExifShortArray(ExifTag.SampleFormat), + ExifTagValue.TransferRange => new ExifShortArray(ExifTag.TransferRange), + ExifTagValue.DefaultImageColor => new ExifShortArray(ExifTag.DefaultImageColor), + ExifTagValue.JPEGLosslessPredictors => new ExifShortArray(ExifTag.JPEGLosslessPredictors), + ExifTagValue.JPEGPointTransforms => new ExifShortArray(ExifTag.JPEGPointTransforms), + ExifTagValue.YCbCrSubsampling => new ExifShortArray(ExifTag.YCbCrSubsampling), + ExifTagValue.CFARepeatPatternDim => new ExifShortArray(ExifTag.CFARepeatPatternDim), + ExifTagValue.IntergraphPacketData => new ExifShortArray(ExifTag.IntergraphPacketData), + ExifTagValue.ISOSpeedRatings => new ExifShortArray(ExifTag.ISOSpeedRatings), + ExifTagValue.SubjectArea => new ExifShortArray(ExifTag.SubjectArea), + ExifTagValue.SubjectLocation => new ExifShortArray(ExifTag.SubjectLocation), + ExifTagValue.ShutterSpeedValue => new ExifSignedRational(ExifTag.ShutterSpeedValue), + ExifTagValue.BrightnessValue => new ExifSignedRational(ExifTag.BrightnessValue), + ExifTagValue.ExposureBiasValue => new ExifSignedRational(ExifTag.ExposureBiasValue), + ExifTagValue.AmbientTemperature => new ExifSignedRational(ExifTag.AmbientTemperature), + ExifTagValue.WaterDepth => new ExifSignedRational(ExifTag.WaterDepth), + ExifTagValue.CameraElevationAngle => new ExifSignedRational(ExifTag.CameraElevationAngle), + ExifTagValue.Decode => new ExifSignedRationalArray(ExifTag.Decode), + ExifTagValue.TimeZoneOffset => new ExifSignedShortArray(ExifTag.TimeZoneOffset), + ExifTagValue.ImageDescription => new ExifString(ExifTag.ImageDescription), + ExifTagValue.Make => new ExifString(ExifTag.Make), + ExifTagValue.Model => new ExifString(ExifTag.Model), + ExifTagValue.Software => new ExifString(ExifTag.Software), + ExifTagValue.DateTime => new ExifString(ExifTag.DateTime), + ExifTagValue.Artist => new ExifString(ExifTag.Artist), + ExifTagValue.HostComputer => new ExifString(ExifTag.HostComputer), + ExifTagValue.Copyright => new ExifString(ExifTag.Copyright), + ExifTagValue.DocumentName => new ExifString(ExifTag.DocumentName), + ExifTagValue.PageName => new ExifString(ExifTag.PageName), + ExifTagValue.InkNames => new ExifString(ExifTag.InkNames), + ExifTagValue.TargetPrinter => new ExifString(ExifTag.TargetPrinter), + ExifTagValue.ImageID => new ExifString(ExifTag.ImageID), + ExifTagValue.MDLabName => new ExifString(ExifTag.MDLabName), + ExifTagValue.MDSampleInfo => new ExifString(ExifTag.MDSampleInfo), + ExifTagValue.MDPrepDate => new ExifString(ExifTag.MDPrepDate), + ExifTagValue.MDPrepTime => new ExifString(ExifTag.MDPrepTime), + ExifTagValue.MDFileUnits => new ExifString(ExifTag.MDFileUnits), + ExifTagValue.SEMInfo => new ExifString(ExifTag.SEMInfo), + ExifTagValue.SpectralSensitivity => new ExifString(ExifTag.SpectralSensitivity), + ExifTagValue.DateTimeOriginal => new ExifString(ExifTag.DateTimeOriginal), + ExifTagValue.DateTimeDigitized => new ExifString(ExifTag.DateTimeDigitized), + ExifTagValue.SubsecTime => new ExifString(ExifTag.SubsecTime), + ExifTagValue.SubsecTimeOriginal => new ExifString(ExifTag.SubsecTimeOriginal), + ExifTagValue.SubsecTimeDigitized => new ExifString(ExifTag.SubsecTimeDigitized), + ExifTagValue.RelatedSoundFile => new ExifString(ExifTag.RelatedSoundFile), + ExifTagValue.FaxSubaddress => new ExifString(ExifTag.FaxSubaddress), + ExifTagValue.OffsetTime => new ExifString(ExifTag.OffsetTime), + ExifTagValue.OffsetTimeOriginal => new ExifString(ExifTag.OffsetTimeOriginal), + ExifTagValue.OffsetTimeDigitized => new ExifString(ExifTag.OffsetTimeDigitized), + ExifTagValue.SecurityClassification => new ExifString(ExifTag.SecurityClassification), + ExifTagValue.ImageHistory => new ExifString(ExifTag.ImageHistory), + ExifTagValue.ImageUniqueID => new ExifString(ExifTag.ImageUniqueID), + ExifTagValue.OwnerName => new ExifString(ExifTag.OwnerName), + ExifTagValue.SerialNumber => new ExifString(ExifTag.SerialNumber), + ExifTagValue.LensMake => new ExifString(ExifTag.LensMake), + ExifTagValue.LensModel => new ExifString(ExifTag.LensModel), + ExifTagValue.LensSerialNumber => new ExifString(ExifTag.LensSerialNumber), + ExifTagValue.GDALMetadata => new ExifString(ExifTag.GDALMetadata), + ExifTagValue.GDALNoData => new ExifString(ExifTag.GDALNoData), + ExifTagValue.GPSLatitudeRef => new ExifString(ExifTag.GPSLatitudeRef), + ExifTagValue.GPSLongitudeRef => new ExifString(ExifTag.GPSLongitudeRef), + ExifTagValue.GPSSatellites => new ExifString(ExifTag.GPSSatellites), + ExifTagValue.GPSStatus => new ExifString(ExifTag.GPSStatus), + ExifTagValue.GPSMeasureMode => new ExifString(ExifTag.GPSMeasureMode), + ExifTagValue.GPSSpeedRef => new ExifString(ExifTag.GPSSpeedRef), + ExifTagValue.GPSTrackRef => new ExifString(ExifTag.GPSTrackRef), + ExifTagValue.GPSImgDirectionRef => new ExifString(ExifTag.GPSImgDirectionRef), + ExifTagValue.GPSMapDatum => new ExifString(ExifTag.GPSMapDatum), + ExifTagValue.GPSDestLatitudeRef => new ExifString(ExifTag.GPSDestLatitudeRef), + ExifTagValue.GPSDestLongitudeRef => new ExifString(ExifTag.GPSDestLongitudeRef), + ExifTagValue.GPSDestBearingRef => new ExifString(ExifTag.GPSDestBearingRef), + ExifTagValue.GPSDestDistanceRef => new ExifString(ExifTag.GPSDestDistanceRef), + ExifTagValue.GPSDateStamp => new ExifString(ExifTag.GPSDateStamp), + ExifTagValue.FileSource => new ExifByte(ExifTag.FileSource, ExifDataType.Undefined), + ExifTagValue.SceneType => new ExifByte(ExifTag.SceneType, ExifDataType.Undefined), + ExifTagValue.JPEGTables => new ExifByteArray(ExifTag.JPEGTables, ExifDataType.Undefined), + ExifTagValue.OECF => new ExifByteArray(ExifTag.OECF, ExifDataType.Undefined), + ExifTagValue.ExifVersion => new ExifByteArray(ExifTag.ExifVersion, ExifDataType.Undefined), + ExifTagValue.ComponentsConfiguration => new ExifByteArray(ExifTag.ComponentsConfiguration, ExifDataType.Undefined), + ExifTagValue.MakerNote => new ExifByteArray(ExifTag.MakerNote, ExifDataType.Undefined), + ExifTagValue.FlashpixVersion => new ExifByteArray(ExifTag.FlashpixVersion, ExifDataType.Undefined), + ExifTagValue.SpatialFrequencyResponse => new ExifByteArray(ExifTag.SpatialFrequencyResponse, ExifDataType.Undefined), + ExifTagValue.SpatialFrequencyResponse2 => new ExifByteArray(ExifTag.SpatialFrequencyResponse2, ExifDataType.Undefined), + ExifTagValue.Noise => new ExifByteArray(ExifTag.Noise, ExifDataType.Undefined), + ExifTagValue.CFAPattern => new ExifByteArray(ExifTag.CFAPattern, ExifDataType.Undefined), + ExifTagValue.DeviceSettingDescription => new ExifByteArray(ExifTag.DeviceSettingDescription, ExifDataType.Undefined), + ExifTagValue.ImageSourceData => new ExifByteArray(ExifTag.ImageSourceData, ExifDataType.Undefined), + ExifTagValue.XPTitle => new ExifUcs2String(ExifTag.XPTitle), + ExifTagValue.XPComment => new ExifUcs2String(ExifTag.XPComment), + ExifTagValue.XPAuthor => new ExifUcs2String(ExifTag.XPAuthor), + ExifTagValue.XPKeywords => new ExifUcs2String(ExifTag.XPKeywords), + ExifTagValue.XPSubject => new ExifUcs2String(ExifTag.XPSubject), + ExifTagValue.UserComment => new ExifEncodedString(ExifTag.UserComment), + ExifTagValue.GPSProcessingMethod => new ExifEncodedString(ExifTag.GPSProcessingMethod), + ExifTagValue.GPSAreaInformation => new ExifEncodedString(ExifTag.GPSAreaInformation), + _ => null, + }; } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/IExifValue.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/IExifValue.cs index c5b1574f3..3bb555192 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/IExifValue.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/IExifValue.cs @@ -4,35 +4,35 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; /// -/// A value of the exif profile. +/// A value of the Exif profile. /// public interface IExifValue : IDeepCloneable { /// - /// Gets the data type of the exif value. + /// Gets the data type of the Exif value. /// - ExifDataType DataType { get; } + public ExifDataType DataType { get; } /// /// Gets a value indicating whether the value is an array. /// - bool IsArray { get; } + public bool IsArray { get; } /// - /// Gets the tag of the exif value. + /// Gets the tag of the Exif value. /// - ExifTag Tag { get; } + public ExifTag Tag { get; } /// - /// Gets the value of this exif value. + /// Gets the value of this Exif value. /// - /// The value of this exif value. - object? GetValue(); + /// The value of this Exif value. + public object? GetValue(); /// - /// Sets the value of this exif value. + /// Sets the value of this Exif value. /// - /// The value of this exif value. + /// The value of this Exif value. /// A value indicating whether the value could be set. - bool TrySetValue(object? value); + public bool TrySetValue(object? value); } diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 660ab2e66..1ffbd9f55 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -5,6 +5,7 @@ using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Metadata; +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; @@ -559,4 +560,22 @@ public class WebpDecoderTests image.DebugSave(provider); image.CompareToOriginal(provider, ReferenceDecoder); } + + [Theory] + [WithFile(Lossy.Issue2906, PixelTypes.Rgba32)] + public void WebpDecoder_CanDecode_Issue2906(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(WebpDecoder.Instance); + + ExifProfile exifProfile = image.Metadata.ExifProfile; + IExifValue comment = exifProfile.GetValue(ExifTag.UserComment); + + Assert.NotNull(comment); + Assert.Equal(EncodedString.CharacterCode.Unicode, comment.Value.Code); + Assert.StartsWith("1girl, pariya, ", comment.Value.Text); + + image.DebugSave(provider); + image.CompareToOriginal(provider, ReferenceDecoder); + } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 0908e6e6b..c4f95e512 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -875,6 +875,7 @@ public static class TestImages public const string Issue2801 = "Webp/issues/Issue2801.webp"; public const string Issue2866 = "Webp/issues/Issue2866.webp"; public const string Issue2925 = "Webp/issues/Issue2925.webp"; + public const string Issue2906 = "Webp/issues/Issue2906.webp"; } public const string AlphaBlend = "Webp/alpha-blend.webp"; diff --git a/tests/Images/Input/Webp/issues/Issue2906.webp b/tests/Images/Input/Webp/issues/Issue2906.webp new file mode 100644 index 000000000..0911da047 --- /dev/null +++ b/tests/Images/Input/Webp/issues/Issue2906.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56fe6a91feb9545c0a15966e0f6bc560890b193073c96ae9e39bf387c7e0cbca +size 157092 From 17e9d99a39fcd9d3bfcd9a40d671490c651bfc53 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 11 Jun 2025 19:47:54 +1000 Subject: [PATCH 010/112] Clean up --- .../Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs | 4 ++-- src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index c8725db81..34bbbb79d 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -101,8 +101,8 @@ internal static class ExifEncodedStringHelpers return false; } - public static uint GetDataLength(EncodedString encodedString, ByteOrder order) => - (uint)GetEncoding(encodedString.Code, order).GetByteCount(encodedString.Text) + CharacterCodeBytesLength; + public static uint GetDataLength(EncodedString encodedString) => + (uint)GetEncoding(encodedString.Code, ByteOrder.LittleEndian).GetByteCount(encodedString.Text) + CharacterCodeBytesLength; public static int Write(EncodedString encodedString, Span destination) { diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs index 14120ed49..732e3eab2 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs @@ -281,7 +281,7 @@ internal sealed class ExifWriter if (value is EncodedString encodedString) { - return ExifEncodedStringHelpers.GetDataLength(encodedString, ByteOrder.LittleEndian); + return ExifEncodedStringHelpers.GetDataLength(encodedString); } if (exifValue.DataType == ExifDataType.Ascii) From 3376d5dcd4f7410fab4b46c80eae1419f8b53723 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 11 Jun 2025 20:09:12 +1000 Subject: [PATCH 011/112] Update ExifTag.cs --- src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs index 26edb4b15..ec30f21cd 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.cs @@ -30,7 +30,7 @@ public abstract partial class ExifTag : IEquatable /// /// The first to compare. /// The second to compare. - public static bool operator !=(ExifTag left, ExifTag right) => !(left == right); + public static bool operator !=(ExifTag? left, ExifTag? right) => !(left == right); /// public override bool Equals(object? obj) From 668e223fa11bfbbf6f0c06b77df3351d1c06acfd Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 12 Jun 2025 21:41:20 +1000 Subject: [PATCH 012/112] Update Subject EXIF metadata when transforming images. --- src/ImageSharp/Formats/Bmp/BmpMetadata.cs | 3 +- .../Formats/Cur/CurFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Cur/CurMetadata.cs | 3 +- .../Formats/Gif/GifFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Gif/GifMetadata.cs | 3 +- .../Formats/IFormatFrameMetadata.cs | 4 +- src/ImageSharp/Formats/IFormatMetadata.cs | 4 +- .../Formats/Ico/IcoFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Ico/IcoMetadata.cs | 3 +- src/ImageSharp/Formats/Jpeg/JpegMetadata.cs | 3 +- src/ImageSharp/Formats/Pbm/PbmMetadata.cs | 3 +- .../Formats/Png/PngFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Png/PngMetadata.cs | 3 +- src/ImageSharp/Formats/Qoi/QoiMetadata.cs | 3 +- src/ImageSharp/Formats/Tga/TgaMetadata.cs | 3 +- .../Formats/Tiff/TiffFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Tiff/TiffMetadata.cs | 3 +- .../Formats/Webp/WebpFrameMetadata.cs | 3 +- src/ImageSharp/Formats/Webp/WebpMetadata.cs | 3 +- src/ImageSharp/Metadata/ImageFrameMetadata.cs | 10 +- src/ImageSharp/Metadata/ImageMetadata.cs | 7 +- .../Metadata/Profiles/Exif/ExifProfile.cs | 69 ++++++++-- .../CloningImageProcessor{TPixel}.cs | 5 +- .../Processors/ImageProcessor{TPixel}.cs | 6 +- .../Transforms/CropProcessor{TPixel}.cs | 18 ++- .../EntropyCropProcessor{TPixel}.cs | 3 +- .../Processors/Transforms/ISwizzler.cs | 4 +- .../AffineTransformProcessor{TPixel}.cs | 5 + .../Linear/FlipProcessor{TPixel}.cs | 42 +++++- .../ProjectiveTransformProcessor{TPixel}.cs | 3 + .../Resize/ResizeProcessor{TPixel}.cs | 34 +++-- .../SwizzleProcessor{TSwizzler,TPixel}.cs | 16 ++- .../Transforms/SwizzleProcessor{TSwizzler}.cs | 5 +- .../Transforms/TransformProcessor{TPixel}.cs | 18 ++- .../Processors/Transforms/TransformUtils.cs | 24 +++- .../Processors/Transforms/CropTest.cs | 32 ++++- .../Processors/Transforms/FlipTests.cs | 78 +++++++++-- .../Transforms/ProjectiveTransformTests.cs | 127 +++++++++++------- .../Processors/Transforms/ResizeTests.cs | 76 +++++++---- .../Processors/Transforms/RotateTests.cs | 56 +++++--- .../Processors/Transforms/SwizzleTests.cs | 40 ++++-- 41 files changed, 560 insertions(+), 177 deletions(-) rename tests/ImageSharp.Tests/Processing/{ => Processors}/Transforms/ProjectiveTransformTests.cs (66%) diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs index 1dac74ba3..3572687c9 100644 --- a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs +++ b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; // TODO: Add color table information. @@ -156,7 +157,7 @@ public class BmpMetadata : IFormatMetadata public BmpMetadata DeepClone() => new(this); /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.ColorTable = null; } diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs index 9854854aa..086025754 100644 --- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Icon; using SixLabors.ImageSharp.PixelFormats; @@ -117,7 +118,7 @@ public class CurFrameMetadata : IFormatFrameMetadata }; /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { float ratioX = destination.Width / (float)source.Width; diff --git a/src/ImageSharp/Formats/Cur/CurMetadata.cs b/src/ImageSharp/Formats/Cur/CurMetadata.cs index d8fdb3290..4c4d83dd8 100644 --- a/src/ImageSharp/Formats/Cur/CurMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Icon; using SixLabors.ImageSharp.PixelFormats; @@ -148,7 +149,7 @@ public class CurMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.ColorTable = null; diff --git a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs index e1b3354ad..1a0deb8ba 100644 --- a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Gif; @@ -103,7 +104,7 @@ public class GifFrameMetadata : IFormatFrameMetadata } /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.LocalColorTable = null; diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs index 77f600633..978209b23 100644 --- a/src/ImageSharp/Formats/Gif/GifMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Gif; @@ -105,7 +106,7 @@ public class GifMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.GlobalColorTable = null; diff --git a/src/ImageSharp/Formats/IFormatFrameMetadata.cs b/src/ImageSharp/Formats/IFormatFrameMetadata.cs index 261cc1263..68959272c 100644 --- a/src/ImageSharp/Formats/IFormatFrameMetadata.cs +++ b/src/ImageSharp/Formats/IFormatFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats; @@ -22,7 +23,8 @@ public interface IFormatFrameMetadata : IDeepCloneable /// The type of pixel format. /// The source image frame. /// The destination image frame. - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + /// The transformation matrix applied to the image frame. + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel; } diff --git a/src/ImageSharp/Formats/IFormatMetadata.cs b/src/ImageSharp/Formats/IFormatMetadata.cs index 3142b465c..81b344935 100644 --- a/src/ImageSharp/Formats/IFormatMetadata.cs +++ b/src/ImageSharp/Formats/IFormatMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats; @@ -27,7 +28,8 @@ public interface IFormatMetadata : IDeepCloneable /// /// The type of pixel format. /// The destination image . - public void AfterImageApply(Image destination) + /// The transformation matrix applied to the image. + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel; } diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs index 31f65133e..e8656775d 100644 --- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Icon; using SixLabors.ImageSharp.PixelFormats; @@ -110,7 +111,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata }; /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { float ratioX = destination.Width / (float)source.Width; diff --git a/src/ImageSharp/Formats/Ico/IcoMetadata.cs b/src/ImageSharp/Formats/Ico/IcoMetadata.cs index f8c2ff40f..ae768d311 100644 --- a/src/ImageSharp/Formats/Ico/IcoMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Icon; using SixLabors.ImageSharp.PixelFormats; @@ -148,7 +149,7 @@ public class IcoMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.ColorTable = null; diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs index fe4855dc7..c620079bf 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.PixelFormats; @@ -200,7 +201,7 @@ public class JpegMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index d852f3c8e..bef5da605 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Pbm; @@ -130,7 +131,7 @@ public class PbmMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index b8086cd6d..e337a8796 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Png.Chunks; using SixLabors.ImageSharp.PixelFormats; @@ -86,7 +87,7 @@ public class PngFrameMetadata : IFormatFrameMetadata } /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 59ca3b17a..011672db8 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Png.Chunks; using SixLabors.ImageSharp.PixelFormats; @@ -227,7 +228,7 @@ public class PngMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel => this.ColorTable = null; diff --git a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs index e463d511d..46ed2f210 100644 --- a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs +++ b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Qoi; @@ -89,7 +90,7 @@ public class QoiMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Tga/TgaMetadata.cs b/src/ImageSharp/Formats/Tga/TgaMetadata.cs index 8d40f8646..07aec8c3e 100644 --- a/src/ImageSharp/Formats/Tga/TgaMetadata.cs +++ b/src/ImageSharp/Formats/Tga/TgaMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Tga; @@ -95,7 +96,7 @@ public class TgaMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs index 189fee8b0..d9dfafbcc 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; @@ -96,7 +97,7 @@ public class TiffFrameMetadata : IFormatFrameMetadata }; /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { float ratioX = destination.Width / (float)source.Width; diff --git a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs index e965fcb4f..69b03f36f 100644 --- a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.PixelFormats; @@ -181,7 +182,7 @@ public class TiffMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Webp/WebpFrameMetadata.cs b/src/ImageSharp/Formats/Webp/WebpFrameMetadata.cs index 3f976a640..8a6b30ab4 100644 --- a/src/ImageSharp/Formats/Webp/WebpFrameMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Webp; @@ -66,7 +67,7 @@ public class WebpFrameMetadata : IFormatFrameMetadata }; /// - public void AfterFrameApply(ImageFrame source, ImageFrame destination) + public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index db57bd8f2..51721c53e 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Webp; @@ -146,7 +147,7 @@ public class WebpMetadata : IFormatMetadata }; /// - public void AfterImageApply(Image destination) + public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { } diff --git a/src/ImageSharp/Metadata/ImageFrameMetadata.cs b/src/ImageSharp/Metadata/ImageFrameMetadata.cs index b24aa140f..554afd69a 100644 --- a/src/ImageSharp/Metadata/ImageFrameMetadata.cs +++ b/src/ImageSharp/Metadata/ImageFrameMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Metadata.Profiles.Cicp; using SixLabors.ImageSharp.Metadata.Profiles.Exif; @@ -158,16 +159,21 @@ public sealed class ImageFrameMetadata : IDeepCloneable /// The type of pixel format. /// The source image frame. /// The destination image frame. - internal void AfterFrameApply(ImageFrame source, ImageFrame destination) + /// The transformation matrix applied to the frame. + internal void AfterFrameApply( + ImageFrame source, + ImageFrame destination, + Matrix4x4 matrix) where TPixel : unmanaged, IPixel { // Always updated using the full frame dimensions. // Individual format frame metadata will update with sub region dimensions if appropriate. this.ExifProfile?.SyncDimensions(destination.Width, destination.Height); + this.ExifProfile?.SyncSubject(destination.Width, destination.Height, matrix); foreach (KeyValuePair meta in this.formatMetadata) { - meta.Value.AfterFrameApply(source, destination); + meta.Value.AfterFrameApply(source, destination, matrix); } } } diff --git a/src/ImageSharp/Metadata/ImageMetadata.cs b/src/ImageSharp/Metadata/ImageMetadata.cs index 1961dbf19..918cf162a 100644 --- a/src/ImageSharp/Metadata/ImageMetadata.cs +++ b/src/ImageSharp/Metadata/ImageMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Metadata.Profiles.Cicp; using SixLabors.ImageSharp.Metadata.Profiles.Exif; @@ -235,14 +236,16 @@ public sealed class ImageMetadata : IDeepCloneable /// /// The type of pixel format. /// The destination image. - internal void AfterImageApply(Image destination) + /// The transformation matrix applied to the image. + internal void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { this.ExifProfile?.SyncDimensions(destination.Width, destination.Height); + this.ExifProfile?.SyncSubject(destination.Width, destination.Height, matrix); foreach (KeyValuePair meta in this.formatMetadata) { - meta.Value.AfterImageApply(destination); + meta.Value.AfterImageApply(destination, matrix); } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index e91a69444..284c040b6 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -2,8 +2,9 @@ // Licensed under the Six Labors Split License. using System.Diagnostics.CodeAnalysis; +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -using static System.Runtime.InteropServices.JavaScript.JSType; +using SixLabors.ImageSharp.Processing.Processors.Transforms; namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; @@ -48,7 +49,7 @@ public sealed class ExifProfile : IDeepCloneable { this.Parts = ExifParts.All; this.data = data; - this.InvalidTags = Array.Empty(); + this.InvalidTags = []; } /// @@ -161,11 +162,9 @@ public sealed class ExifProfile : IDeepCloneable return false; } - using (MemoryStream memStream = new(this.data, this.thumbnailOffset, this.thumbnailLength)) - { - image = Image.Load(memStream); - return true; - } + using MemoryStream memStream = new(this.data, this.thumbnailOffset, this.thumbnailLength); + image = Image.Load(memStream); + return true; } /// @@ -267,7 +266,7 @@ public sealed class ExifProfile : IDeepCloneable /// /// The tag of the exif value. /// The value. - /// Newly created value is null. + /// The newly created value is null. internal void SetValueInternal(ExifTag tag, object? value) { foreach (IExifValue exifValue in this.Values) @@ -312,6 +311,60 @@ public sealed class ExifProfile : IDeepCloneable } } + internal void SyncSubject(int width, int height, Matrix4x4 matrix) + { + if (matrix.IsIdentity) + { + return; + } + + if (this.TryGetValue(ExifTag.SubjectLocation, out IExifValue? location)) + { + if (location.Value?.Length == 2) + { + Vector2 point = TransformUtils.ProjectiveTransform2D(location.Value[0], location.Value[1], matrix); + + // Ensure the point is within the image dimensions. + point = Vector2.Clamp(point, Vector2.Zero, new Vector2(width - 1, height - 1)); + + // Round the point to the nearest pixel. + location.Value[0] = (ushort)Math.Floor(point.X); + location.Value[1] = (ushort)Math.Floor(point.Y); + + this.SetValue(ExifTag.SubjectLocation, location.Value); + } + else + { + this.RemoveValue(ExifTag.SubjectLocation); + } + } + + if (this.TryGetValue(ExifTag.SubjectArea, out IExifValue? area)) + { + if (area.Value?.Length == 4) + { + RectangleF rectangle = new(area.Value[0], area.Value[1], area.Value[2], area.Value[3]); + if (!TransformUtils.TryGetTransformedRectangle(rectangle, matrix, out Rectangle bounds)) + { + return; + } + + // Ensure the bounds are within the image dimensions. + bounds = Rectangle.Intersect(bounds, new Rectangle(0, 0, width, height)); + + area.Value[0] = (ushort)bounds.X; + area.Value[1] = (ushort)bounds.Y; + area.Value[2] = (ushort)bounds.Width; + area.Value[3] = (ushort)bounds.Height; + this.SetValue(ExifTag.SubjectArea, area.Value); + } + else + { + this.RemoveValue(ExifTag.SubjectArea); + } + } + } + /// /// Synchronizes the profiles with the specified metadata. /// diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index bc34f759a..b641dceb5 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Processing.Processors; @@ -132,14 +133,14 @@ public abstract class CloningImageProcessor : ICloningImageProcessorThe source image. Cannot be null. /// The cloned/destination image. Cannot be null. protected virtual void AfterFrameApply(ImageFrame source, ImageFrame destination) - => destination.Metadata.AfterFrameApply(source, destination); + => destination.Metadata.AfterFrameApply(source, destination, Matrix4x4.Identity); /// /// This method is called after the process is applied to prepare the processor. /// /// The cloned/destination image. Cannot be null. protected virtual void AfterImageApply(Image destination) - => destination.Metadata.AfterImageApply(destination); + => destination.Metadata.AfterImageApply(destination, Matrix4x4.Identity); /// /// Disposes the object and frees resources for the Garbage Collector. diff --git a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs index e1f7d1fff..3510fe7a8 100644 --- a/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/ImageProcessor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Processing.Processors; @@ -99,14 +100,13 @@ public abstract class ImageProcessor : IImageProcessor /// /// The source image. Cannot be null. protected virtual void AfterFrameApply(ImageFrame source) - { - } + => source.Metadata.AfterFrameApply(source, source, Matrix4x4.Identity); /// /// This method is called after the process is applied to the complete image. /// protected virtual void AfterImageApply() - => this.Source.Metadata.AfterImageApply(this.Source); + => this.Source.Metadata.AfterImageApply(this.Source, Matrix4x4.Identity); /// /// Disposes the object and frees resources for the Garbage Collector. diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 1d82dd12a..e3341f9df 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; @@ -16,6 +17,7 @@ internal class CropProcessor : TransformProcessor where TPixel : unmanaged, IPixel { private readonly Rectangle cropRectangle; + private readonly Matrix4x4 transformMatrix; /// /// Initializes a new instance of the class. @@ -26,10 +28,20 @@ internal class CropProcessor : TransformProcessor /// The source area to process for the current processor instance. public CropProcessor(Configuration configuration, CropProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) - => this.cropRectangle = definition.CropRectangle; + { + this.cropRectangle = definition.CropRectangle; + + // Calculate the transform matrix from the crop operation to allow us + // to update any metadata that represents pixel coordinates in the source image. + this.transformMatrix = new ProjectiveTransformBuilder() + .AppendTranslation(new PointF(-this.cropRectangle.X, -this.cropRectangle.Y)) + .BuildMatrix(sourceRectangle); + } /// - protected override Size GetDestinationSize() => new Size(this.cropRectangle.Width, this.cropRectangle.Height); + protected override Size GetDestinationSize() => new(this.cropRectangle.Width, this.cropRectangle.Height); + + protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix; /// protected override void OnFrameApply(ImageFrame source, ImageFrame destination) @@ -50,7 +62,7 @@ internal class CropProcessor : TransformProcessor ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(this.Configuration).MultiplyMinimumPixelsPerTask(4); - var operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); + RowOperation operation = new(bounds, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( bounds, diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs index 2eda61e41..8a76ca42f 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs @@ -2,7 +2,6 @@ // Licensed under the Six Labors Split License. using System.Runtime.CompilerServices; -using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors.Binarization; using SixLabors.ImageSharp.Processing.Processors.Convolution; @@ -36,7 +35,7 @@ internal class EntropyCropProcessor : ImageProcessor // TODO: This is clunky. We should add behavior enum to ExtractFrame. // All frames have be the same size so we only need to calculate the correct dimensions for the first frame - using (Image temp = new(this.Configuration, this.Source.Metadata.DeepClone(), new[] { this.Source.Frames.RootFrame.Clone() })) + using (Image temp = new(this.Configuration, this.Source.Metadata.DeepClone(), [this.Source.Frames.RootFrame.Clone()])) { Configuration configuration = this.Source.Configuration; diff --git a/src/ImageSharp/Processing/Processors/Transforms/ISwizzler.cs b/src/ImageSharp/Processing/Processors/Transforms/ISwizzler.cs index 321ecf968..3c11c32b4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ISwizzler.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ISwizzler.cs @@ -11,12 +11,12 @@ public interface ISwizzler /// /// Gets the size of the image after transformation. /// - Size DestinationSize { get; } + public Size DestinationSize { get; } /// /// Applies the swizzle transformation to a given point. /// /// Point to transform. /// The transformed point. - Point Transform(Point point); + public Point Transform(Point point); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index b3919e584..59f5773cf 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -18,6 +18,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR { private readonly Size destinationSize; private readonly Matrix3x2 transformMatrix; + private readonly Matrix4x4 transformMatrix4x4; private readonly IResampler resampler; private ImageFrame? source; private ImageFrame? destination; @@ -34,6 +35,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR { this.destinationSize = definition.DestinationSize; this.transformMatrix = definition.TransformMatrix; + this.transformMatrix4x4 = new(this.transformMatrix); this.resampler = definition.Sampler; } @@ -47,6 +49,9 @@ internal class AffineTransformProcessor : TransformProcessor, IR this.resampler.ApplyTransform(this); } + /// + protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix4x4; + /// public void ApplyTransform(in TResampler sampler) where TResampler : struct, IResampler diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs index 1adda1d04..86ba2f0f9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/FlipProcessor{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; @@ -17,16 +18,45 @@ internal class FlipProcessor : ImageProcessor where TPixel : unmanaged, IPixel { private readonly FlipProcessor definition; + private readonly Matrix4x4 transformMatrix; /// /// Initializes a new instance of the class. /// - /// The configuration which allows altering default behaviour or extending the library. + /// The configuration which allows altering default behavior or extending the library. /// The . /// The source for the current processor instance. /// The source area to process for the current processor instance. public FlipProcessor(Configuration configuration, FlipProcessor definition, Image source, Rectangle sourceRectangle) - : base(configuration, source, sourceRectangle) => this.definition = definition; + : base(configuration, source, sourceRectangle) + { + this.definition = definition; + + // Calculate the transform matrix from the flip operation to allow us + // to update any metadata that represents pixel coordinates in the source image. + ProjectiveTransformBuilder builder = new(); + switch (this.definition.FlipMode) + { + // No default needed as we have already set the pixels. + case FlipMode.Vertical: + + // Flip vertically by scaling the Y axis by -1 and translating the Y coordinate. + builder.AppendScale(new Vector2(1, -1)) + .AppendTranslation(new PointF(0, this.SourceRectangle.Height - 1)); + break; + case FlipMode.Horizontal: + + // Flip horizontally by scaling the X axis by -1 and translating the X coordinate. + builder.AppendScale(new Vector2(-1, 1)) + .AppendTranslation(new PointF(this.SourceRectangle.Width - 1, 0)); + break; + default: + this.transformMatrix = Matrix4x4.Identity; + return; + } + + this.transformMatrix = builder.BuildMatrix(sourceRectangle); + } /// protected override void OnFrameApply(ImageFrame source) @@ -43,6 +73,14 @@ internal class FlipProcessor : ImageProcessor } } + /// + protected override void AfterFrameApply(ImageFrame source) + => source.Metadata.AfterFrameApply(source, source, this.transformMatrix); + + /// + protected override void AfterImageApply() + => this.Source.Metadata.AfterImageApply(this.Source, this.transformMatrix); + /// /// Swaps the image at the X-axis, which goes horizontally through the middle at half the height of the image. /// diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs index 16b0070e9..1c30fd114 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs @@ -47,6 +47,9 @@ internal class ProjectiveTransformProcessor : TransformProcessor this.resampler.ApplyTransform(this); } + /// + protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix; + /// public void ApplyTransform(in TResampler sampler) where TResampler : struct, IResampler diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index cfc30edc0..49439545b 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; @@ -21,6 +22,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling private readonly IResampler resampler; private readonly Rectangle destinationRectangle; private Image? destination; + private readonly Matrix4x4 transformMatrix; public ResizeProcessor(Configuration configuration, ResizeProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) @@ -30,6 +32,17 @@ internal class ResizeProcessor : TransformProcessor, IResampling this.destinationRectangle = definition.DestinationRectangle; this.options = definition.Options; this.resampler = definition.Options.Sampler; + + // Calculate the transform matrix from the resize operation to allow us + // to update any metadata that represents pixel coordinates in the source image. + Vector2 scale = new( + this.destinationRectangle.Width / (float)this.SourceRectangle.Width, + this.destinationRectangle.Height / (float)this.SourceRectangle.Height); + + this.transformMatrix = new ProjectiveTransformBuilder() + .AppendScale(scale) + .AppendTranslation((PointF)this.destinationRectangle.Location) + .BuildMatrix(sourceRectangle); } /// @@ -50,6 +63,9 @@ internal class ResizeProcessor : TransformProcessor, IResampling // Everything happens in BeforeImageApply. } + /// + protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix; + public void ApplyTransform(in TResampler sampler) where TResampler : struct, IResampler { @@ -81,7 +97,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling return; } - var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); + Rectangle interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); if (sampler is NearestNeighborResampler) { @@ -110,13 +126,13 @@ internal class ResizeProcessor : TransformProcessor, IResampling // Since all image frame dimensions have to be the same we can calculate // the kernel maps and reuse for all frames. MemoryAllocator allocator = configuration.MemoryAllocator; - using var horizontalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap horizontalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Width, sourceRectangle.Width, allocator); - using var verticalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap verticalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Height, sourceRectangle.Height, @@ -158,7 +174,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling float widthFactor = sourceRectangle.Width / (float)destinationRectangle.Width; float heightFactor = sourceRectangle.Height / (float)destinationRectangle.Height; - var operation = new NNRowOperation( + NNRowOperation operation = new( sourceRectangle, destinationRectangle, interest, @@ -179,10 +195,8 @@ internal class ResizeProcessor : TransformProcessor, IResampling { return PixelConversionModifiers.Premultiply.ApplyCompanding(compand); } - else - { - return PixelConversionModifiers.None.ApplyCompanding(compand); - } + + return PixelConversionModifiers.None.ApplyCompanding(compand); } private static void ApplyResizeFrameTransform( @@ -208,7 +222,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling // To reintroduce parallel processing, we would launch multiple workers // for different row intervals of the image. - using var worker = new ResizeWorker( + using ResizeWorker worker = new( configuration, sourceRegion, conversionModifiers, @@ -218,7 +232,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling destinationRectangle.Location); worker.Initialize(); - var workingInterval = new RowInterval(interest.Top, interest.Bottom); + RowInterval workingInterval = new(interest.Top, interest.Bottom); worker.FillDestinationPixels(workingInterval, destination.PixelBuffer); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs index 1ea2156c8..3bec82cce 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -12,17 +13,28 @@ internal class SwizzleProcessor : TransformProcessor { private readonly TSwizzler swizzler; private readonly Size destinationSize; + private readonly Matrix4x4 transformMatrix; public SwizzleProcessor(Configuration configuration, TSwizzler swizzler, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) { this.swizzler = swizzler; this.destinationSize = swizzler.DestinationSize; + + // Calculate the transform matrix from the swizzle operation to allow us + // to update any metadata that represents pixel coordinates in the source image. + this.transformMatrix = new ProjectiveTransformBuilder() + .AppendMatrix(TransformUtils.GetSwizzlerMatrix(swizzler, sourceRectangle)) + .BuildMatrix(sourceRectangle); } - protected override Size GetDestinationSize() - => this.destinationSize; + /// + protected override Size GetDestinationSize() => this.destinationSize; + + /// + protected override Matrix4x4 GetTransformMatrix() => this.transformMatrix; + /// protected override void OnFrameApply(ImageFrame source, ImageFrame destination) { Point p = default; diff --git a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler}.cs b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler}.cs index 0b8274aff..d00e01711 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler}.cs @@ -16,10 +16,7 @@ public sealed class SwizzleProcessor : IImageProcessor /// Initializes a new instance of the class. /// /// The swizzler operation. - public SwizzleProcessor(TSwizzler swizzler) - { - this.Swizzler = swizzler; - } + public SwizzleProcessor(TSwizzler swizzler) => this.Swizzler = swizzler; /// /// Gets the swizzler operation. diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor{TPixel}.cs index a8455a06e..0d40cd32f 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformProcessor{TPixel}.cs @@ -1,9 +1,9 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.PixelFormats; -// TODO: DO we need this class? namespace SixLabors.ImageSharp.Processing.Processors.Transforms; /// @@ -23,4 +23,20 @@ internal abstract class TransformProcessor : CloningImageProcessor + /// Gets the transform matrix that will be applied to the image. + /// + /// + /// The that represents the transformation to be applied to the image. + /// + protected abstract Matrix4x4 GetTransformMatrix(); + + /// + protected override void AfterFrameApply(ImageFrame source, ImageFrame destination) + => destination.Metadata.AfterFrameApply(source, destination, this.GetTransformMatrix()); + + /// + protected override void AfterImageApply(Image destination) + => destination.Metadata.AfterImageApply(destination, this.GetTransformMatrix()); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 47b3250b8..b7afea449 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -419,6 +419,28 @@ internal static class TransformUtils return size; } + /// + /// Attempts to derive a 4x4 projective transform matrix that approximates the behavior of an . + /// + /// + /// The swizzler to use for the transformation. + /// + /// + /// The source rectangle that defines the area to be transformed. + /// + /// + /// The type of the swizzler, which must implement . + /// + public static Matrix4x4 GetSwizzlerMatrix(T swizzler, Rectangle sourceRectangle) + where T : struct, ISwizzler + => CreateQuadDistortionMatrix( + sourceRectangle, + swizzler.Transform(new Point(sourceRectangle.Left, sourceRectangle.Top)), + swizzler.Transform(new Point(sourceRectangle.Right, sourceRectangle.Top)), + swizzler.Transform(new Point(sourceRectangle.Right, sourceRectangle.Bottom)), + swizzler.Transform(new Point(sourceRectangle.Left, sourceRectangle.Bottom)), + TransformSpace.Pixel); + /// /// Returns the size relative to the source for the given transformation matrix. /// @@ -504,7 +526,7 @@ internal static class TransformUtils /// if the transformation was successful; otherwise, . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out Rectangle bounds) + internal static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out Rectangle bounds) { if (matrix.IsIdentity || rectangle.Equals(default)) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 18a7a9bd0..56e9a5201 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -1,8 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; @@ -17,12 +19,36 @@ public class CropTest public void Crop(TestImageProvider provider, int x, int y, int w, int h) where TPixel : unmanaged, IPixel { - var rect = new Rectangle(x, y, w, h); + Rectangle rect = new(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; provider.RunValidatingProcessorTest( ctx => ctx.Crop(rect), info, - appendPixelTypeToFileName: false, - comparer: ImageComparer.Exact); + comparer: ImageComparer.Exact, + appendPixelTypeToFileName: false); + } + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void CropUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]); + + image.Mutate(ctx => ctx.Crop(Rectangle.FromLTRB(20, 20, 50, 50))); + + // The new subject area is now relative to the cropped area. + // overhanging pixels are constrained to the dimensions of the image. + Assert.Equal( + [0, 0], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + Assert.Equal( + [0, 0, 30, 30], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs index 717582274..9aa04e370 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs @@ -1,8 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Tests.TestUtilities; // ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; @@ -12,12 +14,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class FlipTests { public static readonly TheoryData FlipValues = - new TheoryData - { - FlipMode.None, - FlipMode.Vertical, - FlipMode.Horizontal, - }; + new() + { + FlipMode.None, + FlipMode.Vertical, + FlipMode.Horizontal + }; [Theory] [WithTestPatternImages(nameof(FlipValues), 20, 37, PixelTypes.Rgba32)] @@ -25,23 +27,77 @@ public class FlipTests [WithTestPatternImages(nameof(FlipValues), 17, 32, PixelTypes.Rgba32)] public void Flip(TestImageProvider provider, FlipMode flipMode) where TPixel : unmanaged, IPixel - { - provider.RunValidatingProcessorTest( + => provider.RunValidatingProcessorTest( ctx => ctx.Flip(flipMode), testOutputDetails: flipMode, appendPixelTypeToFileName: false); - } [Theory] [WithTestPatternImages(nameof(FlipValues), 53, 37, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(FlipValues), 17, 32, PixelTypes.Rgba32)] public void Flip_WorksOnWrappedMemoryImage(TestImageProvider provider, FlipMode flipMode) where TPixel : unmanaged, IPixel - { - provider.RunValidatingProcessorTestOnWrappedMemoryImage( + => provider.RunValidatingProcessorTestOnWrappedMemoryImage( ctx => ctx.Flip(flipMode), testOutputDetails: flipMode, useReferenceOutputFrom: nameof(this.Flip), appendPixelTypeToFileName: false); + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void FlipVerticalUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]); + + image.Mutate(ctx => ctx.Flip(FlipMode.Vertical)); + + // The subject location is a single coordinate, so a vertical flip simply reflects its Y position: + // newY = imageHeight - originalY - 1 + // This mirrors the point vertically around the image's horizontal axis, preserving its X coordinate. + Assert.Equal( + [5, 84], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + // The subject area is now inverted because a vertical flip reflects the image across + // the horizontal axis passing through the image center. + // The Y-coordinate of the top edge is recalculated as: + // newY = imageHeight - originalY - height - 1 + Assert.Equal( + [5, 34, 50, 50], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); + } + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void FlipHorizontalUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]); + + image.Mutate(ctx => ctx.Flip(FlipMode.Horizontal)); + + // The subject location is a single coordinate, so a horizontal flip simply reflects its X position: + // newX = imageWidth - originalX - 1 + // This mirrors the point horizontally around the image's vertical axis, preserving its Y coordinate. + Assert.Equal( + [94, 15], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + // The subject area is now inverted because a horizontal flip reflects the image across + // the vertical axis passing through the image center. + // The X-coordinate of the left edge is recalculated as: + // newX = imageWidth - originalX - width - 1 + Assert.Equal( + [44, 15, 50, 50], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs similarity index 66% rename from tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs rename to tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs index 6b6db69c1..2e580ea9f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs @@ -3,14 +3,16 @@ using System.Numerics; using System.Reflection; +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Transforms; +using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using Xunit.Abstractions; // ReSharper disable InconsistentNaming -namespace SixLabors.ImageSharp.Tests.Processing.Transforms; +namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [Trait("Category", "Processors")] public class ProjectiveTransformTests @@ -20,7 +22,7 @@ public class ProjectiveTransformTests private ITestOutputHelper Output { get; } - public static readonly TheoryData ResamplerNames = new TheoryData + public static readonly TheoryData ResamplerNames = new() { nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), @@ -39,7 +41,7 @@ public class ProjectiveTransformTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData TaperMatrixData = new TheoryData + public static readonly TheoryData TaperMatrixData = new() { { TaperSide.Bottom, TaperCorner.Both }, { TaperSide.Bottom, TaperCorner.LeftOrTop }, @@ -71,16 +73,14 @@ public class ProjectiveTransformTests where TPixel : unmanaged, IPixel { IResampler sampler = GetResampler(resamplerName); - using (Image image = provider.GetImage()) - { - ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() - .AppendTaper(TaperSide.Right, TaperCorner.Both, .5F); + using Image image = provider.GetImage(); + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + .AppendTaper(TaperSide.Right, TaperCorner.Both, .5F); - image.Mutate(i => i.Transform(builder, sampler)); + image.Mutate(i => i.Transform(builder, sampler)); - image.DebugSave(provider, resamplerName); - image.CompareToReferenceOutput(ValidatorComparer, provider, resamplerName); - } + image.DebugSave(provider, resamplerName); + image.CompareToReferenceOutput(ValidatorComparer, provider, resamplerName); } [Theory] @@ -88,17 +88,15 @@ public class ProjectiveTransformTests public void Transform_WithTaperMatrix(TestImageProvider provider, TaperSide taperSide, TaperCorner taperCorner) where TPixel : unmanaged, IPixel { - using (Image image = provider.GetImage()) - { - ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() - .AppendTaper(taperSide, taperCorner, .5F); + using Image image = provider.GetImage(); + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + .AppendTaper(taperSide, taperCorner, .5F); - image.Mutate(i => i.Transform(builder)); + image.Mutate(i => i.Transform(builder)); - FormattableString testOutputDetails = $"{taperSide}-{taperCorner}"; - image.DebugSave(provider, testOutputDetails); - image.CompareFirstFrameToReferenceOutput(TolerantComparer, provider, testOutputDetails); - } + FormattableString testOutputDetails = $"{taperSide}-{taperCorner}"; + image.DebugSave(provider, testOutputDetails); + image.CompareFirstFrameToReferenceOutput(TolerantComparer, provider, testOutputDetails); } [Theory] @@ -106,17 +104,15 @@ public class ProjectiveTransformTests public void Transform_WithQuadDistortion(TestImageProvider provider, PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) where TPixel : unmanaged, IPixel { - using (Image image = provider.GetImage()) - { - ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() - .AppendQuadDistortion(topLeft, topRight, bottomRight, bottomLeft); + using Image image = provider.GetImage(); + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + .AppendQuadDistortion(topLeft, topRight, bottomRight, bottomLeft); - image.Mutate(i => i.Transform(builder)); + image.Mutate(i => i.Transform(builder)); - FormattableString testOutputDetails = $"{topLeft}-{topRight}-{bottomRight}-{bottomLeft}"; - image.DebugSave(provider, testOutputDetails); - image.CompareFirstFrameToReferenceOutput(TolerantComparer, provider, testOutputDetails); - } + FormattableString testOutputDetails = $"{topLeft}-{topRight}-{bottomRight}-{bottomLeft}"; + image.DebugSave(provider, testOutputDetails); + image.CompareFirstFrameToReferenceOutput(TolerantComparer, provider, testOutputDetails); } [Theory] @@ -129,19 +125,17 @@ public class ProjectiveTransformTests // This test matches the output described in the example at // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/transforms/non-affine - using (Image image = provider.GetImage()) - { - Matrix4x4 matrix = Matrix4x4.Identity; - matrix.M14 = 0.01F; + using Image image = provider.GetImage(); + Matrix4x4 matrix = Matrix4x4.Identity; + matrix.M14 = 0.01F; - ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() .AppendMatrix(matrix); - image.Mutate(i => i.Transform(builder)); + image.Mutate(i => i.Transform(builder)); - image.DebugSave(provider); - image.CompareToReferenceOutput(TolerantComparer, provider); - } + image.DebugSave(provider); + image.CompareToReferenceOutput(TolerantComparer, provider); } [Theory] @@ -151,30 +145,28 @@ public class ProjectiveTransformTests { // https://jsfiddle.net/dFrHS/545/ // https://github.com/SixLabors/ImageSharp/issues/787 - using (Image image = provider.GetImage()) - { + using Image image = provider.GetImage(); #pragma warning disable SA1117 // Parameters should be on same line or separate lines - Matrix4x4 matrix = new( - 0.260987f, -0.434909f, 0, -0.0022184f, - 0.373196f, 0.949882f, 0, -0.000312129f, - 0, 0, 1, 0, - 52, 165, 0, 1); + Matrix4x4 matrix = new( + 0.260987f, -0.434909f, 0, -0.0022184f, + 0.373196f, 0.949882f, 0, -0.000312129f, + 0, 0, 1, 0, + 52, 165, 0, 1); #pragma warning restore SA1117 // Parameters should be on same line or separate lines - ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() .AppendMatrix(matrix); - image.Mutate(i => i.Transform(builder)); + image.Mutate(i => i.Transform(builder)); - image.DebugSave(provider); - image.CompareToReferenceOutput(TolerantComparer, provider); - } + image.DebugSave(provider); + image.CompareToReferenceOutput(TolerantComparer, provider); } [Fact] public void Issue1911() { - using var image = new Image(100, 100); + using Image image = new(100, 100); image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix4x4.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); @@ -240,13 +232,44 @@ public class ProjectiveTransformTests ImageComparer.Exact.VerifySimilarity(img, img3); } + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void TransformUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]); + + ProjectiveTransformBuilder builder = new ProjectiveTransformBuilder() + .AppendRotationDegrees(180); + + image.Mutate(ctx => ctx.Transform(builder)); + + // A 180-degree rotation inverts both axes around the image center. + // The subject location (5, 15) becomes (imageWidth - 5 - 1, imageHeight - 15 - 1) = (94, 84) + Assert.Equal( + [94, 84], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + // The subject area is also mirrored around the center. + // New X = imageWidth - originalX - width + // New Y = imageHeight - originalY - height + // (5, 15, 50, 50) becomes (44, 34, 50, 50) + Assert.Equal( + [44, 34, 50, 50], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); + } + private static IResampler GetResampler(string name) { PropertyInfo property = typeof(KnownResamplers).GetTypeInfo().GetProperty(name); if (property is null) { - throw new Exception($"No resampler named {name}"); + throw new InvalidOperationException($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index d1b005ee4..f9cf10d22 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -3,10 +3,12 @@ using System.Numerics; using System.Runtime.CompilerServices; +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Tests.Memory; +using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; // ReSharper disable InconsistentNaming @@ -20,15 +22,15 @@ public class ResizeTests public static readonly string[] AllResamplerNames = TestUtils.GetAllResamplerNames(); - public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial }; + public static readonly string[] CommonTestImages = [TestImages.Png.CalliphoraPartial]; public static readonly string[] SmokeTestResamplerNames = - { + [ nameof(KnownResamplers.NearestNeighbor), nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), nameof(KnownResamplers.Lanczos5), - }; + ]; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.07F); @@ -78,7 +80,7 @@ public class ResizeTests // resizing: (15, 12) -> (10, 6) // kernel dimensions: (3, 4) using Image image = provider.GetImage(); - Size destSize = new Size(image.Width * wN / wD, image.Height * hN / hD); + Size destSize = new(image.Width * wN / wD, image.Height * hN / hD); image.Mutate(x => x.Resize(destSize, KnownResamplers.Bicubic, false)); FormattableString outputInfo = $"({wN}÷{wD},{hN}÷{hD})"; image.DebugSave(provider, outputInfo, appendPixelTypeToFileName: false); @@ -106,7 +108,7 @@ public class ResizeTests Configuration configuration = Configuration.CreateDefaultInstance(); int workingBufferSizeHintInBytes = workingBufferLimitInRows * destSize.Width * SizeOfVector4; - TestMemoryAllocator allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.EnableNonThreadSafeLogging(); configuration.MemoryAllocator = allocator; configuration.WorkingBufferSizeHintInBytes = workingBufferSizeHintInBytes; @@ -211,7 +213,7 @@ public class ResizeTests provider.RunValidatingProcessorTest( x => { - ResizeOptions resizeOptions = new ResizeOptions() + ResizeOptions resizeOptions = new() { Size = x.GetCurrentSize() / 2, Mode = ResizeMode.Crop, @@ -242,9 +244,7 @@ public class ResizeTests [WithTestPatternImages(50, 50, CommonNonDefaultPixelTypes)] public void Resize_IsNotBoundToSinglePixelType(TestImageProvider provider) where TPixel : unmanaged, IPixel - { - provider.RunValidatingProcessorTest(x => x.Resize(x.GetCurrentSize() / 2), comparer: ValidatorComparer); - } + => provider.RunValidatingProcessorTest(x => x.Resize(x.GetCurrentSize() / 2), comparer: ValidatorComparer); [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] @@ -257,7 +257,7 @@ public class ResizeTests using Image image1 = Image.WrapMemory(mmg.Memory, image0.Width, image0.Height); Assert.ThrowsAny( - () => { image1.Mutate(x => x.Resize(image0.Width / 2, image0.Height / 2, true)); }); + () => image1.Mutate(x => x.Resize(image0.Width / 2, image0.Height / 2, true))); } [Theory] @@ -365,12 +365,12 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Rectangle sourceRectangle = new Rectangle( + Rectangle sourceRectangle = new( image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); - Rectangle destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); + Rectangle destRectangle = new(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); image.Mutate( x => x.Resize( @@ -437,7 +437,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(image.Width + 200, image.Height + 200), Mode = ResizeMode.BoxPad, @@ -456,7 +456,8 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width, image.Height / 2) }; + ResizeOptions options = new() + { Size = new Size(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -470,7 +471,8 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width / 2, image.Height) }; + ResizeOptions options = new() + { Size = new Size(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -484,7 +486,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(480, 600), Mode = ResizeMode.Crop @@ -502,7 +504,8 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() + { Size = new Size(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); @@ -516,7 +519,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min @@ -534,7 +537,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(image.Width + 200, image.Height), Mode = ResizeMode.Pad, @@ -553,7 +556,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { Size = new Size(image.Width / 2, image.Height), Mode = ResizeMode.Stretch @@ -579,6 +582,7 @@ public class ResizeTests } using Image image = provider.GetImage(); + // Don't bother saving, we're testing the EXIF metadata updates. image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2)); } @@ -586,8 +590,8 @@ public class ResizeTests [Fact] public void Issue1195() { - using Image image = new Image(2, 300); - Size size = new Size(50, 50); + using Image image = new(2, 300); + Size size = new(50, 50); image.Mutate(x => x .Resize( new ResizeOptions @@ -605,8 +609,8 @@ public class ResizeTests [InlineData(3, 7)] public void Issue1342(int width, int height) { - using Image image = new Image(1, 1); - Size size = new Size(width, height); + using Image image = new(1, 1); + Size size = new(width, height); image.Mutate(x => x .Resize( new ResizeOptions @@ -630,4 +634,28 @@ public class ResizeTests appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); } + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void ResizeUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 20, 20]); + + image.Mutate(ctx => ctx.Resize(new Size(image.Width / 2, image.Height / 2))); + + // The transform operates in pixel space, so the resulting values correspond to the + // scaled pixel centers, producing whole-number coordinates after resizing. + Assert.Equal( + [2, 7], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + Assert.Equal( + [2, 7, 11, 11], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); + } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index b150da1d8..dfa263fec 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -1,8 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; @@ -11,35 +13,59 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class RotateTests { public static readonly TheoryData RotateAngles - = new TheoryData - { - 50, -50, 170, -170 - }; + = new() + { + 50, -50, 170, -170 + }; public static readonly TheoryData RotateEnumValues - = new TheoryData - { - RotateMode.None, - RotateMode.Rotate90, - RotateMode.Rotate180, - RotateMode.Rotate270 - }; + = new() + { + RotateMode.None, + RotateMode.Rotate90, + RotateMode.Rotate180, + RotateMode.Rotate270 + }; [Theory] [WithTestPatternImages(nameof(RotateAngles), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateAngles), 50, 100, PixelTypes.Rgba32)] public void Rotate_WithAngle(TestImageProvider provider, float value) where TPixel : unmanaged, IPixel - { - provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); - } + => provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); [Theory] [WithTestPatternImages(nameof(RotateEnumValues), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateEnumValues), 50, 100, PixelTypes.Rgba32)] public void Rotate_WithRotateTypeEnum(TestImageProvider provider, RotateMode value) where TPixel : unmanaged, IPixel + => provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void RotateUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel { - provider.RunValidatingProcessorTest(ctx => ctx.Rotate(value), value, appendPixelTypeToFileName: false); + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 50, 50]); + + image.Mutate(ctx => ctx.Rotate(180)); + + // A 180-degree rotation inverts both axes around the image center. + // The subject location (5, 15) becomes (imageWidth - 5 - 1, imageHeight - 15 - 1) = (94, 84) + Assert.Equal( + [94, 84], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + // The subject area is also mirrored around the center. + // New X = imageWidth - originalX - width + // New Y = imageHeight - originalY - height + // (5, 15, 50, 50) becomes (44, 34, 50, 50) + Assert.Equal( + [44, 34, 50, 50], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index de02502e2..04f11644b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -1,9 +1,11 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Transforms; +using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; @@ -12,17 +14,15 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [GroupOutput("Transforms")] public class SwizzleTests { - private struct InvertXAndYSwizzler : ISwizzler + private readonly struct SwapXAndYSwizzler : ISwizzler { - public InvertXAndYSwizzler(Size sourceSize) - { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); - } + public SwapXAndYSwizzler(Size sourceSize) + => this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); public Size DestinationSize { get; } public Point Transform(Point point) - => new Point(point.Y, point.X); + => new(point.Y, point.X); } [Theory] @@ -35,15 +35,15 @@ public class SwizzleTests using Image expectedImage = provider.GetImage(); using Image image = provider.GetImage(); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new SwapXAndYSwizzler(new Size(image.Width, image.Height)))); image.DebugSave( provider, - nameof(InvertXAndYSwizzler), + nameof(SwapXAndYSwizzler), appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new SwapXAndYSwizzler(new Size(image.Width, image.Height)))); image.DebugSave( provider, @@ -53,4 +53,26 @@ public class SwizzleTests ImageComparer.Exact.VerifySimilarity(expectedImage, image); } + + [Theory] + [WithTestPatternImages(100, 100, PixelTypes.Rgba32)] + public void SwizzleUpdatesSubject(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectLocation, [5, 15]); + image.Metadata.ExifProfile.SetValue(ExifTag.SubjectArea, [5, 15, 20, 20]); + + image.Mutate(ctx => ctx.Swizzle(new SwapXAndYSwizzler(new Size(image.Width, image.Height)))); + + Assert.Equal( + [15, 5], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); + + Assert.Equal( + [15, 5, 20, 20], + image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); + } } From a84348aeaae436edca16a4256a72dcf55f34b9e6 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 12 Jun 2025 22:30:39 +1000 Subject: [PATCH 013/112] Optimize based on feedback --- .../Profiles/Exif/ExifEncodedStringHelpers.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index 34bbbb79d..d2b88cbff 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -67,29 +67,23 @@ internal static class ExifEncodedStringHelpers if (code == CharacterCode.Unicode && textBuffer.Length >= 2) { // Check BOM - if (textBuffer[0] == 0xFF && textBuffer[1] == 0xFE) + if (textBuffer.StartsWith((ReadOnlySpan)[0xFF, 0xFE])) { // Little-endian BOM string text = Encoding.Unicode.GetString(textBuffer[2..]); encodedString = new EncodedString(code, text); return true; } - else if (textBuffer[0] == 0xFE && textBuffer[1] == 0xFF) + + if (textBuffer.StartsWith((ReadOnlySpan)[0xFE, 0xFF])) { // Big-endian BOM string text = Encoding.BigEndianUnicode.GetString(textBuffer[2..]); encodedString = new EncodedString(code, text); return true; } - else - { - // No BOM, use EXIF byte order - string text = GetEncoding(code, order).GetString(textBuffer); - encodedString = new EncodedString(code, text); - return true; - } } - else + { string text = GetEncoding(code, order).GetString(textBuffer); encodedString = new EncodedString(code, text); From 2715f0ecb9c3719efed4e3017853223e87df247a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 12 Jun 2025 23:13:49 +1000 Subject: [PATCH 014/112] Update ExifProfile.cs --- src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index 70189eb9f..d7932f90b 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -323,7 +323,7 @@ public sealed class ExifProfile : IDeepCloneable // Ensure the point is within the image dimensions. point = Vector2.Clamp(point, Vector2.Zero, new Vector2(width - 1, height - 1)); - // Round the point to the nearest pixel. + // Floor the point to the nearest pixel. location.Value[0] = (ushort)Math.Floor(point.X); location.Value[1] = (ushort)Math.Floor(point.Y); From 57f5966fe79f6530af0f0e3763c389771601994b Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 21 Jun 2025 19:57:59 +0200 Subject: [PATCH 015/112] use Explicit Types and Target Type new --- .editorconfig | 8 ++ .../Advanced/ParallelExecutionSettings.cs | 4 +- .../Advanced/ParallelRowIterator.Wrappers.cs | 4 +- .../Advanced/ParallelRowIterator.cs | 28 ++-- src/ImageSharp/Color/Color.WebSafePalette.cs | 2 +- src/ImageSharp/ColorProfiles/CieLab.cs | 6 +- src/ImageSharp/ColorProfiles/CieLch.cs | 10 +- src/ImageSharp/ColorProfiles/CieLchuv.cs | 8 +- src/ImageSharp/ColorProfiles/CieLuv.cs | 4 +- src/ImageSharp/ColorProfiles/CieXyy.cs | 8 +- src/ImageSharp/ColorProfiles/CieXyz.cs | 8 +- src/ImageSharp/ColorProfiles/Cmyk.cs | 6 +- .../ColorProfileConverterExtensionsIcc.cs | 16 +-- src/ImageSharp/ColorProfiles/Hsl.cs | 8 +- src/ImageSharp/ColorProfiles/Hsv.cs | 10 +- src/ImageSharp/ColorProfiles/HunterLab.cs | 8 +- .../Icc/Calculators/ColorTrcCalculator.cs | 4 +- .../Icc/Calculators/CurveCalculator.cs | 2 +- .../Icc/Calculators/GrayTrcCalculator.cs | 2 +- .../Icc/Calculators/LutABCalculator.cs | 10 +- .../Icc/Calculators/LutEntryCalculator.cs | 4 +- .../Icc/Calculators/MatrixCalculator.cs | 2 +- .../ColorProfiles/Icc/CompactSrgbV4Profile.cs | 2 +- .../Icc/IccConverterbase.Conversions.cs | 4 +- .../KnownChromaticAdaptationMatrices.cs | 12 +- .../ColorProfiles/KnownRgbWorkingSpaces.cs | 38 +++--- .../ColorProfiles/KnownYCbCrMatrices.cs | 18 +-- src/ImageSharp/ColorProfiles/Lms.cs | 4 +- src/ImageSharp/ColorProfiles/Rgb.cs | 6 +- .../VonKriesChromaticAdaptation.cs | 4 +- src/ImageSharp/ColorProfiles/Y.cs | 2 +- src/ImageSharp/ColorProfiles/YCbCr.cs | 6 +- src/ImageSharp/ColorProfiles/YccK.cs | 6 +- .../Extensions/ConfigurationExtensions.cs | 2 +- src/ImageSharp/Common/Helpers/Numerics.cs | 10 +- .../Common/Helpers/SimdUtils.Pack.cs | 2 +- src/ImageSharp/Common/Helpers/SimdUtils.cs | 2 +- .../Common/Helpers/UnitConverter.cs | 4 +- src/ImageSharp/Compression/Zlib/Deflater.cs | 2 +- .../Compression/Zlib/DeflaterEngine.cs | 2 +- .../Compression/Zlib/DeflaterHuffman.cs | 8 +- .../Compression/Zlib/DeflaterOutputStream.cs | 2 +- .../Compression/Zlib/ZlibDeflateStream.cs | 2 +- .../Compression/Zlib/ZlibInflateStream.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 12 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 6 +- src/ImageSharp/Formats/Bmp/BmpMetadata.cs | 16 +-- .../Formats/Cur/CurFrameMetadata.cs | 6 +- src/ImageSharp/Formats/Cur/CurMetadata.cs | 4 +- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 6 +- src/ImageSharp/Formats/Gif/GifMetadata.cs | 2 +- .../GifNetscapeLoopingApplicationExtension.cs | 2 +- .../Sections/GifXmpApplicationExtension.cs | 2 +- .../Formats/Ico/IcoFrameMetadata.cs | 6 +- src/ImageSharp/Formats/Ico/IcoMetadata.cs | 4 +- .../Formats/Jpeg/Components/Block8x8.cs | 2 +- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 8 +- .../ColorConverters/JpegColorConverterBase.cs | 2 +- .../Jpeg/Components/Decoder/AdobeMarker.cs | 2 +- .../Decoder/ArithmeticScanDecoder.cs | 2 +- .../Components/Decoder/HuffmanScanDecoder.cs | 4 +- .../Jpeg/Components/Decoder/JFifMarker.cs | 2 +- .../Jpeg/Components/Decoder/JpegComponent.cs | 4 +- .../Components/Decoder/SpectralConverter.cs | 2 +- .../Jpeg/Components/Encoder/Component.cs | 4 +- .../Components/Encoder/ComponentProcessor.cs | 2 +- .../Components/Encoder/HuffmanScanEncoder.cs | 4 +- .../Jpeg/Components/Encoder/JpegFrame.cs | 2 +- .../Encoder/SpectralConverter{TPixel}.cs | 6 +- .../Formats/Jpeg/Components/SizeExtensions.cs | 8 +- .../Formats/Jpeg/JpegDecoderCore.cs | 32 ++--- .../Jpeg/JpegEncoderCore.FrameConfig.cs | 16 +-- src/ImageSharp/Formats/Jpeg/JpegMetadata.cs | 4 +- src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs | 6 +- src/ImageSharp/Formats/Pbm/PbmMetadata.cs | 4 +- src/ImageSharp/Formats/Pbm/PlainDecoder.cs | 8 +- .../Formats/Png/Chunks/PngPhysical.cs | 4 +- src/ImageSharp/Formats/Png/PngDecoder.cs | 2 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 28 ++-- .../Formats/Png/PngFrameMetadata.cs | 2 +- src/ImageSharp/Formats/Png/PngMetadata.cs | 2 +- src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs | 4 +- src/ImageSharp/Formats/Qoi/QoiMetadata.cs | 6 +- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 10 +- .../Formats/Tga/TgaImageFormatDetector.cs | 2 +- src/ImageSharp/Formats/Tga/TgaMetadata.cs | 10 +- .../Compressors/DeflateCompressor.cs | 2 +- .../Compression/Compressors/LzwCompressor.cs | 2 +- .../Compression/Compressors/PackBitsWriter.cs | 2 +- .../Compressors/TiffJpegCompressor.cs | 4 +- .../Decompressors/DeflateTiffCompression.cs | 2 +- .../Compression/Decompressors/LzwString.cs | 6 +- .../Decompressors/LzwTiffCompression.cs | 2 +- .../ModifiedHuffmanTiffCompression.cs | 2 +- .../Decompressors/T4TiffCompression.cs | 2 +- .../Decompressors/T6TiffCompression.cs | 6 +- .../Decompressors/TiffLzwDecoder.cs | 2 +- .../Decompressors/WebpTiffCompression.cs | 2 +- .../Tiff/Compression/HorizontalPredictor.cs | 6 +- .../BlackIsZero32FloatTiffColor{TPixel}.cs | 4 +- .../CmykTiffColor{TPixel}.cs | 2 +- .../RgbTiffColor{TPixel}.cs | 2 +- .../WhiteIsZero32FloatTiffColor{TPixel}.cs | 2 +- .../WhiteIsZeroTiffColor{TPixel}.cs | 2 +- .../YCbCrConverter.cs | 10 +- .../YCbCrPlanarTiffColor{TPixel}.cs | 2 +- .../YCbCrTiffColor{TPixel}.cs | 2 +- .../Formats/Tiff/TiffBitsPerSample.cs | 2 +- .../Formats/Tiff/TiffDecoderCore.cs | 6 +- .../Tiff/TiffDecoderMetadataCreator.cs | 4 +- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 6 +- .../Tiff/TiffEncoderEntriesCollector.cs | 6 +- src/ImageSharp/Formats/Tiff/TiffMetadata.cs | 14 +- .../Tiff/Writers/TiffBiColorWriter{TPixel}.cs | 2 +- .../Tiff/Writers/TiffPaletteWriter{TPixel}.cs | 4 +- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 6 +- src/ImageSharp/Formats/Webp/AlphaEncoder.cs | 2 +- .../Formats/Webp/BitWriter/Vp8LBitWriter.cs | 2 +- .../Webp/Lossless/BackwardReferenceEncoder.cs | 12 +- .../Formats/Webp/Lossless/CostManager.cs | 14 +- .../Formats/Webp/Lossless/HTreeGroup.cs | 2 +- .../Formats/Webp/Lossless/HuffmanUtils.cs | 2 +- .../Formats/Webp/Lossless/PredictorEncoder.cs | 6 +- .../Formats/Webp/Lossless/Vp8LDecoder.cs | 2 +- .../Formats/Webp/Lossless/Vp8LEncoder.cs | 18 +-- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 2 +- .../Formats/Webp/Lossless/Vp8LHistogramSet.cs | 4 +- .../Webp/Lossless/WebpLosslessDecoder.cs | 8 +- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 20 +-- .../Formats/Webp/Lossy/Vp8BandProbas.cs | 2 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs | 2 +- .../Formats/Webp/Lossy/Vp8Decoder.cs | 18 +-- .../Formats/Webp/Lossy/Vp8EncIterator.cs | 8 +- .../Formats/Webp/Lossy/Vp8EncProba.cs | 8 +- .../Formats/Webp/Lossy/Vp8Encoder.cs | 12 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs | 2 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs | 2 +- .../Formats/Webp/Lossy/WebpLossyDecoder.cs | 4 +- .../Formats/Webp/WebpAnimationDecoder.cs | 4 +- .../Formats/Webp/WebpChunkParsingUtils.cs | 4 +- src/ImageSharp/Formats/Webp/WebpDecoder.cs | 8 +- .../Formats/Webp/WebpDecoderCore.cs | 10 +- src/ImageSharp/Formats/Webp/WebpMetadata.cs | 2 +- .../GraphicOptionsDefaultsExtensions.cs | 10 +- src/ImageSharp/Image.Decode.cs | 2 +- src/ImageSharp/Image.WrapMemory.cs | 20 +-- src/ImageSharp/Image.cs | 2 +- src/ImageSharp/ImageFrame.LoadPixelData.cs | 2 +- .../ImageFrameCollection{TPixel}.cs | 8 +- src/ImageSharp/ImageFrame{TPixel}.cs | 6 +- src/ImageSharp/Image{TPixel}.cs | 16 +-- .../Allocators/Internals/ManagedBufferBase.cs | 2 +- .../Internals/SharedArrayPoolBuffer{T}.cs | 2 +- ...iformUnmanagedMemoryPool.LifetimeGuards.cs | 2 +- .../Internals/UniformUnmanagedMemoryPool.cs | 6 +- .../Internals/UnmanagedBuffer{T}.cs | 2 +- .../Internals/UnmanagedMemoryHandle.cs | 4 +- ...iformUnmanagedMemoryPoolMemoryAllocator.cs | 8 +- .../Allocators/UnmanagedMemoryAllocator.cs | 2 +- src/ImageSharp/Memory/Buffer2DExtensions.cs | 2 +- src/ImageSharp/Memory/Buffer2DRegion{T}.cs | 4 +- src/ImageSharp/Memory/ByteMemoryOwner{T}.cs | 2 +- .../MemoryGroupExtensions.cs | 12 +- .../MemoryGroupView{T}.cs | 4 +- .../MemoryGroup{T}.Consumed.cs | 4 +- .../MemoryGroup{T}.Owned.cs | 14 +- .../DiscontiguousBuffers/MemoryGroup{T}.cs | 10 +- .../Memory/MemoryAllocatorExtensions.cs | 4 +- .../Memory/UnmanagedMemoryManager{T}.cs | 4 +- .../Profiles/Exif/ExifEncodedStringHelpers.cs | 6 +- .../Metadata/Profiles/Exif/ExifProfile.cs | 2 +- .../Metadata/Profiles/Exif/ExifReader.cs | 4 +- .../Profiles/Exif/Values/ExifEncodedString.cs | 2 +- .../Profiles/Exif/Values/ExifRational.cs | 2 +- .../Profiles/Exif/Values/ExifRationalArray.cs | 4 +- .../ICC/DataReader/IccDataReader.Curves.cs | 38 +++--- .../ICC/DataReader/IccDataReader.Lut.cs | 12 +- .../IccDataReader.MultiProcessElement.cs | 8 +- .../DataReader/IccDataReader.NonPrimitives.cs | 26 ++-- .../DataReader/IccDataReader.Primitives.cs | 2 +- .../DataReader/IccDataReader.TagDataEntry.cs | 106 +++++++-------- .../DataWriter/IccDataWriter.NonPrimitives.cs | 4 +- .../DataWriter/IccDataWriter.TagDataEntry.cs | 6 +- .../Profiles/ICC/DataWriter/IccDataWriter.cs | 2 +- .../Metadata/Profiles/ICC/IccProfile.cs | 2 +- .../Metadata/Profiles/ICC/IccReader.cs | 6 +- .../Metadata/Profiles/ICC/IccWriter.cs | 2 +- .../TagDataEntries/IccLut16TagDataEntry.cs | 2 +- .../IccTextDescriptionTagDataEntry.cs | 12 +- .../Metadata/Profiles/IPTC/IptcProfile.cs | 4 +- .../Metadata/Profiles/IPTC/IptcValue.cs | 2 +- .../PixelBlenders/PorterDuffFunctions.cs | 4 +- .../PixelFormats/PixelComponentInfo.cs | 2 +- .../PixelImplementations/Bgr565.cs | 4 +- .../PixelImplementations/Bgra4444.cs | 2 +- .../PixelImplementations/Bgra5551.cs | 2 +- .../PixelImplementations/Byte4.cs | 2 +- .../PixelImplementations/HalfSingle.cs | 2 +- .../PixelImplementations/HalfVector4.cs | 2 +- .../PixelFormats/PixelImplementations/L16.cs | 2 +- .../PixelFormats/PixelImplementations/L8.cs | 2 +- .../PixelFormats/PixelImplementations/La16.cs | 2 +- .../PixelFormats/PixelImplementations/La32.cs | 2 +- .../PixelImplementations/NormalizedByte2.cs | 6 +- .../PixelImplementations/NormalizedByte4.cs | 2 +- .../PixelImplementations/NormalizedShort2.cs | 6 +- .../PixelImplementations/NormalizedShort4.cs | 2 +- .../PixelFormats/PixelImplementations/Rg32.cs | 4 +- .../PixelImplementations/Rgb24.cs | 2 +- .../PixelImplementations/Rgba1010102.cs | 2 +- .../PixelImplementations/Rgba32.cs | 4 +- .../PixelImplementations/Short2.cs | 6 +- .../PixelImplementations/Short4.cs | 2 +- src/ImageSharp/Primitives/ColorMatrix.Impl.cs | 10 +- src/ImageSharp/Primitives/Complex64.cs | 6 +- src/ImageSharp/Primitives/DenseMatrix{T}.cs | 8 +- src/ImageSharp/Primitives/LongRational.cs | 12 +- src/ImageSharp/Primitives/Point.cs | 2 +- src/ImageSharp/Primitives/Rectangle.cs | 14 +- src/ImageSharp/Primitives/RectangleF.cs | 8 +- src/ImageSharp/Primitives/SignedRational.cs | 16 +-- src/ImageSharp/Primitives/Size.cs | 26 ++-- src/ImageSharp/Primitives/SizeF.cs | 4 +- src/ImageSharp/Primitives/ValueSize.cs | 6 +- .../HistogramEqualizationExtensions.cs | 2 +- .../Extensions/Transforms/CropExtensions.cs | 2 +- .../Extensions/Transforms/PadExtensions.cs | 4 +- .../Extensions/Transforms/ResizeExtensions.cs | 12 +- .../Transforms/TransformExtensions.cs | 4 +- .../Processing/KnownFilterMatrices.cs | 34 ++--- .../CloningImageProcessor{TPixel}.cs | 4 +- .../Convolution/BoxBlurProcessor{TPixel}.cs | 4 +- .../Convolution2DRowOperation{TPixel}.cs | 4 +- .../Convolution/Convolution2DState.cs | 4 +- .../Convolution/ConvolutionState.cs | 2 +- .../EdgeDetector2DProcessor{TPixel}.cs | 2 +- .../Implementation/LaplacianKernelFactory.cs | 2 +- .../Convolution/MedianConvolutionState.cs | 2 +- .../Convolution/MedianRowOperation{TPixel}.cs | 4 +- .../Parameters/BokehBlurKernelDataProvider.cs | 12 +- .../Dithering/ErrorDither.KnownTypes.cs | 18 +-- .../Processors/Dithering/OrderedDither.cs | 2 +- .../Dithering/OrderedDitherFactory.cs | 2 +- .../PaletteDitherProcessor{TPixel}.cs | 2 +- .../Effects/OilPaintingProcessor{TPixel}.cs | 2 +- .../Effects/PixelRowDelegateProcessor.cs | 2 +- ...lRowDelegateProcessor{TPixel,TDelegate}.cs | 2 +- .../PositionAwarePixelRowDelegateProcessor.cs | 2 +- ...eHistogramEqualizationProcessor{TPixel}.cs | 10 +- .../AutoLevelProcessor{TPixel}.cs | 2 +- ...lHistogramEqualizationProcessor{TPixel}.cs | 2 +- .../GrayscaleLevelsRowOperation{TPixel}.cs | 2 +- .../Overlays/GlowProcessor{TPixel}.cs | 2 +- .../Overlays/VignetteProcessor{TPixel}.cs | 2 +- .../Quantization/OctreeQuantizer.cs | 2 +- .../Quantization/OctreeQuantizer{TPixel}.cs | 6 +- .../Quantization/PaletteQuantizer.cs | 2 +- .../Quantization/WebSafePaletteQuantizer.cs | 2 +- .../Quantization/WernerPaletteQuantizer.cs | 2 +- .../Processors/Quantization/WuQuantizer.cs | 2 +- .../Quantization/WuQuantizer{TPixel}.cs | 2 +- .../Transforms/CropProcessor{TPixel}.cs | 2 +- .../AffineTransformProcessor{TPixel}.cs | 4 +- .../Transforms/Resize/ResizeHelper.cs | 16 +-- .../Transforms/Resize/ResizeKernelMap.cs | 2 +- .../Resize/ResizeProcessor{TPixel}.cs | 12 +- .../Transforms/Resize/ResizeWorker.cs | 4 +- .../Processors/Transforms/TransformUtils.cs | 16 +-- .../Processing/ProjectiveTransformBuilder.cs | 26 ++-- .../Bulk/FromRgba32Bytes.cs | 2 +- .../Codecs/Bmp/DecodeBmp.cs | 2 +- .../Codecs/Gif/DecodeEncodeGif.cs | 4 +- .../Codecs/Gif/DecodeGif.cs | 2 +- .../Codecs/Gif/EncodeGif.cs | 4 +- .../Codecs/Gif/EncodeGifMultiple.cs | 2 +- .../BlockOperations/Block8x8F_CopyTo2x2.cs | 56 ++++---- .../BlockOperations/Block8x8F_DivideRound.cs | 2 +- .../Block8x8F_MultiplyInPlaceBlock.cs | 2 +- .../ColorConversionBenchmark.cs | 6 +- .../Codecs/Jpeg/DecodeJpeg.cs | 2 +- .../Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs | 4 +- .../Codecs/Jpeg/EncodeJpegComparison.cs | 6 +- .../Codecs/Jpeg/EncodeJpegFeatures.cs | 4 +- .../Codecs/MultiImageBenchmarkBase.cs | 2 +- .../Codecs/Png/EncodeIndexedPng.cs | 6 +- .../Codecs/Tga/EncodeTga.cs | 2 +- .../Codecs/Tiff/EncodeTiff.cs | 2 +- .../Codecs/Webp/EncodeWebp.cs | 2 +- .../Color/ColorEquality.cs | 2 +- .../Color/RgbWorkingSpaceAdapt.cs | 2 +- .../ImageSharp.Benchmarks/Color/YcbCrToRgb.cs | 4 +- .../ImageSharp.Benchmarks/General/Array2D.cs | 2 +- .../General/BasicMath/ClampSpan.cs | 2 +- .../General/BasicMath/ClampVector4.cs | 4 +- .../General/CopyBuffers.cs | 4 +- .../General/IO/BufferedStreams.cs | 32 ++--- .../PixelConversion_ConvertFromRgba32.cs | 6 +- .../PixelConversion_ConvertFromVector4.cs | 4 +- .../PixelConversion_ConvertToRgba32.cs | 4 +- ...vertToRgba32_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_ConvertToVector4.cs | 2 +- ...ertToVector4_AsPartOfCompositeOperation.cs | 2 +- .../PixelConversion_PackFromRgbPlanes.cs | 2 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 4 +- .../General/Vector4Constants.cs | 20 +-- .../General/Vectorization/BitwiseOrUint32.cs | 4 +- .../General/Vectorization/DivFloat.cs | 4 +- .../General/Vectorization/DivUInt32.cs | 4 +- .../General/Vectorization/MulFloat.cs | 6 +- .../General/Vectorization/MulUInt32.cs | 4 +- .../General/Vectorization/Premultiply.cs | 6 +- .../Vectorization/ReinterpretUInt32AsFloat.cs | 4 +- .../General/Vectorization/UInt32ToSingle.cs | 18 +-- .../General/Vectorization/VectorFetching.cs | 12 +- .../LoadResizeSaveStressBenchmarks.cs | 2 +- .../LoadResizeSaveStressRunner.cs | 6 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 4 +- .../ImageSharp.Benchmarks/Processing/Crop.cs | 4 +- .../Processing/HistogramEqualization.cs | 4 +- .../Processing/Resize.cs | 6 +- .../LoadResizeSaveParallelMemoryStress.cs | 10 +- .../Program.cs | 4 +- .../Color/ColorTests.CastTo.cs | 40 +++--- tests/ImageSharp.Tests/Color/ColorTests.cs | 16 +-- .../ColorProfiles/CieLabTests.cs | 4 +- .../ColorProfiles/CieLchTests.cs | 4 +- .../ColorProfiles/CieLchuvTests.cs | 4 +- .../ColorProfiles/CieLuvTests.cs | 4 +- .../CieXyChromaticityCoordinatesTests.cs | 4 +- .../ColorProfiles/CieXyyTests.cs | 4 +- .../ColorProfiles/CieXyzTests.cs | 4 +- .../ColorProfiles/CmykTests.cs | 4 +- .../ColorProfiles/CompandingTests.cs | 2 +- .../ColorProfiles/HslTests.cs | 4 +- .../ColorProfiles/HsvTests.cs | 4 +- .../ColorProfiles/HunterLabTests.cs | 4 +- .../Icc/ColorProfileConverterTests.Icc.cs | 16 +-- .../ColorProfiles/Icc/TestIccProfiles.cs | 4 +- .../ColorProfiles/LmsTests.cs | 4 +- .../ColorProfiles/RgbTests.cs | 4 +- .../StringRepresentationTests.cs | 2 +- .../ColorProfiles/YCbCrTests.cs | 4 +- .../ImageSharp.Tests/ColorProfiles/YTests.cs | 4 +- .../ColorProfiles/YccKTests.cs | 4 +- .../Common/EncoderExtensionsTests.cs | 4 +- .../ImageSharp.Tests/Common/NumericsTests.cs | 2 +- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 6 +- .../Common/StreamExtensionsTests.cs | 8 +- tests/ImageSharp.Tests/ConfigurationTests.cs | 28 ++-- .../Drawing/DrawImageTests.cs | 20 +-- .../Formats/Bmp/BmpFileHeaderTests.cs | 4 +- .../Formats/Bmp/ImageExtensionsTest.cs | 4 +- .../Formats/Gif/GifEncoderTests.cs | 8 +- .../Formats/Gif/GifMetadataTests.cs | 4 +- .../Formats/Gif/ImageExtensionsTest.cs | 4 +- .../Formats/Icon/Cur/CurEncoderTests.cs | 2 +- .../Formats/ImageFormatManagerTests.cs | 2 +- .../Formats/Jpg/Block8x8Tests.cs | 20 +-- .../ImageSharp.Tests/Formats/Jpg/DCTTests.cs | 4 +- .../Formats/Jpg/HuffmanScanEncoderTests.cs | 2 +- .../Formats/Jpg/ImageExtensionsTest.cs | 4 +- .../Formats/Jpg/JpegColorConverterTests.cs | 4 +- .../Formats/Jpg/JpegDecoderTests.Metadata.cs | 8 +- .../Formats/Jpg/JpegEncoderTests.Metadata.cs | 4 +- .../Formats/Jpg/JpegFileMarkerTests.cs | 2 +- .../Formats/Jpg/JpegMetadataTests.cs | 18 +-- .../Formats/Jpg/ParseStreamTests.cs | 12 +- ...plementationsTests.FastFloatingPointDCT.cs | 2 +- .../Formats/Jpg/SpectralJpegTests.cs | 26 ++-- .../Jpg/SpectralToPixelConversionTests.cs | 12 +- .../Formats/Jpg/Utils/JpegFixture.cs | 12 +- .../Formats/Jpg/Utils/LibJpegTools.cs | 18 +-- .../ReferenceImplementations.AccurateDCT.cs | 4 +- ...ceImplementations.LLM_FloatingPoint_DCT.cs | 42 +++--- ...renceImplementations.StandardIntegerDCT.cs | 8 +- .../Formats/Jpg/Utils/SpanExtensions.cs | 6 +- .../Formats/Jpg/Utils/VerifyJpeg.cs | 2 +- .../Formats/Pbm/ImageExtensionsTest.cs | 4 +- .../Formats/Pbm/PbmDecoderTests.cs | 22 +-- .../Formats/Pbm/PbmEncoderTests.cs | 22 +-- .../Formats/Pbm/PbmRoundTripTests.cs | 16 +-- .../Formats/Png/Adler32Tests.cs | 2 +- .../Formats/Png/ImageExtensionsTest.cs | 4 +- .../Formats/Png/PngDecoderTests.Chunks.cs | 2 +- .../Formats/Png/PngDecoderTests.cs | 4 +- .../Formats/Png/PngEncoderFilterTests.cs | 28 ++-- .../Formats/Png/PngEncoderTests.cs | 6 +- .../Formats/Png/PngMetadataTests.cs | 6 +- .../Formats/Png/PngTextDataTests.cs | 16 +-- .../Formats/Qoi/ImageExtensionsTest.cs | 4 +- .../Formats/Tga/ImageExtensionsTest.cs | 4 +- .../Formats/Tiff/BigTiffMetadataTests.cs | 32 ++--- .../DeflateTiffCompressionTests.cs | 4 +- .../Compression/LzwTiffCompressionTests.cs | 6 +- .../Compression/NoneTiffCompressionTests.cs | 6 +- .../PackBitsTiffCompressionTests.cs | 6 +- .../Formats/Tiff/ImageExtensionsTest.cs | 4 +- .../BlackIsZeroTiffColorTests.cs | 2 +- .../PaletteTiffColorTests.cs | 10 +- .../PhotometricInterpretationTestBase.cs | 4 +- .../RgbPlanarTiffColorTests.cs | 2 +- .../WhiteIsZeroTiffColorTests.cs | 18 +-- .../Formats/Tiff/TiffEncoderBaseTester.cs | 8 +- .../Tiff/TiffEncoderMultiframeTests.cs | 24 ++-- .../Formats/Tiff/TiffEncoderTests.cs | 2 +- .../Formats/Tiff/Utils/TiffWriterTests.cs | 32 ++--- .../Formats/WebP/ImageExtensionsTests.cs | 4 +- .../Formats/WebP/LosslessUtilsTests.cs | 4 +- .../Formats/WebP/PredictorEncoderTests.cs | 2 +- .../Formats/WebP/Vp8HistogramTests.cs | 12 +- .../Formats/WebP/Vp8ModeScoreTests.cs | 10 +- .../Formats/WebP/Vp8ResidualTests.cs | 6 +- .../Formats/WebP/WebpDecoderTests.cs | 4 +- .../Formats/WebP/WebpEncoderTests.cs | 2 +- .../Formats/WebP/WebpMetaDataTests.cs | 20 +-- .../Formats/WebP/YuvConversionTests.cs | 2 +- .../GraphicOptionsDefaultsExtensionsTests.cs | 70 +++++----- .../ImageSharp.Tests/GraphicsOptionsTests.cs | 4 +- .../Helpers/ColorNumericsTests.cs | 2 +- .../ImageSharp.Tests/Helpers/NumericsTests.cs | 6 +- .../Helpers/ParallelExecutionSettingsTests.cs | 2 +- .../Helpers/ParallelRowIteratorTests.cs | 68 +++++----- .../Helpers/RowIntervalTests.cs | 14 +- .../IO/ChunkedMemoryStreamTests.cs | 4 +- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 4 +- .../Image/ImageFrameCollectionTests.cs | 6 +- .../ImageSharp.Tests/Image/ImageFrameTests.cs | 16 +-- .../Image/ImageRotationTests.cs | 6 +- .../ImageSharp.Tests/Image/ImageSaveTests.cs | 12 +- .../Image/ImageTests.EncodeCancellation.cs | 28 ++-- .../Image/ImageTests.ImageLoadTestBase.cs | 18 +-- ..._FileSystemPath_UseDefaultConfiguration.cs | 2 +- ...s.Load_FromBytes_UseGlobalConfiguration.cs | 2 +- ...Load_FromStream_UseDefaultConfiguration.cs | 6 +- .../Image/ImageTests.WrapMemory.cs | 116 ++++++++-------- .../Image/LargeImageIntegrationTests.cs | 4 +- .../Image/ProcessPixelRowsTestBase.cs | 54 ++++---- .../Memory/Allocators/BufferTestSuite.cs | 4 +- .../RefCountedLifetimeGuardTests.cs | 12 +- .../Allocators/SharedArrayPoolBufferTests.cs | 4 +- .../UniformUnmanagedMemoryPoolTests.Trim.cs | 18 +-- .../UniformUnmanagedMemoryPoolTests.cs | 52 ++++---- ...niformUnmanagedPoolMemoryAllocatorTests.cs | 34 ++--- .../Memory/Allocators/UnmanagedBufferTests.cs | 8 +- .../Allocators/UnmanagedMemoryHandleTests.cs | 14 +- .../Memory/Buffer2DTests.SwapOrCopyContent.cs | 26 ++-- .../ImageSharp.Tests/Memory/Buffer2DTests.cs | 20 +-- .../Memory/BufferAreaTests.cs | 12 +- .../DiscontiguousBuffers/MemoryGroupIndex.cs | 6 +- .../MemoryGroupIndexTests.cs | 24 ++-- .../MemoryGroupTests.Allocate.cs | 10 +- .../MemoryGroupTests.CopyTo.cs | 8 +- .../DiscontiguousBuffers/MemoryGroupTests.cs | 12 +- .../MemoryGroupTestsBase.cs | 2 +- tests/ImageSharp.Tests/Memory/TestStructs.cs | 8 +- .../MemoryAllocatorValidator.cs | 2 +- .../Metadata/ImageFrameMetadataTests.cs | 2 +- .../Metadata/ImageMetadataTests.cs | 6 +- .../Profiles/CICP/CicpProfileTests.cs | 10 +- .../Profiles/Exif/ExifProfileTests.cs | 74 +++++----- .../Metadata/Profiles/Exif/ExifReaderTests.cs | 4 +- .../Exif/ExifTagDescriptionAttributeTests.cs | 2 +- .../Profiles/Exif/Values/ExifValuesTests.cs | 46 +++---- .../DataReader/IccDataReaderCurvesTests.cs | 2 +- .../ICC/DataReader/IccDataReaderLutTests.cs | 2 +- .../IccDataReaderMultiProcessElementTests.cs | 2 +- .../IccDataReaderNonPrimitivesTests.cs | 2 +- .../IccDataReaderPrimitivesTests.cs | 2 +- .../IccDataReaderTagDataEntryTests.cs | 2 +- .../Metadata/Profiles/ICC/IccProfileTests.cs | 4 +- .../Metadata/Profiles/ICC/IccWriterTests.cs | 2 +- .../Profiles/ICC/Various/IccProfileIdTests.cs | 2 +- .../Profiles/IPTC/IptcProfileTests.cs | 52 ++++---- .../Metadata/Profiles/XMP/XmpProfileTests.cs | 28 ++-- .../Numerics/RationalTests.cs | 20 +-- .../Numerics/SignedRationalTests.cs | 48 +++---- .../ImageSharp.Tests/PixelFormats/A8Tests.cs | 2 +- .../PixelFormats/Abgr32Tests.cs | 4 +- .../PixelFormats/Argb32Tests.cs | 2 +- .../PixelFormats/Bgr24Tests.cs | 4 +- .../PixelFormats/Bgr565Tests.cs | 30 ++--- .../PixelFormats/Bgra32Tests.cs | 4 +- .../PixelFormats/Bgra4444Tests.cs | 28 ++-- .../PixelFormats/Bgra5551Tests.cs | 30 ++--- .../PixelFormats/Byte4Tests.cs | 26 ++-- .../PixelFormats/HalfVector2Tests.cs | 2 +- .../PixelFormats/HalfVector4Tests.cs | 2 +- .../ImageSharp.Tests/PixelFormats/L16Tests.cs | 4 +- .../ImageSharp.Tests/PixelFormats/L8Tests.cs | 4 +- .../PixelFormats/La16Tests.cs | 4 +- .../PixelFormats/La32Tests.cs | 4 +- .../PixelFormats/NormalizedByte2Tests.cs | 6 +- .../PixelFormats/NormalizedByte4Tests.cs | 26 ++-- .../PixelFormats/NormalizedShort2Tests.cs | 6 +- .../PixelFormats/NormalizedShort4Tests.cs | 26 ++-- .../PixelFormats/PixelBlenderTests.cs | 24 ++-- .../PixelBlenders/PorterDuffFunctionsTests.cs | 52 ++++---- .../PorterDuffFunctionsTestsTPixel.cs | 38 +++--- .../PixelOperations/PixelOperationsTests.cs | 14 +- .../PixelFormats/Rg32Tests.cs | 2 +- .../PixelFormats/Rgb24Tests.cs | 4 +- .../PixelFormats/Rgb48Tests.cs | 2 +- .../PixelFormats/Rgba1010102Tests.cs | 28 ++-- .../PixelFormats/Rgba32Tests.cs | 2 +- .../PixelFormats/Rgba64Tests.cs | 2 +- .../PixelFormats/RgbaVectorTests.cs | 6 +- .../PixelFormats/Short2Tests.cs | 8 +- .../PixelFormats/Short4Tests.cs | 2 +- .../Primitives/ColorMatrixTests.cs | 2 +- .../Primitives/DenseMatrixTests.cs | 16 +-- .../Primitives/PointFTests.cs | 47 ++++--- .../ImageSharp.Tests/Primitives/PointTests.cs | 64 ++++----- .../Primitives/RectangleFTests.cs | 74 +++++----- .../Primitives/RectangleTests.cs | 84 ++++++------ .../ImageSharp.Tests/Primitives/SizeFTests.cs | 54 ++++---- .../ImageSharp.Tests/Primitives/SizeTests.cs | 78 +++++------ .../BaseImageOperationsExtensionTest.cs | 8 +- .../Processing/Convolution/BoxBlurTest.cs | 6 +- .../Convolution/KernelSamplingMapTest.cs | 126 +++++++++--------- .../Processing/Effects/OilPaintTest.cs | 8 +- .../Processing/Effects/PixelateTest.cs | 6 +- .../Processing/FakeImageOperationsProvider.cs | 10 +- .../Processing/Filters/BrightnessTest.cs | 16 +-- .../Processing/Filters/HueTest.cs | 4 +- .../Processing/Filters/LomographTest.cs | 4 +- .../Processing/Filters/PolaroidTest.cs | 4 +- .../Processing/ImageOperationTests.cs | 12 +- .../Processing/ImageProcessingContextTests.cs | 12 +- .../HistogramEqualizationTests.cs | 20 +-- .../Normalization/MagickCompareTests.cs | 2 +- .../Processing/Overlays/GlowTest.cs | 2 +- .../Processing/Overlays/VignetteTest.cs | 2 +- .../Binarization/BinaryDitherTests.cs | 4 +- .../Binarization/BinaryThresholdTest.cs | 10 +- .../Processors/Convolution/BokehBlurTest.cs | 6 +- .../Processors/Convolution/DetectEdgesTest.cs | 4 +- .../Processors/Dithering/DitherTests.cs | 4 +- .../Processors/Effects/OilPaintTest.cs | 6 +- .../Processors/Effects/PixelShaderTest.cs | 8 +- .../Quantization/OctreeQuantizerTests.cs | 22 +-- .../Quantization/PaletteQuantizerTests.cs | 22 +-- .../Quantization/WuQuantizerTests.cs | 22 +-- .../Transforms/AffineTransformTests.cs | 10 +- .../Processors/Transforms/AutoOrientTests.cs | 6 +- .../Processors/Transforms/CropTest.cs | 2 +- .../Processors/Transforms/EntropyCropTest.cs | 4 +- .../Transforms/ResizeHelperTests.cs | 58 ++++---- ...ResizeKernelMapTests.ReferenceKernelMap.cs | 8 +- .../Transforms/ResizeKernelMapTests.cs | 12 +- .../Processors/Transforms/ResizeTests.cs | 46 +++---- .../Processors/Transforms/SwizzleTests.cs | 9 +- .../Processing/Transforms/CropTest.cs | 6 +- .../Transforms/ProjectiveTransformTests.cs | 24 ++-- .../Processing/Transforms/ResizeTests.cs | 6 +- .../Processing/Transforms/SwizzleTests.cs | 7 +- .../Transforms/TransformBuilderTestBase.cs | 104 +++++++-------- .../LoadResizeSaveProfilingBenchmarks.cs | 6 +- .../ResizeProfilingBenchmarks.cs | 2 +- .../Quantization/QuantizedImageTests.cs | 2 +- .../Quantization/WuQuantizerTests.cs | 22 +-- .../Conversion/IccConversionDataLutEntry.cs | 2 +- .../IccConversionDataMultiProcessElement.cs | 8 +- .../Conversion/IccConversionDataTrc.cs | 10 +- .../TestDataIcc/IccTestDataLut.cs | 2 +- .../TestDataIcc/IccTestDataProfiles.cs | 8 +- .../TestDataIcc/IccTestDataTagDataEntry.cs | 6 +- tests/ImageSharp.Tests/TestFile.cs | 2 +- tests/ImageSharp.Tests/TestFontUtilities.cs | 4 +- tests/ImageSharp.Tests/TestFormat.cs | 10 +- .../TestUtilities/ArrayHelper.cs | 4 +- .../Attributes/WithFileCollectionAttribute.cs | 2 +- .../TestUtilities/ByteArrayUtility.cs | 2 +- .../TestUtilities/EofHitCounter.cs | 4 +- .../FeatureTesting/FeatureTestRunner.cs | 16 +-- .../ImageComparison/ExactImageComparer.cs | 12 +- .../ImageComparison/ImageComparer.cs | 4 +- .../ImageComparison/ImageComparingUtils.cs | 2 +- .../ImageComparison/ImageSimilarityReport.cs | 2 +- .../ImageComparison/TolerantImageComparer.cs | 10 +- .../BasicTestPatternProvider.cs | 2 +- .../ImageProviders/FileProvider.cs | 14 +- .../ImageProviders/MemberMethodProvider.cs | 2 +- .../ImageProviders/TestImageProvider.cs | 2 +- .../TestUtilities/MeasureFixture.cs | 2 +- .../TestUtilities/PausedMemoryStream.cs | 4 +- .../TestUtilities/PausedStream.cs | 4 +- .../ReferenceCodecs/SystemDrawingBridge.cs | 12 +- .../SixLaborsXunitTestFramework.cs | 2 +- .../TestUtilities/TestDataGenerator.cs | 10 +- .../TestUtilities/TestEnvironment.cs | 15 +-- .../TestUtilities/TestImageExtensions.cs | 2 +- .../TestUtilities/TestMemoryAllocator.cs | 12 +- .../TestUtilities/TestMemoryManager.cs | 4 +- .../TestUtilities/TestPixel.cs | 2 +- .../TestUtilities/TestUtils.cs | 4 +- .../TestUtilities/TestVector4.cs | 2 +- .../Tests/BasicSerializerTests.cs | 2 +- .../TestUtilities/Tests/ImageComparerTests.cs | 12 +- .../Tests/ReferenceDecoderBenchmarks.cs | 2 +- .../Tests/SystemDrawingReferenceCodecTests.cs | 9 +- .../Tests/TestUtilityExtensionsTests.cs | 2 +- 601 files changed, 2796 insertions(+), 2791 deletions(-) diff --git a/.editorconfig b/.editorconfig index af1e5b44c..4aaab02c1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -161,6 +161,9 @@ csharp_style_deconstructed_variable_declaration = true:warning csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_implicit_object_creation_when_type_is_apparent = true:error +# Collection expression preferences +# dotnet_style_prefer_collection_expression = true:error + # "Null" checking preferences csharp_style_throw_expression = true:warning csharp_style_conditional_delegate_call = true:warning @@ -175,6 +178,11 @@ csharp_prefer_static_local_function = true:warning # Primary constructor preferences csharp_style_prefer_primary_constructors = false:none +# ReSharper inspection severities +resharper_arrange_object_creation_when_type_evident_highlighting = error +resharper_arrange_object_creation_when_type_not_evident_highlighting = error +# resharper_use_collection_expression_highlighting = error + ########################################## # Unnecessary Code Rules # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules diff --git a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs index fd9692f9a..f295ddb1b 100644 --- a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs +++ b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs @@ -79,7 +79,7 @@ public readonly struct ParallelExecutionSettings { Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier)); - return new ParallelExecutionSettings( + return new( this.MaxDegreeOfParallelism, this.MinimumPixelsProcessedPerTask * multiplier, this.MemoryAllocator); @@ -92,6 +92,6 @@ public readonly struct ParallelExecutionSettings /// The . public static ParallelExecutionSettings FromConfiguration(Configuration configuration) { - return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); + return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); } } diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs index a959faa3b..b76f2948f 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs @@ -139,7 +139,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - var rows = new RowInterval(yMin, yMax); + RowInterval rows = new RowInterval(yMin, yMax); // Skip the safety copy when invoking a potentially impure method on a readonly field Unsafe.AsRef(in this.operation).Invoke(in rows); @@ -185,7 +185,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - var rows = new RowInterval(yMin, yMax); + RowInterval rows = new RowInterval(yMin, yMax); using IMemoryOwner buffer = this.allocator.Allocate(this.bufferLength); diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.cs b/src/ImageSharp/Advanced/ParallelRowIterator.cs index 1284a3a89..b878f9ec0 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.cs @@ -26,7 +26,7 @@ public static partial class ParallelRowIterator public static void IterateRows(Configuration configuration, Rectangle rectangle, in T operation) where T : struct, IRowOperation { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRows(rectangle, in parallelSettings, in operation); } @@ -65,8 +65,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation); Parallel.For( 0, @@ -88,7 +88,7 @@ public static partial class ParallelRowIterator where T : struct, IRowOperation where TBuffer : unmanaged { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRows(rectangle, in parallelSettings, in operation); } @@ -135,8 +135,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation); Parallel.For( 0, @@ -156,7 +156,7 @@ public static partial class ParallelRowIterator public static void IterateRowIntervals(Configuration configuration, Rectangle rectangle, in T operation) where T : struct, IRowIntervalOperation { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRowIntervals(rectangle, in parallelSettings, in operation); } @@ -186,14 +186,14 @@ public static partial class ParallelRowIterator // Avoid TPL overhead in this trivial case: if (numOfSteps == 1) { - var rows = new RowInterval(top, bottom); + RowInterval rows = new(top, bottom); Unsafe.AsRef(in operation).Invoke(in rows); return; } int verticalStep = DivideCeil(rectangle.Height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, in operation); Parallel.For( 0, @@ -215,7 +215,7 @@ public static partial class ParallelRowIterator where T : struct, IRowIntervalOperation where TBuffer : unmanaged { - var parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); + ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(configuration); IterateRowIntervals(rectangle, in parallelSettings, in operation); } @@ -250,7 +250,7 @@ public static partial class ParallelRowIterator // Avoid TPL overhead in this trivial case: if (numOfSteps == 1) { - var rows = new RowInterval(top, bottom); + RowInterval rows = new(top, bottom); using IMemoryOwner buffer = allocator.Allocate(bufferLength); Unsafe.AsRef(in operation).Invoke(in rows, buffer.Memory.Span); @@ -259,8 +259,8 @@ public static partial class ParallelRowIterator } int verticalStep = DivideCeil(height, numOfSteps); - var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = numOfSteps }; - var wrappingOperation = new RowIntervalOperationWrapper(top, bottom, verticalStep, bufferLength, allocator, in operation); + ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = numOfSteps }; + RowIntervalOperationWrapper wrappingOperation = new(top, bottom, verticalStep, bufferLength, allocator, in operation); Parallel.For( 0, diff --git a/src/ImageSharp/Color/Color.WebSafePalette.cs b/src/ImageSharp/Color/Color.WebSafePalette.cs index feb4a8659..b805d63f9 100644 --- a/src/ImageSharp/Color/Color.WebSafePalette.cs +++ b/src/ImageSharp/Color/Color.WebSafePalette.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp; /// public partial struct Color { - private static readonly Lazy WebSafePaletteLazy = new Lazy(CreateWebSafePalette, true); + private static readonly Lazy WebSafePaletteLazy = new(CreateWebSafePalette, true); /// /// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4. diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs index ca72dd745..c1f53c162 100644 --- a/src/ImageSharp/ColorProfiles/CieLab.cs +++ b/src/ImageSharp/ColorProfiles/CieLab.cs @@ -88,7 +88,7 @@ public readonly struct CieLab : IProfileConnectingSpace v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -97,7 +97,7 @@ public readonly struct CieLab : IProfileConnectingSpace Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new CieLab(v3); + return new(v3); } /// @@ -145,7 +145,7 @@ public readonly struct CieLab : IProfileConnectingSpace float a = 500F * (fx - fy); float b = 200F * (fy - fz); - return new CieLab(l, a, b); + return new(l, a, b); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLch.cs b/src/ImageSharp/ColorProfiles/CieLch.cs index e62aa2ba2..53afc0053 100644 --- a/src/ImageSharp/ColorProfiles/CieLch.cs +++ b/src/ImageSharp/ColorProfiles/CieLch.cs @@ -25,7 +25,7 @@ public readonly struct CieLch : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLch(float l, float c, float h) - : this(new Vector3(l, c, h)) + : this(new(l, c, h)) { } @@ -100,7 +100,7 @@ public readonly struct CieLch : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -109,7 +109,7 @@ public readonly struct CieLch : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new CieLch(v3, true); + return new(v3, true); } /// @@ -155,7 +155,7 @@ public readonly struct CieLch : IColorProfile hDegrees += 360; } - return new CieLch(l, c, hDegrees); + return new(l, c, hDegrees); } /// @@ -181,7 +181,7 @@ public readonly struct CieLch : IColorProfile float a = c * MathF.Cos(hRadians); float b = c * MathF.Sin(hRadians); - return new CieLab(l, a, b); + return new(l, a, b); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLchuv.cs b/src/ImageSharp/ColorProfiles/CieLchuv.cs index 5478752dd..c08d6cc40 100644 --- a/src/ImageSharp/ColorProfiles/CieLchuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLchuv.cs @@ -25,7 +25,7 @@ public readonly struct CieLchuv : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLchuv(float l, float c, float h) - : this(new Vector3(l, c, h)) + : this(new(l, c, h)) { } @@ -97,7 +97,7 @@ public readonly struct CieLchuv : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -106,7 +106,7 @@ public readonly struct CieLchuv : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new CieLchuv(v3, true); + return new(v3, true); } /// @@ -154,7 +154,7 @@ public readonly struct CieLchuv : IColorProfile hDegrees += 360; } - return new CieLchuv(l, c, hDegrees); + return new(l, c, hDegrees); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLuv.cs b/src/ImageSharp/ColorProfiles/CieLuv.cs index b17c43331..58ec9048c 100644 --- a/src/ImageSharp/ColorProfiles/CieLuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLuv.cs @@ -134,7 +134,7 @@ public readonly struct CieLuv : IColorProfile v = 0; } - return new CieLuv((float)l, (float)u, (float)v); + return new((float)l, (float)u, (float)v); } /// @@ -188,7 +188,7 @@ public readonly struct CieLuv : IColorProfile z = 0; } - return new CieXyz((float)x, (float)y, (float)z); + return new((float)x, (float)y, (float)z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyy.cs b/src/ImageSharp/ColorProfiles/CieXyy.cs index 744b6195e..ef45f352d 100644 --- a/src/ImageSharp/ColorProfiles/CieXyy.cs +++ b/src/ImageSharp/ColorProfiles/CieXyy.cs @@ -122,10 +122,10 @@ public readonly struct CieXyy : IColorProfile if (float.IsNaN(x) || float.IsNaN(y)) { - return new CieXyy(0, 0, source.Y); + return new(0, 0, source.Y); } - return new CieXyy(x, y, source.Y); + return new(x, y, source.Y); } /// @@ -144,14 +144,14 @@ public readonly struct CieXyy : IColorProfile { if (MathF.Abs(this.Y) < Constants.Epsilon) { - return new CieXyz(0, 0, this.Yl); + return new(0, 0, this.Yl); } float x = (this.X * this.Yl) / this.Y; float y = this.Yl; float z = ((1 - this.X - this.Y) * y) / this.Y; - return new CieXyz(x, y, z); + return new(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyz.cs b/src/ImageSharp/ColorProfiles/CieXyz.cs index 94fcfb21b..b14f01469 100644 --- a/src/ImageSharp/ColorProfiles/CieXyz.cs +++ b/src/ImageSharp/ColorProfiles/CieXyz.cs @@ -88,7 +88,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -97,13 +97,13 @@ public readonly struct CieXyz : IProfileConnectingSpace Vector3 v3 = default; v3 += this.AsVector3Unsafe(); v3 *= 32768F / 65535; - return new Vector4(v3, 1F); + return new(v3, 1F); } internal static CieXyz FromVector4(Vector4 source) { Vector3 v3 = source.AsVector3(); - return new CieXyz(v3); + return new(v3); } /// @@ -111,7 +111,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = source.AsVector3(); v3 *= 65535 / 32768F; - return new CieXyz(v3); + return new(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs index ee81ff9f7..3a2ffd6fb 100644 --- a/src/ImageSharp/ColorProfiles/Cmyk.cs +++ b/src/ImageSharp/ColorProfiles/Cmyk.cs @@ -26,7 +26,7 @@ public readonly struct Cmyk : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Cmyk(float c, float m, float y, float k) - : this(new Vector4(c, m, y, k)) + : this(new(c, m, y, k)) { } @@ -138,12 +138,12 @@ public readonly struct Cmyk : IColorProfile if (k.X >= 1F - Constants.Epsilon) { - return new Cmyk(0, 0, 0, 1F); + return new(0, 0, 0, 1F); } cmy = (cmy - k) / (Vector3.One - k); - return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X); + return new(cmy.X, cmy.Y, cmy.Z, k.X); } /// diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs index c33f40001..b00ff8200 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs @@ -57,11 +57,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new ColorConversionOptions + ColorProfileConverter pcsConverter = new(new() { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); // Normalize the source, then convert to the PCS space. @@ -101,11 +101,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new ColorConversionOptions + ColorProfileConverter pcsConverter = new(new() { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); using IMemoryOwner pcsBuffer = converter.Options.MemoryAllocator.Allocate(source.Length); @@ -355,7 +355,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new CieXyz(AdjustPcsFromV2BlackPoint(vector)); + xyz = new(AdjustPcsFromV2BlackPoint(vector)); } // when converting from PCS to device with v2 perceptual intent @@ -371,7 +371,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new CieXyz(vector); + xyz = new(vector); } switch (targetParams.PcsType) diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs index 7a9365fb7..2735b5513 100644 --- a/src/ImageSharp/ColorProfiles/Hsl.cs +++ b/src/ImageSharp/ColorProfiles/Hsl.cs @@ -24,7 +24,7 @@ public readonly struct Hsl : IColorProfile /// The l value (lightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsl(float h, float s, float l) - : this(new Vector3(h, s, l)) + : this(new(h, s, l)) { } @@ -141,7 +141,7 @@ public readonly struct Hsl : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new Hsl(0F, s, l); + return new(0F, s, l); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -172,7 +172,7 @@ public readonly struct Hsl : IColorProfile s = chroma / (2F - max - min); } - return new Hsl(h, s, l); + return new(h, s, l); } /// @@ -213,7 +213,7 @@ public readonly struct Hsl : IColorProfile } } - return new Rgb(r, g, b); + return new(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/Hsv.cs b/src/ImageSharp/ColorProfiles/Hsv.cs index 1e013fe1f..d29b3023e 100644 --- a/src/ImageSharp/ColorProfiles/Hsv.cs +++ b/src/ImageSharp/ColorProfiles/Hsv.cs @@ -24,7 +24,7 @@ public readonly struct Hsv : IColorProfile /// The v value (brightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsv(float h, float s, float v) - : this(new Vector3(h, s, v)) + : this(new(h, s, v)) { } @@ -139,7 +139,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new Hsv(0, s, v); + return new(0, s, v); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -163,7 +163,7 @@ public readonly struct Hsv : IColorProfile s = chroma / v; - return new Hsv(h, s, v); + return new(h, s, v); } /// @@ -185,7 +185,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(s) < Constants.Epsilon) { - return new Rgb(v, v, v); + return new(v, v, v); } float h = (MathF.Abs(this.H - 360) < Constants.Epsilon) ? 0 : this.H / 60; @@ -236,7 +236,7 @@ public readonly struct Hsv : IColorProfile break; } - return new Rgb(r, g, b); + return new(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/HunterLab.cs b/src/ImageSharp/ColorProfiles/HunterLab.cs index e978c6de2..341360b12 100644 --- a/src/ImageSharp/ColorProfiles/HunterLab.cs +++ b/src/ImageSharp/ColorProfiles/HunterLab.cs @@ -87,7 +87,7 @@ public readonly struct HunterLab : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -96,7 +96,7 @@ public readonly struct HunterLab : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new HunterLab(v3); + return new(v3); } /// @@ -151,7 +151,7 @@ public readonly struct HunterLab : IColorProfile b = 0; } - return new HunterLab(l, a, b); + return new(l, a, b); } /// @@ -184,7 +184,7 @@ public readonly struct HunterLab : IColorProfile float x = (((a / ka) * sqrtPow) + pow) * xn; float z = (((b / kb) * sqrtPow) - pow) * (-zn); - return new CieXyz(x, y, z); + return new(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs index 3604642c9..e5d95d513 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs @@ -23,12 +23,12 @@ internal class ColorTrcCalculator : IVector4Calculator bool toPcs) { this.toPcs = toPcs; - this.curveCalculator = new TrcCalculator([redTrc, greenTrc, blueTrc], !toPcs); + this.curveCalculator = new([redTrc, greenTrc, blueTrc], !toPcs); Vector3 mr = redMatrixColumn.Data[0]; Vector3 mg = greenMatrixColumn.Data[0]; Vector3 mb = blueMatrixColumn.Data[0]; - this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); + this.matrix = new(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); if (!toPcs) { diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs index c39eaf958..9c7a18ae8 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs @@ -31,7 +31,7 @@ internal partial class CurveCalculator : ISingleCalculator } else { - this.lutCalculator = new LutCalculator(entry.CurveData, inverted); + this.lutCalculator = new(entry.CurveData, inverted); this.type = CalculationType.Lut; } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs index 8d823c1e9..f39f4da52 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs @@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator private readonly TrcCalculator calculator; public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) - => this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); + => this.calculator = new(new IccTagDataEntry[] { grayTrc }, !toPcs); [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value); diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs index 172d80639..e0d1ad8d4 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs @@ -109,27 +109,27 @@ internal partial class LutABCalculator : IVector4Calculator if (hasACurve) { - this.curveACalculator = new TrcCalculator(curveA, false); + this.curveACalculator = new(curveA, false); } if (hasBCurve) { - this.curveBCalculator = new TrcCalculator(curveB, false); + this.curveBCalculator = new(curveB, false); } if (hasMCurve) { - this.curveMCalculator = new TrcCalculator(curveM, false); + this.curveMCalculator = new(curveM, false); } if (hasMatrix) { - this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); + this.matrixCalculator = new(matrix3x3.Value, matrix3x1.Value); } if (hasClut) { - this.clutCalculator = new ClutCalculator(clut); + this.clutCalculator = new(clut); } } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs index c97578ee3..fbeae88f8 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs @@ -61,7 +61,7 @@ internal class LutEntryCalculator : IVector4Calculator { this.inputCurve = InitLut(inputCurve); this.outputCurve = InitLut(outputCurve); - this.clutCalculator = new ClutCalculator(clut); + this.clutCalculator = new(clut); this.matrix = matrix; this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; @@ -72,7 +72,7 @@ internal class LutEntryCalculator : IVector4Calculator LutCalculator[] calculators = new LutCalculator[curves.Length]; for (int i = 0; i < curves.Length; i++) { - calculators[i] = new LutCalculator(curves[i].Values, false); + calculators[i] = new(curves[i].Values, false); } return calculators; diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs index 6be1fdbf9..5eade1fc8 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs @@ -14,7 +14,7 @@ internal class MatrixCalculator : IVector4Calculator public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) { this.matrix2D = matrix3x3; - this.matrix1D = new Vector4(matrix3x1, 0); + this.matrix1D = new(matrix3x1, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs index 29e30b53e..f0ee4ba58 100644 --- a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs +++ b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs @@ -37,6 +37,6 @@ internal static class CompactSrgbV4Profile { byte[] buffer = new byte[Data.Length]; Data.CopyTo(buffer); - return new IccProfile(buffer); + return new(buffer); } } diff --git a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs index 20df08e37..917be020b 100644 --- a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs @@ -91,7 +91,7 @@ internal abstract partial class IccConverterBase throw new InvalidIccProfileException("Missing matrix column or channel."); } - return new ColorTrcCalculator( + return new( redMatrixColumn, greenMatrixColumn, blueMatrixColumn, @@ -104,6 +104,6 @@ internal abstract partial class IccConverterBase private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs) { IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); - return new GrayTrcCalculator(entry, toPcs); + return new(entry, toPcs); } } diff --git a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs index 71d565f87..a5486580f 100644 --- a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs @@ -24,7 +24,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65) /// public static readonly Matrix4x4 VonKriesHPEAdjusted - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.40024F, M12 = 0.7076F, @@ -42,7 +42,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy) /// public static readonly Matrix4x4 VonKriesHPE - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.3897F, M12 = 0.6890F, @@ -65,7 +65,7 @@ public static class KnownChromaticAdaptationMatrices /// Bradford chromatic adaptation transform matrix (used in CMCCAT97) /// public static readonly Matrix4x4 Bradford - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.8951F, M12 = 0.2664F, @@ -83,7 +83,7 @@ public static class KnownChromaticAdaptationMatrices /// Spectral sharpening and the Bradford transform /// public static readonly Matrix4x4 BradfordSharp - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 1.2694F, M12 = -0.0988F, @@ -101,7 +101,7 @@ public static class KnownChromaticAdaptationMatrices /// CMCCAT2000 (fitted from all available color data sets) /// public static readonly Matrix4x4 CMCCAT2000 - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.7982F, M12 = 0.3389F, @@ -119,7 +119,7 @@ public static class KnownChromaticAdaptationMatrices /// CAT02 (optimized for minimizing CIELAB differences) /// public static readonly Matrix4x4 CAT02 - = Matrix4x4.Transpose(new Matrix4x4 + = Matrix4x4.Transpose(new() { M11 = 0.7328F, M12 = 0.4296F, diff --git a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs index 916383936..1c5f1664c 100644 --- a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs +++ b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs @@ -18,96 +18,96 @@ public static class KnownRgbWorkingSpaces /// Uses proper companding function, according to: /// /// - public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); /// /// Simplified sRgb working space (uses gamma companding instead of ). /// See also . /// - public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); /// /// Rec. 709 (ITU-R Recommendation BT.709) working space. /// - public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.64F, 0.33F), new CieXyChromaticityCoordinates(0.30F, 0.60F), new CieXyChromaticityCoordinates(0.15F, 0.06F))); + public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new(new(0.64F, 0.33F), new(0.30F, 0.60F), new(0.15F, 0.06F))); /// /// Rec. 2020 (ITU-R Recommendation BT.2020F) working space. /// - public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.708F, 0.292F), new CieXyChromaticityCoordinates(0.170F, 0.797F), new CieXyChromaticityCoordinates(0.131F, 0.046F))); + public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new(new(0.708F, 0.292F), new(0.170F, 0.797F), new(0.131F, 0.046F))); /// /// ECI Rgb v2 working space. /// - public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); /// /// Adobe Rgb (1998) working space. /// - public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2100F, 0.7100F), new(0.1500F, 0.0600F))); /// /// Apple sRgb working space. /// - public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6250F, 0.3400F), new CieXyChromaticityCoordinates(0.2800F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new(new(0.6250F, 0.3400F), new(0.2800F, 0.5950F), new(0.1550F, 0.0700F))); /// /// Best Rgb working space. /// - public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.2150F, 0.7750F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.2150F, 0.7750F), new(0.1300F, 0.0350F))); /// /// Beta Rgb working space. /// - public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6888F, 0.3112F), new CieXyChromaticityCoordinates(0.1986F, 0.7551F), new CieXyChromaticityCoordinates(0.1265F, 0.0352F))); + public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6888F, 0.3112F), new(0.1986F, 0.7551F), new(0.1265F, 0.0352F))); /// /// Bruce Rgb working space. /// - public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2800F, 0.6500F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2800F, 0.6500F), new(0.1500F, 0.0600F))); /// /// CIE Rgb working space. /// - public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.2740F, 0.7170F), new CieXyChromaticityCoordinates(0.1670F, 0.0090F))); + public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new(new(0.7350F, 0.2650F), new(0.2740F, 0.7170F), new(0.1670F, 0.0090F))); /// /// ColorMatch Rgb working space. /// - public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.2950F, 0.6050F), new CieXyChromaticityCoordinates(0.1500F, 0.0750F))); + public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.6300F, 0.3400F), new(0.2950F, 0.6050F), new(0.1500F, 0.0750F))); /// /// Don Rgb 4 working space. /// - public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6960F, 0.3000F), new CieXyChromaticityCoordinates(0.2150F, 0.7650F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6960F, 0.3000F), new(0.2150F, 0.7650F), new(0.1300F, 0.0350F))); /// /// Ekta Space PS5 working space. /// - public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6950F, 0.3050F), new CieXyChromaticityCoordinates(0.2600F, 0.7000F), new CieXyChromaticityCoordinates(0.1100F, 0.0050F))); + public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6950F, 0.3050F), new(0.2600F, 0.7000F), new(0.1100F, 0.0050F))); /// /// NTSC Rgb working space. /// - public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); /// /// PAL/SECAM Rgb working space. /// - public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2900F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2900F, 0.6000F), new(0.1500F, 0.0600F))); /// /// ProPhoto Rgb working space. /// - public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.1596F, 0.8404F), new CieXyChromaticityCoordinates(0.0366F, 0.0001F))); + public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.1596F, 0.8404F), new(0.0366F, 0.0001F))); /// /// SMPTE-C Rgb working space. /// - public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.3100F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6300F, 0.3400F), new(0.3100F, 0.5950F), new(0.1550F, 0.0700F))); /// /// Wide Gamut Rgb working space. /// - public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.1150F, 0.8260F), new CieXyChromaticityCoordinates(0.1570F, 0.0180F))); + public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7350F, 0.2650F), new(0.1150F, 0.8260F), new(0.1570F, 0.0180F))); } diff --git a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs index d32833a38..b838f9ddc 100644 --- a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs @@ -16,47 +16,47 @@ public static class KnownYCbCrMatrices /// ITU-R BT.601 (SD video standard). /// public static readonly YCbCrTransform BT601 = new( - new Matrix4x4( + new( 0.299000F, 0.587000F, 0.114000F, 0F, -0.168736F, -0.331264F, 0.500000F, 0F, 0.500000F, -0.418688F, -0.081312F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.402000F, 0F, 1.000000F, -0.344136F, -0.714136F, 0F, 1.000000F, 1.772000F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); /// /// ITU-R BT.709 (HD video, sRGB standard). /// public static readonly YCbCrTransform BT709 = new( - new Matrix4x4( + new( 0.212600F, 0.715200F, 0.072200F, 0F, -0.114572F, -0.385428F, 0.500000F, 0F, 0.500000F, -0.454153F, -0.045847F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.574800F, 0F, 1.000000F, -0.187324F, -0.468124F, 0F, 1.000000F, 1.855600F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); /// /// ITU-R BT.2020 (UHD/4K video standard). /// public static readonly YCbCrTransform BT2020 = new( - new Matrix4x4( + new( 0.262700F, 0.678000F, 0.059300F, 0F, -0.139630F, -0.360370F, 0.500000F, 0F, 0.500000F, -0.459786F, -0.040214F, 0F, 0F, 0F, 0F, 1F), - new Matrix4x4( + new( 1.000000F, 0.000000F, 1.474600F, 0F, 1.000000F, -0.164553F, -0.571353F, 0F, 1.000000F, 1.881400F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new Vector3(0F, 0.5F, 0.5F)); + new(0F, 0.5F, 0.5F)); } diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs index 3aa3d7255..86cb7956b 100644 --- a/src/ImageSharp/ColorProfiles/Lms.cs +++ b/src/ImageSharp/ColorProfiles/Lms.cs @@ -89,7 +89,7 @@ public readonly struct Lms : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(1F); v3 /= 2F; - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -98,7 +98,7 @@ public readonly struct Lms : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= 2F; v3 -= new Vector3(1F); - return new Lms(v3); + return new(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 42e502592..4d7788fcf 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -154,7 +154,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(this.ToScaledVector4())); // Then convert to xyz - return new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); + return new(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); } /// @@ -171,7 +171,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(rgb.ToScaledVector4())); // Then convert to xyz - destination[i] = new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); + destination[i] = new(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); } } @@ -274,7 +274,7 @@ public readonly struct Rgb : IProfileConnectingSpace Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.AsVector3Unsafe(), inverseXyzMatrix); // Use transposed Rows/Columns - return new Matrix4x4 + return new() { M11 = vector.X * mXr, M21 = vector.Y * mXg, diff --git a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs index ec25d0e1c..6f06ccf27 100644 --- a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs @@ -42,7 +42,7 @@ public static class VonKriesChromaticAdaptation Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); Matrix4x4.Invert(matrix, out Matrix4x4 inverseMatrix); - return new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); + return new(Vector3.Transform(targetColorLms, inverseMatrix)); } /// @@ -89,7 +89,7 @@ public static class VonKriesChromaticAdaptation Vector3 sourceColorLms = Vector3.Transform(sp.AsVector3Unsafe(), matrix); Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); - dp = new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); + dp = new(Vector3.Transform(targetColorLms, inverseMatrix)); } } } diff --git a/src/ImageSharp/ColorProfiles/Y.cs b/src/ImageSharp/ColorProfiles/Y.cs index 83321a085..62cef7814 100644 --- a/src/ImageSharp/ColorProfiles/Y.cs +++ b/src/ImageSharp/ColorProfiles/Y.cs @@ -92,7 +92,7 @@ public readonly struct Y : IColorProfile { Matrix4x4 m = options.YCbCrTransform.Forward; float offset = options.YCbCrTransform.Offset.X; - return new(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset); + return new(Vector3.Dot(source.AsVector3Unsafe(), new(m.M11, m.M12, m.M13)) + offset); } /// diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs index 22d629373..e112ef799 100644 --- a/src/ImageSharp/ColorProfiles/YCbCr.cs +++ b/src/ImageSharp/ColorProfiles/YCbCr.cs @@ -24,7 +24,7 @@ public readonly struct YCbCr : IColorProfile /// The cr chroma component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YCbCr(float y, float cb, float cr) - : this(new Vector3(y, cb, cr)) + : this(new(y, cb, cr)) { } @@ -95,7 +95,7 @@ public readonly struct YCbCr : IColorProfile { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new Vector4(v3, 1F); + return new(v3, 1F); } /// @@ -133,7 +133,7 @@ public readonly struct YCbCr : IColorProfile Matrix4x4 m = options.TransposedYCbCrTransform.Forward; Vector3 offset = options.TransposedYCbCrTransform.Offset; - return new YCbCr(Vector3.Transform(rgb, m) + offset, true); + return new(Vector3.Transform(rgb, m) + offset, true); } /// diff --git a/src/ImageSharp/ColorProfiles/YccK.cs b/src/ImageSharp/ColorProfiles/YccK.cs index df5eb4894..d0966a6d1 100644 --- a/src/ImageSharp/ColorProfiles/YccK.cs +++ b/src/ImageSharp/ColorProfiles/YccK.cs @@ -27,7 +27,7 @@ public readonly struct YccK : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YccK(float y, float cb, float cr, float k) - : this(new Vector4(y, cb, cr, k)) + : this(new(y, cb, cr, k)) { } @@ -149,11 +149,11 @@ public readonly struct YccK : IColorProfile if (k >= 1F - Constants.Epsilon) { - return new YccK(new Vector4(0F, 0.5F, 0.5F, 1F), true); + return new(new(0F, 0.5F, 0.5F, 1F), true); } rgb /= 1F - k; - return new YccK(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); + return new(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); } /// diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs index 6ed83a0d8..c20c6e9c9 100644 --- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs +++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs @@ -14,6 +14,6 @@ internal static class ConfigurationExtensions /// public static ParallelOptions GetParallelOptions(this Configuration configuration) { - return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + return new() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 5f91dcd99..0aa8e4a41 100644 --- a/src/ImageSharp/Common/Helpers/Numerics.cs +++ b/src/ImageSharp/Common/Helpers/Numerics.cs @@ -470,8 +470,8 @@ internal static class Numerics where T : unmanaged { ref T sRef = ref MemoryMarshal.GetReference(span); - var vmin = new Vector(min); - var vmax = new Vector(max); + Vector vmin = new(min); + Vector vmax = new(max); nint n = (nint)(uint)span.Length / Vector.Count; nint m = Modulo4(n); @@ -726,12 +726,12 @@ internal static class Numerics ref Vector128 vectors128Ref = ref Unsafe.As>(ref MemoryMarshal.GetReference(vectors)); ref Vector128 vectors128End = ref Unsafe.Add(ref vectors128Ref, (uint)vectors.Length); - var v128_341 = Vector128.Create(341); + Vector128 v128_341 = Vector128.Create(341); Vector128 v128_negativeZero = Vector128.Create(-0.0f).AsInt32(); Vector128 v128_one = Vector128.Create(1.0f).AsInt32(); - var v128_13rd = Vector128.Create(1 / 3f); - var v128_23rds = Vector128.Create(2 / 3f); + Vector128 v128_13rd = Vector128.Create(1 / 3f); + Vector128 v128_23rds = Vector128.Create(2 / 3f); while (Unsafe.IsAddressLessThan(ref vectors128Ref, ref vectors128End)) { diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs index f471d0231..80bfa29ca 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs @@ -134,7 +134,7 @@ internal static partial class SimdUtils ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); nuint count = (uint)redChannel.Length / 4; - destination.Fill(new Rgba32(0, 0, 0, 255)); + destination.Fill(new(0, 0, 0, 255)); for (nuint i = 0; i < count; i++) { ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 7f98c8375..883e18ae7 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -29,7 +29,7 @@ internal static partial class SimdUtils [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Vector4 PseudoRound(this Vector4 v) { - Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1)); + Vector4 sign = Numerics.Clamp(v, new(-1), new(1)); return v + (sign * 0.5f); } diff --git a/src/ImageSharp/Common/Helpers/UnitConverter.cs b/src/ImageSharp/Common/Helpers/UnitConverter.cs index 45dbe41cb..c50766ec2 100644 --- a/src/ImageSharp/Common/Helpers/UnitConverter.cs +++ b/src/ImageSharp/Common/Helpers/UnitConverter.cs @@ -131,9 +131,9 @@ internal static class UnitConverter ushort exifUnit = (ushort)(unit + 1); if (unit == PixelResolutionUnit.AspectRatio) { - return new ExifResolutionValues(exifUnit, null, null); + return new(exifUnit, null, null); } - return new ExifResolutionValues(exifUnit, horizontal, vertical); + return new(exifUnit, horizontal, vertical); } } diff --git a/src/ImageSharp/Compression/Zlib/Deflater.cs b/src/ImageSharp/Compression/Zlib/Deflater.cs index f642ec85a..2e39d435d 100644 --- a/src/ImageSharp/Compression/Zlib/Deflater.cs +++ b/src/ImageSharp/Compression/Zlib/Deflater.cs @@ -79,7 +79,7 @@ internal sealed class Deflater : IDisposable } // TODO: Possibly provide DeflateStrategy as an option. - this.engine = new DeflaterEngine(memoryAllocator, DeflateStrategy.Default); + this.engine = new(memoryAllocator, DeflateStrategy.Default); this.SetLevel(level); this.Reset(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs index 6009fdfbc..c9613610d 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs @@ -147,7 +147,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable /// The deflate strategy to use. public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy) { - this.huffman = new DeflaterHuffman(memoryAllocator); + this.huffman = new(memoryAllocator); this.Pending = this.huffman.Pending; this.strategy = strategy; diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index e4dc1945a..a05320a09 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -58,11 +58,11 @@ internal sealed unsafe class DeflaterHuffman : IDisposable /// The memory allocator to use for buffer allocations. public DeflaterHuffman(MemoryAllocator memoryAllocator) { - this.Pending = new DeflaterPendingBuffer(memoryAllocator); + this.Pending = new(memoryAllocator); - this.literalTree = new Tree(memoryAllocator, LiteralNumber, 257, 15); - this.distTree = new Tree(memoryAllocator, DistanceNumber, 1, 15); - this.blTree = new Tree(memoryAllocator, BitLengthNumber, 4, 7); + this.literalTree = new(memoryAllocator, LiteralNumber, 257, 15); + this.distTree = new(memoryAllocator, DistanceNumber, 1, 15); + this.blTree = new(memoryAllocator, BitLengthNumber, 4, 7); this.distanceMemoryOwner = memoryAllocator.Allocate(BufferSize); this.distanceBufferHandle = this.distanceMemoryOwner.Memory.Pin(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs index de818fd8f..76a5a045e 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs @@ -30,7 +30,7 @@ internal sealed class DeflaterOutputStream : Stream this.rawStream = rawStream; this.memoryOwner = memoryAllocator.Allocate(BufferLength); this.buffer = this.memoryOwner.Memory; - this.deflater = new Deflater(memoryAllocator, compressionLevel); + this.deflater = new(memoryAllocator, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs index 2e52f84d7..936444406 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs @@ -101,7 +101,7 @@ internal sealed class ZlibDeflateStream : Stream this.rawStream.WriteByte(Cmf); this.rawStream.WriteByte((byte)flg); - this.deflateStream = new DeflaterOutputStream(memoryAllocator, this.rawStream, compressionLevel); + this.deflateStream = new(memoryAllocator, this.rawStream, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs index 1d743bf3a..aa4beba18 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs @@ -270,7 +270,7 @@ internal sealed class ZlibInflateStream : Stream } // Initialize the deflate BufferedReadStream. - this.CompressedStream = new DeflateStream(this, CompressionMode.Decompress, true); + this.CompressedStream = new(this, CompressionMode.Decompress, true); return true; } diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index b9b32dede..acf69529a 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -132,7 +132,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore { int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette); - image = new Image(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); + image = new(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); @@ -220,7 +220,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadImageHeaders(stream, out _, out _); - return new ImageInfo(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata); + return new(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata); } /// @@ -343,7 +343,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -404,7 +404,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -1332,7 +1332,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore long infoHeaderStart = stream.Position; // Resolution is stored in PPM. - this.metadata = new ImageMetadata + this.metadata = new() { ResolutionUnits = PixelResolutionUnit.PixelsPerMeter }; @@ -1426,7 +1426,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore byte[] iccProfileData = new byte[this.infoHeader.ProfileSize]; stream.Position = infoHeaderStart + this.infoHeader.ProfileData; stream.Read(iccProfileData); - this.metadata.IccProfile = new IccProfile(iccProfileData); + this.metadata.IccProfile = new(iccProfileData); stream.Position = streamPosition; } } diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 46da46345..ba9a0dc23 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -655,7 +655,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() { MaxColors = 16, Dither = this.quantizer.Options.Dither, @@ -712,7 +712,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() { MaxColors = 4, Dither = this.quantizer.Options.Dither, @@ -778,7 +778,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() { MaxColors = 2, Dither = this.quantizer.Options.Dither, diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs index 1dac74ba3..3514a7ed5 100644 --- a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs +++ b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs @@ -54,21 +54,21 @@ public class BmpMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit1 }, - 2 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit2 }, - <= 4 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit4 }, - <= 8 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit8 }, - <= 16 => new BmpMetadata + 1 => new() { BitsPerPixel = BmpBitsPerPixel.Bit1 }, + 2 => new() { BitsPerPixel = BmpBitsPerPixel.Bit2 }, + <= 4 => new() { BitsPerPixel = BmpBitsPerPixel.Bit4 }, + <= 8 => new() { BitsPerPixel = BmpBitsPerPixel.Bit8 }, + <= 16 => new() { BitsPerPixel = BmpBitsPerPixel.Bit16, InfoHeaderType = BmpInfoHeaderType.WinVersion3 }, - <= 24 => new BmpMetadata + <= 24 => new() { BitsPerPixel = BmpBitsPerPixel.Bit24, InfoHeaderType = BmpInfoHeaderType.WinVersion4 }, - _ => new BmpMetadata + _ => new() { BitsPerPixel = BmpBitsPerPixel.Bit32, InfoHeaderType = BmpInfoHeaderType.WinVersion5 @@ -131,7 +131,7 @@ public class BmpMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs index 9854854aa..454f15b86 100644 --- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs @@ -73,7 +73,7 @@ public class CurFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new CurFrameMetadata + return new() { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -98,7 +98,7 @@ public class CurFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new CurFrameMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression, @@ -210,7 +210,7 @@ public class CurFrameMetadata : IFormatFrameMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurMetadata.cs b/src/ImageSharp/Formats/Cur/CurMetadata.cs index d8fdb3290..6499c5b42 100644 --- a/src/ImageSharp/Formats/Cur/CurMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurMetadata.cs @@ -68,7 +68,7 @@ public class CurMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new CurMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class CurMetadata : IFormatMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index f6e3643d5..e749cb1a3 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -266,7 +266,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowNoHeader(); } - return new ImageInfo( + return new( new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), this.metadata, framesMetadata); @@ -344,7 +344,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifXmpApplicationExtension extension = GifXmpApplicationExtension.Read(stream, this.memoryAllocator); if (extension.Data.Length > 0) { - this.metadata!.XmpProfile = new XmpProfile(extension.Data); + this.metadata!.XmpProfile = new(extension.Data); } else { @@ -549,7 +549,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (previousFrame is null && previousDisposalMode is null) { image = transFlag - ? new Image(this.configuration, imageWidth, imageHeight, this.metadata) + ? new(this.configuration, imageWidth, imageHeight, this.metadata) : new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata); this.SetFrameMetadata(image.Frames.RootFrame.Metadata); diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs index 77f600633..d6e9c780b 100644 --- a/src/ImageSharp/Formats/Gif/GifMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs @@ -87,7 +87,7 @@ public class GifMetadata : IFormatMetadata ? Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.GlobalColorTable.Value.Length), 1, 8) : 8; - return new PixelTypeInfo(bpp) + return new(bpp) { ColorType = PixelColorType.Indexed, ComponentInfo = PixelComponentInfo.Create(1, bpp, bpp), diff --git a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs index e41389675..4c2ffbe4d 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs @@ -22,7 +22,7 @@ internal readonly struct GifNetscapeLoopingApplicationExtension : IGifExtension public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan buffer) { ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer[..2]); - return new GifNetscapeLoopingApplicationExtension(repeatCount); + return new(repeatCount); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs index 1c1127c3b..b32f91205 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs @@ -42,7 +42,7 @@ internal readonly struct GifXmpApplicationExtension : IGifExtension stream.Skip(1); // Skip the terminator. } - return new GifXmpApplicationExtension(buffer); + return new(buffer); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs index 31f65133e..3afb02456 100644 --- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs @@ -66,7 +66,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new IcoFrameMetadata + return new() { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -91,7 +91,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new IcoFrameMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression, @@ -205,7 +205,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Ico/IcoMetadata.cs b/src/ImageSharp/Formats/Ico/IcoMetadata.cs index f8c2ff40f..4436dce85 100644 --- a/src/ImageSharp/Formats/Ico/IcoMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoMetadata.cs @@ -68,7 +68,7 @@ public class IcoMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new IcoMetadata + return new() { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class IcoMetadata : IFormatMetadata } } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 731ad0f76..754f1f8b4 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -140,7 +140,7 @@ internal partial struct Block8x8 /// public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append('['); for (int i = 0; i < Size; i++) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index efc1dbd72..1c0615ef5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -57,19 +57,19 @@ internal partial struct Block8x8F ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); - var xyLeft = new Vector4(sLeft.X); + Vector4 xyLeft = new Vector4(sLeft.X); xyLeft.Z = sLeft.Y; xyLeft.W = sLeft.Y; - var zwLeft = new Vector4(sLeft.Z); + Vector4 zwLeft = new Vector4(sLeft.Z); zwLeft.Z = sLeft.W; zwLeft.W = sLeft.W; - var xyRight = new Vector4(sRight.X); + Vector4 xyRight = new Vector4(sRight.X); xyRight.Z = sRight.Y; xyRight.W = sRight.Y; - var zwRight = new Vector4(sRight.Z); + Vector4 zwRight = new Vector4(sRight.Z); zwRight.Z = sRight.W; zwRight.W = sRight.W; diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs index 74227c7a6..7d236eeae 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs @@ -514,7 +514,7 @@ internal abstract partial class JpegColorConverterBase Span c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : []; Span c3 = this.Component3.Length > 0 ? this.Component3.Slice(start, length) : []; - return new ComponentValues(this.ComponentCount, c0, c1, c2, c3); + return new(this.ComponentCount, c0, c1, c2, c3); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs index cf2369b2c..5109b1862 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs @@ -71,7 +71,7 @@ internal readonly struct AdobeMarker : IEquatable short app14Flags1 = (short)((bytes[9] << 8) | bytes[10]); byte colorTransform = bytes[11]; - marker = new AdobeMarker(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); + marker = new(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index 6e83f5b2b..ba6276a5c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -242,7 +242,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index 9ee43a2c8..b43df4d97 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -116,7 +116,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new JpegBitReader(this.stream); + this.scanBuffer = new(this.stream); this.frame.AllocateComponents(); @@ -784,6 +784,6 @@ internal class HuffmanScanDecoder : IJpegScanDecoder public void BuildHuffmanTable(int type, int index, ReadOnlySpan codeLengths, ReadOnlySpan values, Span workspace) { HuffmanTable[] tables = type == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[index] = new HuffmanTable(codeLengths, values, workspace); + tables[index] = new(codeLengths, values, workspace); } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs index 7e25e945a..b31376992 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs @@ -80,7 +80,7 @@ internal readonly struct JFifMarker : IEquatable byte densityUnits = bytes[7]; short xDensity = (short)((bytes[8] << 8) | bytes[9]); short yDensity = (short)((bytes[10] << 8) | bytes[11]); - marker = new JFifMarker(majorVersion, minorVersion, densityUnits, xDensity, yDensity); + marker = new(majorVersion, minorVersion, densityUnits, xDensity, yDensity); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs index b2debf393..7e4a06d41 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs @@ -21,7 +21,7 @@ internal class JpegComponent : IDisposable, IJpegComponent this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); + this.SamplingFactors = new(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); this.QuantizationTableIndex = quantizationTableIndex; this.Index = index; @@ -109,7 +109,7 @@ internal class JpegComponent : IDisposable, IJpegComponent int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs index 0703e4d9e..5b77ab153 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs @@ -121,7 +121,7 @@ internal abstract class SpectralConverter if (scaledWidth >= tSize.Width && scaledHeight >= tSize.Height) { blockPixelSize = blockSize; - return new Size(scaledWidth, scaledHeight); + return new(scaledWidth, scaledHeight); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs index cc565c4d8..7398e97a0 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs @@ -19,7 +19,7 @@ internal class Component : IDisposable this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new Size(horizontalFactor, verticalFactor); + this.SamplingFactors = new(horizontalFactor, verticalFactor); this.QuantizationTableIndex = quantizationTableIndex; } @@ -95,7 +95,7 @@ internal class Component : IDisposable int blocksPerLineForMcu = frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index c33a8a196..1704ae1e7 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -241,7 +241,7 @@ internal class ComponentProcessor : IDisposable ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); nuint count = target.VectorCount(); - var multiplierVector = new Vector(multiplier); + Vector multiplierVector = new Vector(multiplier); for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 90e16f6df..857f2a1fe 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -134,7 +134,7 @@ internal class HuffmanScanEncoder public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig) { HuffmanLut[] tables = tableConfig.Class == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[tableConfig.DestinationIndex] = new HuffmanLut(tableConfig.Table); + tables[tableConfig.DestinationIndex] = new(tableConfig.Table); } /// @@ -409,7 +409,7 @@ internal class HuffmanScanEncoder { this.FlushRemainingBytes(); this.WriteRestart(restarts % 8); - foreach (var component in frame.Components) + foreach (Component component in frame.Components) { component.DcPredictor = 0; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs index 6ba0b8272..f8a3d6dd2 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs @@ -27,7 +27,7 @@ internal sealed class JpegFrame : IDisposable for (int i = 0; i < this.Components.Length; i++) { JpegComponentConfig componentConfig = componentConfigs[i]; - this.Components[i] = new Component(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) + this.Components[i] = new(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) { DcTableId = componentConfig.DcTableSelector, AcTableId = componentConfig.AcTableSelector, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs index baaa7213a..e97c57cd9 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs @@ -46,12 +46,12 @@ internal class SpectralConverter : SpectralConverter, IDisposable // component processors from spectral to Rgb24 const int blockPixelWidth = 8; this.alignedPixelWidth = majorBlockWidth * blockPixelWidth; - var postProcessorBufferSize = new Size(this.alignedPixelWidth, this.pixelRowsPerStep); + Size postProcessorBufferSize = new(this.alignedPixelWidth, this.pixelRowsPerStep); this.componentProcessors = new ComponentProcessor[frame.Components.Length]; for (int i = 0; i < this.componentProcessors.Length; i++) { Component component = frame.Components[i]; - this.componentProcessors[i] = new ComponentProcessor( + this.componentProcessors[i] = new( allocator, component, postProcessorBufferSize, @@ -119,7 +119,7 @@ internal class SpectralConverter : SpectralConverter, IDisposable bLane.Slice(paddingStartIndex).Fill(bLane[paddingStartIndex - 1]); // Convert from rgb24 to target pixel type - var values = new JpegColorConverterBase.ComponentValues(this.componentProcessors, y); + JpegColorConverterBase.ComponentValues values = new(this.componentProcessors, y); this.colorConverter.ConvertFromRgb(values, rLane, gLane, bLane); } diff --git a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs index c7212fc2d..c92c2e7bd 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs @@ -14,25 +14,25 @@ internal static class SizeExtensions /// Multiplies 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size MultiplyBy(this Size a, Size b) => new Size(a.Width * b.Width, a.Height * b.Height); + public static Size MultiplyBy(this Size a, Size b) => new(a.Width * b.Width, a.Height * b.Height); /// /// Divides 'a.Width' with 'b.Width' and 'a.Height' with 'b.Height'. /// TODO: Shouldn't we expose this as operator in SixLabors.Core? /// - public static Size DivideBy(this Size a, Size b) => new Size(a.Width / b.Width, a.Height / b.Height); + public static Size DivideBy(this Size a, Size b) => new(a.Width / b.Width, a.Height / b.Height); /// /// Divide Width and Height as real numbers and return the Ceiling. /// public static Size DivideRoundUp(this Size originalSize, int divX, int divY) { - var sizeVect = (Vector2)(SizeF)originalSize; + Vector2 sizeVect = (Vector2)(SizeF)originalSize; sizeVect /= new Vector2(divX, divY); sizeVect.X = MathF.Ceiling(sizeVect.X); sizeVect.Y = MathF.Ceiling(sizeVect.Y); - return new Size((int)sizeVect.X, (int)sizeVect.Y); + return new((int)sizeVect.X, (int)sizeVect.Y); } /// diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 0b2d3d67e..c9ac1e6bb 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -167,7 +167,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData int b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } // Found a marker. @@ -179,14 +179,14 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData b = stream.ReadByte(); if (b == -1) { - return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); + return new(JpegConstants.Markers.EOI, stream.Length - 2); } } // Found a valid marker. Exit loop if (b is not 0 and (< JpegConstants.Markers.RST0 or > JpegConstants.Markers.RST7)) { - return new JpegFileMarker((byte)(uint)b, stream.Position - 2); + return new((byte)(uint)b, stream.Position - 2); } } } @@ -205,7 +205,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData _ = this.Options.TryGetIccProfileForColorConversion(this.Metadata.IccProfile, out IccProfile profile); - return new Image( + return new( this.configuration, spectralConverter.GetPixelBuffer(profile, cancellationToken), this.Metadata); @@ -222,7 +222,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.InitDerivedMetadataProperties(); Size pixelSize = this.Frame.PixelSize; - return new ImageInfo(new(pixelSize.Width, pixelSize.Height), this.Metadata); + return new(new(pixelSize.Width, pixelSize.Height), this.Metadata); } /// @@ -233,7 +233,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The scan decoder. public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) { - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); this.QuantizationTables = new Block8x8F[4]; this.scanDecoder = scanDecoder; if (tableBytes.Length < 4) @@ -256,7 +256,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData // Read next marker. bytesRead = stream.Read(markerBuffer); - fileMarker = new JpegFileMarker(markerBuffer[1], (int)stream.Position - 2); + fileMarker = new(markerBuffer[1], (int)stream.Position - 2); while (fileMarker.Marker != JpegConstants.Markers.EOI || (fileMarker.Marker == JpegConstants.Markers.EOI && fileMarker.Invalid)) { @@ -300,7 +300,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowInvalidImageContentException("Not enough data to read marker"); } - fileMarker = new JpegFileMarker(markerBuffer[1], 0); + fileMarker = new(markerBuffer[1], 0); } } @@ -316,7 +316,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.scanDecoder ??= new HuffmanScanDecoder(stream, spectralConverter, cancellationToken); - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); Span markerBuffer = stackalloc byte[2]; @@ -529,7 +529,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData chars[i] = (char)read; } - metadata.Comments.Add(new JpegComData(chars)); + metadata.Comments.Add(new(chars)); } /// @@ -661,7 +661,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasExif) { - this.Metadata.ExifProfile = new ExifProfile(this.exifData); + this.Metadata.ExifProfile = new(this.exifData); } } @@ -685,7 +685,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData if (!this.skipMetadata && profile?.CheckIsValid() == true) { this.hasIcc = true; - this.Metadata ??= new ImageMetadata(); + this.Metadata ??= new(); this.Metadata.IccProfile = profile; } } @@ -697,7 +697,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasIptc) { - this.Metadata.IptcProfile = new IptcProfile(this.iptcData); + this.Metadata.IptcProfile = new(this.iptcData); } } @@ -708,7 +708,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasXmp) { - this.Metadata.XmpProfile = new XmpProfile(this.xmpData); + this.Metadata.XmpProfile = new(this.xmpData); } } @@ -992,7 +992,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The remaining bytes in the segment block. private void ProcessArithmeticTable(BufferedReadStream stream, int remaining) { - this.arithmeticDecodingTables ??= new List(4); + this.arithmeticDecodingTables ??= new(4); while (remaining > 0) { @@ -1242,7 +1242,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowNotSupportedComponentCount(componentCount); } - this.Frame = new JpegFrame(frameMarker, precision, frameWidth, frameHeight, componentCount); + this.Frame = new(frameMarker, precision, frameWidth, frameHeight, componentCount); this.Dimensions = new(frameWidth, frameHeight); this.Metadata.GetJpegMetadata().Progressive = this.Frame.Progressive; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs index 71f852a09..9a89eced2 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs @@ -13,15 +13,15 @@ internal sealed unsafe partial class JpegEncoderCore { private static JpegFrameConfig[] CreateFrameConfigs() { - var defaultLuminanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); - var defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); - var defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); - var defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); + JpegHuffmanTableConfig defaultLuminanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); + JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); + JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); + JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); - var defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); - var defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); + JpegQuantizationTableConfig defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); + JpegQuantizationTableConfig defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); - var yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] + JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] { defaultLuminanceHuffmanDC, defaultLuminanceHuffmanAC, @@ -29,7 +29,7 @@ internal sealed unsafe partial class JpegEncoderCore defaultChrominanceHuffmanAC, }; - var yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[] + JpegQuantizationTableConfig[] yCbCrQuantTableConfigs = new JpegQuantizationTableConfig[] { defaultLuminanceQuantTable, defaultChrominanceQuantTable, diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs index fe4855dc7..88bea3dc9 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs @@ -139,7 +139,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new JpegMetadata + return new() { ColorType = color, ChrominanceQuality = metadata.Quality, @@ -182,7 +182,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index 9d3dd3ea4..d2a2f661f 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -79,7 +79,7 @@ internal sealed class PbmDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ProcessHeader(stream); - return new ImageInfo( + return new( new(this.pixelSize.Width, this.pixelSize.Height), this.metadata); } @@ -171,9 +171,9 @@ internal sealed class PbmDecoderCore : ImageDecoderCore this.componentType = PbmComponentType.Bit; } - this.pixelSize = new Size(width, height); + this.pixelSize = new(width, height); this.Dimensions = this.pixelSize; - this.metadata = new ImageMetadata(); + this.metadata = new(); PbmMetadata meta = this.metadata.GetPbmMetadata(); meta.Encoding = this.encoding; meta.ColorType = this.colorType; diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index d852f3c8e..9045671fb 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -77,7 +77,7 @@ public class PbmMetadata : IFormatMetadata _ => PbmComponentType.Short }; - return new PbmMetadata + return new() { ColorType = color, ComponentType = componentType @@ -114,7 +114,7 @@ public class PbmMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index 8748d90fa..4ffd824c5 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -71,7 +71,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L8((byte)value); + rowSpan[x] = new((byte)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -107,7 +107,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new L16((ushort)value); + rowSpan[x] = new((ushort)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -154,7 +154,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new Rgb24((byte)red, (byte)green, (byte)blue); + rowSpan[x] = new((byte)red, (byte)green, (byte)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -201,7 +201,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new Rgb48((ushort)red, (ushort)green, (ushort)blue); + rowSpan[x] = new((ushort)red, (ushort)green, (ushort)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { diff --git a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs index 8af0ac8ca..a68b1cab4 100644 --- a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs +++ b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs @@ -50,7 +50,7 @@ internal readonly struct PngPhysical uint vResolution = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(4, 4)); byte unit = data[8]; - return new PngPhysical(hResolution, vResolution, unit); + return new(hResolution, vResolution, unit); } /// @@ -92,7 +92,7 @@ internal readonly struct PngPhysical break; } - return new PngPhysical(x, y, unitSpecifier); + return new(x, y, unitSpecifier); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index cfea0e602..b0adbe6c5 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -25,7 +25,7 @@ public sealed class PngDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new PngDecoderCore(new PngDecoderOptions() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new PngDecoderCore(new() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 0971c3ecf..577c15272 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -297,7 +297,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -497,7 +497,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); } break; @@ -525,7 +525,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowInvalidHeader(); } - return new ImageInfo(new(this.header.Width, this.header.Height), metadata, framesMetadata); + return new(new(this.header.Width, this.header.Height), metadata, framesMetadata); } finally { @@ -626,7 +626,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void InitializeImage(ImageMetadata metadata, FrameControl frameControl, out Image image) where TPixel : unmanaged, IPixel { - image = new Image(this.configuration, this.header.Width, this.header.Height, metadata); + image = new(this.configuration, this.header.Width, this.header.Height, metadata); PngFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetPngMetadata(); frameMetadata.FromChunk(in frameControl); @@ -1377,7 +1377,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (!TryReadTextChunkMetadata(baseMetadata, name, value)) { - metadata.TextData.Add(new PngTextData(name, value, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, value, string.Empty, string.Empty)); } } @@ -1418,7 +1418,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.Encoding, out string? uncompressed) && !TryReadTextChunkMetadata(baseMetadata, name, uncompressed)) { - metadata.TextData.Add(new PngTextData(name, uncompressed, string.Empty, string.Empty)); + metadata.TextData.Add(new(name, uncompressed, string.Empty, string.Empty)); } } @@ -1476,7 +1476,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore fullRange = null; } - metadata.CicpProfile = new CicpProfile(colorPrimaries, transferFunction, matrixCoefficients, fullRange); + metadata.CicpProfile = new(colorPrimaries, transferFunction, matrixCoefficients, fullRange); } /// @@ -1560,7 +1560,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore return false; } - MergeOrSetExifProfile(metadata, new ExifProfile(exifBlob), replaceExistingKeys: false); + MergeOrSetExifProfile(metadata, new(exifBlob), replaceExistingKeys: false); return true; } @@ -1594,7 +1594,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressZlibData(compressedData, this.maxUncompressedLength, out byte[] iccpProfileBytes)) { - metadata.IccProfile = new IccProfile(iccpProfileBytes); + metadata.IccProfile = new(iccpProfileBytes); } } @@ -1750,17 +1750,17 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.TranslatedEncoding, out string? uncompressed)) { - pngMetadata.TextData.Add(new PngTextData(keyword, uncompressed, language, translatedKeyword)); + pngMetadata.TextData.Add(new(keyword, uncompressed, language, translatedKeyword)); } } else if (IsXmpTextData(keywordBytes)) { - metadata.XmpProfile = new XmpProfile(data[dataStartIdx..].ToArray()); + metadata.XmpProfile = new(data[dataStartIdx..].ToArray()); } else { string value = PngConstants.TranslatedEncoding.GetString(data[dataStartIdx..]); - pngMetadata.TextData.Add(new PngTextData(keyword, value, language, translatedKeyword)); + pngMetadata.TextData.Add(new(keyword, value, language, translatedKeyword)); } } @@ -1950,14 +1950,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore type != PngChunkType.AnimationControl && type != PngChunkType.FrameControl) { - chunk = new PngChunk(length, type); + chunk = new(length, type); return true; } // A chunk might report a length that exceeds the length of the stream. // Take the minimum of the two values to ensure we don't read past the end of the stream. position = this.currentStream.Position; - chunk = new PngChunk( + chunk = new( length: (int)Math.Min(length, this.currentStream.Length - position), type: type, data: this.ReadChunkData(length)); diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index b8086cd6d..dd642cf6d 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -53,7 +53,7 @@ public class PngFrameMetadata : IFormatFrameMetadata /// The chunk to create an instance from. internal void FromChunk(in FrameControl frameControl) { - this.FrameDelay = new Rational(frameControl.DelayNumerator, frameControl.DelayDenominator); + this.FrameDelay = new(frameControl.DelayNumerator, frameControl.DelayDenominator); this.DisposalMode = frameControl.DisposalMode; this.BlendMode = frameControl.BlendMode; } diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 59ca3b17a..fcbb93bf0 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -209,7 +209,7 @@ public class PngMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs index 85fac7ea2..45f79c040 100644 --- a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs +++ b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs @@ -68,7 +68,7 @@ internal class QoiDecoderCore : ImageDecoderCore qoiMetadata.Channels = this.header.Channels; qoiMetadata.ColorSpace = this.header.ColorSpace; - return new ImageInfo(size, metadata); + return new(size, metadata); } /// @@ -124,7 +124,7 @@ internal class QoiDecoderCore : ImageDecoderCore ThrowInvalidImageContentException(); } - this.header = new QoiHeader(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); + this.header = new(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); } [DoesNotReturn] diff --git a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs index e463d511d..8f71ebeee 100644 --- a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs +++ b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs @@ -44,10 +44,10 @@ public class QoiMetadata : IFormatMetadata if (color.HasFlag(PixelColorType.Alpha)) { - return new QoiMetadata { Channels = QoiChannels.Rgba }; + return new() { Channels = QoiChannels.Rgba }; } - return new QoiMetadata { Channels = QoiChannels.Rgb }; + return new() { Channels = QoiChannels.Rgb }; } /// @@ -73,7 +73,7 @@ public class QoiMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index dc6b33422..59977ecbc 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -622,7 +622,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore else { byte alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; - color = TPixel.FromBgra32(new Bgra32(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); + color = TPixel.FromBgra32(new(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); } break; @@ -638,7 +638,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadFileHeader(stream); - return new ImageInfo( + return new( new(this.fileHeader.Width, this.fileHeader.Height), this.metadata); } @@ -705,7 +705,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore Guard.NotNull(this.tgaMetadata); byte alpha = this.tgaMetadata.AlphaChannelBits == 0 ? byte.MaxValue : scratchBuffer[3]; - pixelRow[x] = TPixel.FromBgra32(new Bgra32(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); + pixelRow[x] = TPixel.FromBgra32(new(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -907,9 +907,9 @@ internal sealed class TgaDecoderCore : ImageDecoderCore stream.Read(buffer, 0, TgaFileHeader.Size); this.fileHeader = TgaFileHeader.Parse(buffer); - this.Dimensions = new Size(this.fileHeader.Width, this.fileHeader.Height); + this.Dimensions = new(this.fileHeader.Width, this.fileHeader.Height); - this.metadata = new ImageMetadata(); + this.metadata = new(); this.tgaMetadata = this.metadata.GetTgaMetadata(); this.tgaMetadata.BitsPerPixel = (TgaBitsPerPixel)this.fileHeader.PixelDepth; diff --git a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs index ad76bc3fb..50d992030 100644 --- a/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs +++ b/src/ImageSharp/Formats/Tga/TgaImageFormatDetector.cs @@ -34,7 +34,7 @@ public sealed class TgaImageFormatDetector : IImageFormatDetector } // The third byte is the image type. - var imageType = (TgaImageType)header[2]; + TgaImageType imageType = (TgaImageType)header[2]; if (!imageType.IsValid()) { return false; diff --git a/src/ImageSharp/Formats/Tga/TgaMetadata.cs b/src/ImageSharp/Formats/Tga/TgaMetadata.cs index 8d40f8646..a7be538ec 100644 --- a/src/ImageSharp/Formats/Tga/TgaMetadata.cs +++ b/src/ImageSharp/Formats/Tga/TgaMetadata.cs @@ -41,10 +41,10 @@ public class TgaMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - <= 8 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit8 }, - <= 16 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit16 }, - <= 24 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit24 }, - _ => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit32 } + <= 8 => new() { BitsPerPixel = TgaBitsPerPixel.Bit8 }, + <= 16 => new() { BitsPerPixel = TgaBitsPerPixel.Bit16 }, + <= 24 => new() { BitsPerPixel = TgaBitsPerPixel.Bit24 }, + _ => new() { BitsPerPixel = TgaBitsPerPixel.Bit32 } }; } @@ -79,7 +79,7 @@ public class TgaMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs index 6881e3a7b..1d7de583f 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs @@ -29,7 +29,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor public override void CompressStrip(Span rows, int height) { this.memoryStream.Seek(0, SeekOrigin.Begin); - using (var stream = new ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) + using (ZlibDeflateStream stream = new ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) { if (this.Predictor == TiffPredictor.Horizontal) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs index a6242114e..7dfb60bad 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs @@ -20,7 +20,7 @@ internal sealed class LzwCompressor : TiffBaseCompressor public override TiffCompression Method => TiffCompression.Lzw; /// - public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new TiffLzwEncoder(this.Allocator); + public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new(this.Allocator); /// public override void CompressStrip(Span rows, int height) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs index 1c0a47365..4229cfada 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/PackBitsWriter.cs @@ -101,7 +101,7 @@ internal static class PackBitsWriter private static int FindRunLength(ReadOnlySpan rowSpan, int startPos, int maxRunLength) { - var startByte = rowSpan[startPos]; + byte startByte = rowSpan[startPos]; int count = 1; for (int i = startPos + 1; i < rowSpan.Length; i++) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs index 08faa539a..a2a83be0a 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs @@ -29,8 +29,8 @@ internal class TiffJpegCompressor : TiffBaseCompressor int pixelCount = rows.Length / 3; int width = pixelCount / height; - using var memoryStream = new MemoryStream(); - var image = Image.LoadPixelData(rows, width, height); + using MemoryStream memoryStream = new MemoryStream(); + Image image = Image.LoadPixelData(rows, width, height); image.Save(memoryStream, new JpegEncoder() { ColorType = JpegColorType.Rgb diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs index 64e702f1b..39c392815 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs @@ -54,7 +54,7 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { long pos = stream.Position; - using (var deframeStream = new ZlibInflateStream( + using (ZlibInflateStream deframeStream = new ZlibInflateStream( stream, () => { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index 5f18fc2d7..cad46e987 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; /// public class LzwString { - private static readonly LzwString Empty = new LzwString(0, 0, 0, null); + private static readonly LzwString Empty = new(0, 0, 0, null); private readonly LzwString previous; private readonly byte value; @@ -50,10 +50,10 @@ public class LzwString { if (this == Empty) { - return new LzwString(other); + return new(other); } - return new LzwString(other, this.FirstChar, this.Length + 1, this); + return new(other, this.FirstChar, this.Length + 1, this); } /// diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs index 240292718..beb22a2bb 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs @@ -48,7 +48,7 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var decoder = new TiffLzwDecoder(stream); + TiffLzwDecoder decoder = new TiffLzwDecoder(stream); decoder.DecodePixels(buffer); if (this.Predictor == TiffPredictor.Horizontal) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs index d2dbedc9c..f0ed12c41 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs @@ -41,7 +41,7 @@ internal sealed class ModifiedHuffmanTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - var bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount); + ModifiedHuffmanBitReader bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs index 6bdcad2b8..4d09f7b4e 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs @@ -60,7 +60,7 @@ internal sealed class T4TiffCompression : TiffBaseDecompressor } bool eolPadding = this.faxCompressionOptions.HasFlag(FaxCompressionOptions.EolPadding); - var bitReader = new T4BitReader(stream, this.FillOrder, byteCount, eolPadding); + T4BitReader bitReader = new T4BitReader(stream, this.FillOrder, byteCount, eolPadding); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index c868fec62..c0ec49d8e 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -57,9 +57,9 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor Span scanLine = scanLineBuffer.GetSpan()[..this.width]; Span referenceScanLineSpan = scanLineBuffer.GetSpan().Slice(this.width, this.width); - var bitReader = new T6BitReader(stream, this.FillOrder, byteCount); + T6BitReader bitReader = new(stream, this.FillOrder, byteCount); - var referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, this.width); + CcittReferenceScanline referenceScanLine = new(this.isWhiteZero, this.width); nint bitsWritten = 0; for (int y = 0; y < height; y++) { @@ -69,7 +69,7 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor bitsWritten = this.WriteScanLine(buffer, scanLine, bitsWritten); scanLine.CopyTo(referenceScanLineSpan); - referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, referenceScanLineSpan); + referenceScanLine = new(this.isWhiteZero, referenceScanLineSpan); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs index a53e1bc74..40278dca2 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs @@ -103,7 +103,7 @@ internal sealed class TiffLzwDecoder this.table = new LzwString[TableSize]; for (int i = 0; i < 256; i++) { - this.table[i] = new LzwString((byte)i); + this.table[i] = new((byte)i); } this.Init(); diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs index 76d0bb641..5f4ca12bd 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs @@ -32,7 +32,7 @@ internal class WebpTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - using WebpDecoderCore decoder = new(new WebpDecoderOptions() { GeneralOptions = this.options }); + using WebpDecoderCore decoder = new(new() { GeneralOptions = this.options }); using Image image = decoder.Decode(this.options.Configuration, stream, cancellationToken); CopyImageBytesToBuffer(buffer, image.Frames.RootFrame.PixelBuffer); } diff --git a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs index 706e6a38c..ebf4042e2 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs @@ -222,7 +222,7 @@ internal static class HorizontalPredictor byte r = (byte)(rowRgb[x].R - rowRgb[x - 1].R); byte g = (byte)(rowRgb[x].G - rowRgb[x - 1].G); byte b = (byte)(rowRgb[x].B - rowRgb[x - 1].B); - rowRgb[x] = new Rgb24(r, g, b); + rowRgb[x] = new(r, g, b); } } } @@ -429,7 +429,7 @@ internal static class HorizontalPredictor r += pixel.R; g += pixel.G; b += pixel.B; - pixel = new Rgb24(r, g, b); + pixel = new(r, g, b); } } @@ -462,7 +462,7 @@ internal static class HorizontalPredictor g += pixel.G; b += pixel.B; a += pixel.A; - pixel = new Rgba32(r, g, b, a); + pixel = new(r, g, b, a); } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs index ac316459d..b30700adb 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ internal class BlackIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder : TiffBaseColorDecoder Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); for (int x = 0; x < pixelRow.Length; x++) { - pixelRow[x] = TPixel.FromVector4(new Vector4(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); + pixelRow[x] = TPixel.FromVector4(new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); offset += 3; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs index 3c205d147..2b85c2fd6 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs @@ -52,7 +52,7 @@ internal class RgbTiffColor : TiffBaseColorDecoder float g = bitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs index 7d31f23ab..0db555cbb 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs @@ -50,7 +50,7 @@ internal class WhiteIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = 1f - (value / this.factor); - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 0a1cf6ab9..754cbd005 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -45,10 +45,10 @@ internal class YCbCrConverter TiffThrowHelper.ThrowImageFormatException("luma coefficients array should have 6 entry's"); } - this.yExpander = new CodingRangeExpander(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); - this.cbExpander = new CodingRangeExpander(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); - this.crExpander = new CodingRangeExpander(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); - this.converter = new YCbCrToRgbConverter(coefficients[0], coefficients[1], coefficients[2]); + this.yExpander = new(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); + this.cbExpander = new(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); + this.crExpander = new(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); + this.converter = new(coefficients[0], coefficients[1], coefficients[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -107,7 +107,7 @@ internal class YCbCrConverter [MethodImpl(MethodImplOptions.AggressiveInlining)] public Rgba32 Convert(float y, float cb, float cr) { - var pixel = default(Rgba32); + Rgba32 pixel = default(Rgba32); pixel.R = RoundAndClampTo8Bit((cr * this.cr2R) + y); pixel.G = RoundAndClampTo8Bit((this.y2G * y) + (this.cr2G * cr) + (this.cb2G * cb)); pixel.B = RoundAndClampTo8Bit((cb * this.cb2B) + y); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs index 768177bfc..ebae82430 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs @@ -20,7 +20,7 @@ internal class YCbCrPlanarTiffColor : TiffBasePlanarColorDecoder public YCbCrPlanarTiffColor(Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs index 5a1389035..3bf550fe5 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs @@ -24,7 +24,7 @@ internal class YCbCrTiffColor : TiffBaseColorDecoder public YCbCrTiffColor(MemoryAllocator memoryAllocator, Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { this.memoryAllocator = memoryAllocator; - this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); + this.converter = new(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs index 2bfd9a626..e9b620ea2 100644 --- a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs +++ b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs @@ -120,7 +120,7 @@ public readonly struct TiffBitsPerSample : IEquatable break; } - sample = new TiffBitsPerSample(c0, c1, c2, c3); + sample = new(c0, c1, c2, c3); return true; } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index e594ee812..73f66a062 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -191,7 +191,7 @@ internal class TiffDecoderCore : ImageDecoderCore this.Dimensions = frames[0].Size; ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new Image(this.configuration, metadata, frames); + return new(this.configuration, metadata, frames); } catch { @@ -228,7 +228,7 @@ internal class TiffDecoderCore : ImageDecoderCore ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new ImageInfo(new(width, height), metadata, framesMetadata); + return new(new(width, height), metadata, framesMetadata); } /// @@ -285,7 +285,7 @@ internal class TiffDecoderCore : ImageDecoderCore // We resolve the ICC profile early so that we can use it for color conversion if needed. if (tags.TryGetValue(ExifTag.IccProfile, out IExifValue iccProfileBytes)) { - imageFrameMetaData.IccProfile = new IccProfile(iccProfileBytes.Value); + imageFrameMetaData.IccProfile = new(iccProfileBytes.Value); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs index ebf407f9b..db27854a1 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs @@ -33,12 +33,12 @@ internal static class TiffDecoderMetadataCreator ImageFrameMetadata frameMetaData = frames[i]; if (TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes)) { - frameMetaData.IptcProfile = new IptcProfile(iptcBytes); + frameMetaData.IptcProfile = new(iptcBytes); } if (frameMetaData.ExifProfile.TryGetValue(ExifTag.XMP, out IExifValue xmpProfileBytes)) { - frameMetaData.XmpProfile = new XmpProfile(xmpProfileBytes.Value); + frameMetaData.XmpProfile = new(xmpProfileBytes.Value); } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 7519871b7..958399454 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -531,7 +531,7 @@ internal static class TiffDecoderOptionsParser // Some encoders do not set the BitsPerSample correctly, so we set those values here to the required values: // https://github.com/SixLabors/ImageSharp/issues/2587 - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -549,7 +549,7 @@ internal static class TiffDecoderOptionsParser options.FaxCompressionOptions = FaxCompressionOptions.None; } - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; @@ -557,7 +557,7 @@ internal static class TiffDecoderOptionsParser case TiffCompression.Ccitt1D: options.CompressionType = TiffDecoderCompressionType.HuffmanRle; - options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); + options.BitsPerSample = new(1, 0, 0); options.BitsPerPixel = 1; break; diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index 803b77fb0..8890c61a5 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs @@ -16,7 +16,7 @@ internal class TiffEncoderEntriesCollector { private const string SoftwareValue = "ImageSharp"; - public List Entries { get; } = new List(); + public List Entries { get; } = new(); public void ProcessMetadata(Image image, bool skipMetadata) => new MetadataProcessor(this).Process(image, skipMetadata); @@ -298,12 +298,12 @@ internal class TiffEncoderEntriesCollector { this.Collector.AddOrReplace(new ExifRational(ExifTagValue.XResolution) { - Value = new Rational(resolution.HorizontalResolution.Value) + Value = new(resolution.HorizontalResolution.Value) }); this.Collector.AddOrReplace(new ExifRational(ExifTagValue.YResolution) { - Value = new Rational(resolution.VerticalResolution.Value) + Value = new(resolution.VerticalResolution.Value) }); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs index e965fcb4f..7d2056469 100644 --- a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs @@ -75,7 +75,7 @@ public class TiffMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new TiffMetadata + 1 => new() { BitsPerPixel = TiffBitsPerPixel.Bit1, BitsPerSample = TiffConstants.BitsPerSample1Bit, @@ -83,7 +83,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.CcittGroup4Fax, Predictor = TiffPredictor.None }, - <= 4 => new TiffMetadata + <= 4 => new() { BitsPerPixel = TiffBitsPerPixel.Bit4, BitsPerSample = TiffConstants.BitsPerSample4Bit, @@ -91,7 +91,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.None // Best match for low bit depth }, - 8 => new TiffMetadata + 8 => new() { BitsPerPixel = TiffBitsPerPixel.Bit8, BitsPerSample = TiffConstants.BitsPerSample8Bit, @@ -99,7 +99,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 16 => new TiffMetadata + 16 => new() { BitsPerPixel = TiffBitsPerPixel.Bit16, BitsPerSample = TiffConstants.BitsPerSample16Bit, @@ -107,7 +107,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 32 or 64 => new TiffMetadata + 32 or 64 => new() { BitsPerPixel = TiffBitsPerPixel.Bit32, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -115,7 +115,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - _ => new TiffMetadata + _ => new() { BitsPerPixel = TiffBitsPerPixel.Bit24, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -165,7 +165,7 @@ public class TiffMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { ColorType = colorType, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs index 647ff8a1a..8ede73279 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs @@ -30,7 +30,7 @@ internal sealed class TiffBiColorWriter : TiffBaseColorWriter : base(image, encodingSize, memoryAllocator, configuration, entriesCollector) { // Convert image to black and white. - this.imageBlackWhite = new Image(configuration, new ImageMetadata(), [image.Clone()]); + this.imageBlackWhite = new(configuration, new(), [image.Clone()]); this.imageBlackWhite.Mutate(img => img.BinaryDither(KnownDitherings.FloydSteinberg)); } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs index da6637363..a6106ae85 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs @@ -44,13 +44,13 @@ internal sealed class TiffPaletteWriter : TiffBaseColorWriter this.colorPaletteBytes = this.colorPaletteSize * 2; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer( this.Configuration, - new QuantizerOptions() + new() { MaxColors = this.maxColors }); frameQuantizer.BuildPalette(pixelSamplingStrategy, frame); - this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new Rectangle(Point.Empty, encodingSize)); + this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new(Point.Empty, encodingSize)); this.AddColorMapTag(); } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index c7ce12fc7..f374daba4 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -56,12 +56,12 @@ internal class AlphaDecoder : IDisposable this.Alpha = memoryAllocator.Allocate(totalPixels); this.AlphaFilterType = (WebpAlphaFilterType)filter; - this.Vp8LDec = new Vp8LDecoder(width, height, memoryAllocator); + this.Vp8LDec = new(width, height, memoryAllocator); if (this.Compressed) { - Vp8LBitReader bitReader = new Vp8LBitReader(data); - this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration); + Vp8LBitReader bitReader = new(data); + this.LosslessDecoder = new(bitReader, memoryAllocator, configuration); this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true); // Special case: if alpha data uses only the color indexing transform and diff --git a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs index fd6f508e4..56587da18 100644 --- a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs @@ -92,7 +92,7 @@ internal static class AlphaEncoder for (int x = 0; x < width; x++) { // Leave A/R/B channels zero'd. - pixelRow[x] = new Bgra32(0, alphaRow[x], 0, 0); + pixelRow[x] = new(0, alphaRow[x], 0, 0); } } diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs index dc867fa85..0b71a3ed0 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs @@ -102,7 +102,7 @@ internal class Vp8LBitWriter : BitWriterBase { byte[] clonedBuffer = new byte[this.Buffer.Length]; System.Buffer.BlockCopy(this.Buffer, 0, clonedBuffer, 0, this.cur); - return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur); + return new(clonedBuffer, this.bits, this.used, this.cur); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index 274d4426f..bac6d5167 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -72,7 +72,7 @@ internal static class BackwardReferenceEncoder BackwardReferencesLz77(width, height, bgra, 0, hashChain, worst); break; case Vp8LLz77Type.Lz77Box: - hashChainBox = new Vp8LHashChain(memoryAllocator, width * height); + hashChainBox = new(memoryAllocator, width * height); BackwardReferencesLz77Box(width, height, bgra, 0, hashChain, hashChainBox, worst); break; } @@ -145,7 +145,7 @@ internal static class BackwardReferenceEncoder for (int i = 0; i < colorCache.Length; i++) { histos[i].PaletteCodeBits = i; - colorCache[i] = new ColorCache(i); + colorCache[i] = new(i); } // Find the cacheBits giving the lowest entropy. @@ -281,7 +281,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } costModel.Build(xSize, cacheBits, refs); @@ -383,7 +383,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } backwardRefs.Clear(); @@ -475,7 +475,7 @@ internal static class BackwardReferenceEncoder ColorCache? colorCache = null; if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } refs.Clear(); @@ -730,7 +730,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new ColorCache(cacheBits); + colorCache = new(cacheBits); } refs.Clear(); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs index 63ce9dbec..2b2286e04 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs @@ -17,21 +17,21 @@ internal sealed class CostManager : IDisposable private const int FreeIntervalsStartCount = 25; - private readonly Stack freeIntervals = new Stack(FreeIntervalsStartCount); + private readonly Stack freeIntervals = new(FreeIntervalsStartCount); public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner distArray, int pixCount, CostModel costModel) { int costCacheSize = pixCount > BackwardReferenceEncoder.MaxLength ? BackwardReferenceEncoder.MaxLength : pixCount; - this.CacheIntervals = new List(); - this.CostCache = new List(); + this.CacheIntervals = new(); + this.CostCache = new(); this.Costs = memoryAllocator.Allocate(pixCount); this.DistArray = distArray; this.Count = 0; for (int i = 0; i < FreeIntervalsStartCount; i++) { - this.freeIntervals.Push(new CostInterval()); + this.freeIntervals.Push(new()); } // Fill in the cost cache. @@ -49,7 +49,7 @@ internal sealed class CostManager : IDisposable } // Fill in the cache intervals. - var cur = new CostCacheInterval() + CostCacheInterval cur = new() { Start = 0, End = 1, @@ -62,7 +62,7 @@ internal sealed class CostManager : IDisposable double costVal = this.CostCache[i]; if (costVal != cur.Cost) { - cur = new CostCacheInterval() + cur = new() { Start = i, Cost = costVal @@ -258,7 +258,7 @@ internal sealed class CostManager : IDisposable } else { - intervalNew = new CostInterval() { Cost = cost, Start = start, End = end, Index = position }; + intervalNew = new() { Cost = cost, Start = start, End = end, Index = position }; } this.PositionOrphanInterval(intervalNew, intervalIn); diff --git a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs index 5806ee5b5..1375218da 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs @@ -15,7 +15,7 @@ internal struct HTreeGroup { public HTreeGroup(uint packedTableSize) { - this.HTrees = new List(WebpConstants.HuffmanCodesPerMetaCode); + this.HTrees = new(WebpConstants.HuffmanCodesPerMetaCode); this.PackedTable = new HuffmanCode[packedTableSize]; this.IsTrivialCode = false; this.IsTrivialLiteral = false; diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index 027d4f7ee..fd5d1dd94 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -425,7 +425,7 @@ internal static class HuffmanUtils tableSize = 1 << tableBits; totalSize += tableSize; low = key & mask; - table[low] = new HuffmanCode + table[low] = new() { BitsUsed = tableBits + rootBits, Value = (uint)(tablePos - low) diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 736070a1c..19dc08fc5 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -122,8 +122,8 @@ internal static unsafe class PredictorEncoder int tileYSize = LosslessUtils.SubSampleSize(height, bits); int[] accumulatedRedHisto = new int[256]; int[] accumulatedBlueHisto = new int[256]; - var prevX = default(Vp8LMultipliers); - var prevY = default(Vp8LMultipliers); + Vp8LMultipliers prevX = default(Vp8LMultipliers); + Vp8LMultipliers prevY = default(Vp8LMultipliers); for (int tileY = 0; tileY < tileYSize; tileY++) { for (int tileX = 0; tileX < tileXSize; tileX++) @@ -856,7 +856,7 @@ internal static unsafe class PredictorEncoder int tileHeight = allYMax - tileYOffset; Span tileArgb = argb[((tileYOffset * xSize) + tileXOffset)..]; - var bestTx = default(Vp8LMultipliers); + Vp8LMultipliers bestTx = default(Vp8LMultipliers); GetBestGreenToRed(tileArgb, xSize, scratch, tileWidth, tileHeight, prevX, prevY, quality, accumulatedRedHisto, ref bestTx); diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs index 374465cf7..c22abd83e 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs @@ -22,7 +22,7 @@ internal class Vp8LDecoder : IDisposable { this.Width = width; this.Height = height; - this.Metadata = new Vp8LMetadata(); + this.Metadata = new(); this.Pixels = memoryAllocator.Allocate(width * height, AllocationOptions.Clean); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index b398554eb..2cbe4bbb6 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -124,16 +124,16 @@ internal class Vp8LEncoder : IDisposable this.transparentColorMode = transparentColorMode; this.nearLossless = nearLossless; this.nearLosslessQuality = Numerics.Clamp(nearLosslessQuality, 0, 100); - this.bitWriter = new Vp8LBitWriter(initialSize); + this.bitWriter = new(initialSize); this.Bgra = memoryAllocator.Allocate(pixelCount); this.EncodedData = memoryAllocator.Allocate(pixelCount); this.Palette = memoryAllocator.Allocate(WebpConstants.MaxPaletteSize); this.Refs = new Vp8LBackwardRefs[3]; - this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); + this.HashChain = new(memoryAllocator, pixelCount); for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount); + this.Refs[i] = new(memoryAllocator, pixelCount); } } @@ -549,14 +549,14 @@ internal class Vp8LEncoder : IDisposable // We can only apply kPalette or kPaletteAndSpatial if we can indeed use a palette. if ((entropyIx != EntropyIx.Palette && entropyIx != EntropyIx.PaletteAndSpatial) || usePalette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIx }); } } } else { // Only choose the guessed best transform. - crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIdx }); + crunchConfigs.Add(new() { EntropyIdx = entropyIdx }); if (this.quality >= 75 && this.method == WebpEncodingMethod.Level5) { // Test with and without color cache. @@ -565,7 +565,7 @@ internal class Vp8LEncoder : IDisposable // If we have a palette, also check in combination with spatial. if (entropyIdx == EntropyIx.Palette) { - crunchConfigs.Add(new CrunchConfig { EntropyIdx = EntropyIx.PaletteAndSpatial }); + crunchConfigs.Add(new() { EntropyIdx = EntropyIx.PaletteAndSpatial }); } } } @@ -575,7 +575,7 @@ internal class Vp8LEncoder : IDisposable { for (int j = 0; j < nlz77s; j++) { - crunchConfig.SubConfigs.Add(new CrunchSubConfig + crunchConfig.SubConfigs.Add(new() { Lz77 = j == 0 ? (int)Vp8LLz77Type.Lz77Standard | (int)Vp8LLz77Type.Lz77Rle : (int)Vp8LLz77Type.Lz77Box, DoNotCache = doNotCache @@ -712,7 +712,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } for (int i = 0; i < 5 * histogramImageSize; i++) @@ -858,7 +858,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new HuffmanTreeToken(); + tokens[i] = new(); } // Store Huffman codes. diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 03bedfe67..5b3ecc7f5 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -613,7 +613,7 @@ internal sealed unsafe class OwnedVp8LHistogram : Vp8LHistogram, IDisposable { IMemoryOwner bufferOwner = memoryAllocator.Allocate(BufferSize, AllocationOptions.Clean); MemoryHandle bufferHandle = bufferOwner.Memory.Pin(); - return new OwnedVp8LHistogram(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); + return new(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs index a46838ee6..68b52f22b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs @@ -25,7 +25,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), cacheBits)); @@ -41,7 +41,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new List(capacity); + this.items = new(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), refs, cacheBits)); diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index 6de3ae749..af26616cc 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -108,7 +108,7 @@ internal sealed class WebpLosslessDecoder int numberOfTransformsPresent = 0; if (isLevel0) { - decoder.Transforms = new List(WebpConstants.MaxNumberOfTransforms); + decoder.Transforms = new(WebpConstants.MaxNumberOfTransforms); // Next bit indicates, if a transformation is present. while (this.bitReader.ReadBit()) @@ -129,7 +129,7 @@ internal sealed class WebpLosslessDecoder } else { - decoder.Metadata = new Vp8LMetadata(); + decoder.Metadata = new(); } // Color cache. @@ -156,7 +156,7 @@ internal sealed class WebpLosslessDecoder // Finish setting up the color-cache. if (isColorCachePresent) { - decoder.Metadata.ColorCache = new ColorCache(colorCacheBits); + decoder.Metadata.ColorCache = new(colorCacheBits); colorCacheSize = 1 << colorCacheBits; decoder.Metadata.ColorCacheSize = colorCacheSize; } @@ -416,7 +416,7 @@ internal sealed class WebpLosslessDecoder int[] codeLengths = new int[maxAlphabetSize]; for (int i = 0; i < numHTreeGroupsMax; i++) { - hTreeGroups[i] = new HTreeGroup(HuffmanUtils.HuffmanPackedTableSize); + hTreeGroups[i] = new(HuffmanUtils.HuffmanPackedTableSize); HTreeGroup hTreeGroup = hTreeGroups[i]; int totalSize = 0; bool isTrivialLiteral = true; diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index e9eb1110b..31030adb0 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -36,8 +36,8 @@ internal static unsafe class QuantEnc int tlambda = dqm.TLambda; Span src = it.YuvIn.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdTmp = new Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); Vp8ModeScore rdCur = rdTmp; Vp8ModeScore rdBest = rd; int mode; @@ -107,7 +107,7 @@ internal static unsafe class QuantEnc Span bestBlocks = it.YuvOut2.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; int totalHeaderBits = 0; - var rdBest = new Vp8ModeScore(); + Vp8ModeScore rdBest = new Vp8ModeScore(); if (maxI4HeaderBits == 0) { @@ -118,9 +118,9 @@ internal static unsafe class QuantEnc rdBest.H = 211; // '211' is the value of VP8BitCost(0, 145) rdBest.SetRdScore(dqm.LambdaMode); it.StartI4(); - var rdi4 = new Vp8ModeScore(); - var rdTmp = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdi4 = new Vp8ModeScore(); + Vp8ModeScore rdTmp = new Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); Span tmpLevels = stackalloc short[16]; do { @@ -220,9 +220,9 @@ internal static unsafe class QuantEnc Span tmpDst = it.YuvOut2.AsSpan(Vp8EncIterator.UOffEnc); Span dst0 = it.YuvOut.AsSpan(Vp8EncIterator.UOffEnc); Span dst = dst0; - var rdBest = new Vp8ModeScore(); - var rdUv = new Vp8ModeScore(); - var res = new Vp8Residual(); + Vp8ModeScore rdBest = new Vp8ModeScore(); + Vp8ModeScore rdUv = new Vp8ModeScore(); + Vp8Residual res = new Vp8Residual(); int mode; rd.ModeUv = -1; @@ -628,7 +628,7 @@ internal static unsafe class QuantEnc Vector128 out8 = Sse2.PackSignedSaturate(out08.AsInt32(), out12.AsInt32()); // if (coeff > 2047) coeff = 2047 - var maxCoeff2047 = Vector128.Create((short)MaxLevel); + Vector128 maxCoeff2047 = Vector128.Create((short)MaxLevel); out0 = Sse2.Min(out0, maxCoeff2047); out8 = Sse2.Min(out8, maxCoeff2047); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs index 90506efb8..0c25fb4e4 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs @@ -16,7 +16,7 @@ internal class Vp8BandProbas this.Probabilities = new Vp8ProbaArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Probabilities[i] = new Vp8ProbaArray(); + this.Probabilities[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs index eee22159e..a0fe03486 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs @@ -13,7 +13,7 @@ internal class Vp8Costs this.Costs = new Vp8CostArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Costs[i] = new Vp8CostArray(); + this.Costs[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs index 3c8bafa1b..cd9a0dea2 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs @@ -25,7 +25,7 @@ internal class Vp8Decoder : IDisposable /// Used for allocating memory for the pixel data output and the temporary buffers. public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities, MemoryAllocator memoryAllocator) { - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); this.FrameHeader = frameHeader; this.PictureHeader = pictureHeader; this.SegmentHeader = segmentHeader; @@ -41,22 +41,22 @@ internal class Vp8Decoder : IDisposable this.FilterInfo = new Vp8FilterInfo[this.MbWidth]; for (int i = 0; i < this.MbWidth; i++) { - this.MacroBlockInfo[i] = new Vp8MacroBlock(); - this.MacroBlockData[i] = new Vp8MacroBlockData(); - this.YuvTopSamples[i] = new Vp8TopSamples(); - this.FilterInfo[i] = new Vp8FilterInfo(); + this.MacroBlockInfo[i] = new(); + this.MacroBlockData[i] = new(); + this.YuvTopSamples[i] = new(); + this.FilterInfo[i] = new(); } - this.MacroBlockInfo[this.MbWidth] = new Vp8MacroBlock(); + this.MacroBlockInfo[this.MbWidth] = new(); this.DeQuantMatrices = new Vp8QuantMatrix[WebpConstants.NumMbSegments]; this.FilterStrength = new Vp8FilterInfo[WebpConstants.NumMbSegments, 2]; for (int i = 0; i < WebpConstants.NumMbSegments; i++) { - this.DeQuantMatrices[i] = new Vp8QuantMatrix(); + this.DeQuantMatrices[i] = new(); for (int j = 0; j < 2; j++) { - this.FilterStrength[i, j] = new Vp8FilterInfo(); + this.FilterStrength[i, j] = new(); } } @@ -245,7 +245,7 @@ internal class Vp8Decoder : IDisposable public Vp8MacroBlock CurrentMacroBlock => this.MacroBlockInfo[this.MbX]; - public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new Vp8MacroBlock(); + public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new(); public Vp8MacroBlockData CurrentBlockData => this.MacroBlockData[this.MbX]; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index 52c7e9703..7f57c81f8 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -396,7 +396,7 @@ internal class Vp8EncIterator this.MakeLuma16Preds(); for (mode = 0; mode < maxMode; mode++) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(YOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8I16ModeOffsets[mode]), 0, 16); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) @@ -414,7 +414,7 @@ internal class Vp8EncIterator { Span modes = stackalloc byte[16]; const int maxMode = MaxIntra4Mode; - Vp8Histogram totalHisto = new Vp8Histogram(); + Vp8Histogram totalHisto = new(); int curHisto = 0; this.StartI4(); do @@ -427,7 +427,7 @@ internal class Vp8EncIterator this.MakeIntra4Preds(); for (mode = 0; mode < maxMode; ++mode) { - histos[curHisto] = new Vp8Histogram(); + histos[curHisto] = new(); histos[curHisto].CollectHistogram(src, this.YuvP.AsSpan(Vp8Encoding.Vp8I4ModeOffsets[mode]), 0, 1); int alpha = histos[curHisto].GetAlpha(); @@ -467,7 +467,7 @@ internal class Vp8EncIterator this.MakeChroma8Preds(); for (mode = 0; mode < maxMode; ++mode) { - Vp8Histogram histo = new Vp8Histogram(); + Vp8Histogram histo = new(); histo.CollectHistogram(this.YuvIn.AsSpan(UOffEnc), this.YuvP.AsSpan(Vp8Encoding.Vp8UvModeOffsets[mode]), 16, 16 + 4 + 4); int alpha = histo.GetAlpha(); if (alpha > bestAlpha) diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs index 070e70574..a6faddc04 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs @@ -29,7 +29,7 @@ internal class Vp8EncProba this.Coeffs[i] = new Vp8BandProbas[WebpConstants.NumBands]; for (int j = 0; j < this.Coeffs[i].Length; j++) { - this.Coeffs[i][j] = new Vp8BandProbas(); + this.Coeffs[i][j] = new(); } } @@ -39,7 +39,7 @@ internal class Vp8EncProba this.Stats[i] = new Vp8Stats[WebpConstants.NumBands]; for (int j = 0; j < this.Stats[i].Length; j++) { - this.Stats[i][j] = new Vp8Stats(); + this.Stats[i][j] = new(); } } @@ -49,7 +49,7 @@ internal class Vp8EncProba this.LevelCost[i] = new Vp8Costs[WebpConstants.NumBands]; for (int j = 0; j < this.LevelCost[i].Length; j++) { - this.LevelCost[i][j] = new Vp8Costs(); + this.LevelCost[i][j] = new(); } } @@ -59,7 +59,7 @@ internal class Vp8EncProba this.RemappedCosts[i] = new Vp8Costs[16]; for (int j = 0; j < this.RemappedCosts[i].Length; j++) { - this.RemappedCosts[i][j] = new Vp8Costs(); + this.RemappedCosts[i][j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index e4ebe1473..608c5391b 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -172,19 +172,19 @@ internal class Vp8Encoder : IDisposable this.MbInfo = new Vp8MacroBlockInfo[this.Mbw * this.Mbh]; for (int i = 0; i < this.MbInfo.Length; i++) { - this.MbInfo[i] = new Vp8MacroBlockInfo(); + this.MbInfo[i] = new(); } this.SegmentInfos = new Vp8SegmentInfo[4]; for (int i = 0; i < 4; i++) { - this.SegmentInfos[i] = new Vp8SegmentInfo(); + this.SegmentInfos[i] = new(); } - this.FilterHeader = new Vp8FilterHeader(); + this.FilterHeader = new(); int predSize = (((4 * this.Mbw) + 1) * ((4 * this.Mbh) + 1)) + this.PredsWidth + 1; this.PredsWidth = (4 * this.Mbw) + 1; - this.Proba = new Vp8EncProba(); + this.Proba = new(); this.Preds = new byte[predSize + this.PredsWidth + this.Mbw]; // Initialize with default values, which the reference c implementation uses, @@ -424,14 +424,14 @@ internal class Vp8Encoder : IDisposable this.uvAlpha /= totalMb; // Analysis is done, proceed to actual encoding. - this.SegmentHeader = new Vp8EncSegmentHeader(4); + this.SegmentHeader = new(4); this.AssignSegments(alphas); this.SetLoopParams(this.quality); // Initialize the bitwriter. int averageBytesPerMacroBlock = AverageBytesPerMb[this.BaseQuant >> 4]; int expectedSize = this.Mbw * this.Mbh * averageBytesPerMacroBlock; - this.bitWriter = new Vp8BitWriter(expectedSize, this); + this.bitWriter = new(expectedSize, this); // Stats-collection loop. this.StatLoop(width, height, yStride, uvStride); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs index 0da6dfcad..de03f3c93 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs @@ -23,7 +23,7 @@ internal class Vp8Proba { for (int j = 0; j < WebpConstants.NumBands; j++) { - this.Bands[i, j] = new Vp8BandProbas(); + this.Bands[i, j] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs index dda921a7c..bd335f298 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs @@ -13,7 +13,7 @@ internal class Vp8Stats this.Stats = new Vp8StatsArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Stats[i] = new Vp8StatsArray(); + this.Stats[i] = new(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index 65d5b65e8..bd87b385c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -1173,13 +1173,13 @@ internal sealed class WebpLossyDecoder pSize = sizeLeft; } - dec.Vp8BitReaders[p] = new Vp8BitReader(this.bitReader.Data, (uint)pSize, partStart); + dec.Vp8BitReaders[p] = new(this.bitReader.Data, (uint)pSize, partStart); partStart += pSize; sizeLeft -= pSize; sz = sz[3..]; } - dec.Vp8BitReaders[lastPart] = new Vp8BitReader(this.bitReader.Data, (uint)sizeLeft, partStart); + dec.Vp8BitReaders[lastPart] = new(this.bitReader.Data, (uint)sizeLeft, partStart); } private void ParseDequantizationIndices(Vp8Decoder decoder) diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 173d9436d..d19efec3b 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -93,7 +93,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame? previousFrame = null; WebpFrameData? prevFrameData = null; - this.metadata = new ImageMetadata(); + this.metadata = new(); this.webpMetadata = this.metadata.GetWebpMetadata(); this.webpMetadata.RepeatCount = features.AnimationLoopCount; @@ -204,7 +204,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame currentFrame; if (previousFrame is null) { - image = new Image(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); + image = new(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); currentFrame = image.Frames.RootFrame; SetFrameMetadata(currentFrame.Metadata, frameData); diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 4ccaf6503..a4e88e227 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -358,7 +358,7 @@ internal static class WebpChunkParsingUtils if (metadata.ExifProfile != null) { - metadata.ExifProfile = new ExifProfile(exifData); + metadata.ExifProfile = new(exifData); } break; @@ -372,7 +372,7 @@ internal static class WebpChunkParsingUtils if (metadata.XmpProfile != null) { - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } break; diff --git a/src/ImageSharp/Formats/Webp/WebpDecoder.cs b/src/ImageSharp/Formats/Webp/WebpDecoder.cs index dfbf4ef0e..41c5d60f7 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoder.cs @@ -17,7 +17,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder /// /// Gets the shared instance. /// - public static WebpDecoder Instance { get; } = new WebpDecoder(); + public static WebpDecoder Instance { get; } = new(); /// protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -25,7 +25,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(new WebpDecoderOptions() { GeneralOptions = options }); + using WebpDecoderCore decoder = new(new() { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } @@ -35,7 +35,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new WebpDecoderCore(options); + using WebpDecoderCore decoder = new(options); Image image = decoder.Decode(options.GeneralOptions.Configuration, stream, cancellationToken); ScaleToTargetSize(options.GeneralOptions, image); @@ -52,5 +52,5 @@ public sealed class WebpDecoder : SpecializedImageDecoder => this.Decode(options, stream, cancellationToken); /// - protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new WebpDecoderOptions { GeneralOptions = options }; + protected override WebpDecoderOptions CreateDefaultSpecializedOptions(DecoderOptions options) => new() { GeneralOptions = options }; } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 51379a32a..dfd80c838 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -93,7 +93,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } - image = new Image(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); + image = new(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.webImageInfo.IsLossless) { @@ -136,8 +136,8 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable ImageMetadata metadata = new(); using (this.webImageInfo = this.ReadVp8Info(stream, metadata, true)) { - return new ImageInfo( - new Size((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), + return new( + new((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), metadata); } } @@ -229,7 +229,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable default: WebpThrowHelper.ThrowImageFormatException("Unrecognized VP8 header"); return - new WebpImageInfo(); // this return will never be reached, because throw helper will throw an exception. + new(); // this return will never be reached, because throw helper will throw an exception. } } @@ -389,7 +389,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return; } - metadata.XmpProfile = new XmpProfile(xmpData); + metadata.XmpProfile = new(xmpData); } } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index db57bd8f2..817addac5 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -126,7 +126,7 @@ public class WebpMetadata : IFormatMetadata break; } - return new PixelTypeInfo(bpp) + return new(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs index 4220b3df7..aa0590619 100644 --- a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs +++ b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs @@ -18,7 +18,7 @@ public static class GraphicOptionsDefaultsExtensions /// The passed in to allow chaining. public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, Action optionsBuilder) { - var cloned = context.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = context.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); context.Properties[typeof(GraphicsOptions)] = cloned; return context; @@ -31,7 +31,7 @@ public static class GraphicOptionsDefaultsExtensions /// The default options to use. public static void SetGraphicsOptions(this Configuration configuration, Action optionsBuilder) { - var cloned = configuration.GetGraphicsOptions().DeepClone(); + GraphicsOptions cloned = configuration.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); configuration.Properties[typeof(GraphicsOptions)] = cloned; } @@ -65,7 +65,7 @@ public static class GraphicOptionsDefaultsExtensions /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this IImageProcessingContext context) { - if (context.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (context.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } @@ -82,12 +82,12 @@ public static class GraphicOptionsDefaultsExtensions /// The globaly configued default options. public static GraphicsOptions GetGraphicsOptions(this Configuration configuration) { - if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out var options) && options is GraphicsOptions go) + if (configuration.Properties.TryGetValue(typeof(GraphicsOptions), out object? options) && options is GraphicsOptions go) { return go; } - var configOptions = new GraphicsOptions(); + GraphicsOptions configOptions = new GraphicsOptions(); // capture the fallback so the same instance will always be returned in case its mutated configuration.Properties[typeof(GraphicsOptions)] = configOptions; diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index d2ee0f906..7e61e5095 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -36,7 +36,7 @@ public abstract partial class Image width, height, configuration.PreferContiguousImageBuffers); - return new Image(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); + return new(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); } /// diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index 03bec8bc6..ab2718f6c 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -53,7 +53,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemory.Length >= (long)width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -87,7 +87,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemory, width, height, new()); /// /// @@ -148,7 +148,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -171,7 +171,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, pixelMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -235,7 +235,7 @@ public abstract partial class Image Guard.IsTrue(memoryManager.Memory.Length >= (long)width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -269,7 +269,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemory, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemory, width, height, new()); /// /// @@ -333,7 +333,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -356,7 +356,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemoryOwner, width, height, new ImageMetadata()); + => WrapMemory(configuration, byteMemoryOwner, width, height, new()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -429,7 +429,7 @@ public abstract partial class Image Guard.MustBeGreaterThanOrEqualTo(bufferSizeInBytes / sizeof(TPixel), memoryManager.Memory.Span.Length, nameof(bufferSizeInBytes)); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new Image(configuration, memorySource, width, height, metadata); + return new(configuration, memorySource, width, height, metadata); } /// @@ -470,7 +470,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new ImageMetadata()); + => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new()); /// /// diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 07b40a41a..693b58db6 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -47,7 +47,7 @@ public abstract partial class Image : IDisposable, IConfigurationProvider ImageMetadata metadata, int width, int height) - : this(configuration, pixelType, metadata, new Size(width, height)) + : this(configuration, pixelType, metadata, new(width, height)) { } diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 61f4c0ea9..90fe16bad 100644 --- a/src/ImageSharp/ImageFrame.LoadPixelData.cs +++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs @@ -40,7 +40,7 @@ public partial class ImageFrame int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); - var image = new ImageFrame(configuration, width, height); + ImageFrame image = new ImageFrame(configuration, width, height); data = data[..count]; data.CopyTo(image.PixelBuffer.FastMemoryGroup); diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index ad7d71974..da76aa4ab 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -23,7 +23,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, backgroundColor)); + this.frames.Add(new(parent.Configuration, width, height, backgroundColor)); } internal ImageFrameCollection(Image parent, int width, int height, MemoryGroup memorySource) @@ -31,7 +31,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new ImageFrame(parent.Configuration, width, height, memorySource)); + this.frames.Add(new(parent.Configuration, width, height, memorySource)); } internal ImageFrameCollection(Image parent, IEnumerable> frames) @@ -269,7 +269,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.frames.Remove(frame); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); } /// @@ -284,7 +284,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer ImageFrame frame = this[index]; ImageFrame clonedFrame = frame.Clone(); - return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); + return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); } /// diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index de71e77ca..ce673ba40 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -81,7 +81,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The color to clear the image with. internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageFrameMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -114,7 +114,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The memory source. internal ImageFrame(Configuration configuration, int width, int height, MemoryGroup memorySource) - : this(configuration, width, height, memorySource, new ImageFrameMetadata()) + : this(configuration, width, height, memorySource, new()) { } @@ -132,7 +132,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - this.PixelBuffer = new Buffer2D(memorySource, width, height); + this.PixelBuffer = new(memorySource, width, height); } /// diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 7ec791838..543d6ab43 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -41,7 +41,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new ImageMetadata()) + : this(configuration, width, height, backgroundColor, new()) { } @@ -53,7 +53,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(int width, int height, TPixel backgroundColor) - : this(Configuration.Default, width, height, backgroundColor, new ImageMetadata()) + : this(Configuration.Default, width, height, backgroundColor, new()) { } @@ -78,7 +78,7 @@ public sealed class Image : Image /// The images metadata. internal Image(Configuration configuration, int width, int height, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); + => this.frames = new(this, width, height, default(TPixel)); /// /// Initializes a new instance of the class @@ -111,7 +111,7 @@ public sealed class Image : Image int height, ImageMetadata metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, width, height) - => this.frames = new ImageFrameCollection(this, width, height, memoryGroup); + => this.frames = new(this, width, height, memoryGroup); /// /// Initializes a new instance of the class @@ -129,7 +129,7 @@ public sealed class Image : Image TPixel backgroundColor, ImageMetadata? metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new ImageFrameCollection(this, width, height, backgroundColor); + => this.frames = new(this, width, height, backgroundColor); /// /// Initializes a new instance of the class @@ -140,7 +140,7 @@ public sealed class Image : Image /// The frames that will be owned by this image instance. internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable> frames) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, ValidateFramesAndGetSize(frames)) - => this.frames = new ImageFrameCollection(this, frames); + => this.frames = new(this, frames); /// protected override ImageFrameCollection NonGenericFrameCollection => this.Frames; @@ -344,7 +344,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].Clone(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// @@ -363,7 +363,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].CloneAs(configuration); } - return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); + return new(configuration, this.Metadata.DeepClone(), clonedFrames); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs index a6ed797d6..cbf64e6a1 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs @@ -27,7 +27,7 @@ internal abstract class ManagedBufferBase : MemoryManager void* ptr = Unsafe.Add((void*)this.pinHandle.AddrOfPinnedObject(), elementIndex); // We should only pass pinnable:this, when GCHandle lifetime is managed by the MemoryManager instance. - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs index 02bdf0f48..364aa05af 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs @@ -19,7 +19,7 @@ internal class SharedArrayPoolBuffer : ManagedBufferBase, IRefCounted { this.lengthInBytes = lengthInElements * Unsafe.SizeOf(); this.Array = ArrayPool.Shared.Rent(this.lengthInBytes); - this.lifetimeGuard = new LifetimeGuard(this.Array); + this.lifetimeGuard = new(this.Array); } public byte[]? Array { get; private set; } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs index 24bf52b1f..a505548d2 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs @@ -11,7 +11,7 @@ internal partial class UniformUnmanagedMemoryPool bool clear) where T : struct { - var buffer = new UnmanagedBuffer(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); + UnmanagedBuffer buffer = new UnmanagedBuffer(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); if (clear) { buffer.Clear(); diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs index aa8bcd385..d7212a41f 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -214,14 +214,14 @@ internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedEx { lock (AllPools) { - AllPools.Add(new WeakReference(pool)); + AllPools.Add(new(pool)); // Invoke the timer callback more frequently, than trimSettings.TrimPeriodMilliseconds. // We are checking in the callback if enough time passed since the last trimming. If not, we do nothing. int period = settings.TrimPeriodMilliseconds / 4; if (trimTimer == null) { - trimTimer = new Timer(_ => TimerCallback(), null, period, period); + trimTimer = new(_ => TimerCallback(), null, period, period); } else if (settings.TrimPeriodMilliseconds < minTrimPeriodMilliseconds) { @@ -337,6 +337,6 @@ internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedEx public bool Enabled => this.Rate > 0; - public static TrimSettings Default => new TrimSettings(); + public static TrimSettings Default => new(); } } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs index de0964726..5e7f386fd 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs @@ -48,7 +48,7 @@ internal sealed unsafe class UnmanagedBuffer : MemoryManager, IRefCounted this.lifetimeGuard.AddRef(); void* pbData = Unsafe.Add(this.Pointer, elementIndex); - return new MemoryHandle(pbData, pinnable: this); + return new(pbData, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs index 6b31cadf4..0fc5d2dea 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs @@ -64,7 +64,7 @@ internal struct UnmanagedMemoryHandle : IEquatable public static UnmanagedMemoryHandle Allocate(int lengthInBytes) { IntPtr handle = AllocateHandle(lengthInBytes); - return new UnmanagedMemoryHandle(handle, lengthInBytes); + return new(handle, lengthInBytes); } private static IntPtr AllocateHandle(int lengthInBytes) @@ -84,7 +84,7 @@ internal struct UnmanagedMemoryHandle : IEquatable counter++; Interlocked.Increment(ref totalOomRetries); - Interlocked.CompareExchange(ref lowMemoryMonitor, new object(), null); + Interlocked.CompareExchange(ref lowMemoryMonitor, new(), null); Monitor.Enter(lowMemoryMonitor); Monitor.Wait(lowMemoryMonitor, millisecondsTimeout: 1); Monitor.Exit(lowMemoryMonitor); diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 621073a3d..203a5df69 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -67,8 +67,8 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato this.poolBufferSizeInBytes = poolBufferSizeInBytes; this.poolCapacity = (int)(maxPoolSizeInBytes / poolBufferSizeInBytes); this.trimSettings = trimSettings; - this.pool = new UniformUnmanagedMemoryPool(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); - this.nonPoolAllocator = new UnmanagedMemoryAllocator(unmanagedBufferSizeInBytes); + this.pool = new(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); + this.nonPoolAllocator = new(unmanagedBufferSizeInBytes); } // This delegate allows overriding the method returning the available system memory, @@ -96,7 +96,7 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato if (lengthInBytes <= (ulong)this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer(length); + SharedArrayPoolBuffer buffer = new(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); @@ -127,7 +127,7 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato { if (totalLengthInBytes <= this.sharedArrayPoolThresholdInBytes) { - var buffer = new SharedArrayPoolBuffer((int)totalLengthInElements); + SharedArrayPoolBuffer buffer = new((int)totalLengthInElements); return MemoryGroup.CreateContiguous(buffer, options.Has(AllocationOptions.Clean)); } diff --git a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs index da202aa59..daf1a7992 100644 --- a/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UnmanagedMemoryAllocator.cs @@ -20,7 +20,7 @@ internal class UnmanagedMemoryAllocator : MemoryAllocator public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) { - var buffer = UnmanagedBuffer.Allocate(length); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(length); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index f0fa1438d..b8ac5a584 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -126,7 +126,7 @@ public static class Buffer2DExtensions internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height) where T : unmanaged => - new(buffer, new Rectangle(x, y, width, height)); + new(buffer, new(x, y, width, height)); /// /// Return a to the whole area of 'buffer' diff --git a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs index f4b257b58..c628bfd85 100644 --- a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs +++ b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs @@ -124,8 +124,8 @@ public readonly struct Buffer2DRegion int x = this.Rectangle.X + rectangle.X; int y = this.Rectangle.Y + rectangle.Y; - rectangle = new Rectangle(x, y, rectangle.Width, rectangle.Height); - return new Buffer2DRegion(this.Buffer, rectangle); + rectangle = new(x, y, rectangle.Width, rectangle.Height); + return new(this.Buffer, rectangle); } /// diff --git a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs index bc7175141..91525e5ad 100644 --- a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs +++ b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs @@ -24,7 +24,7 @@ internal sealed class ByteMemoryOwner : IMemoryOwner public ByteMemoryOwner(IMemoryOwner memoryOwner) { this.memoryOwner = memoryOwner; - this.memoryManager = new ByteMemoryManager(memoryOwner.Memory); + this.memoryManager = new(memoryOwner.Memory); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs index e2e933f3c..d2e4d00fb 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs @@ -77,7 +77,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(target.Length, source.TotalLength, nameof(target)); - var cur = new MemoryGroupCursor(source); + MemoryGroupCursor cur = new MemoryGroupCursor(source); long position = 0; while (position < source.TotalLength) { @@ -100,7 +100,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(target, nameof(target)); Guard.MustBeGreaterThanOrEqualTo(target.TotalLength, source.Length, nameof(target)); - var cur = new MemoryGroupCursor(target); + MemoryGroupCursor cur = new MemoryGroupCursor(target); while (!source.IsEmpty) { @@ -126,8 +126,8 @@ internal static class MemoryGroupExtensions } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new MemoryGroupCursor(source); + MemoryGroupCursor trgCur = new MemoryGroupCursor(target); while (position < source.TotalLength) { @@ -162,8 +162,8 @@ internal static class MemoryGroupExtensions } long position = 0; - var srcCur = new MemoryGroupCursor(source); - var trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new MemoryGroupCursor(source); + MemoryGroupCursor trgCur = new MemoryGroupCursor(target); while (position < source.TotalLength) { diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs index 76371e674..a3f45c8cf 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs @@ -31,7 +31,7 @@ internal class MemoryGroupView : IMemoryGroup for (int i = 0; i < owner.Count; i++) { - this.memoryWrappers[i] = new MemoryOwnerWrapper(this, i); + this.memoryWrappers[i] = new(this, i); } } @@ -79,7 +79,7 @@ internal class MemoryGroupView : IMemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs index 950e2a019..783ab53a5 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs @@ -18,7 +18,7 @@ internal abstract partial class MemoryGroup : base(bufferLength, totalLength) { this.source = source; - this.View = new MemoryGroupView(this); + this.View = new(this); } public override int Count @@ -33,7 +33,7 @@ internal abstract partial class MemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public override MemoryGroupEnumerator GetEnumerator() { - return new MemoryGroupEnumerator(this); + return new(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs index 9da0139e6..937a1a32b 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs @@ -23,7 +23,7 @@ internal abstract partial class MemoryGroup { this.memoryOwners = memoryOwners; this.Swappable = swappable; - this.View = new MemoryGroupView(this); + this.View = new(this); this.memoryGroupSpanCache = MemoryGroupSpanCache.Create(memoryOwners); } @@ -66,14 +66,14 @@ internal abstract partial class MemoryGroup int sizeOfLastBuffer, AllocationOptions options) { - var result = new IMemoryOwner[pooledBuffers.Length]; + IMemoryOwner[] result = new IMemoryOwner[pooledBuffers.Length]; for (int i = 0; i < pooledBuffers.Length - 1; i++) { - var currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); + ObservedBuffer currentBuffer = ObservedBuffer.Create(pooledBuffers[i], bufferLength, options); result[i] = currentBuffer; } - var lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); + ObservedBuffer lastBuffer = ObservedBuffer.Create(pooledBuffers[pooledBuffers.Length - 1], sizeOfLastBuffer, options); result[result.Length - 1] = lastBuffer; return result; } @@ -124,7 +124,7 @@ internal abstract partial class MemoryGroup public override void RecreateViewAfterSwap() { this.View.Invalidate(); - this.View = new MemoryGroupView(this); + this.View = new(this); } /// @@ -193,7 +193,7 @@ internal abstract partial class MemoryGroup int lengthInElements, AllocationOptions options) { - var buffer = new ObservedBuffer(handle, lengthInElements); + ObservedBuffer buffer = new(handle, lengthInElements); if (options.Has(AllocationOptions.Clean)) { buffer.GetSpan().Clear(); @@ -212,7 +212,7 @@ internal abstract partial class MemoryGroup public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* pbData = Unsafe.Add(this.handle.Pointer, elementIndex); - return new MemoryHandle(pbData); + return new(pbData); } public override void Unpin() diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index 03c29a723..8e4c88104 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs @@ -97,7 +97,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable if (totalLengthInElements == 0) { - var buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; + IMemoryOwner[] buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; return new Owned(buffers0, 0, 0, true); } @@ -120,7 +120,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable bufferCount++; } - var buffers = new IMemoryOwner[bufferCount]; + IMemoryOwner[] buffers = new IMemoryOwner[bufferCount]; for (int i = 0; i < buffers.Length - 1; i++) { buffers[i] = allocator.Allocate(bufferLength, options); @@ -142,7 +142,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable } int length = buffer.Memory.Length; - var buffers = new IMemoryOwner[1] { buffer }; + IMemoryOwner[] buffers = new IMemoryOwner[1] { buffer }; return new Owned(buffers, length, length, true); } @@ -260,14 +260,14 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable case SpanCacheMode.SinglePointer: { void* start = Unsafe.Add(this.memoryGroupSpanCache.SinglePointer, y * width); - return new Span(start, width); + return new(start, width); } case SpanCacheMode.MultiPointer: { this.GetMultiBufferPosition(y, width, out int bufferIdx, out int bufferStart); void* start = Unsafe.Add(this.memoryGroupSpanCache.MultiPointer[bufferIdx], bufferStart); - return new Span(start, width); + return new(start, width); } default: diff --git a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs index ff306e1e4..8178ca818 100644 --- a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs +++ b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs @@ -41,7 +41,7 @@ public static class MemoryAllocatorExtensions memoryGroup = memoryAllocator.AllocateGroup(groupLength, width, options); } - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// @@ -109,7 +109,7 @@ public static class MemoryAllocatorExtensions groupLength, width * alignmentMultiplier, options); - return new Buffer2D(memoryGroup, width, height); + return new(memoryGroup, width, height); } /// diff --git a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs index 7f3163af3..df845dd7a 100644 --- a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs +++ b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs @@ -42,13 +42,13 @@ internal sealed unsafe class UnmanagedMemoryManager : MemoryManager /// public override Span GetSpan() { - return new Span(this.pointer, this.length); + return new(this.pointer, this.length); } /// public override MemoryHandle Pin(int elementIndex = 0) { - return new MemoryHandle(((T*)this.pointer) + elementIndex, pinnable: this); + return new(((T*)this.pointer) + elementIndex, pinnable: this); } /// diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index d2b88cbff..a58e22869 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -71,7 +71,7 @@ internal static class ExifEncodedStringHelpers { // Little-endian BOM string text = Encoding.Unicode.GetString(textBuffer[2..]); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } @@ -79,14 +79,14 @@ internal static class ExifEncodedStringHelpers { // Big-endian BOM string text = Encoding.BigEndianUnicode.GetString(textBuffer[2..]); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } } { string text = GetEncoding(code, order).GetString(textBuffer); - encodedString = new EncodedString(code, text); + encodedString = new(code, text); return true; } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index aa987bbe7..f67395165 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -82,7 +82,7 @@ public sealed class ExifProfile : IDeepCloneable if (other.values != null) { - this.values = new List(other.Values.Count); + this.values = new(other.Values.Count); foreach (IExifValue value in other.Values) { diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index 4cd4b4aac..c04a6f78e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -669,7 +669,7 @@ internal abstract class BaseExifReader uint numerator = this.ConvertToUInt32(buffer[..4]); uint denominator = this.ConvertToUInt32(buffer.Slice(4, 4)); - return new Rational(numerator, denominator, false); + return new(numerator, denominator, false); } private sbyte ConvertToSignedByte(ReadOnlySpan buffer) => unchecked((sbyte)buffer[0]); @@ -696,7 +696,7 @@ internal abstract class BaseExifReader int numerator = this.ConvertToInt32(buffer[..4]); int denominator = this.ConvertToInt32(buffer.Slice(4, 4)); - return new SignedRational(numerator, denominator, false); + return new(numerator, denominator, false); } private short ConvertToSignedShort(ReadOnlySpan buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs index 14b097f81..a7b9d44ae 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs @@ -33,7 +33,7 @@ internal sealed class ExifEncodedString : ExifValue if (value is string stringValue) { - this.Value = new EncodedString(stringValue); + this.Value = new(stringValue); return true; } else if (value is byte[] buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs index c25f0f5dc..e5c27f60a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs @@ -39,7 +39,7 @@ internal sealed class ExifRational : ExifValue if (signed.Numerator >= uint.MinValue && signed.Denominator >= uint.MinValue) { - this.Value = new Rational((uint)signed.Numerator, (uint)signed.Denominator); + this.Value = new((uint)signed.Numerator, (uint)signed.Denominator); } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs index e8b2006df..4ae2850a1 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs @@ -38,7 +38,7 @@ internal sealed class ExifRationalArray : ExifArrayValue { if (signed.Numerator >= 0 && signed.Denominator >= 0) { - this.Value = [new Rational((uint)signed.Numerator, (uint)signed.Denominator)]; + this.Value = [new((uint)signed.Numerator, (uint)signed.Denominator)]; } return true; @@ -60,7 +60,7 @@ internal sealed class ExifRationalArray : ExifArrayValue for (int i = 0; i < signed.Length; i++) { SignedRational s = signed[i]; - unsigned[i] = new Rational((uint)s.Numerator, (uint)s.Denominator); + unsigned[i] = new((uint)s.Numerator, (uint)s.Denominator); } this.Value = unsigned; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 3cf66c0c1..3e061c9d8 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -18,19 +18,19 @@ internal sealed partial class IccDataReader { ushort segmentCount = this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved - var breakPoints = new float[segmentCount - 1]; + float[] breakPoints = new float[segmentCount - 1]; for (int i = 0; i < breakPoints.Length; i++) { breakPoints[i] = this.ReadSingle(); } - var segments = new IccCurveSegment[segmentCount]; + IccCurveSegment[] segments = new IccCurveSegment[segmentCount]; for (int i = 0; i < segmentCount; i++) { segments[i] = this.ReadCurveSegment(); } - return new IccOneDimensionalCurve(breakPoints, segments); + return new(breakPoints, segments); } /// @@ -40,20 +40,20 @@ internal sealed partial class IccDataReader /// The read curve public IccResponseCurve ReadResponseCurve(int channelCount) { - var type = (IccCurveMeasurementEncodings)this.ReadUInt32(); - var measurement = new uint[channelCount]; + IccCurveMeasurementEncodings type = (IccCurveMeasurementEncodings)this.ReadUInt32(); + uint[] measurement = new uint[channelCount]; for (int i = 0; i < channelCount; i++) { measurement[i] = this.ReadUInt32(); } - var xyzValues = new Vector3[channelCount]; + Vector3[] xyzValues = new Vector3[channelCount]; for (int i = 0; i < channelCount; i++) { xyzValues[i] = this.ReadXyzNumber(); } - var response = new IccResponseNumber[channelCount][]; + IccResponseNumber[][] response = new IccResponseNumber[channelCount][]; for (int i = 0; i < channelCount; i++) { response[i] = new IccResponseNumber[measurement[i]]; @@ -63,7 +63,7 @@ internal sealed partial class IccDataReader } } - return new IccResponseCurve(type, xyzValues, response); + return new(type, xyzValues, response); } /// @@ -106,11 +106,11 @@ internal sealed partial class IccDataReader switch (type) { - case 0: return new IccParametricCurve(gamma); - case 1: return new IccParametricCurve(gamma, a, b); - case 2: return new IccParametricCurve(gamma, a, b, c); - case 3: return new IccParametricCurve(gamma, a, b, c, d); - case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f); + case 0: return new(gamma); + case 1: return new(gamma, a, b); + case 2: return new(gamma, a, b, c); + case 3: return new(gamma, a, b, c, d); + case 4: return new(gamma, a, b, c, d, e, f); default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}"); } } @@ -121,7 +121,7 @@ internal sealed partial class IccDataReader /// The read segment public IccCurveSegment ReadCurveSegment() { - var signature = (IccCurveSegmentSignature)this.ReadUInt32(); + IccCurveSegmentSignature signature = (IccCurveSegmentSignature)this.ReadUInt32(); this.AddIndex(4); // 4 bytes reserved switch (signature) @@ -141,7 +141,7 @@ internal sealed partial class IccDataReader /// The read segment public IccFormulaCurveElement ReadFormulaCurveElement() { - var type = (IccFormulaCurveType)this.ReadUInt16(); + IccFormulaCurveType type = (IccFormulaCurveType)this.ReadUInt16(); this.AddIndex(2); // 2 bytes reserved float gamma, a, b, c, d, e; gamma = d = e = 0; @@ -165,7 +165,7 @@ internal sealed partial class IccDataReader e = this.ReadSingle(); } - return new IccFormulaCurveElement(type, gamma, a, b, c, d, e); + return new(type, gamma, a, b, c, d, e); } /// @@ -175,13 +175,13 @@ internal sealed partial class IccDataReader public IccSampledCurveElement ReadSampledCurveElement() { uint count = this.ReadUInt32(); - var entries = new float[count]; + float[] entries = new float[count]; for (int i = 0; i < count; i++) { entries[i] = this.ReadSingle(); } - return new IccSampledCurveElement(entries); + return new(entries); } /// @@ -191,7 +191,7 @@ internal sealed partial class IccDataReader /// The curve data private IccTagDataEntry[] ReadCurves(int count) { - var tdata = new IccTagDataEntry[count]; + IccTagDataEntry[] tdata = new IccTagDataEntry[count]; for (int i = 0; i < count; i++) { IccTypeSignature type = this.ReadTagDataEntryHeader(); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index f3ce6cd79..ff65125c3 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -21,13 +21,13 @@ internal sealed partial class IccDataReader /// The read LUT. public IccLut ReadLut16(int count) { - var values = new ushort[count]; + ushort[] values = new ushort[count]; for (int i = 0; i < count; i++) { values[i] = this.ReadUInt16(); } - return new IccLut(values); + return new(values); } /// @@ -41,7 +41,7 @@ internal sealed partial class IccDataReader public IccClut ReadClut(int inChannelCount, int outChannelCount, bool isFloat) { // Grid-points are always 16 bytes long but only 0-inChCount are used. - var gridPointCount = new byte[inChannelCount]; + byte[] gridPointCount = new byte[inChannelCount]; Buffer.BlockCopy(this.data, this.AddIndex(16), gridPointCount, 0, inChannelCount); if (!isFloat) @@ -92,7 +92,7 @@ internal sealed partial class IccDataReader } } - return new IccClut(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); + return new(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); } /// @@ -126,7 +126,7 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChannelCount * 2); - return new IccClut(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); + return new(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); } /// @@ -158,6 +158,6 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChCount * 4); - return new IccClut(values, gridPointCount, IccClutDataType.Float, outChCount); + return new(values, gridPointCount, IccClutDataType.Float, outChCount); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index 5baa90404..bff5e31bc 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -48,14 +48,14 @@ internal sealed partial class IccDataReader /// The read public IccCurveSetProcessElement ReadCurveSetProcessElement(int inChannelCount, int outChannelCount) { - var curves = new IccOneDimensionalCurve[inChannelCount]; + IccOneDimensionalCurve[] curves = new IccOneDimensionalCurve[inChannelCount]; for (int i = 0; i < inChannelCount; i++) { curves[i] = this.ReadOneDimensionalCurve(); this.AddPadding(); } - return new IccCurveSetProcessElement(curves); + return new(curves); } /// @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// The read public IccMatrixProcessElement ReadMatrixProcessElement(int inChannelCount, int outChannelCount) { - return new IccMatrixProcessElement( + return new( this.ReadMatrix(inChannelCount, outChannelCount, true), this.ReadMatrix(outChannelCount, true)); } @@ -79,6 +79,6 @@ internal sealed partial class IccDataReader /// The read public IccClutProcessElement ReadClutProcessElement(int inChannelCount, int outChannelCount) { - return new IccClutProcessElement(this.ReadClut(inChannelCount, outChannelCount, true)); + return new(this.ReadClut(inChannelCount, outChannelCount, true)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index d5369e5fc..ea969b7ec 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -18,7 +18,7 @@ internal sealed partial class IccDataReader { try { - return new DateTime( + return new( year: this.ReadUInt16(), month: this.ReadUInt16(), day: this.ReadUInt16(), @@ -45,7 +45,7 @@ internal sealed partial class IccDataReader int minor = (version >> 20) & 0x0F; int bugfix = (version >> 16) & 0x0F; - return new IccVersion(major, minor, bugfix); + return new(major, minor, bugfix); } /// @@ -54,7 +54,7 @@ internal sealed partial class IccDataReader /// the XYZ number public Vector3 ReadXyzNumber() { - return new Vector3( + return new( x: this.ReadFix16(), y: this.ReadFix16(), z: this.ReadFix16()); @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// the profile ID public IccProfileId ReadProfileId() { - return new IccProfileId( + return new( p1: this.ReadUInt32(), p2: this.ReadUInt32(), p3: this.ReadUInt32(), @@ -79,7 +79,7 @@ internal sealed partial class IccDataReader /// the position number public IccPositionNumber ReadPositionNumber() { - return new IccPositionNumber( + return new( offset: this.ReadUInt32(), size: this.ReadUInt32()); } @@ -90,7 +90,7 @@ internal sealed partial class IccDataReader /// the response number public IccResponseNumber ReadResponseNumber() { - return new IccResponseNumber( + return new( deviceCode: this.ReadUInt16(), measurementValue: this.ReadFix16()); } @@ -104,14 +104,14 @@ internal sealed partial class IccDataReader { string name = this.ReadAsciiString(32); ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; - var deviceCoord = new ushort[deviceCoordCount]; + ushort[] deviceCoord = new ushort[deviceCoordCount]; for (int i = 0; i < deviceCoordCount; i++) { deviceCoord[i] = this.ReadUInt16(); } - return new IccNamedColor(name, pcsCoord, deviceCoord); + return new(name, pcsCoord, deviceCoord); } /// @@ -122,13 +122,13 @@ internal sealed partial class IccDataReader { uint manufacturer = this.ReadUInt32(); uint model = this.ReadUInt32(); - var attributes = (IccDeviceAttribute)this.ReadInt64(); - var technologyInfo = (IccProfileTag)this.ReadUInt32(); + IccDeviceAttribute attributes = (IccDeviceAttribute)this.ReadInt64(); + IccProfileTag technologyInfo = (IccProfileTag)this.ReadUInt32(); IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = ReadText(); IccMultiLocalizedUnicodeTagDataEntry modelInfo = ReadText(); - return new IccProfileDescription( + return new( manufacturer, model, attributes, @@ -158,7 +158,7 @@ internal sealed partial class IccDataReader /// the profile description public IccColorantTableEntry ReadColorantTableEntry() { - return new IccColorantTableEntry( + return new( name: this.ReadAsciiString(32), pcs1: this.ReadUInt16(), pcs2: this.ReadUInt16(), @@ -171,7 +171,7 @@ internal sealed partial class IccDataReader /// the screening channel public IccScreeningChannel ReadScreeningChannel() { - return new IccScreeningChannel( + return new( frequency: this.ReadFix16(), angle: this.ReadFix16(), spotShape: (IccScreeningSpotType)this.ReadInt32()); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs index 7a526ef1a..99dc3ce3c 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Primitives.cs @@ -143,7 +143,7 @@ internal sealed partial class IccDataReader /// The read bytes public byte[] ReadBytes(int count) { - var bytes = new byte[count]; + byte[] bytes = new byte[count]; Buffer.BlockCopy(this.data, this.AddIndex(count), bytes, 0, count); return bytes; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index c1b22e82b..591e08c6f 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -130,7 +130,7 @@ internal sealed partial class IccDataReader public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size - return new IccUnknownTagDataEntry(this.ReadBytes(count)); + return new(this.ReadBytes(count)); } /// @@ -140,13 +140,13 @@ internal sealed partial class IccDataReader public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry() { ushort channelCount = this.ReadUInt16(); - var colorant = (IccColorantEncoding)this.ReadUInt16(); + IccColorantEncoding colorant = (IccColorantEncoding)this.ReadUInt16(); if (Enum.IsDefined(colorant) && colorant != IccColorantEncoding.Unknown) { // The type is known and so are the values (they are constant) // channelCount should always be 3 but it doesn't really matter if it's not - return new IccChromaticityTagDataEntry(colorant); + return new(colorant); } else { @@ -157,7 +157,7 @@ internal sealed partial class IccDataReader values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; } - return new IccChromaticityTagDataEntry(values); + return new(values); } } @@ -169,7 +169,7 @@ internal sealed partial class IccDataReader { uint colorantCount = this.ReadUInt32(); byte[] number = this.ReadBytes((int)colorantCount); - return new IccColorantOrderTagDataEntry(number); + return new(number); } /// @@ -179,13 +179,13 @@ internal sealed partial class IccDataReader public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry() { uint colorantCount = this.ReadUInt32(); - var cdata = new IccColorantTableEntry[colorantCount]; + IccColorantTableEntry[] cdata = new IccColorantTableEntry[colorantCount]; for (int i = 0; i < colorantCount; i++) { cdata[i] = this.ReadColorantTableEntry(); } - return new IccColorantTableTagDataEntry(cdata); + return new(cdata); } /// @@ -198,12 +198,12 @@ internal sealed partial class IccDataReader if (pointCount == 0) { - return new IccCurveTagDataEntry(); + return new(); } if (pointCount == 1) { - return new IccCurveTagDataEntry(this.ReadUFix8()); + return new(this.ReadUFix8()); } float[] cdata = new float[pointCount]; @@ -212,7 +212,7 @@ internal sealed partial class IccDataReader cdata[i] = this.ReadUInt16() / 65535f; } - return new IccCurveTagDataEntry(cdata); + return new(cdata); // TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768). } @@ -232,14 +232,14 @@ internal sealed partial class IccDataReader int length = (int)size - 12; byte[] cdata = this.ReadBytes(length); - return new IccDataTagDataEntry(cdata, ascii); + return new(cdata, ascii); } /// /// Reads a /// /// The read entry. - public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() => new IccDateTimeTagDataEntry(this.ReadDateTime()); + public IccDateTimeTagDataEntry ReadDateTimeTagDataEntry() => new(this.ReadDateTime()); /// /// Reads a @@ -258,7 +258,7 @@ internal sealed partial class IccDataReader ushort outTableCount = this.ReadUInt16(); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -270,13 +270,13 @@ internal sealed partial class IccDataReader IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut16(outTableCount); } - return new IccLut16TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -293,7 +293,7 @@ internal sealed partial class IccDataReader float[,] matrix = this.ReadMatrix(3, 3, false); // Input LUT - var inValues = new IccLut[inChCount]; + IccLut[] inValues = new IccLut[inChCount]; byte[] gridPointCount = new byte[inChCount]; for (int i = 0; i < inChCount; i++) { @@ -305,13 +305,13 @@ internal sealed partial class IccDataReader IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount); // Output LUT - var outValues = new IccLut[outChCount]; + IccLut[] outValues = new IccLut[outChCount]; for (int i = 0; i < outChCount; i++) { outValues[i] = this.ReadLut8(); } - return new IccLut8TagDataEntry(matrix, inValues, clut, outValues); + return new(matrix, inValues, clut, outValues); } /// @@ -370,7 +370,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutAToBTagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -429,7 +429,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new IccLutBToATagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -453,9 +453,9 @@ internal sealed partial class IccDataReader uint recordCount = this.ReadUInt32(); this.ReadUInt32(); // Record size (always 12) - var text = new IccLocalizedString[recordCount]; + IccLocalizedString[] text = new IccLocalizedString[recordCount]; - var culture = new CultureInfo[recordCount]; + CultureInfo[] culture = new CultureInfo[recordCount]; uint[] length = new uint[recordCount]; uint[] offset = new uint[recordCount]; @@ -472,10 +472,10 @@ internal sealed partial class IccDataReader for (int i = 0; i < recordCount; i++) { this.currentIndex = (int)(start + offset[i]); - text[i] = new IccLocalizedString(culture[i], this.ReadUnicodeString((int)length[i])); + text[i] = new(culture[i], this.ReadUnicodeString((int)length[i])); } - return new IccMultiLocalizedUnicodeTagDataEntry(text); + return new(text); CultureInfo ReadCulture(string language, string country) { @@ -487,7 +487,7 @@ internal sealed partial class IccDataReader { try { - return new CultureInfo(language); + return new(language); } catch (CultureNotFoundException) { @@ -498,7 +498,7 @@ internal sealed partial class IccDataReader { try { - return new CultureInfo($"{language}-{country}"); + return new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -520,20 +520,20 @@ internal sealed partial class IccDataReader this.ReadUInt16(); uint elementCount = this.ReadUInt32(); - var positionTable = new IccPositionNumber[elementCount]; + IccPositionNumber[] positionTable = new IccPositionNumber[elementCount]; for (int i = 0; i < elementCount; i++) { positionTable[i] = this.ReadPositionNumber(); } - var elements = new IccMultiProcessElement[elementCount]; + IccMultiProcessElement[] elements = new IccMultiProcessElement[elementCount]; for (int i = 0; i < elementCount; i++) { this.currentIndex = (int)positionTable[i].Offset + start; elements[i] = this.ReadMultiProcessElement(); } - return new IccMultiProcessElementsTagDataEntry(elements); + return new(elements); } /// @@ -548,13 +548,13 @@ internal sealed partial class IccDataReader string prefix = this.ReadAsciiString(32); string suffix = this.ReadAsciiString(32); - var colors = new IccNamedColor[colorCount]; + IccNamedColor[] colors = new IccNamedColor[colorCount]; for (int i = 0; i < colorCount; i++) { colors[i] = this.ReadNamedColor(coordCount); } - return new IccNamedColor2TagDataEntry(vendorFlag, prefix, suffix, colors); + return new(vendorFlag, prefix, suffix, colors); } /// @@ -570,13 +570,13 @@ internal sealed partial class IccDataReader public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry() { uint count = this.ReadUInt32(); - var description = new IccProfileDescription[count]; + IccProfileDescription[] description = new IccProfileDescription[count]; for (int i = 0; i < count; i++) { description[i] = this.ReadProfileDescription(); } - return new IccProfileSequenceDescTagDataEntry(description); + return new(description); } /// @@ -587,23 +587,23 @@ internal sealed partial class IccDataReader { int start = this.currentIndex - 8; // 8 is the tag header size uint count = this.ReadUInt32(); - var table = new IccPositionNumber[count]; + IccPositionNumber[] table = new IccPositionNumber[count]; for (int i = 0; i < count; i++) { table[i] = this.ReadPositionNumber(); } - var entries = new IccProfileSequenceIdentifier[count]; + IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count]; for (int i = 0; i < count; i++) { this.currentIndex = (int)(start + table[i].Offset); IccProfileId id = this.ReadProfileId(); this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode); IccMultiLocalizedUnicodeTagDataEntry description = this.ReadMultiLocalizedUnicodeTagDataEntry(); - entries[i] = new IccProfileSequenceIdentifier(id, description.Texts); + entries[i] = new(id, description.Texts); } - return new IccProfileSequenceIdentifierTagDataEntry(entries); + return new(entries); } /// @@ -622,14 +622,14 @@ internal sealed partial class IccDataReader offset[i] = this.ReadUInt32(); } - var curves = new IccResponseCurve[measurementCount]; + IccResponseCurve[] curves = new IccResponseCurve[measurementCount]; for (int i = 0; i < measurementCount; i++) { this.currentIndex = (int)(start + offset[i]); curves[i] = this.ReadResponseCurve(channelCount); } - return new IccResponseCurveSet16TagDataEntry(curves); + return new(curves); } /// @@ -646,7 +646,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadFix16() / 256f; } - return new IccFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -676,7 +676,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUFix16(); } - return new IccUFix16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -693,7 +693,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt16(); } - return new IccUInt16ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -710,7 +710,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt32(); } - return new IccUInt32ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -727,7 +727,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt64(); } - return new IccUInt64ArrayTagDataEntry(arrayData); + return new(arrayData); } /// @@ -740,7 +740,7 @@ internal sealed partial class IccDataReader int count = (int)size - 8; // 8 is the tag header size byte[] adata = this.ReadBytes(count); - return new IccUInt8ArrayTagDataEntry(adata); + return new(adata); } /// @@ -760,13 +760,13 @@ internal sealed partial class IccDataReader public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size) { uint count = (size - 8) / 12; - var arrayData = new Vector3[count]; + Vector3[] arrayData = new Vector3[count]; for (int i = 0; i < count; i++) { arrayData[i] = this.ReadXyzNumber(); } - return new IccXyzTagDataEntry(arrayData); + return new(arrayData); } /// @@ -801,7 +801,7 @@ internal sealed partial class IccDataReader this.AddIndex(1); // Null terminator } - return new IccTextDescriptionTagDataEntry( + return new( asciiValue, unicodeValue, scriptcodeValue, @@ -830,7 +830,7 @@ internal sealed partial class IccDataReader uint crd3Count = this.ReadUInt32(); string crd3Name = this.ReadAsciiString((int)crd3Count); - return new IccCrdInfoTagDataEntry(productName, crd0Name, crd1Name, crd2Name, crd3Name); + return new(productName, crd0Name, crd1Name, crd2Name, crd3Name); } /// @@ -839,15 +839,15 @@ internal sealed partial class IccDataReader /// The read entry. public IccScreeningTagDataEntry ReadScreeningTagDataEntry() { - var flags = (IccScreeningFlag)this.ReadInt32(); + IccScreeningFlag flags = (IccScreeningFlag)this.ReadInt32(); uint channelCount = this.ReadUInt32(); - var channels = new IccScreeningChannel[channelCount]; + IccScreeningChannel[] channels = new IccScreeningChannel[channelCount]; for (int i = 0; i < channels.Length; i++) { channels[i] = this.ReadScreeningChannel(); } - return new IccScreeningTagDataEntry(flags, channels); + return new(flags, channels); } /// @@ -876,6 +876,6 @@ internal sealed partial class IccDataReader int descriptionLength = (int)(size - 8 - dataSize); // 8 is the tag header size string description = this.ReadAsciiString(descriptionLength); - return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description); + return new(ucrCurve, bgCurve, description); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs index db199b438..8ad81415d 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs @@ -111,9 +111,9 @@ internal sealed partial class IccDataWriter + this.WriteInt64((long)value.DeviceAttributes) + this.WriteUInt32((uint)value.TechnologyInformation) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceManufacturerInfo)) + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceManufacturerInfo)) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceModelInfo)); + + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceModelInfo)); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 6019a0bff..1233beda7 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -20,7 +20,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)this.dataStream.Position; int count = this.WriteTagDataEntry(data); this.WritePadding(); - table = new IccTagTableEntry(data.TagSignature, offset, (uint)count); + table = new(data.TagSignature, offset, (uint)count); return count; } @@ -546,7 +546,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteMultiProcessElement(value.Data[i]); count += this.WritePadding(); - posTable[i] = new IccPositionNumber(offset, (uint)size); + posTable[i] = new(offset, (uint)size); count += size; } @@ -634,7 +634,7 @@ internal sealed partial class IccDataWriter int size = this.WriteProfileId(sequenceIdentifier.Id); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description)); size += this.WritePadding(); - table[i] = new IccPositionNumber(offset, (uint)size); + table[i] = new(offset, (uint)size); count += size; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs index ce5332544..941d3bb65 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs @@ -23,7 +23,7 @@ internal sealed partial class IccDataWriter : IDisposable /// public IccDataWriter() { - this.dataStream = new MemoryStream(); + this.dataStream = new(); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index 392ccb306..b33c98432 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -186,7 +186,7 @@ public sealed class IccProfile : IDeepCloneable if (this.data is null) { - this.header = new IccProfileHeader(); + this.header = new(); return; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 074712d30..da3566514 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -22,7 +22,7 @@ internal sealed class IccReader IccProfileHeader header = ReadHeader(reader); IccTagDataEntry[] tagData = ReadTagData(reader); - return new IccProfile(header, tagData); + return new(header, tagData); } /// @@ -57,7 +57,7 @@ internal sealed class IccReader { reader.SetIndex(0); - return new IccProfileHeader + return new() { Size = reader.ReadUInt32(), CmmType = reader.ReadAsciiString(4), @@ -128,7 +128,7 @@ internal sealed class IccReader // Exclude entries that have nonsense values and could cause exceptions further on if (tagOffset < reader.DataLength && tagSize < reader.DataLength - 128) { - table.Add(new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize)); + table.Add(new((IccProfileTag)tagSignature, tagOffset, tagSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs index 5e73e2dd0..8e0b4ae6d 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs @@ -77,7 +77,7 @@ internal sealed class IccWriter writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry); foreach (IccTagDataEntry item in group) { - table.Add(new IccTagTableEntry(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); + table.Add(new(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index 9ddd0ce13..b8c29ae09 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -147,7 +147,7 @@ internal sealed class IccLut16TagDataEntry : IccTagDataEntry, IEquatable= 0x41 && p4 <= 0x5A) { string culture = new(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); - return new CultureInfo(culture); + return new(culture); } return null; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 85c23d174..8d13d3862 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -185,7 +185,7 @@ public sealed class IptcProfile : IDeepCloneable } } - this.values.Add(new IptcValue(tag, encoding, value, strict)); + this.values.Add(new(tag, encoding, value, strict)); } /// @@ -322,7 +322,7 @@ public sealed class IptcProfile : IDeepCloneable { byte[] iptcData = new byte[byteCount]; Buffer.BlockCopy(this.Data, offset, iptcData, 0, (int)byteCount); - this.values.Add(new IptcValue(tag, iptcData, false)); + this.values.Add(new(tag, iptcData, false)); } offset += (int)byteCount; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 78f7f6de0..f0b1b717a 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -191,7 +191,7 @@ public sealed class IptcValue : IDeepCloneable /// A array. public byte[] ToByteArray() { - var result = new byte[this.data.Length]; + byte[] result = new byte[this.data.Length]; this.data.CopyTo(result, 0); return result; } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index ca358be31..63630dd55 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -179,7 +179,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(backdrop.Y, source.Y); float cb = OverlayValueFunction(backdrop.Z, source.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// @@ -208,7 +208,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(source.Y, backdrop.Y); float cb = OverlayValueFunction(source.Z, backdrop.Z); - return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs index 1444b344b..00be93b22 100644 --- a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs +++ b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs @@ -81,7 +81,7 @@ public readonly struct PixelComponentInfo sum += p; } - return new PixelComponentInfo(count, bitsPerPixel - sum, precisionData1, precisionData2); + return new(count, bitsPerPixel - sum, precisionData1, precisionData2); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index 87055bf22..e81b3e66f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs @@ -28,7 +28,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVectorThe y-component /// The z-component public Bgr565(float x, float y, float z) - : this(new Vector3(x, y, z)) + : this(new(x, y, z)) { } @@ -84,7 +84,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector3(source.X, source.Y, source.Z)) }; + public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y, source.Z)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index 55971210c..d6ffa4723 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs @@ -22,7 +22,7 @@ public partial struct Bgra4444 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra4444(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index 4c94dea5f..45f013fb1 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs @@ -23,7 +23,7 @@ public partial struct Bgra5551 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra5551(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index 680a7ee0b..b4479fd50 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs @@ -25,7 +25,7 @@ public partial struct Byte4 : IPixel, IPackedVector /// The z-component /// The w-component public Byte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 888d992d8..3ef711d6a 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -55,7 +55,7 @@ public partial struct HalfSingle : IPixel, IPackedVector { float single = this.ToSingle() + 1F; single /= 2F; - return new Vector4(single, 0, 0, 1F); + return new(single, 0, 0, 1F); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index d0b57d788..254e9290d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs @@ -22,7 +22,7 @@ public partial struct HalfVector4 : IPixel, IPackedVector /// The z-component. /// The w-component. public HalfVector4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 64a22060c..faad37ab5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -64,7 +64,7 @@ public partial struct L16 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float scaled = this.PackedValue / Max; - return new Vector4(scaled, scaled, scaled, 1f); + return new(scaled, scaled, scaled, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index cf8646cfa..1ef5951fe 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -66,7 +66,7 @@ public partial struct L8 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.PackedValue / 255f; - return new Vector4(rgb, rgb, rgb, 1f); + return new(rgb, rgb, rgb, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index 026d0c299..b1149dc3e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -93,7 +93,7 @@ public partial struct La16 : IPixel, IPackedVector { const float max = 255f; float rgb = this.L / max; - return new Vector4(rgb, rgb, rgb, this.A / max); + return new(rgb, rgb, rgb, this.A / max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 0ddcf16a1..ec2c38e3e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -90,7 +90,7 @@ public partial struct La32 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.L / Max; - return new Vector4(rgb, rgb, rgb, this.A / Max); + return new(rgb, rgb, rgb, this.A / Max); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index 9551d7242..c4b6bf818 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -24,7 +24,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVectorThe x-component. /// The y-component. public NormalizedByte2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -70,7 +70,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector @@ -98,7 +98,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 1fb386725..380465f4e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs @@ -27,7 +27,7 @@ public partial struct NormalizedByte4 : IPixel, IPackedVectorThe z-component. /// The w-component. public NormalizedByte4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index a17868f6d..edd2271ec 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -26,7 +26,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// The x-component. /// The y-component. public NormalizedShort2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -72,7 +72,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2f; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -100,7 +100,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index 2b33fec27..2c30a0a56 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs @@ -28,7 +28,7 @@ public partial struct NormalizedShort4 : IPixel, IPackedVector /// The z-component. /// The w-component. public NormalizedShort4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index e7c97269e..89b2a65b2 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs @@ -22,7 +22,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// The x-component /// The y-component public Rg32(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -90,7 +90,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index b03a54c58..8eaabe02e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -62,7 +62,7 @@ public partial struct Rgb24 : IPixel /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Rgb24(Rgb color) - => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); + => FromScaledVector4(new(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index cdee22964..a022476fd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs @@ -25,7 +25,7 @@ public partial struct Rgba1010102 : IPixel, IPackedVector /// The z-component /// The w-component public Rgba1010102(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 507d6d70b..f618b9a2f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -187,7 +187,7 @@ public partial struct Rgba32 : IPixel, IPackedVector /// The instance of to convert. /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); + public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. @@ -444,6 +444,6 @@ public partial struct Rgba32 : IPixel, IPackedVector char g = hex[1]; char r = hex[0]; - return new string(new[] { r, r, g, g, b, b, a, a }); + return new(new[] { r, r, g, g, b, b, a, a }); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index 403d3fbea..c76f87047 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -29,7 +29,7 @@ public partial struct Short2 : IPixel, IPackedVector /// The x-component. /// The y-component. public Short2(float x, float y) - : this(new Vector2(x, y)) + : this(new(x, y)) { } @@ -75,7 +75,7 @@ public partial struct Short2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += new Vector2(32767f); scaled /= 65534F; - return new Vector4(scaled, 0f, 1f); + return new(scaled, 0f, 1f); } /// @@ -103,7 +103,7 @@ public partial struct Short2 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; + public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index b6cece2be..c657263c0 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs @@ -31,7 +31,7 @@ public partial struct Short4 : IPixel, IPackedVector /// The z-component. /// The w-component. public Short4(float x, float y, float z, float w) - : this(new Vector4(x, y, z, w)) + : this(new(x, y, z, w)) { } diff --git a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs index 559fcdde0..7eb95569d 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs @@ -181,11 +181,11 @@ public partial struct ColorMatrix float m41, float m42, float m43, float m44, float m51, float m52, float m53, float m54) { - this.X = new Vector4(m11, m12, m13, m14); - this.Y = new Vector4(m21, m22, m23, m24); - this.Z = new Vector4(m31, m32, m33, m34); - this.W = new Vector4(m41, m42, m43, m44); - this.V = new Vector4(m51, m52, m53, m54); + this.X = new(m11, m12, m13, m14); + this.Y = new(m21, m22, m23, m24); + this.Z = new(m31, m32, m33, m34); + this.W = new(m41, m42, m43, m44); + this.V = new(m51, m52, m53, m54); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Primitives/Complex64.cs b/src/ImageSharp/Primitives/Complex64.cs index 4baedd9ba..2a16df969 100644 --- a/src/ImageSharp/Primitives/Complex64.cs +++ b/src/ImageSharp/Primitives/Complex64.cs @@ -42,7 +42,7 @@ internal readonly struct Complex64 : IEquatable /// The scalar to use to multiply the value. /// The result [MethodImpl(InliningOptions.ShortMethod)] - public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar); + public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar); /// /// Performs the multiplication operation between a instance and a . @@ -53,7 +53,7 @@ internal readonly struct Complex64 : IEquatable [MethodImpl(InliningOptions.ShortMethod)] public static ComplexVector4 operator *(Complex64 value, Vector4 vector) { - return new ComplexVector4 { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; + return new() { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; } /// @@ -67,7 +67,7 @@ internal readonly struct Complex64 : IEquatable { Vector4 real = (value.Real * vector.Real) - (value.Imaginary * vector.Imaginary); Vector4 imaginary = (value.Real * vector.Imaginary) + (value.Imaginary * vector.Real); - return new ComplexVector4 { Real = real, Imaginary = imaginary }; + return new() { Real = real, Imaginary = imaginary }; } /// diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index 9849e0211..b39f306cb 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -36,7 +36,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = columns * rows; this.Data = new T[this.Columns * this.Rows]; } @@ -56,7 +56,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -84,7 +84,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new Size(columns, rows); + this.Size = new(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -198,7 +198,7 @@ public readonly struct DenseMatrix : IEquatable> [MethodImpl(MethodImplOptions.AggressiveInlining)] public DenseMatrix Transpose() { - DenseMatrix result = new DenseMatrix(this.Rows, this.Columns); + DenseMatrix result = new(this.Rows, this.Columns); for (int y = 0; y < this.Rows; y++) { diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index 69139ac9c..0b3380ca9 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -133,22 +133,22 @@ internal readonly struct LongRational : IEquatable { if (value == 0.0) { - return new LongRational(0, 1); + return new(0, 1); } if (double.IsNaN(value)) { - return new LongRational(0, 0); + return new(0, 0); } if (double.IsPositiveInfinity(value)) { - return new LongRational(1, 0); + return new(1, 0); } if (double.IsNegativeInfinity(value)) { - return new LongRational(-1, 0); + return new(-1, 0); } long numerator = 1; @@ -208,14 +208,14 @@ internal readonly struct LongRational : IEquatable if (this.Numerator == this.Denominator) { - return new LongRational(1, 1); + return new(1, 1); } long gcd = GreatestCommonDivisor(Math.Abs(this.Numerator), Math.Abs(this.Denominator)); if (gcd > 1) { - return new LongRational(this.Numerator / gcd, this.Denominator / gcd); + return new(this.Numerator / gcd, this.Denominator / gcd); } return this; diff --git a/src/ImageSharp/Primitives/Point.cs b/src/ImageSharp/Primitives/Point.cs index 8ace7ffac..5eae087ed 100644 --- a/src/ImageSharp/Primitives/Point.cs +++ b/src/ImageSharp/Primitives/Point.cs @@ -232,7 +232,7 @@ public struct Point : IEquatable /// The transformation matrix used. /// The transformed . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new Vector2(point.X, point.Y), matrix)); + public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new(point.X, point.Y), matrix)); /// /// Deconstructs this point into two integers. diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index e2ae5071e..a3cb89cf0 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -214,7 +214,7 @@ public struct Rectangle : IEquatable if (x2 >= x1 && y2 >= y1) { - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -245,7 +245,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)MathF.Ceiling(rectangle.X), (int)MathF.Ceiling(rectangle.Y), (int)MathF.Ceiling(rectangle.Width), @@ -261,9 +261,9 @@ public struct Rectangle : IEquatable /// A transformed rectangle. public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix) { - PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = Point.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = Point.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -276,7 +276,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, @@ -294,7 +294,7 @@ public struct Rectangle : IEquatable { unchecked { - return new Rectangle( + return new( (int)MathF.Round(rectangle.X), (int)MathF.Round(rectangle.Y), (int)MathF.Round(rectangle.Width), @@ -316,7 +316,7 @@ public struct Rectangle : IEquatable int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Bottom, b.Bottom); - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/RectangleF.cs b/src/ImageSharp/Primitives/RectangleF.cs index 68add77d0..9a7a97a13 100644 --- a/src/ImageSharp/Primitives/RectangleF.cs +++ b/src/ImageSharp/Primitives/RectangleF.cs @@ -207,7 +207,7 @@ public struct RectangleF : IEquatable if (x2 >= x1 && y2 >= y1) { - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -236,9 +236,9 @@ public struct RectangleF : IEquatable /// A transformed . public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix) { - PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = PointF.Transform(new(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = PointF.Transform(rectangle.Location, matrix); - return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); + return new(topLeft, new(bottomRight - topLeft)); } /// @@ -255,7 +255,7 @@ public struct RectangleF : IEquatable float y1 = MathF.Min(a.Y, b.Y); float y2 = MathF.Max(a.Bottom, b.Bottom); - return new RectangleF(x1, y1, x2 - x1, y2 - y1); + return new(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index d56ea825e..2b62b4c3e 100644 --- a/src/ImageSharp/Primitives/SignedRational.cs +++ b/src/ImageSharp/Primitives/SignedRational.cs @@ -42,7 +42,7 @@ public readonly struct SignedRational : IEquatable { if (simplify) { - var rational = new LongRational(numerator, denominator).Simplify(); + LongRational rational = new LongRational(numerator, denominator).Simplify(); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -70,7 +70,7 @@ public readonly struct SignedRational : IEquatable /// Whether to use the best possible precision when parsing the value. public SignedRational(double value, bool bestPrecision) { - var rational = LongRational.FromDouble(value, bestPrecision); + LongRational rational = LongRational.FromDouble(value, bestPrecision); this.Numerator = (int)rational.Numerator; this.Denominator = (int)rational.Denominator; @@ -117,7 +117,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value) { - return new SignedRational(value, false); + return new(value, false); } /// @@ -130,7 +130,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value, bool bestPrecision) { - return new SignedRational(value, bestPrecision); + return new(value, bestPrecision); } /// @@ -142,8 +142,8 @@ public readonly struct SignedRational : IEquatable /// public bool Equals(SignedRational other) { - var left = new LongRational(this.Numerator, this.Denominator); - var right = new LongRational(other.Numerator, other.Denominator); + LongRational left = new(this.Numerator, this.Denominator); + LongRational right = new(other.Numerator, other.Denominator); return left.Equals(right); } @@ -151,7 +151,7 @@ public readonly struct SignedRational : IEquatable /// public override int GetHashCode() { - var self = new LongRational(this.Numerator, this.Denominator); + LongRational self = new(this.Numerator, this.Denominator); return self.GetHashCode(); } @@ -182,7 +182,7 @@ public readonly struct SignedRational : IEquatable /// The public string ToString(IFormatProvider provider) { - var rational = new LongRational(this.Numerator, this.Denominator); + LongRational rational = new(this.Numerator, this.Denominator); return rational.ToString(provider); } } diff --git a/src/ImageSharp/Primitives/Size.cs b/src/ImageSharp/Primitives/Size.cs index 945b680da..5ceab493f 100644 --- a/src/ImageSharp/Primitives/Size.cs +++ b/src/ImageSharp/Primitives/Size.cs @@ -85,14 +85,14 @@ public struct Size : IEquatable /// /// The point. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator SizeF(Size size) => new SizeF(size.Width, size.Height); + public static implicit operator SizeF(Size size) => new(size.Width, size.Height); /// /// Converts the given into a . /// /// The size. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Point(Size size) => new Point(size.Width, size.Height); + public static explicit operator Point(Size size) => new(size.Width, size.Height); /// /// Computes the sum of adding two sizes. @@ -138,7 +138,7 @@ public struct Size : IEquatable /// Dividend of type . /// Divisor of type . /// Result of type . - public static Size operator /(Size left, int right) => new Size(unchecked(left.Width / right), unchecked(left.Height / right)); + public static Size operator /(Size left, int right) => new(unchecked(left.Width / right), unchecked(left.Height / right)); /// /// Multiplies by a producing . @@ -163,7 +163,7 @@ public struct Size : IEquatable /// Divisor of type . /// Result of type . public static SizeF operator /(Size left, float right) - => new SizeF(left.Width / right, left.Height / right); + => new(left.Width / right, left.Height / right); /// /// Compares two objects for equality. @@ -202,7 +202,7 @@ public struct Size : IEquatable /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Add(Size left, Size right) => new Size(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); + public static Size Add(Size left, Size right) => new(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); /// /// Contracts a by another . @@ -211,7 +211,7 @@ public struct Size : IEquatable /// The size on the right hand of the operand. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); + public static Size Subtract(Size left, Size right) => new(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); /// /// Converts a to a by performing a ceiling operation on all the dimensions. @@ -219,7 +219,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Ceiling(SizeF size) => new Size(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); + public static Size Ceiling(SizeF size) => new(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); /// /// Converts a to a by performing a round operation on all the dimensions. @@ -227,7 +227,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); + public static Size Round(SizeF size) => new(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); /// /// Transforms a size by the given matrix. @@ -237,9 +237,9 @@ public struct Size : IEquatable /// A transformed size. public static SizeF Transform(Size size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(v.X, v.Y); } /// @@ -248,7 +248,7 @@ public struct Size : IEquatable /// The size. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height)); + public static Size Truncate(SizeF size) => new(unchecked((int)size.Width), unchecked((int)size.Height)); /// /// Deconstructs this size into two integers. @@ -281,7 +281,7 @@ public struct Size : IEquatable /// Multiplier of type . /// Product of type . private static Size Multiply(Size size, int multiplier) => - new Size(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); + new(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier)); /// /// Multiplies by a producing . @@ -290,5 +290,5 @@ public struct Size : IEquatable /// Multiplier of type . /// Product of type SizeF. private static SizeF Multiply(Size size, float multiplier) => - new SizeF(size.Width * multiplier, size.Height * multiplier); + new(size.Width * multiplier, size.Height * multiplier); } diff --git a/src/ImageSharp/Primitives/SizeF.cs b/src/ImageSharp/Primitives/SizeF.cs index 36cf9eb8e..88c3b8319 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -191,9 +191,9 @@ public struct SizeF : IEquatable /// A transformed size. public static SizeF Transform(SizeF size, Matrix3x2 matrix) { - var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); - return new SizeF(v.X, v.Y); + return new(v.X, v.Y); } /// diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index f572dd658..9a76269b3 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -68,7 +68,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfWidth public static ValueSize PercentageOfWidth(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfWidth); + return new(percentage, ValueSizeType.PercentageOfWidth); } /// @@ -78,7 +78,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfHeight public static ValueSize PercentageOfHeight(float percentage) { - return new ValueSize(percentage, ValueSizeType.PercentageOfHeight); + return new(percentage, ValueSizeType.PercentageOfHeight); } /// @@ -88,7 +88,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type Absolute. public static ValueSize Absolute(float value) { - return new ValueSize(value, ValueSizeType.Absolute); + return new(value, ValueSizeType.Absolute); } /// diff --git a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs index d7f4ba359..6af61338d 100644 --- a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs @@ -16,7 +16,7 @@ public static class HistogramEqualizationExtensions /// The current image processing context. /// The . public static IImageProcessingContext HistogramEqualization(this IImageProcessingContext source) => - HistogramEqualization(source, new HistogramEqualizationOptions()); + HistogramEqualization(source, new()); /// /// Equalizes the histogram of an image to increases the contrast. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs index 3025806d4..256bac64e 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs @@ -19,7 +19,7 @@ public static class CropExtensions /// The target image height. /// The . public static IImageProcessingContext Crop(this IImageProcessingContext source, int width, int height) => - Crop(source, new Rectangle(0, 0, width, height)); + Crop(source, new(0, 0, width, height)); /// /// Crops an image to the given rectangle. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs index b6db0172d..cca3e4241 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs @@ -30,10 +30,10 @@ public static class PadExtensions public static IImageProcessingContext Pad(this IImageProcessingContext source, int width, int height, Color color) { Size size = source.GetCurrentSize(); - var options = new ResizeOptions + ResizeOptions options = new() { // Prevent downsizing. - Size = new Size(Math.Max(width, size.Width), Math.Max(height, size.Height)), + Size = new(Math.Max(width, size.Width), Math.Max(height, size.Height)), Mode = ResizeMode.BoxPad, Sampler = KnownResamplers.NearestNeighbor, PadColor = color diff --git a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs index 01f296d09..3ac9553d4 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs @@ -77,7 +77,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, IResampler sampler, bool compand) - => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); + => Resize(source, size.Width, size.Height, sampler, new(0, 0, size.Width, size.Height), compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -90,7 +90,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler, bool compand) - => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); + => Resize(source, width, height, sampler, new(0, 0, width, height), compand); /// /// Resizes an image to the given width and height with the given sampler and @@ -118,9 +118,9 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, @@ -151,9 +151,9 @@ public static class ResizeExtensions Rectangle targetRectangle, bool compand) { - var options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(width, height), + Size = new(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index 60f90b10f..dedde797b 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -34,7 +34,7 @@ public static class TransformExtensions this IImageProcessingContext source, AffineTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs an affine transform of an image using the specified sampling algorithm. @@ -96,7 +96,7 @@ public static class TransformExtensions this IImageProcessingContext source, ProjectiveTransformBuilder builder, IResampler sampler) => - source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs a projective transform of an image using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index b312287b5..0b40fa945 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -20,7 +20,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatomaly (Color desensitivity) color blindness /// - public static ColorMatrix AchromatomalyFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatomalyFilter { get; } = new() { M11 = .618F, M12 = .163F, @@ -37,7 +37,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Achromatopsia (Monochrome) color blindness. /// - public static ColorMatrix AchromatopsiaFilter { get; } = new ColorMatrix + public static ColorMatrix AchromatopsiaFilter { get; } = new() { M11 = .299F, M12 = .299F, @@ -54,7 +54,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranomaly (Green-Weak) color blindness. /// - public static ColorMatrix DeuteranomalyFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranomalyFilter { get; } = new() { M11 = .8F, M12 = .258F, @@ -68,7 +68,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Deuteranopia (Green-Blind) color blindness. /// - public static ColorMatrix DeuteranopiaFilter { get; } = new ColorMatrix + public static ColorMatrix DeuteranopiaFilter { get; } = new() { M11 = .625F, M12 = .7F, @@ -82,7 +82,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanomaly (Red-Weak) color blindness. /// - public static ColorMatrix ProtanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanomalyFilter { get; } = new() { M11 = .817F, M12 = .333F, @@ -96,7 +96,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Protanopia (Red-Blind) color blindness. /// - public static ColorMatrix ProtanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix ProtanopiaFilter { get; } = new() { M11 = .567F, M12 = .558F, @@ -110,7 +110,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanomaly (Blue-Weak) color blindness. /// - public static ColorMatrix TritanomalyFilter { get; } = new ColorMatrix + public static ColorMatrix TritanomalyFilter { get; } = new() { M11 = .967F, M21 = .33F, @@ -124,7 +124,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating Tritanopia (Blue-Blind) color blindness. /// - public static ColorMatrix TritanopiaFilter { get; } = new ColorMatrix + public static ColorMatrix TritanopiaFilter { get; } = new() { M11 = .95F, M21 = .05F, @@ -138,7 +138,7 @@ public static class KnownFilterMatrices /// /// Gets an approximated black and white filter /// - public static ColorMatrix BlackWhiteFilter { get; } = new ColorMatrix + public static ColorMatrix BlackWhiteFilter { get; } = new() { M11 = 1.5F, M12 = 1.5F, @@ -190,7 +190,7 @@ public static class KnownFilterMatrices /// /// Gets a filter recreating an old Polaroid camera effect. /// - public static ColorMatrix PolaroidFilter { get; } = new ColorMatrix + public static ColorMatrix PolaroidFilter { get; } = new() { M11 = 1.538F, M12 = -.062F, @@ -221,7 +221,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -246,7 +246,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float contrast = (-.5F * amount) + .5F; - return new ColorMatrix + return new() { M11 = amount, M22 = amount, @@ -338,7 +338,7 @@ public static class KnownFilterMatrices // The matrix is set up to preserve the luminance of the image. // See http://graficaobscura.com/matrix/index.html // Number are taken from https://msdn.microsoft.com/en-us/library/jj192162(v=vs.85).aspx - return new ColorMatrix + return new() { M11 = .213F + (cosRadian * .787F) - (sinRadian * .213F), M21 = .715F - (cosRadian * .715F) - (sinRadian * .715F), @@ -367,7 +367,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float invert = 1F - (2F * amount); - return new ColorMatrix + return new() { M11 = invert, M22 = invert, @@ -389,7 +389,7 @@ public static class KnownFilterMatrices Guard.MustBeBetweenOrEqualTo(amount, 0, 1, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -443,7 +443,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); amount--; - return new ColorMatrix + return new() { M11 = 1F, M22 = 1F, @@ -467,7 +467,7 @@ public static class KnownFilterMatrices amount = 1F - amount; // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new ColorMatrix + return new() { M11 = .393F + (.607F * amount), M21 = .769F - (.769F * amount), diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index bc34f759a..2e675cdd4 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -158,7 +158,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor[] destinationFrames = new ImageFrame[source.Frames.Count]; for (int i = 0; i < destinationFrames.Length; i++) { - destinationFrames[i] = new ImageFrame( + destinationFrames[i] = new( this.Configuration, destinationSize.Width, destinationSize.Height, @@ -166,7 +166,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor(this.Configuration, source.Metadata.DeepClone(), destinationFrames); + return new(this.Configuration, source.Metadata.DeepClone(), destinationFrames); } private void CheckFrameCount(Image a, Image b) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index ff3b30e9c..96daca47a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs @@ -68,7 +68,7 @@ internal class BoxBlurProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } @@ -80,7 +80,7 @@ internal class BoxBlurProcessor : ImageProcessor /// The . private static float[] CreateBoxKernel(int kernelSize) { - var kernel = new float[kernelSize]; + float[] kernel = new float[kernelSize]; kernel.AsSpan().Fill(1F / kernelSize); diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index 2a4a1abf0..08e8425bb 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -75,7 +75,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. @@ -141,7 +141,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - var state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index 6f5388e22..b3dae6baa 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -22,8 +22,8 @@ internal readonly ref struct Convolution2DState KernelSamplingMap map) { // We check the kernels are the same size upstream. - this.KernelY = new ReadOnlyKernel(kernelY); - this.KernelX = new ReadOnlyKernel(kernelX); + this.KernelY = new(kernelY); + this.KernelX = new(kernelX); this.kernelHeight = (uint)kernelY.Rows; this.kernelWidth = (uint)kernelY.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index 6663c4502..20e95d058 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -20,7 +20,7 @@ internal readonly ref struct ConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new ReadOnlyKernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = (uint)kernel.Rows; this.kernelWidth = (uint)kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index 5af436044..fbf576c23 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs @@ -55,7 +55,7 @@ internal class EdgeDetector2DProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using var processor = new Convolution2DProcessor( + using Convolution2DProcessor processor = new Convolution2DProcessor( this.Configuration, in this.kernelX, in this.kernelY, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs index 7efcbf3a6..cd9f4d7ab 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs @@ -19,7 +19,7 @@ internal static class LaplacianKernelFactory Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); - var kernel = new DenseMatrix((int)length); + DenseMatrix kernel = new DenseMatrix((int)length); kernel.Fill(-1); int mid = (int)(length / 2); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs index 137334c29..5b2c903ba 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs @@ -21,7 +21,7 @@ internal readonly ref struct MedianConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new Kernel(kernel); + this.Kernel = new(kernel); this.kernelHeight = kernel.Rows; this.kernelWidth = kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index ca2cabab5..64fd40f15 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -153,7 +153,7 @@ internal readonly struct MedianRowOperation : IRowOperation // Taking the W value from the source pixels, where the middle index in the kernelSpan is by definition the resulting pixel. // This will preserve the alpha value. - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -176,6 +176,6 @@ internal readonly struct MedianRowOperation : IRowOperation zChannel.Sort(); wChannel.Sort(); - return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); + return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 565a5746d..6832e2498 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -16,7 +16,7 @@ internal static class BokehBlurKernelDataProvider /// /// The mapping of initialized complex kernels and parameters, to speed up the initialization of new instances /// - private static readonly ConcurrentDictionary Cache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary Cache = new(); /// /// Gets the kernel scales to adjust the component values in each kernel @@ -90,7 +90,7 @@ internal static class BokehBlurKernelDataProvider int componentsCount) { // Reuse the initialized values from the cache, if possible - var parameters = new BokehBlurParameters(radius, componentsCount); + BokehBlurParameters parameters = new(radius, componentsCount); if (!Cache.TryGetValue(parameters, out BokehBlurKernelData info)) { // Initialize the complex kernels and parameters with the current arguments @@ -99,7 +99,7 @@ internal static class BokehBlurKernelDataProvider NormalizeKernels(kernels, kernelParameters); // Store them in the cache for future use - info = new BokehBlurKernelData(kernelParameters, kernels); + info = new(kernelParameters, kernels); Cache.TryAdd(parameters, info); } @@ -130,7 +130,7 @@ internal static class BokehBlurKernelDataProvider int kernelSize, float kernelsScale) { - var kernels = new Complex64[kernelParameters.Length][]; + Complex64[][] kernels = new Complex64[kernelParameters.Length][]; ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) { @@ -156,7 +156,7 @@ internal static class BokehBlurKernelDataProvider float a, float b) { - var kernel = new Complex64[kernelSize]; + Complex64[] kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); int r = radius, n = -r; @@ -167,7 +167,7 @@ internal static class BokehBlurKernelDataProvider value *= value; // Fill in the complex kernel values - Unsafe.Add(ref baseRef, (uint)i) = new Complex64( + Unsafe.Add(ref baseRef, (uint)i) = new( MathF.Exp(-a * value) * MathF.Cos(b * value), MathF.Exp(-a * value) * MathF.Sin(b * value)); } diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs index 57d8ef59a..d58f9020c 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs @@ -65,7 +65,7 @@ public readonly partial struct ErrorDither { 0, 1 / divisor, 0, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateBurks() @@ -79,7 +79,7 @@ public readonly partial struct ErrorDither { 2 / divisor, 4 / divisor, 8 / divisor, 4 / divisor, 2 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateFloydSteinberg() @@ -93,7 +93,7 @@ public readonly partial struct ErrorDither { 3 / divisor, 5 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateJarvisJudiceNinke() @@ -108,7 +108,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 3 / divisor, 5 / divisor, 3 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra2() @@ -122,7 +122,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 3 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierra3() @@ -137,7 +137,7 @@ public readonly partial struct ErrorDither { 0, 2 / divisor, 3 / divisor, 2 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateSierraLite() @@ -151,7 +151,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 1 / divisor, 0 } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStevensonArce() @@ -167,7 +167,7 @@ public readonly partial struct ErrorDither { 5 / divisor, 0, 12 / divisor, 0, 12 / divisor, 0, 5 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } private static ErrorDither CreateStucki() @@ -182,6 +182,6 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 4 / divisor, 2 / divisor, 1 / divisor } }; - return new ErrorDither(matrix, offset); + return new(matrix, offset); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index d1f46c744..d4dd10b73 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -32,7 +32,7 @@ public readonly partial struct OrderedDither : IDither, IEquatable((int)length); + DenseMatrix thresholdMatrix = new DenseMatrix((int)length); float m2 = length * length; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs index 7f8b34724..9fa331d7b 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs @@ -29,7 +29,7 @@ internal static class OrderedDitherFactory while (length > bayerLength); // Create our Bayer matrix that matches the given exponent and dimensions - var matrix = new DenseMatrix((int)length); + DenseMatrix matrix = new DenseMatrix((int)length); uint i = 0; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 0d4680e21..2f4a0a9f0 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -37,7 +37,7 @@ internal sealed class PaletteDitherProcessor : ImageProcessor this.paletteOwner = this.Configuration.MemoryAllocator.Allocate(sourcePalette.Length); Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span); - this.ditherProcessor = new DitherProcessor( + this.ditherProcessor = new( this.Configuration, this.paletteOwner.Memory, definition.DitherScale); diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index f811bae0f..5e491c1ee 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -174,7 +174,7 @@ internal class OilPaintingProcessor : ImageProcessor float green = greenBinSpan[maxIndex] / maxIntensity; float alpha = sourceRowVector4Span[x].W; - targetRowVector4Span[x] = new Vector4(red, green, blue, alpha); + targetRowVector4Span[x] = new(red, green, blue, alpha); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs index 06cfa49b3..f1014c0df 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -37,7 +37,7 @@ internal sealed class PixelRowDelegateProcessor : IImageProcessor public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixel : unmanaged, IPixel => new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index d38ffc801..a3aba4cfc 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -96,7 +96,7 @@ internal sealed class PixelRowDelegateProcessor : ImageProces PixelOperations.Instance.ToVector4(this.configuration, rowSpan, span, this.modifiers); // Run the user defined pixel shader to the current row of pixels - Unsafe.AsRef(in this.rowProcessor).Invoke(span, new Point(this.startX, y)); + Unsafe.AsRef(in this.rowProcessor).Invoke(span, new(this.startX, y)); PixelOperations.Instance.FromVector4Destructive(this.configuration, span, rowSpan, this.modifiers); } diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs index 6786eb5f5..a54a7bfd2 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -38,7 +38,7 @@ internal sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( - new PixelRowDelegate(this.PixelRowOperation), + new(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index 78085eaab..e91124958 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -81,7 +81,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz RowIntervalOperation operation = new(cdfData, tileYStartPositions, tileWidth, tileHeight, tileCount, halfTileWidth, luminanceLevels, source.PixelBuffer); ParallelRowIterator.IterateRowIntervals( this.Configuration, - new Rectangle(0, 0, sourceWidth, tileYStartPositions.Count), + new(0, 0, sourceWidth, tileYStartPositions.Count), in operation); // Fix left column @@ -191,7 +191,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } tileY++; @@ -243,7 +243,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX + 1, cdfY, tileX, tileWidth, luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } } @@ -432,7 +432,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz this.tileHeight, this.luminanceLevels); - pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } @@ -515,7 +515,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz ParallelRowIterator.IterateRowIntervals( this.configuration, - new Rectangle(0, 0, this.sourceWidth, this.tileYStartPositions.Count), + new(0, 0, this.sourceWidth, this.tileYStartPositions.Count), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index 606789af9..f104ee34a 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -214,7 +214,7 @@ internal class AutoLevelProcessor : HistogramEqualizationProcessor.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 3ab8f7431..b159847bb 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class GlobalHistogramEqualizationProcessor : HistogramEqualizat Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs index 0a8690ba7..3584f2954 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GrayscaleLevelsRowOperation{TPixel}.cs @@ -56,7 +56,7 @@ internal readonly struct GrayscaleLevelsRowOperation : IRowOperation : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (1 - (.95F * (distance / this.maxDistance))), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index b08cd898e..b24ed7ed5 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -113,7 +113,7 @@ internal class VignetteProcessor : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (.9F * (distance / this.maxDistance)), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs index 0a1032bf0..9a46a9883 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs @@ -16,7 +16,7 @@ public class OctreeQuantizer : IQuantizer /// using the default . /// public OctreeQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 07596b68a..25d3e7416 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -44,7 +44,7 @@ public struct OctreeQuantizer : IQuantizer this.maxColors = this.Options.MaxColors; this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); - this.octree = new Octree(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); + this.octree = new(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.pixelMap = default; this.palette = default; @@ -547,14 +547,14 @@ public struct OctreeQuantizer : IQuantizer Vector4 vector = Vector4.Clamp( (sum + offset) / this.PixelCount, Vector4.Zero, - new Vector4(255)); + new(255)); if (vector.W < octree.transparencyThreshold255) { vector = Vector4.Zero; } - palette[paletteIndex] = TPixel.FromRgba32(new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); + palette[paletteIndex] = TPixel.FromRgba32(new((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); this.PaletteIndex = paletteIndex++; } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index a49691515..91d086fc6 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -19,7 +19,7 @@ public class PaletteQuantizer : IQuantizer /// /// The color palette. public PaletteQuantizer(ReadOnlyMemory palette) - : this(palette, new QuantizerOptions()) + : this(palette, new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs index fa1763367..b1dace40b 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs @@ -12,7 +12,7 @@ public sealed class WebSafePaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WebSafePaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs index cd7b80e81..02c217c36 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs @@ -13,7 +13,7 @@ public sealed class WernerPaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WernerPaletteQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs index 86d798d96..cda78c7d1 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs @@ -15,7 +15,7 @@ public class WuQuantizer : IQuantizer /// using the default . /// public WuQuantizer() - : this(new QuantizerOptions()) + : this(new()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index 03d6ac0da..cb7020486 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -513,7 +513,7 @@ internal struct WuQuantizer : IQuantizer continue; } - vector = new Vector4(half.R, half.G, half.B, half.A); + vector = new(half.R, half.G, half.B, half.A); temp += Vector4.Dot(vector, vector) / half.Weight; if (temp > max) diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 1d82dd12a..5465b502b 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -50,7 +50,7 @@ internal class CropProcessor : TransformProcessor ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(this.Configuration).MultiplyMinimumPixelsPerTask(4); - var operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); + RowOperation operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( bounds, diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index b3919e584..6115ded03 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < destinationRowSpan.Length; x++) { - Vector2 point = Vector2.Transform(new Vector2(x, y), this.matrix); + Vector2 point = Vector2.Transform(new(x, y), this.matrix); int px = (int)MathF.Round(point.X); int py = (int)MathF.Round(point.Y); @@ -204,7 +204,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < span.Length; x++) { - Vector2 point = Vector2.Transform(new Vector2(x, y), matrix); + Vector2 point = Vector2.Transform(new(x, y), matrix); float pY = point.Y; float pX = point.X; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs index d90f948b6..e9e2849ae 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs @@ -72,7 +72,7 @@ internal static class ResizeHelper // case ResizeMode.Stretch: default: - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(0, 0, Sanitize(width), Sanitize(height))); + return (new(Sanitize(width), Sanitize(height)), new(0, 0, Sanitize(width), Sanitize(height))); } } @@ -143,7 +143,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } // Switch to pad mode to downscale and calculate from there. @@ -253,7 +253,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMaxRectangle( @@ -282,7 +282,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( @@ -298,7 +298,7 @@ internal static class ResizeHelper // Don't upscale if (width > sourceWidth || height > sourceHeight) { - return (new Size(sourceWidth, sourceHeight), new Rectangle(0, 0, sourceWidth, sourceHeight)); + return (new(sourceWidth, sourceHeight), new(0, 0, sourceWidth, sourceHeight)); } // Find the shortest distance to go. @@ -330,7 +330,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculatePadRectangle( @@ -398,7 +398,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateManualRectangle( @@ -419,7 +419,7 @@ internal static class ResizeHelper int targetHeight = targetRectangle.Height > 0 ? targetRectangle.Height : height; // Target image width and height can be different to the rectangle width and height. - return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } [DoesNotReturn] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index c1907bb52..fb4d31988 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -255,7 +255,7 @@ internal partial class ResizeKernelMap : IDisposable ref float rowReference = ref MemoryMarshal.GetReference(rowSpan); float* rowPtr = (float*)Unsafe.AsPointer(ref rowReference); - return new ResizeKernel(left, rowPtr, length); + return new(left, rowPtr, length); } [Conditional("DEBUG")] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index cfc30edc0..a2bd29116 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -81,7 +81,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling return; } - var interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); + Rectangle interest = Rectangle.Intersect(destinationRectangle, destination.Bounds); if (sampler is NearestNeighborResampler) { @@ -110,13 +110,13 @@ internal class ResizeProcessor : TransformProcessor, IResampling // Since all image frame dimensions have to be the same we can calculate // the kernel maps and reuse for all frames. MemoryAllocator allocator = configuration.MemoryAllocator; - using var horizontalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap horizontalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Width, sourceRectangle.Width, allocator); - using var verticalKernelMap = ResizeKernelMap.Calculate( + using ResizeKernelMap verticalKernelMap = ResizeKernelMap.Calculate( in sampler, destinationRectangle.Height, sourceRectangle.Height, @@ -158,7 +158,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling float widthFactor = sourceRectangle.Width / (float)destinationRectangle.Width; float heightFactor = sourceRectangle.Height / (float)destinationRectangle.Height; - var operation = new NNRowOperation( + NNRowOperation operation = new NNRowOperation( sourceRectangle, destinationRectangle, interest, @@ -208,7 +208,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling // To reintroduce parallel processing, we would launch multiple workers // for different row intervals of the image. - using var worker = new ResizeWorker( + using ResizeWorker worker = new ResizeWorker( configuration, sourceRegion, conversionModifiers, @@ -218,7 +218,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling destinationRectangle.Location); worker.Initialize(); - var workingInterval = new RowInterval(interest.Top, interest.Bottom); + RowInterval workingInterval = new RowInterval(interest.Top, interest.Bottom); worker.FillDestinationPixels(workingInterval, destination.PixelBuffer); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index cce27a401..3da3fcb6a 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -89,7 +89,7 @@ internal sealed class ResizeWorker : IDisposable this.tempRowBuffer = configuration.MemoryAllocator.Allocate(this.sourceRectangle.Width); this.tempColumnBuffer = configuration.MemoryAllocator.Allocate(targetWorkingRect.Width); - this.currentWindow = new RowInterval(0, this.workerHeight); + this.currentWindow = new(0, this.workerHeight); } public void Dispose() @@ -158,7 +158,7 @@ internal sealed class ResizeWorker : IDisposable 0, this.windowBandHeight); - this.currentWindow = new RowInterval(minY, maxY); + this.currentWindow = new(minY, maxY); // Calculate the remainder: this.CalculateFirstPassValues(this.currentWindow.Slice(this.windowBandHeight)); diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 47b3250b8..1813be2fd 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -407,10 +407,10 @@ internal static class TransformUtils float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) // Apply the offset relative to the scale - SizeF offsetSize = usePixelSpace ? new SizeF(scaleX, scaleY) : SizeF.Empty; + SizeF offsetSize = usePixelSpace ? new(scaleX, scaleY) : SizeF.Empty; // Subtract the offset size to translate to the appropriate space (pixel or coordinate). - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the correct space. return Size.Ceiling(ConstrainSize(bounds) + offsetSize); @@ -459,7 +459,7 @@ internal static class TransformUtils } // Subtract the offset size to translate to the pixel space. - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the coordinate space. return Size.Ceiling((constrain ? ConstrainSize(bounds) : bounds.Size) + offsetSize); @@ -485,10 +485,10 @@ internal static class TransformUtils return false; } - Vector2 tl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Top), matrix); - Vector2 tr = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Top), matrix); - Vector2 bl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Bottom), matrix); - Vector2 br = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Bottom), matrix); + Vector2 tl = Vector2.Transform(new(rectangle.Left, rectangle.Top), matrix); + Vector2 tr = Vector2.Transform(new(rectangle.Right, rectangle.Top), matrix); + Vector2 bl = Vector2.Transform(new(rectangle.Left, rectangle.Bottom), matrix); + Vector2 br = Vector2.Transform(new(rectangle.Right, rectangle.Bottom), matrix); bounds = GetBoundingRectangle(tl, tr, bl, br); return true; @@ -540,7 +540,7 @@ internal static class TransformUtils width = rectangle.Width; } - return new Size(width, height); + return new(width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index 82b897ea5..321196582 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -69,7 +69,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -87,7 +87,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder PrependRotationRadians(float radians, Vector2 origin) - => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Appends a centered rotation matrix using the given rotation in degrees. @@ -103,7 +103,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -121,7 +121,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder AppendRotationRadians(float radians, Vector2 origin) - => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); /// /// Prepends a scale matrix from the given uniform scale. @@ -187,7 +187,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Prepend(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -207,7 +207,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.PrependMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.PrependMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Appends a centered skew matrix from the give angles in degrees. @@ -225,7 +225,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Append(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -245,7 +245,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.AppendMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.AppendMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Prepends a translation matrix from the given vector. @@ -261,7 +261,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder PrependTranslation(Vector2 position) - => this.PrependMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.PrependMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Appends a translation matrix from the given vector. @@ -277,7 +277,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder AppendTranslation(Vector2 position) - => this.AppendMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); + => this.AppendMatrix(Matrix4x4.CreateTranslation(new(position, 0))); /// /// Prepends a quad distortion matrix using the specified corner points. @@ -289,7 +289,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder PrependQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Prepend(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Appends a quad distortion matrix using the specified corner points. @@ -301,7 +301,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder AppendQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Append(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Prepends a raw matrix. @@ -359,7 +359,7 @@ public class ProjectiveTransformBuilder Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle)); // Translate the origin matrix to cater for source rectangle offsets. - Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0)); + Matrix4x4 matrix = Matrix4x4.CreateTranslation(new(-sourceRectangle.Location, 0)); Size size = sourceRectangle.Size; diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs index 92d5bcdbf..e263e3c62 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs @@ -49,7 +49,7 @@ public abstract class FromRgba32Bytes for (int i = 0; i < this.Count; i++) { int i4 = i * 4; - d[i] = TPixel.FromRgba32(new Rgba32(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); + d[i] = TPixel.FromRgba32(new(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs index eec926a23..53b76201c 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs @@ -37,6 +37,6 @@ public class DecodeBmp { using MemoryStream memoryStream = new(this.bmpBytes); using Image image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs index 3238e8dac..84428d2fc 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs @@ -23,7 +23,7 @@ public abstract class DecodeEncodeGif private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); [GlobalSetup] - public void Setup() => this.outputStream = new MemoryStream(); + public void Setup() => this.outputStream = new(); [GlobalCleanup] public void Cleanup() => this.outputStream.Close(); @@ -54,6 +54,6 @@ public class DecodeEncodeGif_CoarsePaletteEncoder : DecodeEncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs index 117cdd25b..044a50d04 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs @@ -36,6 +36,6 @@ public class DecodeGif { using MemoryStream memoryStream = new(this.gifBytes); using Image image = Image.Load(memoryStream); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs index b8f8f7851..60c14ff25 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs @@ -38,7 +38,7 @@ public abstract class EncodeGif this.bmpDrawing = SDImage.FromStream(this.bmpStream); this.bmpStream.Position = 0; - this.magickImage = new MagickImageCollection(this.bmpStream); + this.magickImage = new(this.bmpStream); } } @@ -83,6 +83,6 @@ public class EncodeGif_CoarsePaletteEncoder : EncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs index 303272837..7a0542981 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs @@ -24,7 +24,7 @@ public class EncodeGifMultiple : MultiImageBenchmarkBase.WithImagesPreloaded // Try to get as close to System.Drawing's output as possible GifEncoder options = new() { - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4 }) }; img.Save(ms, options); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 72b6bb72e..29a3ae5de 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs @@ -185,15 +185,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector2(sLeft.X); - var yLeft = new Vector2(sLeft.Y); - var zLeft = new Vector2(sLeft.Z); - var wLeft = new Vector2(sLeft.W); + Vector2 xLeft = new Vector2(sLeft.X); + Vector2 yLeft = new Vector2(sLeft.Y); + Vector2 zLeft = new Vector2(sLeft.Z); + Vector2 wLeft = new Vector2(sLeft.W); - var xRight = new Vector2(sRight.X); - var yRight = new Vector2(sRight.Y); - var zRight = new Vector2(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector2 xRight = new Vector2(sRight.X); + Vector2 yRight = new Vector2(sRight.Y); + Vector2 zRight = new Vector2(sRight.Z); + Vector2 wRight = new Vector2(sRight.W); dTopLeft = xLeft; Unsafe.Add(ref dTopLeft, 1) = yLeft; @@ -245,15 +245,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new Vector4(sLeft.X); + Vector4 yLeft = new Vector4(sLeft.Y); + Vector4 zLeft = new Vector4(sLeft.Z); + Vector4 wLeft = new Vector4(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector4(sRight.W); + Vector4 xRight = new Vector4(sRight.X); + Vector4 yRight = new Vector4(sRight.Y); + Vector4 zRight = new Vector4(sRight.Z); + Vector4 wRight = new Vector4(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -303,15 +303,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); - var xLeft = new Vector4(sLeft.X); - var yLeft = new Vector4(sLeft.Y); - var zLeft = new Vector4(sLeft.Z); - var wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new Vector4(sLeft.X); + Vector4 yLeft = new Vector4(sLeft.Y); + Vector4 zLeft = new Vector4(sLeft.Z); + Vector4 wLeft = new Vector4(sLeft.W); - var xRight = new Vector4(sRight.X); - var yRight = new Vector4(sRight.Y); - var zRight = new Vector4(sRight.Z); - var wRight = new Vector2(sRight.W); + Vector4 xRight = new Vector4(sRight.X); + Vector4 yRight = new Vector4(sRight.Y); + Vector4 zRight = new Vector4(sRight.Z); + Vector2 wRight = new Vector2(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -362,25 +362,25 @@ public class Block8x8F_CopyTo2x2 ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)(offset + destStride))); - var xyLeft = new Vector4(sLeft.X) + Vector4 xyLeft = new Vector4(sLeft.X) { Z = sLeft.Y, W = sLeft.Y }; - var zwLeft = new Vector4(sLeft.Z) + Vector4 zwLeft = new Vector4(sLeft.Z) { Z = sLeft.W, W = sLeft.W }; - var xyRight = new Vector4(sRight.X) + Vector4 xyRight = new Vector4(sRight.X) { Z = sRight.Y, W = sRight.Y }; - var zwRight = new Vector4(sRight.Z) + Vector4 zwRight = new Vector4(sRight.Z) { Z = sRight.W, W = sRight.W diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs index efc347586..ea8a1c47b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs @@ -140,7 +140,7 @@ public unsafe class Block8x8F_DivideRound [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 DivideRound(Vector4 dividend, Vector4 divisor) { - var sign = Vector4.Min(dividend, Vector4.One); + Vector4 sign = Vector4.Min(dividend, Vector4.One); sign = Vector4.Max(sign, MinusOne); return (dividend / divisor) + (sign * Half); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs index 722b09587..3c03f3e05 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_MultiplyInPlaceBlock.cs @@ -20,7 +20,7 @@ public class Block8x8F_MultiplyInPlaceBlock private static Block8x8F Create8x8FloatData() { - var result = new float[64]; + float[] result = new float[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs index 8964667b7..959522d81 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs @@ -38,11 +38,11 @@ public abstract class ColorConversionBenchmark float minVal = 0f, float maxVal = 255f) { - var rnd = new Random(42); - var buffers = new Buffer2D[componentCount]; + Random rnd = new Random(42); + Buffer2D[] buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { - var values = new float[inputBufferLength]; + float[] values = new float[inputBufferLength]; for (int j = 0; j < inputBufferLength; j++) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs index dbd255722..6e089d443 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs @@ -19,7 +19,7 @@ public class DecodeJpeg { this.decoder = JpegDecoder.Instance; byte[] bytes = File.ReadAllBytes(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, imageSubpath)); - this.preloadedImageStream = new MemoryStream(bytes); + this.preloadedImageStream = new(bytes); } private void GenericBenchmark() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 257e44cc4..78beda5ef 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -49,8 +49,8 @@ public class DecodeJpeg_ImageSpecific public Size ImageSharp() { using MemoryStream memoryStream = new(this.jpegBytes); - using Image image = Image.Load(new DecoderOptions() { SkipMetadata = true }, memoryStream); - return new Size(image.Width, image.Height); + using Image image = Image.Load(new() { SkipMetadata = true }, memoryStream); + return new(image.Width, image.Height); } /* diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs index c7cecd1a5..b865bb85d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs @@ -38,9 +38,9 @@ public class EncodeJpegComparison using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.imageImageSharp = Image.Load(imageBinaryStream); - this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; + this.encoderImageSharp = new() { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkImageSharp))] @@ -67,7 +67,7 @@ public class EncodeJpegComparison this.imageSkiaSharp = SKBitmap.Decode(imageBinaryStream); - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup(Target = nameof(BenchmarkSkiaSharp))] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs index 858917995..2e1cae973 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs @@ -44,13 +44,13 @@ public class EncodeJpegFeatures { using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.bmpCore = Image.Load(imageBinaryStream); - this.encoder = new JpegEncoder + this.encoder = new() { Quality = this.Quality, ColorType = this.TargetColorSpace, Interleaved = true, }; - this.destinationStream = new MemoryStream(); + this.destinationStream = new(); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs index 0adc52441..64d06ac17 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs @@ -155,7 +155,7 @@ public abstract class MultiImageBenchmarkBase this.FileNamesToImageSharpImages[fn] = Image.Load(ms1); } - this.FileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes)); + this.FileNamesToSystemDrawingImages[fn] = new(new MemoryStream(bytes)); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs index 125b42680..4c60de663 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs @@ -52,7 +52,7 @@ public class EncodeIndexedPng public void PngCoreOctreeNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) }; + PngEncoder options = new() { Quantizer = new OctreeQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -68,7 +68,7 @@ public class EncodeIndexedPng public void PngCorePaletteNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null }) }; + PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new() { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -84,7 +84,7 @@ public class EncodeIndexedPng public void PngCoreWuNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }), ColorType = PngColorType.Palette }; + PngEncoder options = new() { Quantizer = new WuQuantizer(new() { Dither = null }), ColorType = PngColorType.Palette }; this.bmpCore.SaveAsPng(memoryStream, options); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs index 169a44d91..c9ab74eda 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs @@ -26,7 +26,7 @@ public class EncodeTga if (this.tga == null) { this.tga = Image.Load(this.TestImageFullPath); - this.tgaMagick = new MagickImage(this.TestImageFullPath); + this.tgaMagick = new(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs index 6fa6a15ed..44c04caef 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs @@ -62,7 +62,7 @@ public class EncodeTiff ImageCodecInfo codec = FindCodecForType("image/tiff"); using EncoderParameters parameters = new(1) { - Param = { [0] = new EncoderParameter(Encoder.Compression, (long)Cast(this.Compression)) } + Param = { [0] = new(Encoder.Compression, (long)Cast(this.Compression)) } }; using MemoryStream memoryStream = new(); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs index 3b9058498..9c134c0e1 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs @@ -30,7 +30,7 @@ public class EncodeWebp if (this.webp == null) { this.webp = Image.Load(this.TestImageFullPath); - this.webpMagick = new MagickImage(this.TestImageFullPath); + this.webpMagick = new(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs index 5166c89a9..38715e6ca 100644 --- a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs +++ b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs @@ -15,5 +15,5 @@ public class ColorEquality [Benchmark(Description = "ImageSharp Color Equals")] public bool ColorEqual() - => new Rgba32(128, 128, 128, 128).Equals(new Rgba32(128, 128, 128, 128)); + => new Rgba32(128, 128, 128, 128).Equals(new(128, 128, 128, 128)); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs index b847e3ac5..dcc46df37 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs @@ -13,7 +13,7 @@ public class RgbWorkingSpaceAdapt private static readonly RGBColor RGBColor = new(0.206162, 0.260277, 0.746717); - private static readonly ColorProfileConverter ColorProfileConverter = new(new ColorConversionOptions { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); + private static readonly ColorProfileConverter ColorProfileConverter = new(new() { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); private static readonly IColorConverter ColourfulConverter = new ConverterBuilder().FromRGB(RGBWorkingSpaces.WideGamutRGB).ToRGB(RGBWorkingSpaces.sRGB).Build(); diff --git a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs index 093397ad5..37db166ae 100644 --- a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs +++ b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs @@ -22,7 +22,7 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (0.34414F * ccb) - (0.71414F * ccr), 0, 255); byte b = (byte)Numerics.Clamp(y + (1.772F * ccb), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } [Benchmark(Description = "Scaled Integer Conversion")] @@ -45,6 +45,6 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (g0 >> 10) - (g1 >> 10), 0, 255); byte b = (byte)Numerics.Clamp(y + (b0 >> 10), 0, 255); - return new Vector3(r, g, b); + return new(r, g, b); } } diff --git a/tests/ImageSharp.Benchmarks/General/Array2D.cs b/tests/ImageSharp.Benchmarks/General/Array2D.cs index f0a36ee1d..2d244607b 100644 --- a/tests/ImageSharp.Benchmarks/General/Array2D.cs +++ b/tests/ImageSharp.Benchmarks/General/Array2D.cs @@ -44,7 +44,7 @@ public class Array2D this.jaggedData[i] = new float[this.Count]; } - this.matrix = new DenseMatrix(this.array2D); + this.matrix = new(this.array2D); this.Min = (this.Count / 2) - 10; this.Min = Math.Max(0, this.Min); diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index d47fcb687..458927a35 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs @@ -12,7 +12,7 @@ public class ClampSpan public void Setup() { - var r = new Random(); + Random r = new Random(); for (int i = 0; i < A.Length; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs index 186f88bb7..5d93d2083 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs @@ -42,13 +42,13 @@ public class ClampVector4 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorClamp(float x, float min, float max) { - return Vector4.Clamp(new Vector4(x), new Vector4(min), new Vector4(max)); + return Vector4.Clamp(new(x), new(min), new(max)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorMinMax(float x, float min, float max) { - return Vector4.Min(new Vector4(max), Vector4.Max(new Vector4(min), new Vector4(x))); + return Vector4.Min(new(max), Vector4.Max(new(min), new(x))); } // RESULTS diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 031f9ecf2..85daa5bd2 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -36,11 +36,11 @@ public class CopyBuffers public void Setup() { this.sourceArray = new byte[this.Count]; - this.sourceMemory = new Memory(this.sourceArray); + this.sourceMemory = new(this.sourceArray); this.sourceHandle = this.sourceMemory.Pin(); this.destArray = new byte[this.Count]; - this.destMemory = new Memory(this.destArray); + this.destMemory = new(this.destArray); this.destHandle = this.destMemory.Pin(); } diff --git a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs index d32e1fdd0..f9b32d22a 100644 --- a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs @@ -31,28 +31,28 @@ public class BufferedStreams [GlobalSetup] public void CreateStreams() { - this.stream1 = new MemoryStream(this.buffer); - this.stream2 = new MemoryStream(this.buffer); - this.stream3 = new MemoryStream(this.buffer); - this.stream4 = new MemoryStream(this.buffer); - this.stream5 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - this.stream6 = new MemoryStream(this.buffer); - - this.chunkedMemoryStream1 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.stream1 = new(this.buffer); + this.stream2 = new(this.buffer); + this.stream3 = new(this.buffer); + this.stream4 = new(this.buffer); + this.stream5 = new(this.buffer); + this.stream6 = new(this.buffer); + this.stream6 = new(this.buffer); + + this.chunkedMemoryStream1 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream1.Write(this.buffer); this.chunkedMemoryStream1.Position = 0; - this.chunkedMemoryStream2 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); + this.chunkedMemoryStream2 = new(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream2.Write(this.buffer); this.chunkedMemoryStream2.Position = 0; - this.bufferedStream1 = new BufferedReadStream(Configuration.Default, this.stream3); - this.bufferedStream2 = new BufferedReadStream(Configuration.Default, this.stream4); - this.bufferedStream3 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream1); - this.bufferedStream4 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream2); - this.bufferedStreamWrap1 = new BufferedReadStreamWrapper(this.stream5); - this.bufferedStreamWrap2 = new BufferedReadStreamWrapper(this.stream6); + this.bufferedStream1 = new(Configuration.Default, this.stream3); + this.bufferedStream2 = new(Configuration.Default, this.stream4); + this.bufferedStream3 = new(Configuration.Default, this.chunkedMemoryStream1); + this.bufferedStream4 = new(Configuration.Default, this.chunkedMemoryStream2); + this.bufferedStreamWrap1 = new(this.stream5); + this.bufferedStreamWrap2 = new(this.stream6); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index c864e26c6..33fe56fc6 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -96,9 +96,9 @@ public abstract class PixelConversion_ConvertFromRgba32 [GlobalSetup] public void Setup() { - this.CompatibleMemLayoutRunner = new ConversionRunner(this.Count); - this.PermutedRunnerRgbaToArgb = new ConversionRunner(this.Count); - this.RunnerRgbaToRgbaVector = new ConversionRunner(this.Count); + this.CompatibleMemLayoutRunner = new(this.Count); + this.PermutedRunnerRgbaToArgb = new(this.Count); + this.RunnerRgbaToRgbaVector = new(this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index 57f79ba1f..c0dd6b93d 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -65,8 +65,8 @@ public class PixelConversion_ConvertFromVector4 [GlobalSetup] public void Setup() { - this.nonVectorRunner = new ConversionRunner(this.Count); - this.vectorRunner = new ConversionRunner(this.Count); + this.nonVectorRunner = new(this.Count); + this.vectorRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index 1a03a0c04..4a36e9cf1 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -69,8 +69,8 @@ public class PixelConversion_ConvertToRgba32 [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index 69a71734a..ad2e71626 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -76,8 +76,8 @@ public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); - this.permutedRunner = new ConversionRunner(this.Count); + this.compatibleMemoryLayoutRunner = new(this.Count); + this.permutedRunner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index 9b498b0f2..ee0fbb499 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -59,7 +59,7 @@ public class PixelConversion_ConvertToVector4 [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index 50c3d0d13..d9723b0e3 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -73,7 +73,7 @@ public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.runner = new ConversionRunner(this.Count); + this.runner = new(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs index a42c6c253..226dcc777 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_PackFromRgbPlanes.cs @@ -209,7 +209,7 @@ public unsafe class PixelConversion_PackFromRgbPlanes Vector256 vcontrol = SimdUtils.HwIntrinsics.PermuteMaskEvenOdd8x32().AsInt32(); - var va = Vector256.Create(1F); + Vector256 va = Vector256.Create(1F); for (nuint i = 0; i < count; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index f4fb9e420..21808b5ef 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -252,8 +252,8 @@ public class PixelConversion_Rgba32_To_Bgra32 private static void BitopsSimdImpl(ref Octet s, ref Octet d) { Vector sVec = Unsafe.As, Vector>(ref s); - var aMask = new Vector(0xFF00FF00); - var bMask = new Vector(0x00FF00FF); + Vector aMask = new Vector(0xFF00FF00); + Vector bMask = new Vector(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index 2cd6a5a52..c7df2467b 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -12,10 +12,10 @@ namespace SixLabors.ImageSharp.Benchmarks.General; /// public class Vector4Constants { - private static readonly Vector4 A = new Vector4(1.2f); - private static readonly Vector4 B = new Vector4(3.4f); - private static readonly Vector4 C = new Vector4(5.6f); - private static readonly Vector4 D = new Vector4(7.8f); + private static readonly Vector4 A = new(1.2f); + private static readonly Vector4 B = new(3.4f); + private static readonly Vector4 C = new(5.6f); + private static readonly Vector4 D = new(7.8f); private Random random; @@ -24,8 +24,8 @@ public class Vector4Constants [GlobalSetup] public void Setup() { - this.random = new Random(42); - this.parameter = new Vector4( + this.random = new(42); + this.parameter = new( this.GetRandomFloat(), this.GetRandomFloat(), this.GetRandomFloat(), @@ -39,8 +39,8 @@ public class Vector4Constants Vector4 x = (p * A / B) + (p * C / D); Vector4 y = (p / A * B) + (p / C * D); - var z = Vector4.Min(p, A); - var w = Vector4.Max(p, B); + Vector4 z = Vector4.Min(p, A); + Vector4 w = Vector4.Max(p, B); return x + y + z + w; } @@ -51,8 +51,8 @@ public class Vector4Constants Vector4 x = (p * new Vector4(1.2f) / new Vector4(2.3f)) + (p * new Vector4(4.5f) / new Vector4(6.7f)); Vector4 y = (p / new Vector4(1.2f) * new Vector4(2.3f)) + (p / new Vector4(4.5f) * new Vector4(6.7f)); - var z = Vector4.Min(p, new Vector4(1.2f)); - var w = Vector4.Max(p, new Vector4(2.3f)); + Vector4 z = Vector4.Min(p, new(1.2f)); + Vector4 w = Vector4.Max(p, new(2.3f)); return x + y + z + w; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs index 4d8d9b1ed..69babfb92 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -43,11 +43,11 @@ public class BitwiseOrUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = Vector.BitwiseOr(a, v); a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs index 1b2c56ab9..2c30cd103 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs @@ -43,11 +43,11 @@ public class DivFloat [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a / v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs index d102164e2..6bdbccace 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs @@ -44,11 +44,11 @@ public class DivUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a / v; a.CopyTo(this.result, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index a2eb8d417..8d5d66c4b 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -43,11 +43,11 @@ public class MulFloat [Benchmark] public void SimdMultiplyByVector() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } @@ -60,7 +60,7 @@ public class MulFloat for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs index a234970a5..d8079423f 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -43,11 +43,11 @@ public class MulUInt32 [Benchmark] public void Simd() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); + Vector a = new Vector(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs index 29b90accc..8129222c3 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs @@ -12,14 +12,14 @@ public class Premultiply [Benchmark(Baseline = true)] public Vector4 PremultiplyByVal() { - var input = new Vector4(.5F); + Vector4 input = new Vector4(.5F); return Vector4Utils.Premultiply(input); } [Benchmark] public Vector4 PremultiplyByRef() { - var input = new Vector4(.5F); + Vector4 input = new Vector4(.5F); Vector4Utils.PremultiplyRef(ref input); return input; } @@ -27,7 +27,7 @@ public class Premultiply [Benchmark] public Vector4 PremultiplyRefWithPropertyAssign() { - var input = new Vector4(.5F); + Vector4 input = new Vector4(.5F); Vector4Utils.PremultiplyRefWithPropertyAssign(ref input); return input; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs index 7d626d785..d7204d96d 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -53,8 +53,8 @@ public class ReinterpretUInt32AsFloat { for (int i = 0; i < this.input.Length; i += Vector.Count) { - var a = new Vector(this.input, i); - var b = Vector.AsVectorSingle(a); + Vector a = new Vector(this.input, i); + Vector b = Vector.AsVectorSingle(a); b.CopyTo(this.result, i); } } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 5f1f5666d..54e9622a3 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -27,20 +27,20 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; - var bVec = new Vector(256.0f / 255.0f); - var magicFloat = new Vector(32768.0f); - var magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f - var mask = new Vector(255); + Vector bVec = new Vector(256.0f / 255.0f); + Vector magicFloat = new Vector(32768.0f); + Vector magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f + Vector mask = new Vector(255); for (nuint i = 0; i < n; i++) { ref Vector df = ref Unsafe.Add(ref b, i); - var vi = Vector.AsVectorUInt32(df); + Vector vi = Vector.AsVectorUInt32(df); vi &= mask; vi |= magicInt; - var vf = Vector.AsVectorSingle(vi); + Vector vf = Vector.AsVectorSingle(vi); vf = (vf - magicFloat) * bVec; df = vf; @@ -55,7 +55,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new Vector(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -74,7 +74,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - var scale = new Vector(1f / 255f); + Vector scale = new Vector(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -91,7 +91,7 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); - var scale = new Vector(1f / 255f); + Vector scale = new Vector(1f / 255f); for (nuint i = 0; i < n; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index 5d20f29d1..e8b6626cd 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -47,11 +47,11 @@ public class VectorFetching [Benchmark] public void FetchWithVectorConstructor() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - var a = new Vector(this.data, i); + Vector a = new Vector(this.data, i); a = a * v; a.CopyTo(this.data, i); } @@ -60,7 +60,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCast() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -79,7 +79,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastNoTempVector() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -94,9 +94,9 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastFromReference() { - var v = new Vector(this.testValue); + Vector v = new Vector(this.testValue); - var span = new Span(this.data); + Span span = new Span(this.data); ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs index 04621695c..65ca779ca 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveStressBenchmarks [GlobalSetup] public void Setup() { - this.runner = new LoadResizeSaveStressRunner() + this.runner = new() { ImageCount = Environment.ProcessorCount, Filter = Filter diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index 44c248dc9..1a2d0360e 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -117,7 +117,7 @@ public class LoadResizeSaveStressRunner public void ForEachImageParallel(Action action) => Parallel.ForEach( this.Images, - new ParallelOptions { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, + new() { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, action); public Task ForEachImageParallelAsync(Func action) @@ -148,7 +148,7 @@ public class LoadResizeSaveStressRunner private void LogImageProcessed(int width, int height) { - this.LastProcessedImageSize = new Size(width, height); + this.LastProcessedImageSize = new(width, height); double pixels = width * (double)height; this.TotalProcessedMegapixels += pixels / 1_000_000.0; } @@ -322,7 +322,7 @@ public class LoadResizeSaveStressRunner (int width, int height) = this.ScaledSize(info.Width, info.Height, this.ThumbnailSize); SKSizeI supportedScale = codec.GetScaledDimensions((float)width / info.Width); - using SKBitmap original = SKBitmap.Decode(codec, new SKImageInfo(supportedScale.Width, supportedScale.Height)); + using SKBitmap original = SKBitmap.Decode(codec, new(supportedScale.Width, supportedScale.Height)); using SKBitmap resized = original.Resize(new SKImageInfo(width, height), SKFilterQuality.High); if (resized == null) { diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index a308c0c46..9f75f9dc2 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -73,7 +73,7 @@ public class PorterDuffBulkVsPixel BulkVectorConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } [Benchmark(Description = "ImageSharp BulkPixelConvert")] @@ -89,6 +89,6 @@ public class PorterDuffBulkVsPixel BulkPixelConvert(span, span, span, amounts.GetSpan()); } - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Crop.cs b/tests/ImageSharp.Benchmarks/Processing/Crop.cs index e14366bfd..d526c6ba4 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Crop.cs @@ -24,7 +24,7 @@ public class Crop graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.DrawImage(source, new SDRectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); + graphics.DrawImage(source, new(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); return destination.Size; } @@ -34,6 +34,6 @@ public class Crop { using Image image = new(800, 800); image.Mutate(x => x.Crop(100, 100)); - return new Size(image.Width, image.Height); + return new(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs index 135145a31..8be48260a 100644 --- a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs +++ b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs @@ -33,7 +33,7 @@ public class HistogramEqualization [Benchmark(Description = "Global Histogram Equalization")] public void GlobalHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new() { LuminanceLevels = 256, Method = HistogramEqualizationMethod.Global @@ -42,7 +42,7 @@ public class HistogramEqualization [Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")] public void AdaptiveHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new HistogramEqualizationOptions() + new() { LuminanceLevels = 256, Method = HistogramEqualizationMethod.AdaptiveTileInterpolation diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 09673cb96..949b14afa 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Resize.cs @@ -22,7 +22,7 @@ public abstract class Resize private SDImage sourceBitmap; - protected Configuration Configuration { get; } = new Configuration(new JpegConfigurationModule()); + protected Configuration Configuration { get; } = new(new JpegConfigurationModule()); protected int DestSize { get; private set; } @@ -218,9 +218,9 @@ public class Resize_Bicubic_Compare_Rgba32_Rgb24 [GlobalSetup] public void Setup() { - this.rgb24 = new Resize_Bicubic_Rgb24(); + this.rgb24 = new(); this.rgb24.Setup(); - this.rgba32 = new Resize_Bicubic_Rgba32(); + this.rgba32 = new(); this.rgba32.Setup(); } diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs index 248912b14..79128cfee 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs @@ -17,7 +17,7 @@ internal class LoadResizeSaveParallelMemoryStress { private LoadResizeSaveParallelMemoryStress() { - this.Benchmarks = new LoadResizeSaveStressRunner() + this.Benchmarks = new() { Filter = JpegKind.Baseline, }; @@ -38,7 +38,7 @@ internal class LoadResizeSaveParallelMemoryStress Console.WriteLine($"64 bit: {Environment.Is64BitProcess}"); CommandLineOptions options = args.Length > 0 ? CommandLineOptions.Parse(args) : null; - var lrs = new LoadResizeSaveParallelMemoryStress(); + LoadResizeSaveParallelMemoryStress lrs = new(); if (options != null) { lrs.Benchmarks.MaxDegreeOfParallelism = options.MaxDegreeOfParallelism; @@ -108,7 +108,7 @@ internal class LoadResizeSaveParallelMemoryStress } } - var stats = new Stats(timer, lrs.Benchmarks.TotalProcessedMegapixels); + Stats stats = new(timer, lrs.Benchmarks.TotalProcessedMegapixels); Console.WriteLine($"Total Megapixels: {stats.TotalMegapixels}, TotalOomRetries: {UnmanagedMemoryHandle.TotalOomRetries}, TotalOutstandingHandles: {UnmanagedMemoryHandle.TotalOutstandingHandles}, Total Gen2 GC count: {GC.CollectionCount(2)}"); Console.WriteLine(stats.GetMarkdown()); if (options?.FileOutput != null) @@ -203,7 +203,7 @@ internal class LoadResizeSaveParallelMemoryStress public string GetMarkdown() { - var bld = new StringBuilder(); + StringBuilder bld = new(); bld.AppendLine($"| {nameof(this.TotalSeconds)} | {nameof(this.MegapixelsPerSec)} | {nameof(this.MegapixelsPerSecPerCpu)} |"); bld.AppendLine( $"| {L(nameof(this.TotalSeconds))} | {L(nameof(this.MegapixelsPerSec))} | {L(nameof(this.MegapixelsPerSecPerCpu))} |"); @@ -295,7 +295,7 @@ internal class LoadResizeSaveParallelMemoryStress (int)B(this.MaxContiguousPoolBufferMegaBytes), B(this.MaxPoolSizeMegaBytes), (int)B(this.MaxCapacityOfNonPoolBuffersMegaBytes), - new UniformUnmanagedMemoryPool.TrimSettings + new() { TrimPeriodMilliseconds = this.TrimTimeSeconds.Value * 1000 }); diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index b5c8b70cd..43e17f5c9 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -64,13 +64,13 @@ public class Program private static void RunResizeProfilingTest() { - var test = new ResizeProfilingBenchmarks(new ConsoleOutput()); + ResizeProfilingBenchmarks test = new ResizeProfilingBenchmarks(new ConsoleOutput()); test.ResizeBicubic(4000, 4000); } private static void RunToVector4ProfilingTest() { - var tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); + PixelOperationsTests.Rgba32_OperationsTests tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); tests.Benchmark_ToVector4(); } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index 4247345c7..6c3377d10 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs @@ -13,10 +13,10 @@ public partial class ColorTests [Fact] public void Rgba64() { - var source = new Rgba64(100, 2222, 3333, 4444); + Rgba64 source = new(100, 2222, 3333, 4444); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba64 data = color.ToPixel(); @@ -26,10 +26,10 @@ public partial class ColorTests [Fact] public void Rgba32() { - var source = new Rgba32(1, 22, 33, 231); + Rgba32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgba32 data = color.ToPixel(); @@ -39,10 +39,10 @@ public partial class ColorTests [Fact] public void Argb32() { - var source = new Argb32(1, 22, 33, 231); + Argb32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Argb32 data = color.ToPixel(); @@ -52,10 +52,10 @@ public partial class ColorTests [Fact] public void Bgra32() { - var source = new Bgra32(1, 22, 33, 231); + Bgra32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgra32 data = color.ToPixel(); @@ -65,10 +65,10 @@ public partial class ColorTests [Fact] public void Abgr32() { - var source = new Abgr32(1, 22, 33, 231); + Abgr32 source = new(1, 22, 33, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Abgr32 data = color.ToPixel(); @@ -78,10 +78,10 @@ public partial class ColorTests [Fact] public void Rgb24() { - var source = new Rgb24(1, 22, 231); + Rgb24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Rgb24 data = color.ToPixel(); @@ -91,10 +91,10 @@ public partial class ColorTests [Fact] public void Bgr24() { - var source = new Bgr24(1, 22, 231); + Bgr24 source = new(1, 22, 231); // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: Bgr24 data = color.ToPixel(); @@ -108,10 +108,10 @@ public partial class ColorTests Color color = Color.FromScaledVector(Vector4.One); // Assert: - Assert.Equal(new RgbaVector(1, 1, 1, 1), color.ToPixel()); - Assert.Equal(new Rgba64(65535, 65535, 65535, 65535), color.ToPixel()); - Assert.Equal(new Rgba32(255, 255, 255, 255), color.ToPixel()); - Assert.Equal(new L8(255), color.ToPixel()); + Assert.Equal(new(1, 1, 1, 1), color.ToPixel()); + Assert.Equal(new(65535, 65535, 65535, 65535), color.ToPixel()); + Assert.Equal(new(255, 255, 255, 255), color.ToPixel()); + Assert.Equal(new(255), color.ToPixel()); } [Fact] @@ -129,7 +129,7 @@ public partial class ColorTests where TPixel : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel actual = color.ToPixel(); @@ -150,7 +150,7 @@ public partial class ColorTests where TPixel2 : unmanaged, IPixel { // Act: - var color = Color.FromPixel(source); + Color color = Color.FromPixel(source); // Assert: TPixel2 actual = color.ToPixel(); diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index d430df5b4..8b636ee39 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -108,29 +108,29 @@ public partial class ColorTests [Fact] public void ShortHex() { - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("#fff").ToPixel()); - Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("fff").ToPixel()); - Assert.Equal(new Rgba32(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("#fff").ToPixel()); + Assert.Equal(new(255, 255, 255), Color.ParseHex("fff").ToPixel()); + Assert.Equal(new(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); } [Fact] public void TryShortHex() { Assert.True(Color.TryParseHex("#fff", out Color actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("fff", out actual)); - Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + Assert.Equal(new(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("000f", out actual)); - Assert.Equal(new Rgba32(0, 0, 0, 255), actual.ToPixel()); + Assert.Equal(new(0, 0, 0, 255), actual.ToPixel()); } [Fact] public void LeadingPoundIsOptional() { - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("#008080").ToPixel()); - Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("#008080").ToPixel()); + Assert.Equal(new(0, 128, 128), Color.ParseHex("008080").ToPixel()); } [Fact] diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs index 69fabc750..93e64aa9b 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs @@ -35,8 +35,8 @@ public class CieLabTests Assert.True(new CieLab(1, 0, 1) != default); Assert.False(new CieLab(1, 0, 1) == default); Assert.Equal(default, default(CieLab)); - Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); - Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(new CieLab(1, 0, 1) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs index 484db3e8c..e2bf8655e 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs @@ -33,8 +33,8 @@ public class CieLchTests Assert.True(default == default(CieLch)); Assert.False(default != default(CieLch)); Assert.Equal(default, default(CieLch)); - Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); - Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLch(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLch(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs index 3fe550a5b..cc8f9789a 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs @@ -34,8 +34,8 @@ public class CieLchuvTests Assert.True(default == default(CieLchuv)); Assert.False(default != default(CieLchuv)); Assert.Equal(default, default(CieLchuv)); - Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); - Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLchuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLchuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs index 173491081..7d715349f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs @@ -34,8 +34,8 @@ public class CieLuvTests Assert.True(default == default(CieLuv)); Assert.False(default != default(CieLuv)); Assert.Equal(default, default(CieLuv)); - Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); - Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieLuv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs index 8bc71f1e1..5875b78c1 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs @@ -32,8 +32,8 @@ public class CieXyChromaticityCoordinatesTests Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.Equal(default, default(CieXyChromaticityCoordinates)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); - Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); + Assert.Equal(new(1, 0), new CieXyChromaticityCoordinates(1, 0)); + Assert.Equal(new(1, 1), new CieXyChromaticityCoordinates(1, 1)); Assert.False(x.Equals(y)); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs index 80904c5df..6290546a8 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs @@ -34,8 +34,8 @@ public class CieXyyTests Assert.True(default == default(CieXyy)); Assert.False(default != default(CieXyy)); Assert.Equal(default, default(CieXyy)); - Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); - Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyy(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyy(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs index 683b3b661..e7e4261c6 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs @@ -34,8 +34,8 @@ public class CieXyzTests Assert.True(default == default(CieXyz)); Assert.False(default != default(CieXyz)); Assert.Equal(default, default(CieXyz)); - Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); - Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); + Assert.Equal(new(1, 0, 1), new CieXyz(1, 0, 1)); + Assert.Equal(new(Vector3.One), new CieXyz(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs index 22b7a7f70..a732c68c5 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs @@ -36,8 +36,8 @@ public class CmykTests Assert.True(default == default(Cmyk)); Assert.False(default != default(Cmyk)); Assert.Equal(default, default(Cmyk)); - Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); - Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); + Assert.Equal(new(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); + Assert.Equal(new(Vector4.One), new Cmyk(Vector4.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs index 1bdefa109..24b221155 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs @@ -102,7 +102,7 @@ public class CompandingTests private static void CompandingIsCorrectImpl(Vector4 e, Vector4 c, float expanded, Vector4 compressed) { // W (alpha) is already the linear representation of the color. - Assert.Equal(new Vector4(expanded, expanded, expanded, e.W), e, Comparer); + Assert.Equal(new(expanded, expanded, expanded, e.W), e, Comparer); Assert.Equal(compressed, c, Comparer); } } diff --git a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs index 6697cbfde..6d9af0eee 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs @@ -34,8 +34,8 @@ public class HslTests Assert.True(default == default(Hsl)); Assert.False(default != default(Hsl)); Assert.Equal(default, default(Hsl)); - Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); - Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsl(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsl(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs index dd71fcd3f..36a8d599b 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs @@ -34,8 +34,8 @@ public class HsvTests Assert.True(default == default(Hsv)); Assert.False(default != default(Hsv)); Assert.Equal(default, default(Hsv)); - Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); - Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Hsv(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Hsv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs index af06b3c91..f136aa288 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs @@ -35,8 +35,8 @@ public class HunterLabTests Assert.True(new HunterLab(1, 0, 1) != default); Assert.False(new HunterLab(1, 0, 1) == default); Assert.Equal(default, default(HunterLab)); - Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); - Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); + Assert.Equal(new(1, 0, 1), new HunterLab(1, 0, 1)); + Assert.Equal(new(Vector3.One), new HunterLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs index 6c56dc682..cd6fe33cc 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs @@ -152,7 +152,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) private static Vector4 GetActualTargetValues(float[] input, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new ColorConversionOptions + ColorProfileConverter converter = new(new() { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -163,20 +163,20 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) return sourceDataSpace switch { IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), + => converter.Convert(new(new(input))).ToScaledVector4(), _ => throw new NotSupportedException($"Unsupported ICC profile data color space conversion: {sourceDataSpace} -> {targetDataSpace}") }; } private static List GetBulkActualTargetValues(List inputs, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new ColorConversionOptions + ColorProfileConverter converter = new(new() { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -189,7 +189,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) { case IccColorSpaceType.Cmyk: { - Span inputSpan = inputs.Select(x => new Cmyk(new Vector4(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Cmyk(new(x))).ToArray(); switch (targetDataSpace) { @@ -214,7 +214,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) case IccColorSpaceType.Rgb: { - Span inputSpan = inputs.Select(x => new Rgb(new Vector3(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Rgb(new(x))).ToArray(); switch (targetDataSpace) { diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs index 3e3bb4d49..c5f950784 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs @@ -58,12 +58,12 @@ internal static class TestIccProfiles public const string StandardRgbV2 = "sRGB2014.icc"; public static IccProfile GetProfile(string file) - => ProfileCache.GetOrAdd(file, f => new IccProfile(File.ReadAllBytes(GetFullPath(f)))); + => ProfileCache.GetOrAdd(file, f => new(File.ReadAllBytes(GetFullPath(f)))); public static Wacton.Unicolour.Configuration GetUnicolourConfiguration(string file) => UnicolourConfigurationCache.GetOrAdd( file, - f => new Wacton.Unicolour.Configuration(iccConfig: new(GetFullPath(f), Intent.Unspecified, f))); + f => new(iccConfig: new(GetFullPath(f), Intent.Unspecified, f))); public static bool HasUnicolourConfiguration(string file) => UnicolourConfigurationCache.ContainsKey(file); diff --git a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs index 395b547fd..c409bfd69 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs @@ -35,8 +35,8 @@ public class LmsTests Assert.True(new Lms(1, 0, 1) != default); Assert.False(new Lms(1, 0, 1) == default); Assert.Equal(default, default(Lms)); - Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); - Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Lms(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Lms(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs index 707b3e2a7..5ee4dac11 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs @@ -35,8 +35,8 @@ public class RgbTests Assert.True(default == default(Rgb)); Assert.False(default != default(Rgb)); Assert.Equal(default, default(Rgb)); - Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); - Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); + Assert.Equal(new(1, 0, 1), new Rgb(1, 0, 1)); + Assert.Equal(new(Vector3.One), new Rgb(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs index f61124d8f..1a52d8a7f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs @@ -50,7 +50,7 @@ public class StringRepresentationTests { new HunterLab(Random), "HunterLab(42.4, 94.5, 83.4)" }, { new Lms(Random), "Lms(42.4, 94.5, 83.4)" }, { new Rgb(Random), "Rgb(42.4, 94.5, 83.4)" }, - { Rgb.Clamp(new Rgb(Random)), "Rgb(1, 1, 1)" }, + { Rgb.Clamp(new(Random)), "Rgb(1, 1, 1)" }, { new Hsl(Random), "Hsl(42.4, 1, 1)" }, // clamping to 1 is expected { new Hsv(Random), "Hsv(42.4, 1, 1)" }, // clamping to 1 is expected { new Y(Random.X), "Y(1)" }, diff --git a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs index 64558a3f8..7bd7c5167 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs @@ -34,8 +34,8 @@ public class YCbCrTests Assert.True(default == default(YCbCr)); Assert.False(default != default(YCbCr)); Assert.Equal(default, default(YCbCr)); - Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); - Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); + Assert.Equal(new(1, 0, 1), new YCbCr(1, 0, 1)); + Assert.Equal(new(Vector3.One), new YCbCr(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs index 7e5e48b69..e92448418 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs @@ -28,9 +28,9 @@ public class YTests Assert.True(default == default(Y)); Assert.False(default != default(Y)); Assert.Equal(default, default(Y)); - Assert.Equal(new Y(1), new Y(1)); + Assert.Equal(new(1), new Y(1)); - Assert.Equal(new Y(.5F), new Y(.5F)); + Assert.Equal(new(.5F), new Y(.5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs index bfe0bdb17..ada125f59 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs @@ -34,8 +34,8 @@ public class YccKTests Assert.True(default == default(YccK)); Assert.False(default != default(YccK)); Assert.Equal(default, default(YccK)); - Assert.Equal(new YccK(1, 1, 1, 1), new YccK(1, 1, 1, 1)); - Assert.Equal(new YccK(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); + Assert.Equal(new(1, 1, 1, 1), new YccK(1, 1, 1, 1)); + Assert.Equal(new(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs index 190bfe1dc..db2da6a69 100644 --- a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs @@ -10,7 +10,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_EmptyBuffer_ReturnsEmptyString() { - var buffer = default(ReadOnlySpan); + ReadOnlySpan buffer = default(ReadOnlySpan); string result = Encoding.UTF8.GetString(buffer); @@ -20,7 +20,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_Buffer_ReturnsString() { - var buffer = new ReadOnlySpan(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); + ReadOnlySpan buffer = new ReadOnlySpan(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); string result = Encoding.UTF8.GetString(buffer); diff --git a/tests/ImageSharp.Tests/Common/NumericsTests.cs b/tests/ImageSharp.Tests/Common/NumericsTests.cs index 2b9276943..69f8f9c2c 100644 --- a/tests/ImageSharp.Tests/Common/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Common/NumericsTests.cs @@ -28,7 +28,7 @@ public class NumericsTests [InlineData(1, 100)] public void DivideCeil_RandomValues(int seed, int count) { - var rng = new Random(seed); + Random rng = new Random(seed); for (int i = 0; i < count; i++) { uint value = (uint)rng.Next(); diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 36b301264..e4d9a04b4 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -51,7 +51,7 @@ public partial class SimdUtilsTests data[i] = data[i - 4] + 100f; } - return new Vector(data); + return new(data); } private static Vector CreateRandomTestVector(int seed, float min, float max) @@ -66,7 +66,7 @@ public partial class SimdUtilsTests data[i] = v; } - return new Vector(data); + return new(data); } [Fact] @@ -287,7 +287,7 @@ public partial class SimdUtilsTests TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { - expected[i] = TPixel.FromRgb24(new Rgb24(r[i], g[i], b[i])); + expected[i] = TPixel.FromRgb24(new(r[i], g[i], b[i])); } TPixel[] actual = new TPixel[count + 3]; // padding for Rgb24 AVX2 diff --git a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs index 193110944..3df5e8f30 100644 --- a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs @@ -10,7 +10,7 @@ public class StreamExtensionsTests [InlineData(-1)] public void Skip_CountZeroOrLower_PositionNotChanged(int count) { - using (var memStream = new MemoryStream(5)) + using (MemoryStream memStream = new MemoryStream(5)) { memStream.Position = 4; memStream.Skip(count); @@ -22,7 +22,7 @@ public class StreamExtensionsTests [Fact] public void Skip_SeekableStream_SeekIsCalled() { - using (var seekableStream = new SeekableStream(4)) + using (SeekableStream seekableStream = new SeekableStream(4)) { seekableStream.Skip(4); @@ -34,7 +34,7 @@ public class StreamExtensionsTests [Fact] public void Skip_NonSeekableStream_BytesAreRead() { - using (var nonSeekableStream = new NonSeekableStream()) + using (NonSeekableStream nonSeekableStream = new NonSeekableStream()) { nonSeekableStream.Skip(5); @@ -49,7 +49,7 @@ public class StreamExtensionsTests [Fact] public void Skip_EofStream_NoExceptionIsThrown() { - using (var eofStream = new EofStream(7)) + using (EofStream eofStream = new EofStream(7)) { eofStream.Skip(7); diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index c8e6cd265..b90579a02 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -27,7 +27,7 @@ public class ConfigurationTests // The shallow copy of configuration should behave exactly like the default configuration, // so by using the copy, we test both the default and the copy. this.DefaultConfiguration = Configuration.CreateDefaultInstance().Clone(); - this.ConfigurationEmpty = new Configuration(); + this.ConfigurationEmpty = new(); } [Fact] @@ -58,7 +58,7 @@ public class ConfigurationTests { Assert.True(this.DefaultConfiguration.MaxDegreeOfParallelism == Environment.ProcessorCount); - var cfg = new Configuration(); + Configuration cfg = new(); Assert.True(cfg.MaxDegreeOfParallelism == Environment.ProcessorCount); } @@ -71,7 +71,7 @@ public class ConfigurationTests [InlineData(5, false)] public void MaxDegreeOfParallelism_CompatibleWith_ParallelOptions(int maxDegreeOfParallelism, bool throws) { - var cfg = new Configuration(); + Configuration cfg = new(); if (throws) { Assert.Throws( @@ -87,8 +87,8 @@ public class ConfigurationTests [Fact] public void ConstructorCallConfigureOnFormatProvider() { - var provider = new Mock(); - var config = new Configuration(provider.Object); + Mock provider = new(); + Configuration config = new(provider.Object); provider.Verify(x => x.Configure(config)); } @@ -96,8 +96,8 @@ public class ConfigurationTests [Fact] public void AddFormatCallsConfig() { - var provider = new Mock(); - var config = new Configuration(); + Mock provider = new(); + Configuration config = new(); config.Configure(provider.Object); provider.Verify(x => x.Configure(config)); @@ -118,7 +118,7 @@ public class ConfigurationTests [Fact] public void DefaultConfigurationHasCorrectFormatCount() { - var config = Configuration.CreateDefaultInstance(); + Configuration config = Configuration.CreateDefaultInstance(); Assert.Equal(this.expectedDefaultConfigurationCount, config.ImageFormats.Count()); } @@ -140,7 +140,7 @@ public class ConfigurationTests [Fact] public void StreamBufferSize_CannotGoBelowMinimum() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws( () => config.StreamProcessingBufferSize = 0); @@ -150,14 +150,14 @@ public class ConfigurationTests public void MemoryAllocator_Setter_Roundtrips() { MemoryAllocator customAllocator = new SimpleGcMemoryAllocator(); - var config = new Configuration() { MemoryAllocator = customAllocator }; + Configuration config = new() { MemoryAllocator = customAllocator }; Assert.Same(customAllocator, config.MemoryAllocator); } [Fact] public void MemoryAllocator_SetNull_ThrowsArgumentNullException() { - var config = new Configuration(); + Configuration config = new(); Assert.Throws(() => config.MemoryAllocator = null); } @@ -168,9 +168,9 @@ public class ConfigurationTests static void RunTest() { - var c1 = new Configuration(); - var c2 = new Configuration(new MockConfigurationModule()); - var c3 = Configuration.CreateDefaultInstance(); + Configuration c1 = new(); + Configuration c2 = new(new MockConfigurationModule()); + Configuration c3 = Configuration.CreateDefaultInstance(); Assert.Same(MemoryAllocator.Default, Configuration.Default.MemoryAllocator); Assert.Same(MemoryAllocator.Default, c1.MemoryAllocator); diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 88f4cde7a..2e2c30784 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -195,9 +195,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(64, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(64, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -216,9 +216,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(320, 128, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(320, 128, 32, 32), 1F)); background.DebugSave( provider, @@ -237,9 +237,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -258,9 +258,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -279,9 +279,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new Rgba32(0, 255, 255)); + using Image background = new(100, 100, new(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new Point(80, 80), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new(80, 80), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index d8ec7c900..8b4857645 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs @@ -11,9 +11,9 @@ public class BmpFileHeaderTests [Fact] public void TestWrite() { - var header = new BmpFileHeader(1, 2, 3, 4); + BmpFileHeader header = new BmpFileHeader(1, 2, 3, 4); - var buffer = new byte[14]; + byte[] buffer = new byte[14]; header.WriteTo(buffer); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs index 14b017bee..988e8935a 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(file, new BmpEncoder()); + image.SaveAsBmp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(memoryStream, new BmpEncoder()); + image.SaveAsBmp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 44ed5e38d..740cb9ac7 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -56,7 +56,7 @@ public class GifEncoderTests { // Use the palette quantizer without dithering to ensure results // are consistent - Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }) + Quantizer = new WebSafePaletteQuantizer(new() { Dither = null, TransparencyThreshold = 0 }) }; // Always save as we need to compare the encoded output. @@ -115,7 +115,7 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = FrameColorTableMode.Global, - Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) + Quantizer = new OctreeQuantizer(new() { Dither = null }) }; // Always save as we need to compare the encoded output. @@ -124,7 +124,7 @@ public class GifEncoderTests encoder = new() { ColorTableMode = FrameColorTableMode.Local, - Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }), + Quantizer = new OctreeQuantizer(new() { Dither = null }), }; provider.Utility.SaveTestOutputFile(image, "gif", encoder, "local"); @@ -191,7 +191,7 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = colorMode, - Quantizer = new OctreeQuantizer(new QuantizerOptions { MaxColors = maxColors }) + Quantizer = new OctreeQuantizer(new() { MaxColors = maxColors }) }; image.Save(outStream, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs index dd3879703..625b043d4 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs @@ -86,7 +86,7 @@ public class GifMetadataTests using Image image = testFile.CreateRgba32Image(GifDecoder.Instance); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } @@ -104,7 +104,7 @@ public class GifMetadataTests using Image image = decoder.Decode(DecoderOptions.Default, memoryStream); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new string('c', 349), metadata.Comments[0]); + Assert.Equal(new('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } diff --git a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs index 97fdb38e7..d23efdd79 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(file, new GifEncoder()); + image.SaveAsGif(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(memoryStream, new GifEncoder()); + image.SaveAsGif(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs index 69c6317a7..f895afbd5 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs @@ -122,7 +122,7 @@ public class CurEncoderTests { if (expectedColor != rowSpan[x]) { - var xx = 0; + int xx = 0; } diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 324bd4783..f7743e149 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -24,7 +24,7 @@ public class ImageFormatManagerTests public ImageFormatManagerTests() { this.DefaultFormatsManager = Configuration.CreateDefaultInstance().ImageFormatsManager; - this.FormatsManagerEmpty = new ImageFormatManager(); + this.FormatsManagerEmpty = new(); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index cb8f52a96..ae6f0331d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -21,7 +21,7 @@ public class Block8x8Tests : JpegFixture { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); for (int i = 0; i < Block8x8.Size; i++) { @@ -47,7 +47,7 @@ public class Block8x8Tests : JpegFixture { short[] data = Create8x8ShortData(); - var source = Block8x8.Load(data); + Block8x8 source = Block8x8.Load(data); Block8x8F dest = source.AsFloatBlock(); @@ -61,7 +61,7 @@ public class Block8x8Tests : JpegFixture public void ToArray() { short[] data = Create8x8ShortData(); - var block = Block8x8.Load(data); + Block8x8 block = Block8x8.Load(data); short[] result = block.ToArray(); @@ -72,8 +72,8 @@ public class Block8x8Tests : JpegFixture public void Equality_WhenFalse() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block1[0] = 42; block2[0] = 666; @@ -96,8 +96,8 @@ public class Block8x8Tests : JpegFixture public void TotalDifference() { short[] data = Create8x8ShortData(); - var block1 = Block8x8.Load(data); - var block2 = Block8x8.Load(data); + Block8x8 block1 = Block8x8.Load(data); + Block8x8 block2 = Block8x8.Load(data); block2[10] += 7; block2[63] += 8; @@ -157,7 +157,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new Random(seed); for (int i = 0; i < 1000; i++) { @@ -188,7 +188,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new Random(seed); for (int i = 0; i < 1000; i++) { @@ -223,7 +223,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - var rng = new Random(seed); + Random rng = new Random(seed); for (int i = 0; i < 1000; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 7b411a28f..062a8a5ee 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -46,7 +46,7 @@ public static class DCTTests { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.LLM_FloatingPoint_DCT.TransformIDCT(ref srcBlock); @@ -79,7 +79,7 @@ public static class DCTTests { float[] sourceArray = Create8x8RandomFloatData(MinInputValue, MaxInputValue, seed); - var srcBlock = Block8x8F.Load(sourceArray); + Block8x8F srcBlock = Block8x8F.Load(sourceArray); // reference Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref srcBlock); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs index b89d9ad27..625932e2a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs @@ -69,7 +69,7 @@ public class HuffmanScanEncoderTests { int maxNumber = 1 << 16; - var rng = new Random(seed); + Random rng = new Random(seed); for (int i = 0; i < 1000; i++) { uint number = (uint)rng.Next(0, maxNumber); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs index b1f799732..0d8bf3a74 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(file, new JpegEncoder()); + image.SaveAsJpeg(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(memoryStream, new JpegEncoder()); + image.SaveAsJpeg(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 1dba8ee1c..ba60139c5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -620,10 +620,10 @@ public class JpegColorConverterTests // no need to dispose when buffer is not array owner Memory memory = new(values); MemoryGroup source = MemoryGroup.Wrap(memory); - buffers[i] = new Buffer2D(source, values.Length, 1); + buffers[i] = new(source, values.Length, 1); } - return new JpegColorConverterBase.ComponentValues(buffers, 0); + return new(buffers, 0); } private static float[] CreateRandomValues(int length, Random rnd) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index 20a9ad387..d2c7bcd5c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -400,10 +400,10 @@ public partial class JpegDecoderTests exif.SetValue(ExifTag.XPSubject, "This is a subject"); // exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "ビッ")); - exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); + exif.SetValue(ExifTag.UserComment, new(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); - exif.SetValue(ExifTag.GPSProcessingMethod, new EncodedString(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); - exif.SetValue(ExifTag.GPSAreaInformation, new EncodedString(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); + exif.SetValue(ExifTag.GPSProcessingMethod, new(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); + exif.SetValue(ExifTag.GPSAreaInformation, new(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); image.Metadata.ExifProfile = exif; @@ -495,7 +495,7 @@ public partial class JpegDecoderTests Assert.Equal("Carers; seniors; caregiver; senior care; retirement home; hands; old; elderly; elderly caregiver; elder care; elderly care; geriatric care; nursing home; age; old age care; outpatient; needy; health care; home nurse; home care; sick; retirement; medical; mobile; the elderly; nursing department; nursing treatment; nursing; care services; nursing services; nursing care; nursing allowance; nursing homes; home nursing; care category; nursing class; care; nursing shortage; nursing patient care staff\0", exifProfile.GetValue(ExifTag.XPKeywords).Value); Assert.Equal( - new EncodedString(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), + new(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), exifProfile.GetValue(ExifTag.UserComment).Value); // the profile contains 4 duplicated UserComment diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index 99322687c..ebc5a77a9 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -57,7 +57,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.ExifProfile = new ExifProfile(); + input.Metadata.ExifProfile = new(); input.Metadata.ExifProfile.SetValue(ExifTag.Software, "unit_test"); // act @@ -78,7 +78,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.ProfileRandomArray); + input.Metadata.IccProfile = new(IccTestDataProfiles.ProfileRandomArray); // act using MemoryStream memStream = new(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs index df74d266c..1f8bdd67a 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs @@ -14,7 +14,7 @@ public class JpegFileMarkerTests { const byte app1 = JpegConstants.Markers.APP1; const int position = 5; - var marker = new JpegFileMarker(app1, position); + JpegFileMarker marker = new JpegFileMarker(app1, position); Assert.Equal(app1, marker.Marker); Assert.Equal(position, marker.Position); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs index 19b5265a1..df0595d7b 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs @@ -12,8 +12,8 @@ public class JpegMetadataTests [Fact] public void CloneIsDeep() { - var meta = new JpegMetadata { ColorType = JpegColorType.Luminance }; - var clone = (JpegMetadata)meta.DeepClone(); + JpegMetadata meta = new JpegMetadata { ColorType = JpegColorType.Luminance }; + JpegMetadata clone = (JpegMetadata)meta.DeepClone(); clone.ColorType = JpegColorType.YCbCrRatio420; @@ -23,7 +23,7 @@ public class JpegMetadataTests [Fact] public void Quality_DefaultQuality() { - var meta = new JpegMetadata(); + JpegMetadata meta = new JpegMetadata(); Assert.Equal(meta.Quality, ImageSharp.Formats.Jpeg.Components.Quantization.DefaultQualityFactor); } @@ -33,7 +33,7 @@ public class JpegMetadataTests { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality }; + JpegMetadata meta = new JpegMetadata { LuminanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -43,7 +43,7 @@ public class JpegMetadataTests { int quality = 50; - var meta = new JpegMetadata { LuminanceQuality = quality, ChrominanceQuality = quality }; + JpegMetadata meta = new JpegMetadata { LuminanceQuality = quality, ChrominanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -54,7 +54,7 @@ public class JpegMetadataTests int qualityLuma = 50; int qualityChroma = 30; - var meta = new JpegMetadata { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; + JpegMetadata meta = new JpegMetadata { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; Assert.Equal(meta.Quality, qualityLuma); } @@ -62,7 +62,7 @@ public class JpegMetadataTests [Fact] public void Comment_EmptyComment() { - var meta = new JpegMetadata(); + JpegMetadata meta = new JpegMetadata(); Assert.True(Array.Empty().SequenceEqual(meta.Comments)); } @@ -71,9 +71,9 @@ public class JpegMetadataTests public void Comment_OnlyComment() { string comment = "test comment"; - var expectedCollection = new Collection { comment }; + Collection expectedCollection = new Collection { comment }; - var meta = new JpegMetadata(); + JpegMetadata meta = new JpegMetadata(); meta.Comments.Add(JpegComData.FromString(comment)); Assert.Equal(1, meta.Comments.Count); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index b202fd9ec..e9821db4c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -27,7 +27,7 @@ public class ParseStreamTests [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorSpace.Cmyk)] public void ColorSpace_IsDeducedCorrectly(string imageFile, object expectedColorSpaceValue) { - var expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; + JpegColorSpace expectedColorSpace = (JpegColorSpace)expectedColorSpaceValue; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile, metaDataOnly: true)) { @@ -47,7 +47,7 @@ public class ParseStreamTests Assert.Equal(expectedSizeInBlocks, decoder.Frame.McuSize); - var uniform1 = new Size(1, 1); + Size uniform1 = new Size(1, 1); IJpegComponent c0 = decoder.Components[0]; VerifyJpeg.VerifyComponent(c0, expectedSizeInBlocks, uniform1, uniform1); } @@ -62,7 +62,7 @@ public class ParseStreamTests [InlineData(TestImages.Jpeg.Baseline.Cmyk)] public void PrintComponentData(string imageFile) { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -98,8 +98,8 @@ public class ParseStreamTests object expectedLumaFactors, object expectedChromaFactors) { - var fLuma = (Size)expectedLumaFactors; - var fChroma = (Size)expectedChromaFactors; + Size fLuma = (Size)expectedLumaFactors; + Size fChroma = (Size)expectedChromaFactors; using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -110,7 +110,7 @@ public class ParseStreamTests IJpegComponent c1 = decoder.Components[1]; IJpegComponent c2 = decoder.Components[2]; - var uniform1 = new Size(1, 1); + Size uniform1 = new Size(1, 1); Size expectedLumaSizeInBlocks = decoder.Frame.McuSize.MultiplyBy(fLuma); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs index f5d7c159b..2fcd953ae 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs @@ -53,7 +53,7 @@ public partial class ReferenceImplementationsTests { float[] sourceArray = Create8x8RandomFloatData(-range, range, seed); - var source = Block8x8F.Load(sourceArray); + Block8x8F source = Block8x8F.Load(sourceArray); Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 499cf7991..e069296d1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -47,13 +47,13 @@ public class SpectralJpegTests byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; JpegDecoderOptions option = new(); - using var decoder = new JpegDecoderCore(option); - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using JpegDecoderCore decoder = new(option); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // internal scan decoder which we substitute to assert spectral correctness - var debugConverter = new DebugSpectralConverter(); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, debugConverter, cancellationToken: default); + DebugSpectralConverter debugConverter = new(); + HuffmanScanDecoder scanDecoder = new(bufferedStream, debugConverter, cancellationToken: default); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -77,12 +77,12 @@ public class SpectralJpegTests byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; JpegDecoderOptions options = new(); - using var decoder = new JpegDecoderCore(options); - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using JpegDecoderCore decoder = new(options); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // internal scan decoder which we substitute to assert spectral correctness - var debugConverter = new DebugSpectralConverter(); + DebugSpectralConverter debugConverter = new(); // This would parse entire image decoder.ParseStream(bufferedStream, debugConverter, cancellationToken: default); @@ -101,7 +101,7 @@ public class SpectralJpegTests int componentCount = imageSharpData.ComponentCount; if (libJpegData.ComponentCount != componentCount) { - throw new Exception("libJpegData.ComponentCount != componentCount"); + throw new("libJpegData.ComponentCount != componentCount"); } double averageDifference = 0; @@ -198,14 +198,14 @@ public class SpectralJpegTests public override void PrepareForDecoding() { - var spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; + LibJpegTools.ComponentData[] spectralComponents = new LibJpegTools.ComponentData[this.frame.ComponentCount]; for (int i = 0; i < spectralComponents.Length; i++) { JpegComponent component = this.frame.Components[i]; - spectralComponents[i] = new LibJpegTools.ComponentData(component.WidthInBlocks, component.HeightInBlocks, component.Index); + spectralComponents[i] = new(component.WidthInBlocks, component.HeightInBlocks, component.Index); } - this.spectralData = new LibJpegTools.SpectralData(spectralComponents); + this.spectralData = new(spectralComponents); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index b9f4a90b6..186f72341 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -33,14 +33,14 @@ public class SpectralToPixelConversionTests { // Stream byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; - using var ms = new MemoryStream(sourceBytes); - using var bufferedStream = new BufferedReadStream(Configuration.Default, ms); + using MemoryStream ms = new(sourceBytes); + using BufferedReadStream bufferedStream = new(Configuration.Default, ms); // Decoding JpegDecoderOptions options = new(); - using var converter = new SpectralConverter(Configuration.Default); - using var decoder = new JpegDecoderCore(options); - var scanDecoder = new HuffmanScanDecoder(bufferedStream, converter, cancellationToken: default); + using SpectralConverter converter = new(Configuration.Default); + using JpegDecoderCore decoder = new(options); + HuffmanScanDecoder scanDecoder = new(bufferedStream, converter, cancellationToken: default); decoder.ParseStream(bufferedStream, converter, cancellationToken: default); // Test metadata @@ -48,7 +48,7 @@ public class SpectralToPixelConversionTests provider.Utility.TestName = JpegDecoderTests.DecodeBaselineJpegOutputName; // Comparison - using var image = new Image(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new ImageMetadata()); + using Image image = new(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new()); using Image referenceImage = provider.GetReferenceOutputImage(appendPixelTypeToFileName: false); ImageSimilarityReport report = ImageComparer.Exact.CompareImagesOrFrames(referenceImage, image); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index a3fbe4018..511150c52 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -72,7 +72,7 @@ public class JpegFixture : MeasureFixture // ReSharper disable once InconsistentNaming public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { - var rnd = new Random(seed); + Random rnd = new Random(seed); int[] result = new int[64]; for (int i = 0; i < 8; i++) { @@ -87,7 +87,7 @@ public class JpegFixture : MeasureFixture public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42, int xBorder = 8, int yBorder = 8) { - var rnd = new Random(seed); + Random rnd = new Random(seed); float[] result = new float[64]; for (int y = 0; y < yBorder; y++) { @@ -112,7 +112,7 @@ public class JpegFixture : MeasureFixture internal void Print8x8Data(Span data) { - var bld = new StringBuilder(); + StringBuilder bld = new StringBuilder(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -135,7 +135,7 @@ public class JpegFixture : MeasureFixture count = data.Length; } - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { sb.Append($"{data[i],3} "); @@ -158,7 +158,7 @@ public class JpegFixture : MeasureFixture internal void CompareBlocks(Span a, Span b, float tolerance) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance); double totalDifference = 0.0; bool failed = false; @@ -192,7 +192,7 @@ public class JpegFixture : MeasureFixture internal static bool CompareBlocks(Span a, Span b, float tolerance, out float diff) { - var comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance); bool failed = false; diff = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index bd1df3377..b08202df5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -18,12 +18,12 @@ internal static partial class LibJpegTools BigInteger totalDiff = 0; if (actual.WidthInBlocks < expected.WidthInBlocks) { - throw new Exception("actual.WidthInBlocks < expected.WidthInBlocks"); + throw new("actual.WidthInBlocks < expected.WidthInBlocks"); } if (actual.HeightInBlocks < expected.HeightInBlocks) { - throw new Exception("actual.HeightInBlocks < expected.HeightInBlocks"); + throw new("actual.HeightInBlocks < expected.HeightInBlocks"); } int w = expected.WidthInBlocks; @@ -65,7 +65,7 @@ internal static partial class LibJpegTools } string args = $@"""{sourceFile}"" ""{destFile}"""; - var process = new Process + Process process = new() { StartInfo = { @@ -95,21 +95,21 @@ internal static partial class LibJpegTools { RunDumpJpegCoeffsTool(testFile.FullPath, coeffFileFullPath); - using (var dumpStream = new FileStream(coeffFileFullPath, FileMode.Open)) - using (var rdr = new BinaryReader(dumpStream)) + using (FileStream dumpStream = new(coeffFileFullPath, FileMode.Open)) + using (BinaryReader rdr = new(dumpStream)) { int componentCount = rdr.ReadInt16(); - var result = new ComponentData[componentCount]; + ComponentData[] result = new ComponentData[componentCount]; for (int i = 0; i < componentCount; i++) { int widthInBlocks = rdr.ReadInt16(); int heightInBlocks = rdr.ReadInt16(); - var resultComponent = new ComponentData(widthInBlocks, heightInBlocks, i); + ComponentData resultComponent = new(widthInBlocks, heightInBlocks, i); result[i] = resultComponent; } - var buffer = new byte[64 * sizeof(short)]; + byte[] buffer = new byte[64 * sizeof(short)]; for (int i = 0; i < result.Length; i++) { @@ -127,7 +127,7 @@ internal static partial class LibJpegTools } } - return new SpectralData(result); + return new(result); } } finally diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs index b6e7b29a6..2d4db15df 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs @@ -30,7 +30,7 @@ internal static partial class ReferenceImplementations public static void TransformIDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformIDCT(ref temp); result.CopyTo(span); @@ -45,7 +45,7 @@ internal static partial class ReferenceImplementations public static void TransformFDCTInplace(Span span) { - var temp = default(Block8x8); + Block8x8 temp = default(Block8x8); temp.LoadFrom(span); Block8x8 result = TransformFDCT(ref temp); result.CopyTo(span); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index 0d5f3114d..acb3d27e3 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -208,8 +208,8 @@ internal static partial class ReferenceImplementations /*y[0] = c0 + c1; y[4] = c0 - c1;*/ - var w0 = new Vector4(0.541196f); - var w1 = new Vector4(1.306563f); + Vector4 w0 = new(0.541196f); + Vector4 w1 = new(1.306563f); _mm_store_ps(d, 16, (w0 * c2) + (w1 * c3)); @@ -219,8 +219,8 @@ internal static partial class ReferenceImplementations y[6] = c3 * r[6] - c2 * r[2]; */ - w0 = new Vector4(1.175876f); - w1 = new Vector4(0.785695f); + w0 = new(1.175876f); + w1 = new(0.785695f); c3 = (w0 * t4) + (w1 * t7); c0 = (w0 * t7) - (w1 * t4); /* @@ -228,8 +228,8 @@ internal static partial class ReferenceImplementations c0 = t7 * r[3] - t4 * r[5]; */ - w0 = new Vector4(1.387040f); - w1 = new Vector4(0.275899f); + w0 = new(1.387040f); + w1 = new(0.275899f); c2 = (w0 * t5) + (w1 * t6); c1 = (w0 * t6) - (w1 * t5); /* @@ -242,7 +242,7 @@ internal static partial class ReferenceImplementations _mm_store_ps(d, 40, c3 - c1); // y[5] = c3 - c1; y[3] = c0 - c2; - var invsqrt2 = new Vector4(0.707107f); + Vector4 invsqrt2 = new(0.707107f); c0 = (c0 + c2) * invsqrt2; c3 = (c3 + c1) * invsqrt2; @@ -272,7 +272,7 @@ internal static partial class ReferenceImplementations FDCT2D8x4_32f(temp.Slice(4), d.Slice(4)); - var c = new Vector4(0.1250f); + Vector4 c = new(0.1250f); #pragma warning disable SA1107 // Code should not contain multiple statements on one line _mm_store_ps(d, 0, _mm_load_ps(d, 0) * c); d = d.Slice(4); // 0 @@ -300,7 +300,7 @@ internal static partial class ReferenceImplementations #pragma warning restore SA1300 // Element should begin with upper-case letter { src = src.Slice(offset); - return new Vector4(src[0], src[1], src[2], src[3]); + return new(src[0], src[1], src[2], src[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -318,29 +318,29 @@ internal static partial class ReferenceImplementations // Accurate variants of constants from: // https://github.com/mozilla/mozjpeg/blob/master/simd/jfdctint-altivec.c #pragma warning disable SA1309 // Field names should not begin with underscore - private static readonly Vector4 _1_175876 = new Vector4(1.175875602f); + private static readonly Vector4 _1_175876 = new(1.175875602f); - private static readonly Vector4 _1_961571 = new Vector4(-1.961570560f); + private static readonly Vector4 _1_961571 = new(-1.961570560f); - private static readonly Vector4 _0_390181 = new Vector4(-0.390180644f); + private static readonly Vector4 _0_390181 = new(-0.390180644f); - private static readonly Vector4 _0_899976 = new Vector4(-0.899976223f); + private static readonly Vector4 _0_899976 = new(-0.899976223f); - private static readonly Vector4 _2_562915 = new Vector4(-2.562915447f); + private static readonly Vector4 _2_562915 = new(-2.562915447f); - private static readonly Vector4 _0_298631 = new Vector4(0.298631336f); + private static readonly Vector4 _0_298631 = new(0.298631336f); - private static readonly Vector4 _2_053120 = new Vector4(2.053119869f); + private static readonly Vector4 _2_053120 = new(2.053119869f); - private static readonly Vector4 _3_072711 = new Vector4(3.072711026f); + private static readonly Vector4 _3_072711 = new(3.072711026f); - private static readonly Vector4 _1_501321 = new Vector4(1.501321110f); + private static readonly Vector4 _1_501321 = new(1.501321110f); - private static readonly Vector4 _0_541196 = new Vector4(0.541196100f); + private static readonly Vector4 _0_541196 = new(0.541196100f); - private static readonly Vector4 _1_847759 = new Vector4(-1.847759065f); + private static readonly Vector4 _1_847759 = new(-1.847759065f); - private static readonly Vector4 _0_765367 = new Vector4(0.765366865f); + private static readonly Vector4 _0_765367 = new(0.765366865f); #pragma warning restore SA1309 // Field names should not begin with underscore /// diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs index 95ab076b0..10019c609 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs @@ -71,10 +71,10 @@ internal static partial class ReferenceImplementations public static Block8x8 Subtract128_TransformFDCT_Upscale8(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); Subtract128_TransformFDCT_Upscale8_Inplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } @@ -82,10 +82,10 @@ internal static partial class ReferenceImplementations // [Obsolete("Looks like this method produces really bad results for bigger values!")] public static Block8x8 TransformIDCT(ref Block8x8 block) { - var temp = new int[Block8x8.Size]; + int[] temp = new int[Block8x8.Size]; block.CopyTo(temp); TransformIDCTInplace(temp); - var result = default(Block8x8); + Block8x8 result = default(Block8x8); result.LoadFrom(temp); return result; } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs index 240a338f9..d7c2c0bbb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs @@ -74,7 +74,7 @@ internal static class SpanExtensions /// A new with float values public static float[] ConvertAllToFloat(this int[] src) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i]; @@ -91,7 +91,7 @@ internal static class SpanExtensions /// A new instance of public static Span AddScalarToAllValues(this Span src, float scalar) { - var result = new float[src.Length]; + float[] result = new float[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; @@ -108,7 +108,7 @@ internal static class SpanExtensions /// A new instance of public static Span AddScalarToAllValues(this Span src, int scalar) { - var result = new int[src.Length]; + int[] result = new int[src.Length]; for (int i = 0; i < src.Length; i++) { result[i] = src[i] + scalar; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index 7a31e35d0..d7b0b64b2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -11,7 +11,7 @@ internal static class VerifyJpeg { internal static void VerifySize(IJpegComponent component, int expectedBlocksX, int expectedBlocksY) { - Assert.Equal(new Size(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); + Assert.Equal(new(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); } internal static void VerifyComponent( diff --git a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs index 5cbdd3dab..1b71f49d5 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(file, new PbmEncoder()); + image.SaveAsPbm(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(memoryStream, new PbmEncoder()); + image.SaveAsPbm(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 11dd1cd58..2da801532 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -29,11 +29,11 @@ public class PbmDecoderTests public void ImageLoadCanDecode(string imagePath, PbmColorType expectedColorType, PbmComponentType expectedComponentType) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -53,11 +53,11 @@ public class PbmDecoderTests public void ImageLoadL8CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -70,11 +70,11 @@ public class PbmDecoderTests public void ImageLoadRgb24CanDecode(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); // Act - using var image = Image.Load(stream); + using Image image = Image.Load(stream); // Assert Assert.NotNull(image); @@ -130,7 +130,7 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(bytes); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(100, 100), eofHitCounter.Image.Size); + Assert.Equal(new(100, 100), eofHitCounter.Image.Size); } [Fact] @@ -139,6 +139,6 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(RgbBinaryPrematureEof); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new Size(29, 30), eofHitCounter.Image.Size); + Assert.Equal(new(29, 30), eofHitCounter.Image.Size); } } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 05f1d963b..0501ed2b2 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -38,16 +38,16 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_PreserveColorType(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder(); + PbmEncoder options = new PbmEncoder(); - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { input.Save(memStream, options); memStream.Position = 0; - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -60,15 +60,15 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_WithPlainEncoding_PreserveBitsPerPixel(string imagePath, PbmColorType pbmColorType) { - var options = new PbmEncoder() + PbmEncoder options = new PbmEncoder() { Encoding = PbmEncoding.Plain }; - var testFile = TestFile.Create(imagePath); + TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { input.Save(memStream, options); @@ -78,7 +78,7 @@ public class PbmEncoderTests Assert.Equal(0x20, lastByte); memStream.Seek(0, SeekOrigin.Begin); - using (var output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { PbmMetadata meta = output.Metadata.GetPbmMetadata(); Assert.Equal(pbmColorType, meta.ColorType); @@ -132,13 +132,13 @@ public class PbmEncoderTests { using (Image image = provider.GetImage()) { - var encoder = new PbmEncoder { ColorType = colorType, Encoding = encoding }; + PbmEncoder encoder = new PbmEncoder { ColorType = colorType, Encoding = encoding }; - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { image.Save(memStream, encoder); memStream.Position = 0; - using (var encodedImage = (Image)Image.Load(memStream)) + using (Image encodedImage = (Image)Image.Load(memStream)) { ImageComparingUtils.CompareWithReferenceDecoder(provider, encodedImage, useExactComparer, compareTolerance); } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs index b7ce32ed8..f7c6dc171 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs @@ -21,11 +21,11 @@ public class PbmRoundTripTests public void PbmGrayscaleImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new MemoryStream(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image colorImage = originalImage.CloneAs(); using Image encodedImage = this.RoundTrip(colorImage); @@ -42,11 +42,11 @@ public class PbmRoundTripTests public void PbmColorImageCanRoundTrip(string imagePath) { // Arrange - var testFile = TestFile.Create(imagePath); - using var stream = new MemoryStream(testFile.Bytes, false); + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new MemoryStream(testFile.Bytes, false); // Act - using var originalImage = Image.Load(stream); + using Image originalImage = Image.Load(stream); using Image encodedImage = this.RoundTrip(originalImage); // Assert @@ -57,10 +57,10 @@ public class PbmRoundTripTests private Image RoundTrip(Image originalImage) where TPixel : unmanaged, IPixel { - using var decodedStream = new MemoryStream(); + using MemoryStream decodedStream = new MemoryStream(); originalImage.SaveAsPbm(decodedStream); decodedStream.Seek(0, SeekOrigin.Begin); - var encodedImage = Image.Load(decodedStream); + Image encodedImage = Image.Load(decodedStream); return encodedImage; } } diff --git a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs index 1b66c4cc3..6e03042fa 100644 --- a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs @@ -30,7 +30,7 @@ public class Adler32Tests { // arrange byte[] data = GetBuffer(length); - var adler = new SharpAdler32(); + SharpAdler32 adler = new SharpAdler32(); adler.Update(data); long expected = adler.Value; diff --git a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs index a03e1a7aa..145cc1d68 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(file, new PngEncoder()); + image.SaveAsPng(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(memoryStream, new PngEncoder()); + image.SaveAsPng(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index aff8bc12a..71523d5b6 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -64,7 +64,7 @@ public partial class PngDecoderTests { string chunkName = GetChunkTypeName(chunkType); - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 4d058e54e..26da6f521 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -389,7 +389,7 @@ public partial class PngDecoderTests TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new DecoderOptions() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); + ImageInfo imageInfo = Image.Identify(new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); Assert.NotNull(imageInfo); Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel); @@ -679,7 +679,7 @@ public partial class PngDecoderTests // TODO: Try to reduce this to 1. Assert.True(eofHitCounter.EofHitCount <= 3); - Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size); + Assert.Equal(new(200, 120), eofHitCounter.Image.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 796d35bf7..9ce1a9386 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -31,7 +31,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new TestData(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -45,7 +45,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new TestData(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -59,7 +59,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new TestData(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -73,7 +73,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Average, Size); + TestData data = new TestData(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -87,7 +87,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new TestData(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -101,7 +101,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new TestData(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -115,7 +115,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new TestData(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -129,7 +129,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new TestData(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -143,7 +143,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new TestData(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -157,7 +157,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Up, Size); + TestData data = new TestData(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -171,7 +171,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new TestData(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -185,7 +185,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new TestData(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -199,7 +199,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - var data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new TestData(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -227,7 +227,7 @@ public class PngEncoderFilterTests : MeasureFixture this.expectedResult = new byte[1 + (size * size * bpp)]; this.resultBuffer = new byte[1 + (size * size * bpp)]; - var rng = new Random(12345678); + Random rng = new Random(12345678); byte[] tmp = new byte[6]; for (int i = 0; i < this.previousScanline.Length; i += bpp) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index b0d0563cc..56909b9dc 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -380,7 +380,7 @@ public partial class PngEncoderTests if (colorType is PngColorType.Grayscale or PngColorType.GrayscaleWithAlpha) { byte luminance = ColorNumerics.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); - expectedColor = new Rgba32(luminance, luminance, luminance); + expectedColor = new(luminance, luminance, luminance); } actual.ProcessPixelRows(accessor => @@ -680,7 +680,7 @@ public partial class PngEncoderTests PaletteQuantizer quantizer = new( palette.Select(Color.FromPixel).ToArray(), - new QuantizerOptions() { ColorMatchingMode = ColorMatchingMode.Hybrid }); + new() { ColorMatchingMode = ColorMatchingMode.Hybrid }); using MemoryStream ms = new(); image.Save(ms, new PngEncoder @@ -720,7 +720,7 @@ public partial class PngEncoderTests FilterMethod = pngFilterMethod, CompressionLevel = compressionLevel, BitDepth = bitDepth, - Quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = paletteSize }), + Quantizer = new WuQuantizer(new() { MaxColors = paletteSize }), InterlaceMethod = interlaceMode, ChunkFilter = optimizeMethod, }; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 225e4deef..690299024 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -31,7 +31,7 @@ public class PngMetadataTests ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List { new PngTextData("name", "value", "foo", "bar") }, + TextData = new List { new("name", "value", "foo", "bar") }, RepeatCount = 123, AnimateRootFrame = false }; @@ -111,10 +111,10 @@ public class PngMetadataTests using MemoryStream memoryStream = new(); // This will be a zTXt chunk. - PngTextData expectedText = new("large-text", new string('c', 100), string.Empty, string.Empty); + PngTextData expectedText = new("large-text", new('c', 100), string.Empty, string.Empty); // This will be a iTXt chunk. - PngTextData expectedTextNoneLatin = new("large-text-non-latin", new string('Ф', 100), "language-tag", "translated-keyword"); + PngTextData expectedTextNoneLatin = new("large-text-non-latin", new('Ф', 100), "language-tag", "translated-keyword"); PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs index 878f3fb8d..f4c2f5897 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs @@ -17,8 +17,8 @@ public class PngTextDataTests [Fact] public void AreEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Bar", "foo", "bar"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Bar", "foo", "bar"); Assert.Equal(property1, property2); Assert.True(property1 == property2); @@ -30,10 +30,10 @@ public class PngTextDataTests [Fact] public void AreNotEqual() { - var property1 = new PngTextData("Foo", "Bar", "foo", "bar"); - var property2 = new PngTextData("Foo", "Foo", string.Empty, string.Empty); - var property3 = new PngTextData("Bar", "Bar", "unit", "test"); - var property4 = new PngTextData("Foo", null, "test", "case"); + PngTextData property1 = new("Foo", "Bar", "foo", "bar"); + PngTextData property2 = new("Foo", "Foo", string.Empty, string.Empty); + PngTextData property3 = new("Bar", "Bar", "unit", "test"); + PngTextData property4 = new("Foo", null, "test", "case"); Assert.NotEqual(property1, property2); Assert.True(property1 != property2); @@ -59,13 +59,13 @@ public class PngTextDataTests [Fact] public void ConstructorAssignsProperties() { - var property = new PngTextData("Foo", null, "unit", "test"); + PngTextData property = new("Foo", null, "unit", "test"); Assert.Equal("Foo", property.Keyword); Assert.Null(property.Value); Assert.Equal("unit", property.LanguageTag); Assert.Equal("test", property.TranslatedKeyword); - property = new PngTextData("Foo", string.Empty, string.Empty, null); + property = new("Foo", string.Empty, string.Empty, null); Assert.Equal("Foo", property.Keyword); Assert.Equal(string.Empty, property.Value); Assert.Equal(string.Empty, property.LanguageTag); diff --git a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs index 31ec27da0..11e79512e 100644 --- a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(file, new QoiEncoder()); + image.SaveAsQoi(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(memoryStream, new QoiEncoder()); + image.SaveAsQoi(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs index 9b6daee4c..9648f93e5 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(file, new TgaEncoder()); + image.SaveAsTga(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(memoryStream, new TgaEncoder()); + image.SaveAsTga(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs index 4646de7f8..04e8f2940 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs @@ -16,7 +16,7 @@ public class BigTiffMetadataTests [Fact] public void ExifLong8() { - var long8 = new ExifLong8(ExifTagValue.StripByteCounts); + ExifLong8 long8 = new(ExifTagValue.StripByteCounts); Assert.True(long8.TrySetValue(0)); Assert.Equal(0UL, long8.GetValue()); @@ -34,7 +34,7 @@ public class BigTiffMetadataTests [Fact] public void ExifSignedLong8() { - var long8 = new ExifSignedLong8(ExifTagValue.ImageID); + ExifSignedLong8 long8 = new(ExifTagValue.ImageID); Assert.False(long8.TrySetValue(0)); @@ -53,7 +53,7 @@ public class BigTiffMetadataTests [Fact] public void ExifLong8Array() { - var long8 = new ExifLong8Array(ExifTagValue.StripOffsets); + ExifLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue((short)-123)); Assert.Equal(new[] { 0UL }, long8.GetValue()); @@ -91,7 +91,7 @@ public class BigTiffMetadataTests [Fact] public void ExifSignedLong8Array() { - var long8 = new ExifSignedLong8Array(ExifTagValue.StripOffsets); + ExifSignedLong8Array long8 = new(ExifTagValue.StripOffsets); Assert.True(long8.TrySetValue(new[] { 0L })); Assert.Equal(new[] { 0L }, long8.GetValue()); @@ -105,9 +105,9 @@ public class BigTiffMetadataTests [Fact] public void NotCoveredTags() { - using var input = new Image(10, 10); + using Image input = new(10, 10); - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd01), (ExifDataType.SingleFloat, new float[] { 1.2f, 2.3f, 4.5f }) }, { new ExifTag((ExifTagValue)0xdd02), (ExifDataType.SingleFloat, 2.345f) }, @@ -122,7 +122,7 @@ public class BigTiffMetadataTests }; // arrange - var values = new List(); + List values = new(); foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -131,16 +131,16 @@ public class BigTiffMetadataTests values.Add(newExifValue); } - input.Frames.RootFrame.Metadata.ExifProfile = new ExifProfile(values, Array.Empty()); + input.Frames.RootFrame.Metadata.ExifProfile = new(values, Array.Empty()); // act - var encoder = new TiffEncoder(); - using var memStream = new MemoryStream(); + TiffEncoder encoder = new(); + using MemoryStream memStream = new(); input.Save(memStream, encoder); // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageFrameMetadata loadedFrameMetadata = output.Frames.RootFrame.Metadata; foreach (KeyValuePair tag in testTags) { @@ -158,7 +158,7 @@ public class BigTiffMetadataTests [Fact] public void NotCoveredTags64bit() { - var testTags = new Dictionary + Dictionary testTags = new() { { new ExifTag((ExifTagValue)0xdd11), (ExifDataType.Long8, ulong.MaxValue) }, { new ExifTag((ExifTagValue)0xdd12), (ExifDataType.SignedLong8, long.MaxValue) }, @@ -167,7 +167,7 @@ public class BigTiffMetadataTests ////{ new ExifTag((ExifTagValue)0xdd14), (ExifDataType.SignedLong8, new long[] { -1234, 56789L, long.MaxValue }) }, }; - var values = new List(); + List values = new(); foreach (KeyValuePair tag in testTags) { ExifValue newExifValue = ExifValues.Create((ExifTagValue)(ushort)tag.Key, tag.Value.DataType, tag.Value.Value is Array); @@ -179,7 +179,7 @@ public class BigTiffMetadataTests // act byte[] inputBytes = WriteIfdTags64Bit(values); Configuration config = Configuration.Default; - var reader = new EntryReader( + EntryReader reader = new( new MemoryStream(inputBytes), BitConverter.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian, config.MemoryAllocator); @@ -205,8 +205,8 @@ public class BigTiffMetadataTests private static byte[] WriteIfdTags64Bit(List values) { byte[] buffer = new byte[8]; - var ms = new MemoryStream(); - var writer = new TiffStreamWriter(ms); + MemoryStream ms = new(); + TiffStreamWriter writer = new(ms); WriteLong8(writer, buffer, (ulong)values.Count); foreach (IExifValue entry in values) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs index b16119f33..ca39cd5be 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs @@ -23,7 +23,7 @@ public class DeflateTiffCompressionTests using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new DeflateTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); + using DeflateTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); @@ -41,6 +41,6 @@ public class DeflateTiffCompressionTests } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs index 8c21e346a..01aaca9f5 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs @@ -37,7 +37,7 @@ public class LzwTiffCompressionTests using BufferedReadStream stream = CreateCompressedStream(data); byte[] buffer = new byte[data.Length]; - using var decompressor = new LzwTiffCompression(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); + using LzwTiffCompression decompressor = new(Configuration.Default.MemoryAllocator, 10, 8, TiffColorType.BlackIsZero8, TiffPredictor.None, false, false, 0, 0); decompressor.Decompress(stream, 0, (uint)stream.Length, 1, buffer, default); Assert.Equal(data, buffer); @@ -47,13 +47,13 @@ public class LzwTiffCompressionTests { Stream compressedStream = new MemoryStream(); - using (var encoder = new TiffLzwEncoder(Configuration.Default.MemoryAllocator)) + using (TiffLzwEncoder encoder = new(Configuration.Default.MemoryAllocator)) { encoder.Encode(inputData, compressedStream); } compressedStream.Seek(0, SeekOrigin.Begin); - return new BufferedReadStream(Configuration.Default, compressedStream); + return new(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs index e79ed7ce7..0a2726c21 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs @@ -14,11 +14,11 @@ public class NoneTiffCompressionTests [InlineData(new byte[] { 10, 15, 20, 25, 30, 35, 40, 45 }, 5, new byte[] { 10, 15, 20, 25, 30 })] public void Decompress_ReadsData(byte[] inputData, uint byteCount, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new MemoryStream(inputData); + using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new NoneTiffCompression(default, default, default); + using NoneTiffCompression decompressor = new NoneTiffCompression(default, default, default); decompressor.Decompress(stream, 0, byteCount, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs index c91ab0e7f..f5fbcb2e1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs @@ -22,11 +22,11 @@ public class PackBitsTiffCompressionTests [InlineData(new byte[] { 0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA }, new byte[] { 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA })] // Apple PackBits sample public void Decompress_ReadsData(byte[] inputData, byte[] expectedResult) { - using var memoryStream = new MemoryStream(inputData); - using var stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new MemoryStream(inputData); + using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using var decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); + using PackBitsTiffCompression decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); decompressor.Decompress(stream, 0, (uint)inputData.Length, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs index bf9e73ea6..69d70e5e7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(file, new TiffEncoder()); + image.SaveAsTiff(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(memoryStream, new TiffEncoder()); + image.SaveAsTiff(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index 0fa7e01e8..d2176f7e6 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -154,7 +154,7 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode( expectedResult, - pixels => new BlackIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); + pixels => new BlackIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); [Theory] [MemberData(nameof(BilevelData))] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index c809c6c7f..fce40c4c4 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -83,12 +83,12 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, ushort[] colorMap, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode(expectedResult, pixels => { - new PaletteTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); + new PaletteTiffColor(new(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); }); private static uint[][] GeneratePalette(int count) { - var palette = new uint[count][]; + uint[][] palette = new uint[count][]; for (uint i = 0; i < count; i++) { @@ -101,7 +101,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase private static ushort[] GenerateColorMap(uint[][] colorPalette) { int colorCount = colorPalette.Length; - var colorMap = new ushort[colorCount * 3]; + ushort[] colorMap = new ushort[colorCount * 3]; for (int i = 0; i < colorCount; i++) { @@ -115,7 +115,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase private static Rgba32[][] GenerateResult(uint[][] colorPalette, int[][] pixelLookup) { - var result = new Rgba32[pixelLookup.Length][]; + Rgba32[][] result = new Rgba32[pixelLookup.Length][]; for (int y = 0; y < pixelLookup.Length; y++) { @@ -124,7 +124,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase for (int x = 0; x < pixelLookup[y].Length; x++) { uint[] sourceColor = colorPalette[pixelLookup[y][x]]; - result[y][x] = new Rgba32(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); + result[y][x] = new(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index 3582dc75a..ef57b288c 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -17,7 +17,7 @@ public abstract class PhotometricInterpretationTestBase int inputHeight = input.Length; int inputWidth = input[0].Length; - var output = new Rgba32[height][]; + Rgba32[][] output = new Rgba32[height][]; for (int y = 0; y < output.Length; y++) { @@ -45,7 +45,7 @@ public abstract class PhotometricInterpretationTestBase int resultWidth = expectedResult[0].Length; int resultHeight = expectedResult.Length; - using (var image = new Image(resultWidth, resultHeight)) + using (Image image = new Image(resultWidth, resultHeight)) { image.Mutate(x => x.BackgroundColor(Color.FromPixel(DefaultColor))); Buffer2D pixels = image.GetRootFramePixelBuffer(); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index d8249c361..6e0d5b2be 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -251,7 +251,7 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase expectedResult, pixels => { - var buffers = new IMemoryOwner[inputData.Length]; + IMemoryOwner[] buffers = new IMemoryOwner[inputData.Length]; for (int i = 0; i < buffers.Length; i++) { buffers[i] = Configuration.Default.MemoryAllocator.Allocate(inputData[i].Length); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index 0b58e3891..a79cc0058 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -10,14 +10,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Gray000 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray128 = new Rgba32(127, 127, 127, 255); - private static readonly Rgba32 Gray255 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Gray0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Gray8 = new Rgba32(119, 119, 119, 255); - private static readonly Rgba32 GrayF = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Bit0 = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Bit1 = new Rgba32(0, 0, 0, 255); + private static readonly Rgba32 Gray000 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray128 = new(127, 127, 127, 255); + private static readonly Rgba32 Gray255 = new(0, 0, 0, 255); + private static readonly Rgba32 Gray0 = new(255, 255, 255, 255); + private static readonly Rgba32 Gray8 = new(119, 119, 119, 255); + private static readonly Rgba32 GrayF = new(0, 0, 0, 255); + private static readonly Rgba32 Bit0 = new(255, 255, 255, 255); + private static readonly Rgba32 Bit1 = new(0, 0, 0, 255); private static readonly byte[] BilevelBytes4X4 = { @@ -155,7 +155,7 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { AssertDecode(expectedResult, pixels => { - new WhiteIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); + new WhiteIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); }); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs index 1bf9f5a40..70ba2e5df 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs @@ -26,9 +26,9 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { // arrange - var tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; + TiffEncoder tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new MemoryStream(); TiffFrameMetadata inputMeta = input.Frames.RootFrame.Metadata.GetTiffMetadata(); TiffCompression inputCompression = inputMeta.Compression; @@ -37,7 +37,7 @@ public abstract class TiffEncoderBaseTester // assert memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ExifProfile exifProfileOutput = output.Frames.RootFrame.Metadata.ExifProfile; TiffFrameMetadata outputMeta = output.Frames.RootFrame.Metadata.GetTiffMetadata(); ImageFrame rootFrame = output.Frames.RootFrame; @@ -89,7 +89,7 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - var encoder = new TiffEncoder + TiffEncoder encoder = new TiffEncoder { PhotometricInterpretation = photometricInterpretation, BitsPerPixel = bitsPerPixel, diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs index 716b978a7..a138d9ef8 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs @@ -46,7 +46,7 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new TiffEncoder { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, @@ -69,27 +69,27 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester using Image image = provider.GetImage(); Assert.Equal(1, image.Frames.Count); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image1.Frames.RootFrame); image.Frames.AddFrame(image2.Frames.RootFrame); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - var encoder = new TiffEncoder + TiffEncoder encoder = new TiffEncoder { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Deflate }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new System.IO.MemoryStream()) { image.Save(ms, encoder); ms.Position = 0; - using var output = Image.Load(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); @@ -121,11 +121,11 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester { using Image image = provider.GetImage(); - using var image0 = new Image(image.Width, image.Height, Color.Red.ToPixel()); + using Image image0 = new Image(image.Width, image.Height, Color.Red.ToPixel()); - using var image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); - using var image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image0.Frames.RootFrame); image.Frames.AddFrame(image1.Frames.RootFrame); @@ -133,19 +133,19 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit8; - var encoder = new TiffEncoder + TiffEncoder encoder = new TiffEncoder { PhotometricInterpretation = TiffPhotometricInterpretation.PaletteColor, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Lzw }; - using (var ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new System.IO.MemoryStream()) { image.Save(ms, encoder); ms.Position = 0; - using var output = Image.Load(ms); + using Image output = Image.Load(ms); Assert.Equal(3, output.Frames.Count); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 4317c2714..b00b8d7ac 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -334,7 +334,7 @@ public class TiffEncoderTests : TiffEncoderBaseTester foreach (ImageFrame frame in image.Frames) { TiffFrameMetadata metadata = frame.Metadata.GetTiffMetadata(); - encodedDimensions.Add(new Size(metadata.EncodingWidth, metadata.EncodingHeight)); + encodedDimensions.Add(new(metadata.EncodingWidth, metadata.EncodingHeight)); } const int scale = 2; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 9b26ab270..3bcbd26e5 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs @@ -11,8 +11,8 @@ public class TiffWriterTests [Fact] public void IsLittleEndian_IsTrueOnWindows() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); Assert.True(TiffStreamWriter.IsLittleEndian); } @@ -22,8 +22,8 @@ public class TiffWriterTests [InlineData(new byte[] { 1, 2, 3, 4, 5 }, 5)] public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.Write(data); Assert.Equal(writer.Position, expectedResult); } @@ -31,8 +31,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByte() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.Write(42); Assert.Equal(new byte[] { 42 }, stream.ToArray()); @@ -41,8 +41,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByteArray() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.Write(new byte[] { 2, 4, 6, 8 }); Assert.Equal(new byte[] { 2, 4, 6, 8 }, stream.ToArray()); @@ -51,8 +51,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt16() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.Write(1234, stackalloc byte[2]); Assert.Equal(new byte[] { 0xD2, 0x04 }, stream.ToArray()); @@ -61,8 +61,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt32() { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.Write(12345678U, stackalloc byte[4]); Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray()); @@ -78,8 +78,8 @@ public class TiffWriterTests public void WritePadded_WritesByteArray(byte[] bytes, byte[] expectedResult) { - using var stream = new MemoryStream(); - using var writer = new TiffStreamWriter(stream); + using MemoryStream stream = new MemoryStream(); + using TiffStreamWriter writer = new TiffStreamWriter(stream); writer.WritePadded(bytes); Assert.Equal(expectedResult, stream.ToArray()); @@ -88,10 +88,10 @@ public class TiffWriterTests [Fact] public void WriteMarker_WritesToPlacedPosition() { - using var stream = new MemoryStream(); + using MemoryStream stream = new MemoryStream(); Span buffer = stackalloc byte[4]; - using (var writer = new TiffStreamWriter(stream)) + using (TiffStreamWriter writer = new TiffStreamWriter(stream)) { writer.Write(0x11111111, buffer); long marker = writer.PlaceMarker(buffer); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs index ea13fd712..510d67103 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(file, new WebpEncoder()); + image.SaveAsWebp(file, new()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(memoryStream, new WebpEncoder()); + image.SaveAsWebp(memoryStream, new()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 4551e3e23..321aff2bd 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -89,7 +89,7 @@ public class LosslessUtilsTests 392450, 196861, 16712192, 16711680, 130564, 16451071 }; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new Vp8LMultipliers() { GreenToBlue = 240, GreenToRed = 232, @@ -121,7 +121,7 @@ public class LosslessUtilsTests 16711680, 65027, 16712962 }; - var m = new Vp8LMultipliers() + Vp8LMultipliers m = new Vp8LMultipliers() { GreenToBlue = 240, GreenToRed = 232, diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index b4279b045..a15441756 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -150,7 +150,7 @@ public class PredictorEncoderTests where TPixel : unmanaged, IPixel { Rgba32 rgba = color.ToRgba32(); - return new Bgra32(rgba.R, rgba.G, rgba.B, rgba.A); + return new(rgba.R, rgba.G, rgba.B, rgba.A); } private static string TestImageFullPath(string path) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs index a18eff73c..79c7ff26b 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs @@ -13,7 +13,7 @@ public class Vp8HistogramTests { get { - var result = new List(); + List result = new List(); result.Add(new object[] { new byte[] @@ -69,7 +69,7 @@ public class Vp8HistogramTests private static void RunCollectHistogramTest() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new Vp8Histogram(); byte[] reference = { @@ -172,7 +172,7 @@ public class Vp8HistogramTests public void GetAlpha_WithEmptyHistogram_Works() { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new Vp8Histogram(); // act int alpha = histogram.GetAlpha(); @@ -186,7 +186,7 @@ public class Vp8HistogramTests public void GetAlpha_Works(byte[] reference, byte[] pred) { // arrange - var histogram = new Vp8Histogram(); + Vp8Histogram histogram = new Vp8Histogram(); histogram.CollectHistogram(reference, pred, 0, 1); // act @@ -201,9 +201,9 @@ public class Vp8HistogramTests public void Merge_Works(byte[] reference, byte[] pred) { // arrange - var histogram1 = new Vp8Histogram(); + Vp8Histogram histogram1 = new Vp8Histogram(); histogram1.CollectHistogram(reference, pred, 0, 1); - var histogram2 = new Vp8Histogram(); + Vp8Histogram histogram2 = new Vp8Histogram(); histogram1.Merge(histogram2); // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs index 0b85ececb..a014e8991 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs @@ -11,7 +11,7 @@ public class Vp8ModeScoreTests [Fact] public void InitScore_Works() { - var score = new Vp8ModeScore(); + Vp8ModeScore score = new Vp8ModeScore(); score.InitScore(); Assert.Equal(0, score.D); Assert.Equal(0, score.SD); @@ -25,7 +25,7 @@ public class Vp8ModeScoreTests public void CopyScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new Vp8ModeScore { Score = 123, Nz = 1, @@ -36,7 +36,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore(); + Vp8ModeScore score2 = new Vp8ModeScore(); score2.InitScore(); // act @@ -55,7 +55,7 @@ public class Vp8ModeScoreTests public void AddScore_Works() { // arrange - var score1 = new Vp8ModeScore + Vp8ModeScore score1 = new Vp8ModeScore { Score = 123, Nz = 1, @@ -66,7 +66,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - var score2 = new Vp8ModeScore + Vp8ModeScore score2 = new Vp8ModeScore { Score = 123, Nz = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index 4982929c2..dcb54dc19 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -80,7 +80,7 @@ public class Vp8ResidualTests Vp8BandProbas[] bandProbas = new Vp8BandProbas[8]; for (int i = 0; i < bandProbas.Length; i++) { - bandProbas[i] = new Vp8BandProbas(); + bandProbas[i] = new(); for (int j = 0; j < bandProbas[i].Probabilities.Length; j++) { for (int k = 0; k < 11; k++) @@ -95,7 +95,7 @@ public class Vp8ResidualTests residual.Costs = new Vp8Costs[16]; for (int i = 0; i < residual.Costs.Length; i++) { - residual.Costs[i] = new Vp8Costs(); + residual.Costs[i] = new(); Vp8CostArray[] costsArray = residual.Costs[i].Costs; for (int j = 0; j < costsArray.Length; j++) { @@ -109,7 +109,7 @@ public class Vp8ResidualTests residual.Stats = new Vp8Stats[8]; for (int i = 0; i < residual.Stats.Length; i++) { - residual.Stats[i] = new Vp8Stats(); + residual.Stats[i] = new(); for (int j = 0; j < residual.Stats[i].Stats.Length; j++) { for (int k = 0; k < residual.Stats[i].Stats[j].Stats.Length; k++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 1ffbd9f55..f8c7770e6 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -349,7 +349,7 @@ public class WebpDecoderTests WebpDecoderOptions options = new() { BackgroundColorHandling = BackgroundColorHandling.Ignore, - GeneralOptions = new DecoderOptions() + GeneralOptions = new() { MaxFrames = 1 } @@ -460,7 +460,7 @@ public class WebpDecoderTests // Web using Image image = provider.GetImage( WebpDecoder.Instance, - new WebpDecoderOptions() { BackgroundColorHandling = BackgroundColorHandling.Ignore }); + new() { BackgroundColorHandling = BackgroundColorHandling.Ignore }); // We can't use the reference decoder here. // It creates frames of different size without blending the frames. diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs index af6f7eea1..55a6e8ba0 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs @@ -139,7 +139,7 @@ public class WebpEncoderTests }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "octree"); - gifEncoder = new GifEncoder() + gifEncoder = new() { Quantizer = new WuQuantizer(options) }; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs index ab8fef60f..fefe27790 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs @@ -103,9 +103,9 @@ public class WebpMetaDataTests public void Encode_WritesExifWithPadding(WebpFileFormatType fileFormatType) { // arrange - using var input = new Image(25, 25); - using var memoryStream = new MemoryStream(); - var expectedExif = new ExifProfile(); + using Image input = new Image(25, 25); + using MemoryStream memoryStream = new MemoryStream(); + ExifProfile expectedExif = new ExifProfile(); string expectedSoftware = "ImageSharp"; expectedExif.SetValue(ExifTag.Software, expectedSoftware); input.Metadata.ExifProfile = expectedExif; @@ -115,7 +115,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -129,7 +129,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new MemoryStream(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -137,7 +137,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -150,7 +150,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using var memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new MemoryStream(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -158,7 +158,7 @@ public class WebpMetaDataTests memoryStream.Position = 0; // assert - using var image = Image.Load(memoryStream); + using Image image = Image.Load(memoryStream); ExifProfile actualExif = image.Metadata.ExifProfile; Assert.NotNull(actualExif); Assert.Equal(expectedExif.Values.Count, actualExif.Values.Count); @@ -174,14 +174,14 @@ public class WebpMetaDataTests ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); - using var memStream = new MemoryStream(); + using MemoryStream memStream = new MemoryStream(); input.Save(memStream, new WebpEncoder() { FileFormat = fileFormat }); memStream.Position = 0; - using var output = Image.Load(memStream); + using Image output = Image.Load(memStream); ImageSharp.Metadata.Profiles.Icc.IccProfile actualProfile = output.Metadata.IccProfile; byte[] actualProfileBytes = actualProfile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index f50bc8933..6a46b26f2 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -19,7 +19,7 @@ public class YuvConversionTests public static void RunUpSampleYuvToRgbTest() { - var provider = TestImageProvider.File(TestImageLossyFullPath); + TestImageProvider provider = TestImageProvider.File(TestImageLossyFullPath); using Image image = provider.GetImage(WebpDecoder.Instance); image.DebugSave(provider); image.CompareToOriginal(provider, ReferenceDecoder); diff --git a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs index d663a803b..e894f7b86 100644 --- a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs @@ -12,9 +12,9 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnProcessingContext() { - var option = new GraphicsOptions(); - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + GraphicsOptions option = new GraphicsOptions(); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); context.SetGraphicsOptions(option); @@ -26,12 +26,12 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new GraphicsOptions() { BlendPercentage = 0.9f }; - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); context.SetGraphicsOptions(option); context.SetGraphicsOptions(o => @@ -40,7 +40,7 @@ public class GraphicOptionsDefaultsExtensionsTests o.BlendPercentage = 0.4f; }); - var returnedOption = context.GetGraphicsOptions(); + GraphicsOptions returnedOption = context.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -48,8 +48,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnConfiguration() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new GraphicsOptions(); + Configuration config = new Configuration(); config.SetGraphicsOptions(option); @@ -59,11 +59,11 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() { - var option = new GraphicsOptions() + GraphicsOptions option = new GraphicsOptions() { BlendPercentage = 0.9f }; - var config = new Configuration(); + Configuration config = new Configuration(); config.SetGraphicsOptions(option); config.SetGraphicsOptions(o => @@ -72,7 +72,7 @@ public class GraphicOptionsDefaultsExtensionsTests o.BlendPercentage = 0.4f; }); - var returnedOption = config.GetGraphicsOptions(); + GraphicsOptions returnedOption = config.GetGraphicsOptions(); Assert.Equal(0.4f, returnedOption.BlendPercentage); Assert.Equal(0.9f, option.BlendPercentage); // hasn't been mutated } @@ -80,13 +80,13 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_SettingNullThenReturnsNewInstance() { - var config = new Configuration(); + Configuration config = new Configuration(); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); config.SetGraphicsOptions((GraphicsOptions)null); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.NotNull(options2); // we set it to null should now be a new instance @@ -96,10 +96,10 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); + Configuration config = new Configuration(); config.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } @@ -107,63 +107,63 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsInstance() { - var config = new Configuration(); + Configuration config = new Configuration(); Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys); - var options = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); } [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsSameValue() { - var config = new Configuration(); + Configuration config = new Configuration(); - var options = config.GetGraphicsOptions(); - var options2 = config.GetGraphicsOptions(); + GraphicsOptions options = config.GetGraphicsOptions(); + GraphicsOptions options2 = config.GetGraphicsOptions(); Assert.Equal(options, options2); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstanceEvenIfSetToNull() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); context.SetGraphicsOptions((GraphicsOptions)null); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance() { - var option = new GraphicsOptions(); - var config = new Configuration(); + GraphicsOptions option = new GraphicsOptions(); + Configuration config = new Configuration(); config.SetGraphicsOptions(option); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); - var ctxOptions = context.GetGraphicsOptions(); + GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.Equal(option, ctxOptions); } [Fact] public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry() { - var config = new Configuration(); - var context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new Configuration(); + FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); context.Properties[typeof(GraphicsOptions)] = "wronge type"; - var options = context.GetGraphicsOptions(); + GraphicsOptions options = context.GetGraphicsOptions(); Assert.NotNull(options); Assert.IsType(options); } diff --git a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs index 353159986..351254e40 100644 --- a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs @@ -57,7 +57,7 @@ public class GraphicsOptionsTests [Fact] public void NonDefaultClone() { - var expected = new GraphicsOptions + GraphicsOptions expected = new GraphicsOptions { AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop, Antialias = false, @@ -74,7 +74,7 @@ public class GraphicsOptionsTests [Fact] public void CloneIsDeep() { - var expected = new GraphicsOptions(); + GraphicsOptions expected = new GraphicsOptions(); GraphicsOptions actual = expected.DeepClone(); actual.AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop; diff --git a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs index 4c06d0cd5..1e6ab7bc9 100644 --- a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs @@ -15,7 +15,7 @@ public class ColorNumericsTests public void GetBT709Luminance_WithVector4(float x, float y, float z, int luminanceLevels, int expected) { // arrange - var vector = new Vector4(x, y, z, 0.0f); + Vector4 vector = new Vector4(x, y, z, 0.0f); // act int actual = ColorNumerics.GetBT709Luminance(ref vector, luminanceLevels); diff --git a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs index 75f988a4c..c40fffd55 100644 --- a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs @@ -162,7 +162,7 @@ public class NumericsTests [InlineData(63)] public void PremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new Random(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -182,7 +182,7 @@ public class NumericsTests [InlineData(63)] public void UnPremultiplyVectorSpan(int length) { - var rnd = new Random(42); + Random rnd = new Random(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -280,7 +280,7 @@ public class NumericsTests { Span actual = new T[length]; - var r = new Random(); + Random r = new Random(); for (int i = 0; i < length; i++) { actual[i] = (T)Convert.ChangeType(r.Next(byte.MinValue, byte.MaxValue), typeof(T)); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs index c13a30052..eadae9124 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs @@ -28,7 +28,7 @@ public class ParallelExecutionSettingsTests } else { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new ParallelExecutionSettings( maxDegreeOfParallelism, Configuration.Default.MemoryAllocator); Assert.Equal(maxDegreeOfParallelism, parallelSettings.MaxDegreeOfParallelism); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs index d393850d6..e5e6b18f8 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs @@ -26,7 +26,7 @@ public class ParallelRowIteratorTests /// maxDegreeOfParallelism, minY, maxY, expectedStepLength, expectedLastStepLength /// public static TheoryData IterateRows_OverMinimumPixelsLimit_Data = - new TheoryData + new() { { 1, 0, 100, -1, 100, 1 }, { 2, 0, 9, 5, 4, 2 }, @@ -52,12 +52,12 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -73,7 +73,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -93,15 +93,15 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows) { @@ -111,7 +111,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -131,12 +131,12 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int actualNumberOfSteps = 0; @@ -152,7 +152,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -172,15 +172,15 @@ public class ParallelRowIteratorTests int expectedLastStepLength, int expectedNumberOfSteps) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, 1, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, minY, 10, maxY - minY); + Rectangle rectangle = new(0, minY, 10, maxY - minY); int[] expectedData = Enumerable.Repeat(0, minY).Concat(Enumerable.Range(minY, maxY - minY)).ToArray(); - var actualData = new int[maxY]; + int[] actualData = new int[maxY]; void RowAction(RowInterval rows, Span buffer) { @@ -190,7 +190,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -201,7 +201,7 @@ public class ParallelRowIteratorTests } public static TheoryData IterateRows_WithEffectiveMinimumPixelsLimit_Data = - new TheoryData + new() { { 2, 200, 50, 2, 1, -1, 2 }, { 2, 200, 200, 1, 1, -1, 1 }, @@ -223,12 +223,12 @@ public class ParallelRowIteratorTests int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -244,7 +244,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rectangle, @@ -265,12 +265,12 @@ public class ParallelRowIteratorTests int expectedStepLength, int expectedLastStepLength) { - var parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, minimumPixelsProcessedPerTask, Configuration.Default.MemoryAllocator); - var rectangle = new Rectangle(0, 0, width, height); + Rectangle rectangle = new(0, 0, width, height); int actualNumberOfSteps = 0; @@ -286,7 +286,7 @@ public class ParallelRowIteratorTests Assert.Equal(expected, step); } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals, Vector4>( rectangle, @@ -297,7 +297,7 @@ public class ParallelRowIteratorTests } public static readonly TheoryData IterateRectangularBuffer_Data = - new TheoryData + new() { { 8, 582, 453, 10, 10, 291, 226 }, // boundary data from DetectEdgesTest.DetectEdges_InBox { 2, 582, 453, 10, 10, 291, 226 }, @@ -322,13 +322,13 @@ public class ParallelRowIteratorTests using (Buffer2D expected = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) using (Buffer2D actual = memoryAllocator.Allocate2D(bufferWidth, bufferHeight, AllocationOptions.Clean)) { - var rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); + Rectangle rect = new(rectX, rectY, rectWidth, rectHeight); void FillRow(int y, Buffer2D buffer) { for (int x = rect.Left; x < rect.Right; x++) { - buffer[x, y] = new Point(x, y); + buffer[x, y] = new(x, y); } } @@ -339,7 +339,7 @@ public class ParallelRowIteratorTests } // Fill actual data using IterateRows: - var settings = new ParallelExecutionSettings(maxDegreeOfParallelism, memoryAllocator); + ParallelExecutionSettings settings = new(maxDegreeOfParallelism, memoryAllocator); void RowAction(RowInterval rows) { @@ -350,7 +350,7 @@ public class ParallelRowIteratorTests } } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ParallelRowIterator.IterateRowIntervals( rect, @@ -369,15 +369,15 @@ public class ParallelRowIteratorTests [InlineData(10, -10)] public void IterateRowsRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals(rect, in parallelSettings, in operation)); @@ -392,15 +392,15 @@ public class ParallelRowIteratorTests [InlineData(10, -10)] public void IterateRowsWithTempBufferRequiresValidRectangle(int width, int height) { - var parallelSettings = default(ParallelExecutionSettings); + ParallelExecutionSettings parallelSettings = default(ParallelExecutionSettings); - var rect = new Rectangle(0, 0, width, height); + Rectangle rect = new(0, 0, width, height); void RowAction(RowInterval rows, Span memory) { } - var operation = new TestRowIntervalOperation(RowAction); + TestRowIntervalOperation operation = new(RowAction); ArgumentOutOfRangeException ex = Assert.Throws( () => ParallelRowIterator.IterateRowIntervals, Rgba32>(rect, in parallelSettings, in operation)); @@ -434,7 +434,7 @@ public class ParallelRowIteratorTests { } - public StrongBox MaxY { get; } = new StrongBox(); + public StrongBox MaxY { get; } = new(); public void Invoke(int y) { diff --git a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs index 95f1d4e28..cc367df30 100644 --- a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs +++ b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs @@ -10,7 +10,7 @@ public class RowIntervalTests [Fact] public void Slice1() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new RowInterval(10, 20); RowInterval sliced = rowInterval.Slice(5); Assert.Equal(15, sliced.Min); @@ -20,7 +20,7 @@ public class RowIntervalTests [Fact] public void Slice2() { - var rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new RowInterval(10, 20); RowInterval sliced = rowInterval.Slice(3, 5); Assert.Equal(13, sliced.Min); @@ -30,8 +30,8 @@ public class RowIntervalTests [Fact] public void Equality_WhenTrue() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 123); + RowInterval a = new RowInterval(42, 123); + RowInterval b = new RowInterval(42, 123); Assert.True(a.Equals(b)); Assert.True(a.Equals((object)b)); @@ -42,9 +42,9 @@ public class RowIntervalTests [Fact] public void Equality_WhenFalse() { - var a = new RowInterval(42, 123); - var b = new RowInterval(42, 125); - var c = new RowInterval(40, 123); + RowInterval a = new RowInterval(42, 123); + RowInterval b = new RowInterval(42, 125); + RowInterval c = new RowInterval(40, 123); Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 390170cfe..560d77e21 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -269,7 +269,7 @@ public class ChunkedMemoryStreamTests { ChunkedMemoryStream memoryStream; const string bufferSize = nameof(bufferSize); - using (memoryStream = new ChunkedMemoryStream(this.allocator)) + using (memoryStream = new(this.allocator)) { const string destination = nameof(destination); Assert.Throws(destination, () => memoryStream.CopyTo(destination: null)); @@ -293,7 +293,7 @@ public class ChunkedMemoryStreamTests Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); // Then for the destination being disposed. - memoryStream = new ChunkedMemoryStream(this.allocator); + memoryStream = new(this.allocator); Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); memoryStream.Dispose(); } diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 25674e6a8..409fd46b9 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -10,7 +10,7 @@ public class ImageCloneTests [Fact] public void CloneAs_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new Image(5, 5); image.Dispose(); Assert.Throws(() => image.CloneAs()); @@ -19,7 +19,7 @@ public class ImageCloneTests [Fact] public void Clone_WhenDisposed_Throws() { - var image = new Image(5, 5); + Image image = new Image(5, 5); image.Dispose(); Assert.Throws(() => image.Clone()); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs index 14c38d1f7..c3ed16dcd 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs @@ -14,10 +14,10 @@ public abstract partial class ImageFrameCollectionTests : IDisposable public ImageFrameCollectionTests() { // Needed to get English exception messages, which are checked in several tests. - System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); + System.Threading.Thread.CurrentThread.CurrentUICulture = new("en-US"); - this.Image = new Image(10, 10); - this.Collection = new ImageFrameCollection(this.Image, 10, 10, default(Rgba32)); + this.Image = new(10, 10); + this.Collection = new(this.Image, 10, 10, default(Rgba32)); } public void Dispose() diff --git a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs index ef5b5f4de..f3070311d 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs @@ -16,7 +16,7 @@ public class ImageFrameTests private void LimitBufferCapacity(int bufferCapacityInBytes) { - var allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new TestMemoryAllocator(); allocator.BufferCapacityInBytes = bufferCapacityInBytes; this.configuration.MemoryAllocator = allocator; } @@ -31,7 +31,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; Rgba32 val = frame[3, 4]; Assert.Equal(default(Rgba32), val); @@ -57,7 +57,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => _ = frame[x, 3]); Assert.Equal("x", ex.ParamName); @@ -72,7 +72,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[x, 3] = default); Assert.Equal("x", ex.ParamName); @@ -87,7 +87,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[3, y] = default); Assert.Equal("y", ex.ParamName); @@ -105,7 +105,7 @@ public class ImageFrameTests this.LimitBufferCapacity(20); } - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); if (disco) { Assert.True(image.GetPixelMemoryGroup().Count > 1); @@ -131,7 +131,7 @@ public class ImageFrameTests [InlineData(true)] public void CopyPixelDataTo_DestinationTooShort_Throws(bool byteSpan) { - using var image = new Image(this.configuration, 10, 10); + using Image image = new Image(this.configuration, 10, 10); Assert.ThrowsAny(() => { @@ -173,7 +173,7 @@ public class ImageFrameTests [Fact] public void NullReference_Throws() { - using var img = new Image(1, 1); + using Image img = new Image(1, 1); ImageFrame frame = img.Frames.RootFrame; Assert.Throws(() => frame.ProcessPixelRows(null)); diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index e7d3b548b..e9bdd5128 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -12,14 +12,14 @@ public class ImageRotationTests public void RotateImageByMinus90Degrees() { (Size original, Size rotated) = Rotate(-90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] public void RotateImageBy90Degrees() { (Size original, Size rotated) = Rotate(90); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] @@ -33,7 +33,7 @@ public class ImageRotationTests public void RotateImageBy270Degrees() { (Size original, Size rotated) = Rotate(270); - Assert.Equal(new Size(original.Height, original.Width), rotated); + Assert.Equal(new(original.Height, original.Width), rotated); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index f9c01ab56..c92383ca8 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -23,22 +23,22 @@ public class ImageSaveTests : IDisposable public ImageSaveTests() { - this.localImageFormat = new Mock(); + this.localImageFormat = new(); this.localImageFormat.Setup(x => x.FileExtensions).Returns(new[] { "png" }); this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormat.Object); - this.encoder = new Mock(); + this.encoder = new(); - this.encoderNotInFormat = new Mock(); + this.encoderNotInFormat = new(); - this.fileSystem = new Mock(); - var config = new Configuration + this.fileSystem = new(); + Configuration config = new() { FileSystem = this.fileSystem.Object }; config.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); config.ImageFormatsManager.SetEncoder(this.localImageFormat.Object, this.encoder.Object); - this.image = new Image(config, 1, 1); + this.image = new(config, 1, 1); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs index f3b1a01c9..88e2b86ed 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs @@ -15,7 +15,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsBmpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsBmpAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -23,7 +23,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsCurAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsCurAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -31,7 +31,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -41,7 +41,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -49,7 +49,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsIcoAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsIcoAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -57,7 +57,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsJpegAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsJpegAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -65,7 +65,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPbmAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPbmAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -73,7 +73,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -83,7 +83,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -91,7 +91,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsQoiAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsQoiAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -99,7 +99,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTgaAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsTgaAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -107,7 +107,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTiffAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsTiffAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -115,7 +115,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); } [Fact] @@ -125,7 +125,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); } } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index 51e2a01a2..ae48fde39 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs @@ -35,7 +35,7 @@ public partial class ImageTests public Configuration LocalConfiguration { get; } - public TestFormat TestFormat { get; } = new TestFormat(); + public TestFormat TestFormat { get; } = new(); /// /// Gets the top-level configuration in the context of this test case. @@ -56,13 +56,13 @@ public partial class ImageTests protected ImageLoadTestBase() { // TODO: Remove all this mocking. It's too complicated and we can now use fakes. - this.localStreamReturnImageRgba32 = new Image(1, 1); - this.localStreamReturnImageAgnostic = new Image(1, 1); - this.LocalImageInfo = new(new(1, 1), new ImageMetadata() { DecodedImageFormat = PngFormat.Instance }); + this.localStreamReturnImageRgba32 = new(1, 1); + this.localStreamReturnImageAgnostic = new(1, 1); + this.LocalImageInfo = new(new(1, 1), new() { DecodedImageFormat = PngFormat.Instance }); - this.localImageFormatMock = new Mock(); + this.localImageFormatMock = new(); - this.localDecoder = new Mock(); + this.localDecoder = new(); this.localDecoder.Setup(x => x.Identify(It.IsAny(), It.IsAny())) .Returns(this.LocalImageInfo); @@ -111,15 +111,15 @@ public partial class ImageTests this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object); - this.LocalConfiguration = new Configuration(); + this.LocalConfiguration = new(); this.LocalConfiguration.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); this.LocalConfiguration.ImageFormatsManager.SetDecoder(this.localImageFormatMock.Object, this.localDecoder.Object); - this.TopLevelConfiguration = new Configuration(this.TestFormat); + this.TopLevelConfiguration = new(this.TestFormat); this.Marker = Guid.NewGuid().ToByteArray(); - this.dataStreamLazy = new Lazy(this.CreateStream); + this.dataStreamLazy = new(this.CreateStream); Stream StreamFactory() => this.DataStream; this.LocalFileSystemMock.Setup(x => x.OpenRead(this.MockFilePath)).Returns(StreamFactory); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index 3e488be9a..8c110d143 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private string Path { get; } = TestFile.GetInputFileFullPath(TestImages.Bmp.Bit8); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Path_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index 00ec985ac..80a407a35 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -14,7 +14,7 @@ public partial class ImageTests private static Span ByteSpan => new(ByteArray); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); [Fact] public void Bytes_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs index 7a5bd186b..c16a50b43 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs @@ -21,12 +21,12 @@ public partial class ImageTests public Load_FromStream_UseDefaultConfiguration() { - this.BaseStream = new MemoryStream(Data); - this.Stream = new AsyncStreamWrapper(this.BaseStream, () => this.AllowSynchronousIO); + this.BaseStream = new(Data); + this.Stream = new(this.BaseStream, () => this.AllowSynchronousIO); } private static void VerifyDecodedImage(Image img) - => Assert.Equal(new Size(127, 64), img.Size); + => Assert.Equal(new(127, 64), img.Size); [Fact] public void Stream_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index e3c4a7df1..d38ed749a 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -39,7 +39,7 @@ public partial class ImageTests } this.bitmap = bitmap; - var rectangle = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height); + System.Drawing.Rectangle rectangle = new(0, 0, bitmap.Width, bitmap.Height); this.bmpData = bitmap.LockBits(rectangle, ImageLockMode.ReadWrite, bitmap.PixelFormat); this.length = bitmap.Width * bitmap.Height; } @@ -64,13 +64,13 @@ public partial class ImageTests public override unsafe Span GetSpan() { void* ptr = (void*)this.bmpData.Scan0; - return new Span(ptr, this.length); + return new(ptr, this.length); } public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* ptr = (void*)this.bmpData.Scan0; - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() @@ -124,13 +124,13 @@ public partial class ImageTests [Fact] public void WrapMemory_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[25]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[25]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -149,22 +149,22 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory memory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memory, bmp.Width, bmp.Height)) { Assert.Equal(memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -195,19 +195,19 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - var memoryManager = new BitmapMemoryManager(bmp); + BitmapMemoryManager memoryManager = new(bmp); Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height)) { Assert.Equal(memoryManager.Memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory()); image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -227,13 +227,13 @@ public partial class ImageTests [Fact] public void WrapMemory_FromBytes_CreatedImageIsCorrect() { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new byte[25 * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[25 * Unsafe.SizeOf()]; + Memory memory = new(array); - using (var image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) + using (Image image = Image.WrapMemory(cfg, memory, 5, 5, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); ref Rgba32 pixel0 = ref imageMem.Span[0]; @@ -252,16 +252,16 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Memory byteMemory = new CastMemoryManager(pixelMemory).Memory; Bgra32 bg = Color.Red.ToPixel(); Bgra32 fg = Color.Green.ToPixel(); - using (var image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -276,7 +276,7 @@ public partial class ImageTests image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -300,16 +300,16 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public unsafe void WrapMemory_Throws_OnTooLessWrongSize(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; Exception thrownException = null; fixed (void* ptr = array) { try { - using var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); + using Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData); } catch (Exception e) { @@ -328,14 +328,14 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public unsafe void WrapMemory_FromPointer_CreatedImageIsCorrect(int size, int width, int height) { - var cfg = Configuration.CreateDefaultInstance(); - var metaData = new ImageMetadata(); + Configuration cfg = Configuration.CreateDefaultInstance(); + ImageMetadata metaData = new(); - var array = new Rgba32[size]; + Rgba32[] array = new Rgba32[size]; fixed (void* ptr = array) { - using (var image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) + using (Image image = Image.WrapMemory(cfg, ptr, size * sizeof(Rgba32), width, height, metaData)) { Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory imageMem)); Span imageSpan = imageMem.Span; @@ -359,9 +359,9 @@ public partial class ImageTests return; } - using (var bmp = new Bitmap(51, 23)) + using (Bitmap bmp = new(51, 23)) { - using (var memoryManager = new BitmapMemoryManager(bmp)) + using (BitmapMemoryManager memoryManager = new(bmp)) { Memory pixelMemory = memoryManager.Memory; Bgra32 bg = Color.Red.ToPixel(); @@ -369,7 +369,7 @@ public partial class ImageTests fixed (void* p = pixelMemory.Span) { - using (var image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) + using (Image image = Image.WrapMemory(p, pixelMemory.Length, bmp.Width, bmp.Height)) { Span pixelSpan = pixelMemory.Span; Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span; @@ -381,7 +381,7 @@ public partial class ImageTests image.GetPixelMemoryGroup().Fill(bg); image.ProcessPixelRows(accessor => { - for (var i = 10; i < 20; i++) + for (int i = 10; i < 20; i++) { accessor.GetRowSpan(i).Slice(10, 10).Fill(fg); } @@ -407,8 +407,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -421,8 +421,8 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new Memory(array); + Rgba32[] array = new Rgba32[size]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } @@ -443,8 +443,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfT_InvalidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -457,10 +457,10 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfT_ValidSize(int size, int height, int width) { - var array = new Rgba32[size]; - var memory = new TestMemoryOwner { Memory = array }; + Rgba32[] array = new Rgba32[size]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -469,7 +469,7 @@ public partial class ImageTests { for (int i = 0; i < height; ++i) { - var arrayIndex = width * i; + int arrayIndex = width * i; Span rowSpan = accessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -490,8 +490,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_IMemoryOwnerOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new TestMemoryOwner { Memory = array }; + byte[] array = new byte[size * Unsafe.SizeOf()]; + TestMemoryOwner memory = new() { Memory = array }; Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -504,11 +504,11 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_IMemoryOwnerOfByte_ValidSize(int size, int height, int width) { - var pixelSize = Unsafe.SizeOf(); - var array = new byte[size * pixelSize]; - var memory = new TestMemoryOwner { Memory = array }; + int pixelSize = Unsafe.SizeOf(); + byte[] array = new byte[size * pixelSize]; + TestMemoryOwner memory = new() { Memory = array }; - using (var img = Image.WrapMemory(memory, width, height)) + using (Image img = Image.WrapMemory(memory, width, height)) { Assert.Equal(width, img.Width); Assert.Equal(height, img.Height); @@ -517,7 +517,7 @@ public partial class ImageTests { for (int i = 0; i < height; ++i) { - var arrayIndex = pixelSize * width * i; + int arrayIndex = pixelSize * width * i; Span rowSpan = acccessor.GetRowSpan(i); ref Rgba32 r0 = ref rowSpan[0]; @@ -538,8 +538,8 @@ public partial class ImageTests [InlineData(65536, 65537, 65536)] public void WrapMemory_MemoryOfByte_InvalidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Assert.Throws(() => Image.WrapMemory(memory, height, width)); } @@ -552,8 +552,8 @@ public partial class ImageTests [InlineData(2048, 32, 32)] public void WrapMemory_MemoryOfByte_ValidSize(int size, int height, int width) { - var array = new byte[size * Unsafe.SizeOf()]; - var memory = new Memory(array); + byte[] array = new byte[size * Unsafe.SizeOf()]; + Memory memory = new(array); Image.WrapMemory(memory, height, width); } diff --git a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs index 12caa6e7a..ffb89923a 100644 --- a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs +++ b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs @@ -31,7 +31,7 @@ public class LargeImageIntegrationTests Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - using var image = new Image(configuration, 2048, 2048); + using Image image = new Image(configuration, 2048, 2048); Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory mem)); Assert.Equal(2048 * 2048, mem.Length); } @@ -69,7 +69,7 @@ public class LargeImageIntegrationTests Configuration = configuration }; - using var image = Image.Load(options, path); + using Image image = Image.Load(options, path); File.Delete(path); Assert.Equal(1, image.GetPixelMemoryGroup().Count); } diff --git a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs index 27cbe1a7e..1a6d563c8 100644 --- a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs @@ -32,7 +32,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void PixelAccessorDimensionsAreCorrect() { - using var image = new Image(123, 456); + using Image image = new(123, 456); this.ProcessPixelRowsImpl(image, accessor => { Assert.Equal(123, accessor.Width); @@ -43,7 +43,7 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_SingleImage() { - using var image = new Image(256, 256); + using Image image = new(256, 256); this.ProcessPixelRowsImpl(image, accessor => { for (int y = 0; y < accessor.Height; y++) @@ -51,7 +51,7 @@ public abstract class ProcessPixelRowsTestBase Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } }); @@ -71,18 +71,18 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_MultiImage2() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span row = buffer.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - using var img2 = new Image(256, 256); + using Image img2 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, (accessor1, accessor2) => { @@ -109,19 +109,19 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void WriteImagePixels_MultiImage3() { - using var img1 = new Image(256, 256); + using Image img1 = new(256, 256); Buffer2D buffer2 = img1.Frames.RootFrame.PixelBuffer; for (int y = 0; y < 256; y++) { Span row = buffer2.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new L16((ushort)(x * y)); + row[x] = new((ushort)(x * y)); } } - using var img2 = new Image(256, 256); - using var img3 = new Image(256, 256); + using Image img2 = new(256, 256); + using Image img3 = new(256, 256); this.ProcessPixelRowsImpl(img1, img2, img3, (accessor1, accessor2, accessor3) => { @@ -154,8 +154,8 @@ public abstract class ProcessPixelRowsTestBase [Fact] public void Disposed_ThrowsObjectDisposedException() { - using var nonDisposed = new Image(1, 1); - var disposed = new Image(1, 1); + using Image nonDisposed = new(1, 1); + Image disposed = new(1, 1); disposed.Dispose(); Assert.Throws(() => this.ProcessPixelRowsImpl(disposed, _ => { })); @@ -178,11 +178,11 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer); Configuration.Default.MemoryAllocator = allocator; - var image = new Image(10, 10); + Image image = new(10, 10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -215,13 +215,13 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); Assert.Equal(2, UnmanagedMemoryHandle.TotalOutstandingHandles); try @@ -255,15 +255,15 @@ public abstract class ProcessPixelRowsTestBase static void RunTest(string testTypeName, string throwExceptionStr) { bool throwExceptionInner = bool.Parse(throwExceptionStr); - var buffer1 = UnmanagedBuffer.Allocate(100); - var buffer2 = UnmanagedBuffer.Allocate(100); - var buffer3 = UnmanagedBuffer.Allocate(100); - var allocator = new MockUnmanagedMemoryAllocator(buffer1, buffer2, buffer3); + UnmanagedBuffer buffer1 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer2 = UnmanagedBuffer.Allocate(100); + UnmanagedBuffer buffer3 = UnmanagedBuffer.Allocate(100); + MockUnmanagedMemoryAllocator allocator = new(buffer1, buffer2, buffer3); Configuration.Default.MemoryAllocator = allocator; - var image1 = new Image(10, 10); - var image2 = new Image(10, 10); - var image3 = new Image(10, 10); + Image image1 = new(10, 10); + Image image2 = new(10, 10); + Image image3 = new(10, 10); Assert.Equal(3, UnmanagedMemoryHandle.TotalOutstandingHandles); try diff --git a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs index 33950c469..6b9907ef5 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs @@ -172,7 +172,7 @@ public abstract class BufferTestSuite { using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { - var expectedVals = new T[buffer.Length()]; + T[] expectedVals = new T[buffer.Length()]; for (int i = 0; i < buffer.Length(); i++) { @@ -213,7 +213,7 @@ public abstract class BufferTestSuite private T TestIndexOutOfRangeShouldThrow(int desiredLength) where T : struct, IEquatable { - var dummy = default(T); + T dummy = default(T); using (IMemoryOwner buffer = this.MemoryAllocator.Allocate(desiredLength)) { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs index 517eda707..ac03863fd 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs @@ -14,7 +14,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void Dispose_ResultsInSingleRelease(int disposeCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new MockLifetimeGuard(); Assert.Equal(0, guard.ReleaseInvocationCount); for (int i = 0; i < disposeCount; i++) @@ -45,7 +45,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void AddRef_PreventsReleaseOnDispose(int addRefCount) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new MockLifetimeGuard(); for (int i = 0; i < addRefCount; i++) { @@ -80,7 +80,7 @@ public class RefCountedLifetimeGuardTests [Fact] public void AddRefReleaseRefMisuse_DoesntLeadToMultipleReleases() { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new MockLifetimeGuard(); guard.Dispose(); guard.AddRef(); guard.ReleaseRef(); @@ -91,8 +91,8 @@ public class RefCountedLifetimeGuardTests [Fact] public void UnmanagedBufferLifetimeGuard_Handle_IsReturnedByRef() { - var h = UnmanagedMemoryHandle.Allocate(10); - using var guard = new UnmanagedBufferLifetimeGuard.FreeHandle(h); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(10); + using UnmanagedBufferLifetimeGuard.FreeHandle guard = new UnmanagedBufferLifetimeGuard.FreeHandle(h); Assert.True(guard.Handle.IsValid); guard.Handle.Free(); Assert.False(guard.Handle.IsValid); @@ -101,7 +101,7 @@ public class RefCountedLifetimeGuardTests [MethodImpl(MethodImplOptions.NoInlining)] private static void LeakGuard(bool addRef) { - var guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new MockLifetimeGuard(); if (addRef) { guard.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs index a956190cd..51552be7d 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs @@ -16,7 +16,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - using (var buffer = new SharedArrayPoolBuffer(900)) + using (SharedArrayPoolBuffer buffer = new SharedArrayPoolBuffer(900)) { Assert.Equal(900, buffer.GetSpan().Length); buffer.GetSpan().Fill(42); @@ -36,7 +36,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - var buffer = new SharedArrayPoolBuffer(900); + SharedArrayPoolBuffer buffer = new SharedArrayPoolBuffer(900); Span span = buffer.GetSpan(); buffer.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index fd8b6af59..c5820c27f 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -24,8 +24,8 @@ public partial class UniformUnmanagedMemoryPoolTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; - var pool = new UniformUnmanagedMemoryPool(128, 256, trimSettings); + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, 256, trimSettings); UnmanagedMemoryHandle[] a = pool.Rent(64); UnmanagedMemoryHandle[] b = pool.Rent(64); @@ -77,11 +77,11 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var trimSettings1 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; - var pool1 = new UniformUnmanagedMemoryPool(128, 256, trimSettings1); + UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool pool1 = new UniformUnmanagedMemoryPool(128, 256, trimSettings1); Thread.Sleep(8_000); // Let some callbacks fire already - var trimSettings2 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; - var pool2 = new UniformUnmanagedMemoryPool(128, 256, trimSettings2); + UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool pool2 = new UniformUnmanagedMemoryPool(128, 256, trimSettings2); pool1.Return(pool1.Rent(64)); pool2.Return(pool2.Rent(64)); @@ -104,7 +104,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance() { - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 4_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 4_000 }; _ = new UniformUnmanagedMemoryPool(128, 256, trimSettings); } } @@ -129,13 +129,13 @@ public partial class UniformUnmanagedMemoryPoolTests Assert.False(Environment.Is64BitProcess); const int oneMb = 1 << 20; - var trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { HighPressureThresholdRate = 0.2f }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { HighPressureThresholdRate = 0.2f }; GCMemoryInfo memInfo = GC.GetGCMemoryInfo(); int highLoadThreshold = (int)(memInfo.HighMemoryLoadThresholdBytes / oneMb); highLoadThreshold = (int)(trimSettings.HighPressureThresholdRate * highLoadThreshold); - var pool = new UniformUnmanagedMemoryPool(oneMb, 16, trimSettings); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(oneMb, 16, trimSettings); pool.Return(pool.Rent(16)); Assert.Equal(16, UnmanagedMemoryHandle.TotalOutstandingHandles); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs index 69fc1a5f7..c0c7f5c22 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs @@ -55,7 +55,7 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(7, 4)] public void Constructor_InitializesProperties(int arrayLength, int capacity) { - var pool = new UniformUnmanagedMemoryPool(arrayLength, capacity); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(arrayLength, capacity); Assert.Equal(arrayLength, pool.BufferLength); Assert.Equal(capacity, pool.Capacity); } @@ -65,8 +65,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(8, 10)] public void Rent_SingleBuffer_ReturnsCorrectBuffer(int length, int capacity) { - var pool = new UniformUnmanagedMemoryPool(length, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(length, capacity); + using CleanupUtil cleanup = new CleanupUtil(pool); for (int i = 0; i < capacity; i++) { @@ -83,7 +83,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); @@ -114,8 +114,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(5, 10)] public void Rent_MultiBuffer_ReturnsCorrectBuffers(int length, int bufferCount) { - var pool = new UniformUnmanagedMemoryPool(length, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(length, 10); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle[] handles = pool.Rent(bufferCount); cleanup.Register(handles); @@ -131,8 +131,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_MultipleTimesWithoutReturn_ReturnsDifferentHandles() { - var pool = new UniformUnmanagedMemoryPool(128, 10); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, 10); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle[] a = pool.Rent(2); cleanup.Register(a); UnmanagedMemoryHandle b = pool.Rent(); @@ -149,10 +149,10 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(12, 4, 12)] public void RentReturnRent_SameBuffers(int totalCount, int rentUnit, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); - var allHandles = new HashSet(); - var handleUnits = new List(); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(pool); + HashSet allHandles = new HashSet(); + List handleUnits = new List(); UnmanagedMemoryHandle[] handles; for (int i = 0; i < totalCount; i += rentUnit) @@ -197,8 +197,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() { - var pool = new UniformUnmanagedMemoryPool(7, 1000); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(7, 1000); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle[] initial = pool.Rent(1000); Assert.NotNull(initial); cleanup.Register(initial); @@ -212,8 +212,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(4, 7, 10)] public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle[] initial = pool.Rent(initialRent); Assert.NotNull(initial); cleanup.Register(initial); @@ -228,8 +228,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(3, 3, 7)] public void Rent_MultiBuff_BelowCapacity_Succeeds(int initialRent, int attempt, int capacity) { - var pool = new UniformUnmanagedMemoryPool(128, capacity); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle[] b0 = pool.Rent(initialRent); Assert.NotNull(b0); cleanup.Register(b0); @@ -250,8 +250,8 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest(string multipleInner) { - var pool = new UniformUnmanagedMemoryPool(16, 16); - using var cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); + using CleanupUtil cleanup = new CleanupUtil(pool); UnmanagedMemoryHandle b0 = pool.Rent(); IntPtr h0 = b0.Handle; UnmanagedMemoryHandle b1 = pool.Rent(); @@ -290,7 +290,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - var pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); pool.Return(a); @@ -306,13 +306,13 @@ public partial class UniformUnmanagedMemoryPoolTests public void RentReturn_IsThreadSafe() { int count = Environment.ProcessorCount * 200; - var pool = new UniformUnmanagedMemoryPool(8, count); - using var cleanup = new CleanupUtil(pool); - var rnd = new Random(0); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(8, count); + using CleanupUtil cleanup = new CleanupUtil(pool); + Random rnd = new Random(0); Parallel.For(0, Environment.ProcessorCount, (int i) => { - var allHandles = new List(); + List allHandles = new List(); int pauseAt = rnd.Next(100); for (int j = 0; j < 100; j++) { @@ -359,7 +359,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance(bool withGuardedBuffers) { - var pool = new UniformUnmanagedMemoryPool(16, 128); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 128); if (withGuardedBuffers) { UnmanagedMemoryHandle h = pool.Rent(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index aa34a5c10..e0f129a65 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -44,7 +44,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests } public static TheoryData AllocateData = - new TheoryData() + new() { { default(S4), 16, 256, 256, 1024, 64, 64, 1, -1, 64 }, { default(S4), 16, 256, 256, 1024, 256, 256, 1, -1, 256 }, @@ -69,7 +69,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests int expectedSizeOfLastBuffer) where T : struct { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedArrayPoolThresholdInBytes, maxContiguousPoolBufferInBytes, maxPoolSizeInBytes, @@ -86,13 +86,13 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_MultipleTimes_ExceedPoolLimit() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( 64, 128, 1024, 1024); - var groups = new List>(); + List> groups = new(); for (int i = 0; i < 16; i++) { int lengthInElements = 128 / Unsafe.SizeOf(); @@ -110,7 +110,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_SizeInBytesOverLongMaxValue_ThrowsInvalidMemoryOperationException() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); Assert.Throws(() => allocator.AllocateGroup(int.MaxValue * (long)int.MaxValue, int.MaxValue)); } @@ -128,7 +128,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public unsafe void Allocate_MemoryIsPinnableMultipleTimes() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(null); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(null); using IMemoryOwner memoryOwner = allocator.Allocate(100); using (MemoryHandle pin = memoryOwner.Memory.Pin()) @@ -149,7 +149,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { - var allocator = MemoryAllocator.Create(); + MemoryAllocator allocator = MemoryAllocator.Create(); long sixteenMegabytes = 16 * (1 << 20); // Should allocate 4 times 4MB discontiguos blocks: @@ -165,7 +165,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { - var allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { MaximumPoolSizeMegabytes = 8 }); @@ -205,7 +205,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); IMemoryOwner buffer0 = allocator.Allocate(bool.Parse(sharedStr) ? 300 : 600); buffer0.GetSpan()[0] = 42; buffer0.Dispose(); @@ -223,7 +223,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string sharedStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); MemoryGroup g0 = allocator.AllocateGroup(bool.Parse(sharedStr) ? 300 : 600, 100); g0.Single().Span[0] = 42; g0.Dispose(); @@ -238,7 +238,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); MemoryGroup g = allocator.AllocateGroup(2048, 128); g.Dispose(); Assert.Equal(4, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -253,7 +253,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(128, 512, 16 * 512, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(128, 512, 16 * 512, 1024); IMemoryOwner b = allocator.Allocate(256); MemoryGroup g = allocator.AllocateGroup(2048, 128); Assert.Equal(5, UnmanagedMemoryHandle.TotalOutstandingHandles); @@ -297,7 +297,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateGroupAndForget(allocator, lengthInner); @@ -365,7 +365,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest(string lengthStr) { - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator(512, 1024, 16 * 1024, 1024); + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); int lengthInner = int.Parse(lengthStr); AllocateSingleAndForget(allocator, lengthInner); @@ -422,7 +422,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = 4 }); @@ -434,7 +434,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = 4 }); @@ -450,7 +450,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { const long threeGB = 3L * (1 << 30); - MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions() + MemoryAllocator allocator = MemoryAllocator.Create(new() { AllocationLimitMegabytes = (int)(threeGB / 1024) }); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs index d0a5cfa9a..1e4795bc8 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs @@ -21,7 +21,7 @@ public class UnmanagedBufferTests [Fact] public void Allocate_CreatesValidBuffer() { - using var buffer = UnmanagedBuffer.Allocate(10); + using UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Span span = buffer.GetSpan(); Assert.Equal(10, span.Length); span[9] = 123; @@ -35,7 +35,7 @@ public class UnmanagedBufferTests static void RunTest() { - var buffer = UnmanagedBuffer.Allocate(10); + UnmanagedBuffer buffer = UnmanagedBuffer.Allocate(10); Assert.Equal(1, UnmanagedMemoryHandle.TotalOutstandingHandles); Span span = buffer.GetSpan(); @@ -76,10 +76,10 @@ public class UnmanagedBufferTests static List> FillList(int countInner) { - var l = new List>(); + List> l = new List>(); for (int i = 0; i < countInner; i++) { - var h = UnmanagedBuffer.Allocate(42); + UnmanagedBuffer h = UnmanagedBuffer.Allocate(42); l.Add(h); } diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs index 7a0736b54..ef3af71f4 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs @@ -11,7 +11,7 @@ public class UnmanagedMemoryHandleTests [Fact] public unsafe void Allocate_AllocatesReadWriteMemory() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); Assert.False(h.IsInvalid); Assert.True(h.IsValid); byte* ptr = (byte*)h.Handle; @@ -31,7 +31,7 @@ public class UnmanagedMemoryHandleTests [Fact] public void Free_ClosesHandle() { - var h = UnmanagedMemoryHandle.Allocate(128); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(128); h.Free(); Assert.True(h.IsInvalid); Assert.Equal(IntPtr.Zero, h.Handle); @@ -47,11 +47,11 @@ public class UnmanagedMemoryHandleTests static void RunTest(string countStr) { int countInner = int.Parse(countStr); - var l = new List(); + List l = new List(); for (int i = 0; i < countInner; i++) { Assert.Equal(i, UnmanagedMemoryHandle.TotalOutstandingHandles); - var h = UnmanagedMemoryHandle.Allocate(42); + UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(42); Assert.Equal(i + 1, UnmanagedMemoryHandle.TotalOutstandingHandles); l.Add(h); } @@ -68,7 +68,7 @@ public class UnmanagedMemoryHandleTests [Fact] public void Equality_WhenTrue() { - var h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); UnmanagedMemoryHandle h2 = h1; Assert.True(h1.Equals(h2)); @@ -82,8 +82,8 @@ public class UnmanagedMemoryHandleTests [Fact] public void Equality_WhenFalse() { - var h1 = UnmanagedMemoryHandle.Allocate(10); - var h2 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h1 = UnmanagedMemoryHandle.Allocate(10); + UnmanagedMemoryHandle h2 = UnmanagedMemoryHandle.Allocate(10); Assert.False(h1.Equals(h2)); Assert.False(h2.Equals(h1)); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs index 88c05fdd0..578ffc480 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs @@ -10,7 +10,7 @@ public partial class Buffer2DTests { public class SwapOrCopyContent { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void SwapOrCopyContent_WhenBothAllocated() @@ -29,8 +29,8 @@ public partial class Buffer2DTests Assert.Equal(bb, a.FastMemoryGroup.Single()); Assert.Equal(aa, b.FastMemoryGroup.Single()); - Assert.Equal(new Size(3, 7), a.Size()); - Assert.Equal(new Size(10, 5), b.Size()); + Assert.Equal(new(3, 7), a.Size()); + Assert.Equal(new(10, 5), b.Size()); Assert.Equal(666, b[1, 3]); Assert.Equal(444, a[1, 3]); @@ -40,8 +40,8 @@ public partial class Buffer2DTests [Fact] public void SwapOrCopyContent_WhenDestinationIsOwned_ShouldNotSwapInDisposedSourceBuffer() { - using var destData = MemoryGroup.Wrap(new int[100]); - using var dest = new Buffer2D(destData, 10, 10); + using MemoryGroup destData = MemoryGroup.Wrap(new int[100]); + using Buffer2D dest = new(destData, 10, 10); using (Buffer2D source = this.memoryAllocator.Allocate2D(10, 10, AllocationOptions.Clean)) { @@ -112,11 +112,11 @@ public partial class Buffer2DTests [InlineData(true)] public void WhenDestIsNotAllocated_SameSize_ShouldCopy(bool sourceIsAllocated) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(21, 1); @@ -136,11 +136,11 @@ public partial class Buffer2DTests [InlineData(true)] public void WhenDestIsNotMemoryOwner_DifferentSize_Throws(bool sourceIsOwner) { - var data = new Rgba32[21]; - var color = new Rgba32(1, 2, 3, 4); + Rgba32[] data = new Rgba32[21]; + Rgba32 color = new(1, 2, 3, 4); - using var destOwner = new TestMemoryManager(data); - using var dest = new Buffer2D(MemoryGroup.Wrap(destOwner.Memory), 21, 1); + using TestMemoryManager destOwner = new(data); + using Buffer2D dest = new(MemoryGroup.Wrap(destOwner.Memory), 21, 1); using Buffer2D source = this.memoryAllocator.Allocate2D(22, 1); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index 8ba3bf70a..a5c2eea2d 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -24,7 +24,7 @@ public partial class Buffer2DTests } } - private TestMemoryAllocator MemoryAllocator { get; } = new TestMemoryAllocator(); + private TestMemoryAllocator MemoryAllocator { get; } = new(); private const int Big = 99999; @@ -72,7 +72,7 @@ public partial class Buffer2DTests using Buffer2D buffer = useSizeOverload ? this.MemoryAllocator.Allocate2D( - new Size(200, 200), + new(200, 200), preferContiguosImageBuffers: true) : this.MemoryAllocator.Allocate2D( 200, @@ -147,7 +147,7 @@ public partial class Buffer2DTests const int unpooledBufferSize = 8_000; int elementSize = sizeof(TestStructs.Foo); - var allocator = new UniformUnmanagedMemoryPoolMemoryAllocator( + UniformUnmanagedMemoryPoolMemoryAllocator allocator = new( sharedPoolThreshold * elementSize, poolBufferSize * elementSize, maxPoolSize * elementSize, @@ -155,7 +155,7 @@ public partial class Buffer2DTests using Buffer2D buffer = allocator.Allocate2D(width, height); - var rnd = new Random(42); + Random rnd = new(42); for (int y = 0; y < buffer.Height; y++) { @@ -169,7 +169,7 @@ public partial class Buffer2DTests } // Re-seed - rnd = new Random(42); + rnd = new(42); for (int y = 0; y < buffer.Height; y++) { Span span = buffer.GetSafeRowMemory(y).Span; @@ -208,7 +208,7 @@ public partial class Buffer2DTests } } - public static TheoryData GetRowSpanY_OutOfRange_Data = new TheoryData() + public static TheoryData GetRowSpanY_OutOfRange_Data = new() { { Big, 10, 8, -1 }, { Big, 10, 8, 8 }, @@ -227,7 +227,7 @@ public partial class Buffer2DTests Assert.True(ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException); } - public static TheoryData Indexer_OutOfRange_Data = new TheoryData() + public static TheoryData Indexer_OutOfRange_Data = new() { { Big, 10, 8, 1, -1 }, { Big, 10, 8, 1, 8 }, @@ -284,7 +284,7 @@ public partial class Buffer2DTests [InlineData(5, 1, 1, 3, 2)] public void CopyColumns(int width, int height, int startIndex, int destIndex, int columnCount) { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(width, height)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -306,7 +306,7 @@ public partial class Buffer2DTests [Fact] public void CopyColumns_InvokeMultipleTimes() { - var rnd = new Random(123); + Random rnd = new(123); using (Buffer2D b = this.MemoryAllocator.Allocate2D(100, 100)) { rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1); @@ -354,7 +354,7 @@ public partial class Buffer2DTests [Theory] [MemberData(nameof(InvalidLengths))] public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationException_Size(Size size) - => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new Size(size))); + => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new(size))); [Theory] [MemberData(nameof(InvalidLengths))] diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index 46907b9c0..cb89f6cf6 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -13,8 +13,8 @@ public class BufferAreaTests public void Construct() { using Buffer2D buffer = this.memoryAllocator.Allocate2D(10, 20); - var rectangle = new Rectangle(3, 2, 5, 6); - var area = new Buffer2DRegion(buffer, rectangle); + Rectangle rectangle = new Rectangle(3, 2, 5, 6); + Buffer2DRegion area = new Buffer2DRegion(buffer, rectangle); Assert.Equal(buffer, area.Buffer); Assert.Equal(rectangle, area.Rectangle); @@ -43,7 +43,7 @@ public class BufferAreaTests { this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, 5, 6); + Rectangle r = new Rectangle(rx, ry, 5, 6); Buffer2DRegion region = buffer.GetRegion(r); @@ -62,7 +62,7 @@ public class BufferAreaTests this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - var r = new Rectangle(rx, ry, w, h); + Rectangle r = new Rectangle(rx, ry, w, h); Buffer2DRegion region = buffer.GetRegion(r); @@ -87,7 +87,7 @@ public class BufferAreaTests Buffer2DRegion area1 = area0.GetSubRegion(4, 4, 5, 5); - var expectedRect = new Rectangle(10, 12, 5, 5); + Rectangle expectedRect = new Rectangle(10, 12, 5, 5); Assert.Equal(buffer, area1.Buffer); Assert.Equal(expectedRect, area1.Rectangle); @@ -120,7 +120,7 @@ public class BufferAreaTests this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(22, 13); - var emptyRow = new int[22]; + int[] emptyRow = new int[22]; buffer.GetRegion().Clear(); for (int y = 0; y < 13; y++) diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs index 878084674..ea98357cb 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs @@ -27,7 +27,7 @@ public struct MemoryGroupIndex : IEquatable public static MemoryGroupIndex operator +(MemoryGroupIndex idx, int val) { int nextElementIndex = idx.ElementIndex + val; - return new MemoryGroupIndex( + return new( idx.BufferLength, idx.BufferIndex + (nextElementIndex / idx.BufferLength), nextElementIndex % idx.BufferLength); @@ -105,14 +105,14 @@ internal static class MemoryGroupIndexExtensions public static MemoryGroupIndex MinIndex(this IMemoryGroup group) where T : struct { - return new MemoryGroupIndex(group.BufferLength, 0, 0); + return new(group.BufferLength, 0, 0); } public static MemoryGroupIndex MaxIndex(this IMemoryGroup group) where T : struct { return group.Count == 0 - ? new MemoryGroupIndex(group.BufferLength, 0, 0) + ? new(group.BufferLength, 0, 0) : new MemoryGroupIndex(group.BufferLength, group.Count - 1, group[group.Count - 1].Length); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs index a49ab7778..9c7915e22 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs @@ -8,8 +8,8 @@ public class MemoryGroupIndexTests [Fact] public void Equal() { - var a = new MemoryGroupIndex(10, 1, 3); - var b = new MemoryGroupIndex(10, 1, 3); + MemoryGroupIndex a = new(10, 1, 3); + MemoryGroupIndex b = new(10, 1, 3); Assert.True(a.Equals(b)); Assert.True(a == b); @@ -21,8 +21,8 @@ public class MemoryGroupIndexTests [Fact] public void SmallerBufferIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 5, 3); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 5, 3); Assert.False(a == b); Assert.True(a != b); @@ -33,8 +33,8 @@ public class MemoryGroupIndexTests [Fact] public void SmallerElementIndex() { - var a = new MemoryGroupIndex(10, 3, 3); - var b = new MemoryGroupIndex(10, 3, 9); + MemoryGroupIndex a = new(10, 3, 3); + MemoryGroupIndex b = new(10, 3, 9); Assert.False(a == b); Assert.True(a != b); @@ -45,20 +45,20 @@ public class MemoryGroupIndexTests [Fact] public void Increment() { - var a = new MemoryGroupIndex(10, 3, 3); + MemoryGroupIndex a = new(10, 3, 3); a += 1; - Assert.Equal(new MemoryGroupIndex(10, 3, 4), a); + Assert.Equal(new(10, 3, 4), a); } [Fact] public void Increment_OverflowBuffer() { - var a = new MemoryGroupIndex(10, 5, 3); - var b = new MemoryGroupIndex(10, 5, 9); + MemoryGroupIndex a = new(10, 5, 3); + MemoryGroupIndex b = new(10, 5, 9); a += 8; b += 1; - Assert.Equal(new MemoryGroupIndex(10, 6, 1), a); - Assert.Equal(new MemoryGroupIndex(10, 6, 0), b); + Assert.Equal(new(10, 6, 1), a); + Assert.Equal(new(10, 6, 0), b); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs index 4c7de5412..ac242e846 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs @@ -59,7 +59,7 @@ public partial class MemoryGroupTests this.MemoryAllocator.BufferCapacityInBytes = bufferCapacity; // Act: - using var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferAlignment); // Assert: ValidateAllocateMemoryGroup(expectedNumberOfBuffers, expectedBufferSize, expectedSizeOfLastBuffer, g); @@ -83,7 +83,7 @@ public partial class MemoryGroupTests return; } - var pool = new UniformUnmanagedMemoryPool(bufferCapacity, expectedNumberOfBuffers); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(bufferCapacity, expectedNumberOfBuffers); // Act: Assert.True(MemoryGroup.TryAllocate(pool, totalLength, bufferAlignment, AllocationOptions.None, out MemoryGroup g)); @@ -98,7 +98,7 @@ public partial class MemoryGroupTests [InlineData(AllocationOptions.Clean)] public unsafe void Allocate_FromPool_AllocationOptionsAreApplied(AllocationOptions options) { - var pool = new UniformUnmanagedMemoryPool(10, 5); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(10, 5); UnmanagedMemoryHandle[] buffers = pool.Rent(5); foreach (UnmanagedMemoryHandle b in buffers) { @@ -128,7 +128,7 @@ public partial class MemoryGroupTests int requestBytes, bool shouldSucceed) { - var pool = new UniformUnmanagedMemoryPool(bufferCapacityBytes, poolCapacity); + UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(bufferCapacityBytes, poolCapacity); int alignmentElements = alignmentBytes / Unsafe.SizeOf(); int requestElements = requestBytes / Unsafe.SizeOf(); @@ -194,7 +194,7 @@ public partial class MemoryGroupTests HashSet bufferHashes; int expectedBlockCount = 5; - using (var g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) + using (MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 500, 100, allocationOptions)) { IReadOnlyList allocationLog = this.MemoryAllocator.AllocationLog; Assert.Equal(expectedBlockCount, allocationLog.Count); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs index 23aaf3c55..c140571fc 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.CopyTo.cs @@ -50,7 +50,7 @@ public partial class MemoryGroupTests public void GroupToSpan_Success(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; src.CopyTo(trg); int expected = 1; @@ -67,7 +67,7 @@ public partial class MemoryGroupTests public void GroupToSpan_OutOfRange(long totalLength, int bufferLength, int spanLength) { using MemoryGroup src = this.CreateTestGroup(totalLength, bufferLength, true); - var trg = new int[spanLength]; + int[] trg = new int[spanLength]; Assert.ThrowsAny(() => src.CopyTo(trg)); } @@ -78,7 +78,7 @@ public partial class MemoryGroupTests [InlineData(0, 3, 0)] public void SpanToGroup_Success(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; for (int i = 0; i < src.Length; i++) { src[i] = i + 1; @@ -100,7 +100,7 @@ public partial class MemoryGroupTests [InlineData(0, 3, 1)] public void SpanToGroup_OutOfRange(long totalLength, int bufferLength, int spanLength) { - var src = new int[spanLength]; + int[] src = new int[spanLength]; using MemoryGroup trg = this.CreateTestGroup(totalLength, bufferLength, true); Assert.ThrowsAny(() => src.AsSpan().CopyTo(trg)); } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs index 316150c30..044c8f584 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs @@ -12,7 +12,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase [Fact] public void IsValid_TrueAfterCreation() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); Assert.True(g.IsValid); } @@ -20,7 +20,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase [Fact] public void IsValid_FalseAfterDisposal() { - using var g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); + using MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, 10, 100); g.Dispose(); Assert.False(g.IsValid); @@ -102,10 +102,10 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase int[] data0 = { 1, 2, 3, 4 }; int[] data1 = { 5, 6, 7, 8 }; int[] data2 = { 9, 10 }; - using var mgr0 = new TestMemoryManager(data0); - using var mgr1 = new TestMemoryManager(data1); + using TestMemoryManager mgr0 = new TestMemoryManager(data0); + using TestMemoryManager mgr1 = new TestMemoryManager(data1); - using var group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); + using MemoryGroup group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); Assert.Equal(3, group.Count); Assert.Equal(4, group.BufferLength); @@ -217,7 +217,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase using MemoryGroup group = this.CreateTestGroup(100, 10, true); group.Clear(); - var expectedRow = new int[10]; + int[] expectedRow = new int[10]; foreach (Memory memory in group) { Assert.True(memory.Span.SequenceEqual(expectedRow)); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs index 8fe6ef3dd..56e2e95fe 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs @@ -15,7 +15,7 @@ public abstract class MemoryGroupTestsBase internal MemoryGroup CreateTestGroup(long totalLength, int bufferLength, bool fillSequence = false) { this.MemoryAllocator.BufferCapacityInBytes = bufferLength * sizeof(int); - var g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); + MemoryGroup g = MemoryGroup.Allocate(this.MemoryAllocator, totalLength, bufferLength); if (!fillSequence) { diff --git a/tests/ImageSharp.Tests/Memory/TestStructs.cs b/tests/ImageSharp.Tests/Memory/TestStructs.cs index ccbee5bd5..0fd823ee5 100644 --- a/tests/ImageSharp.Tests/Memory/TestStructs.cs +++ b/tests/ImageSharp.Tests/Memory/TestStructs.cs @@ -19,10 +19,10 @@ public static class TestStructs internal static Foo[] CreateArray(int size) { - var result = new Foo[size]; + Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new Foo(i + 1, i + 1); + result[i] = new(i + 1, i + 1); } return result; @@ -70,10 +70,10 @@ public static class TestStructs internal static AlignedFoo[] CreateArray(int size) { - var result = new AlignedFoo[size]; + AlignedFoo[] result = new AlignedFoo[size]; for (int i = 0; i < size; i++) { - result[i] = new AlignedFoo(i + 1, i + 1); + result[i] = new(i + 1, i + 1); } return result; diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 252784a7c..a19b82e64 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -38,7 +38,7 @@ public static class MemoryAllocatorValidator public static TestMemoryDiagnostics MonitorAllocations() { - var diag = new TestMemoryDiagnostics(); + TestMemoryDiagnostics diag = new TestMemoryDiagnostics(); LocalInstance.Value = diag; return diag; } diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index cdd6f0cc4..2a78b74be 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -48,7 +48,7 @@ public class ImageFrameMetadataTests XmpProfile xmpProfile = new(Array.Empty()); IccProfile iccProfile = new() { - Header = new IccProfileHeader() + Header = new() { CmmType = "Unittest" } diff --git a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs index ae02c3d57..78290db63 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs @@ -36,7 +36,7 @@ public class ImageMetadataTests { ImageMetadata metaData = new() { - ExifProfile = new ExifProfile(), + ExifProfile = new(), HorizontalResolution = 4, VerticalResolution = 2 }; @@ -86,8 +86,8 @@ public class ImageMetadataTests public void SyncProfiles() { ExifProfile exifProfile = new(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(300)); using Image image = new(1, 1); image.Metadata.ExifProfile = exifProfile; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs index 76e2d35c4..ab4d8a0d1 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs @@ -25,10 +25,10 @@ public class CicpProfileTests public void WritingPng_PreservesCicpProfile() { // arrange - using var image = new Image(1, 1); - var original = CreateCicpProfile(); + using Image image = new Image(1, 1); + CicpProfile original = CreateCicpProfile(); image.Metadata.CicpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new PngEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -49,7 +49,7 @@ public class CicpProfileTests private static CicpProfile CreateCicpProfile() { - var profile = new CicpProfile() + CicpProfile profile = new CicpProfile() { ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2, TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084, @@ -70,7 +70,7 @@ public class CicpProfileTests private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs index 8072bebd7..1f8b80b40 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -63,7 +63,7 @@ public class ExifProfileTests Assert.Null(image.Metadata.ExifProfile); const string expected = "Dirk Lemstra"; - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Copyright, expected); image = WriteAndRead(image, imageFormat); @@ -88,7 +88,7 @@ public class ExifProfileTests [Fact] public void EmptyWriter() { - var profile = new ExifProfile() { Parts = ExifParts.GpsTags }; + ExifProfile profile = new() { Parts = ExifParts.GpsTags }; profile.SetValue(ExifTag.Copyright, "Copyright text"); byte[] bytes = profile.ToByteArray(); @@ -120,14 +120,14 @@ public class ExifProfileTests [InlineData(TestImageWriteFormat.WebpLossy)] public void WriteFraction(TestImageWriteFormat imageFormat) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); double exposureTime = 1.0 / 1600; ExifProfile profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime)); - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -142,7 +142,7 @@ public class ExifProfileTests memStream.Position = 0; profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime, true)); + profile.SetValue(ExifTag.ExposureTime, new(exposureTime, true)); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -164,26 +164,26 @@ public class ExifProfileTests public void ReadWriteInfinity(TestImageWriteFormat imageFormat) { Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image(); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.PositiveInfinity)); image = WriteAndReadJpeg(image); IExifValue value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.PositiveInfinity), value.Value); + Assert.Equal(new(double.PositiveInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new SignedRational(double.NegativeInfinity), value.Value); + Assert.Equal(new(double.NegativeInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); IExifValue value2 = image.Metadata.ExifProfile.GetValue(ExifTag.FlashEnergy); Assert.NotNull(value2); - Assert.Equal(new Rational(double.PositiveInfinity), value2.Value); + Assert.Equal(new(double.PositiveInfinity), value2.Value); image.Dispose(); } @@ -209,20 +209,20 @@ public class ExifProfileTests Assert.True(software.TrySetValue(15)); Assert.False(software.TrySetValue(15F)); - image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55)); + image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new(75.55)); IExifValue shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(7555, 100), shutterSpeed.Value); + Assert.Equal(new(7555, 100), shutterSpeed.Value); Assert.False(shutterSpeed.TrySetValue(75)); - image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0)); + image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new(150.0)); // We also need to change this value because this overrides XResolution when the image is written. image.Metadata.HorizontalResolution = 150.0; IExifValue xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150, 1), xResolution.Value); + Assert.Equal(new(150, 1), xResolution.Value); Assert.False(xResolution.TrySetValue("ImageSharp")); @@ -231,7 +231,7 @@ public class ExifProfileTests IExifValue referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite); Assert.Null(referenceBlackWhite.Value); - var expectedLatitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) }; + Rational[] expectedLatitude = new Rational[] { new(12.3), new(4.56), new(789.0) }; image.Metadata.ExifProfile.SetValue(ExifTag.GPSLatitude, expectedLatitude); IExifValue latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude); @@ -251,10 +251,10 @@ public class ExifProfileTests Assert.Equal("15", software.Value); shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new SignedRational(75.55), shutterSpeed.Value); + Assert.Equal(new(75.55), shutterSpeed.Value); xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(150.0), xResolution.Value); + Assert.Equal(new(150.0), xResolution.Value); referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite, false); Assert.Null(referenceBlackWhite); @@ -308,11 +308,11 @@ public class ExifProfileTests [Fact] public void Syncs() { - var exifProfile = new ExifProfile(); - exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); - exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); + ExifProfile exifProfile = new(); + exifProfile.SetValue(ExifTag.XResolution, new(200)); + exifProfile.SetValue(ExifTag.YResolution, new(300)); - var metaData = new ImageMetadata + ImageMetadata metaData = new() { ExifProfile = exifProfile, HorizontalResolution = 200, @@ -366,15 +366,15 @@ public class ExifProfileTests foreach (ExifTag tag in tags) { // Arrange - var junk = new StringBuilder(); + StringBuilder junk = new(); for (int i = 0; i < 65600; i++) { junk.Append('a'); } - var image = new Image(100, 100); + Image image = new(100, 100); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); expectedProfile.SetValue(tag, junk.ToString()); image.Metadata.ExifProfile = expectedProfile; @@ -437,7 +437,7 @@ public class ExifProfileTests byte[] bytes = profile.ToByteArray(); Assert.Equal(531, bytes.Length); - var profile2 = new ExifProfile(bytes); + ExifProfile profile2 = new(bytes); Assert.Equal(25, profile2.Values.Count); } @@ -449,7 +449,7 @@ public class ExifProfileTests public void WritingImagePreservesExifProfile(TestImageWriteFormat imageFormat) { // Arrange - var image = new Image(1, 1); + Image image = new(1, 1); image.Metadata.ExifProfile = CreateExifProfile(); // Act @@ -472,11 +472,11 @@ public class ExifProfileTests // Arrange byte[] exifBytesWithoutExifCode = ExifConstants.LittleEndianByteOrderMarker.ToArray(); ExifProfile expectedProfile = CreateExifProfile(); - var expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); + List expectedProfileTags = expectedProfile.Values.Select(x => x.Tag).ToList(); // Act byte[] actualBytes = expectedProfile.ToByteArray(); - var actualProfile = new ExifProfile(actualBytes); + ExifProfile actualProfile = new(actualBytes); // Assert Assert.NotNull(actualBytes); @@ -492,7 +492,7 @@ public class ExifProfileTests private static ExifProfile CreateExifProfile() { - var profile = new ExifProfile(); + ExifProfile profile = new(); foreach (KeyValuePair exifProfileValue in TestProfileValues) { @@ -505,7 +505,7 @@ public class ExifProfileTests [Fact] public void IfdStructure() { - var exif = new ExifProfile(); + ExifProfile exif = new(); exif.SetValue(ExifTag.XPAuthor, "Dan Petitt"); Span actualBytes = exif.ToByteArray(); @@ -547,7 +547,7 @@ public class ExifProfileTests private static Image WriteAndReadJpeg(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsJpeg(memStream); image.Dispose(); @@ -557,7 +557,7 @@ public class ExifProfileTests private static Image WriteAndReadPng(Image image) { - using var memStream = new MemoryStream(); + using MemoryStream memStream = new(); image.SaveAsPng(memStream); image.Dispose(); @@ -567,8 +567,8 @@ public class ExifProfileTests private static Image WriteAndReadWebp(Image image, WebpFileFormatType fileFormat) { - using var memStream = new MemoryStream(); - image.SaveAsWebp(memStream, new WebpEncoder() { FileFormat = fileFormat }); + using MemoryStream memStream = new(); + image.SaveAsWebp(memStream, new() { FileFormat = fileFormat }); image.Dispose(); memStream.Position = 0; @@ -593,7 +593,7 @@ public class ExifProfileTests Assert.Equal("Windows Photo Editor 10.0.10011.16384", software.Value); IExifValue xResolution = profile.GetValue(ExifTag.XResolution); - Assert.Equal(new Rational(300.0), xResolution.Value); + Assert.Equal(new(300.0), xResolution.Value); IExifValue xDimension = profile.GetValue(ExifTag.PixelXDimension); Assert.Equal(2338U, xDimension.Value); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs index 8fe19b37d..dcdc5f0f3 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs @@ -11,7 +11,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsEmpty_ReturnsEmptyCollection() { - var reader = new ExifReader(Array.Empty()); + ExifReader reader = new ExifReader(Array.Empty()); IList result = reader.ReadValues(); @@ -21,7 +21,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsMinimal_ReturnsEmptyCollection() { - var reader = new ExifReader(new byte[] { 69, 120, 105, 102, 0, 0 }); + ExifReader reader = new ExifReader(new byte[] { 69, 120, 105, 102, 0, 0 }); IList result = reader.ReadValues(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs index 1154b3439..4ba259f39 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs @@ -12,7 +12,7 @@ public class ExifTagDescriptionAttributeTests [Fact] public void TestExifTag() { - var exifProfile = new ExifProfile(); + ExifProfile exifProfile = new ExifProfile(); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1); IExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index 99cafa896..bf6018c65 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -347,7 +347,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -361,7 +361,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -375,7 +375,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifDoubleArray)value; + ExifDoubleArray typed = (ExifDoubleArray)value; Assert.Equal(expected, typed.Value); } @@ -389,7 +389,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLong)value; + ExifLong typed = (ExifLong)value; Assert.Equal(expected, typed.Value); } @@ -403,7 +403,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifLongArray)value; + ExifLongArray typed = (ExifLongArray)value; Assert.Equal(expected, typed.Value); } @@ -447,7 +447,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumber)value; + ExifNumber typed = (ExifNumber)value; Assert.Equal(expected, typed.Value); typed.Value = ushort.MaxValue + 1; @@ -464,7 +464,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifNumberArray)value; + ExifNumberArray typed = (ExifNumberArray)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(int.MaxValue)); @@ -481,14 +481,14 @@ public class ExifValuesTests [MemberData(nameof(RationalTags))] public void ExifRationalTests(ExifTag tag) { - var expected = new Rational(21, 42); + Rational expected = new Rational(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(new SignedRational(expected.ToDouble()))); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRational)value; + ExifRational typed = (ExifRational)value; Assert.Equal(expected, typed.Value); } @@ -502,7 +502,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifRationalArray)value; + ExifRationalArray typed = (ExifRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -518,7 +518,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((short)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShort)value; + ExifShort typed = (ExifShort)value; Assert.Equal(expected, typed.Value); } @@ -532,7 +532,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifShortArray)value; + ExifShortArray typed = (ExifShortArray)value; Assert.Equal(expected, typed.Value); } @@ -540,13 +540,13 @@ public class ExifValuesTests [MemberData(nameof(SignedRationalTags))] public void ExifSignedRationalTests(ExifTag tag) { - var expected = new SignedRational(21, 42); + SignedRational expected = new SignedRational(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRational)value; + ExifSignedRational typed = (ExifSignedRational)value; Assert.Equal(expected, typed.Value); } @@ -560,7 +560,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedRationalArray)value; + ExifSignedRationalArray typed = (ExifSignedRationalArray)value; Assert.Equal(expected, typed.Value); } @@ -575,7 +575,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifSignedShortArray)value; + ExifSignedShortArray typed = (ExifSignedShortArray)value; Assert.Equal(expected, typed.Value); } @@ -589,7 +589,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(0M)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifString)value; + ExifString typed = (ExifString)value; Assert.Equal(expected, typed.Value); } @@ -604,7 +604,7 @@ public class ExifValuesTests Assert.True(value.TrySetValue((int)expected)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByte)value; + ExifByte typed = (ExifByte)value; Assert.Equal(expected, typed.Value); } @@ -618,7 +618,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(expected.ToString())); Assert.True(value.TrySetValue(expected)); - var typed = (ExifByteArray)value; + ExifByteArray typed = (ExifByteArray)value; Assert.Equal(expected, typed.Value); } @@ -628,18 +628,18 @@ public class ExifValuesTests { foreach (object code in Enum.GetValues(typeof(EncodedString.CharacterCode))) { - var charCode = (EncodedString.CharacterCode)code; + EncodedString.CharacterCode charCode = (EncodedString.CharacterCode)code; Assert.Equal(ExifEncodedStringHelpers.CharacterCodeBytesLength, ExifEncodedStringHelpers.GetCodeBytes(charCode).Length); const string expectedText = "test string"; - var expected = new EncodedString(charCode, expectedText); + EncodedString expected = new EncodedString(charCode, expectedText); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifEncodedString)value; + ExifEncodedString typed = (ExifEncodedString)value; Assert.Equal(expected, typed.Value); Assert.Equal(expectedText, (string)typed.Value); Assert.Equal(charCode, typed.Value.Code); @@ -656,7 +656,7 @@ public class ExifValuesTests Assert.False(value.TrySetValue(123)); Assert.True(value.TrySetValue(expected)); - var typed = (ExifUcs2String)value; + ExifUcs2String typed = (ExifUcs2String)value; Assert.Equal(expected, typed.Value); Assert.True(value.TrySetValue(Encoding.GetEncoding("UCS-2").GetBytes(expected))); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs index 86c6a5e9f..9f089f482 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderCurvesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs index a686d4487..817832807 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderLutTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs index 930665a07..030cf0df4 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs @@ -55,6 +55,6 @@ public class IccDataReaderMultiProcessElementTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs index ee0464bb2..f4f89d11d 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs @@ -122,6 +122,6 @@ public class IccDataReaderNonPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs index 9c5be4c67..77e334a49 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs @@ -82,6 +82,6 @@ public class IccDataReaderPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index e0cfa6543..735a6abf7 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -442,6 +442,6 @@ public class IccDataReaderTagDataEntryTests private static IccDataReader CreateReader(byte[] data) { - return new IccDataReader(data); + return new(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index 9c4abfe3e..79a8fb263 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -22,7 +22,7 @@ public class IccProfileTests public void CalculateHash_WithByteArray_DoesNotModifyData() { byte[] data = IccTestDataProfiles.ProfileRandomArray; - var copy = new byte[data.Length]; + byte[] copy = new byte[data.Length]; Buffer.BlockCopy(data, 0, copy, 0, data.Length); IccProfile.CalculateHash(data); @@ -34,7 +34,7 @@ public class IccProfileTests [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) { - var profile = new IccProfile(data); + IccProfile profile = new IccProfile(data); bool result = profile.CheckIsValid(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index 24671aa3c..ffc4ed2eb 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -12,7 +12,7 @@ public class IccWriterTests [Fact] public void WriteProfile_NoEntries() { - var profile = new IccProfile + IccProfile profile = new IccProfile { Header = IccTestDataProfiles.HeaderRandomWrite }; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs index 968fa86c4..e56f7f182 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs @@ -19,7 +19,7 @@ public class IccProfileIdTests [Fact] public void SetIsTrueWhenNonDefaultValue() { - var id = new IccProfileId(1, 2, 3, 4); + IccProfileId id = new IccProfileId(1, 2, 3, 4); Assert.True(id.IsSet); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index 1a52ade62..36df7da0c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -22,7 +22,7 @@ public class IptcProfileTests public void IptcProfile_WithUtf8Data_WritesEnvelopeRecord_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.City, "ESPAÑA"); profile.UpdateData(); byte[] expectedEnvelopeData = { 28, 1, 90, 0, 3, 27, 37, 71 }; @@ -39,7 +39,7 @@ public class IptcProfileTests public void IptcProfile_SetValue_WithStrictEnabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = tag.MaxLength(); @@ -56,7 +56,7 @@ public class IptcProfileTests public void IptcProfile_SetValue_WithStrictDisabled_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); string value = new('s', tag.MaxLength() + 1); int expectedLength = value.Length; @@ -77,8 +77,8 @@ public class IptcProfileTests public void IptcProfile_SetDateValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var datetime = new DateTimeOffset(new DateTime(1994, 3, 17)); + IptcProfile profile = new(); + DateTimeOffset datetime = new(new(1994, 3, 17)); // act profile.SetDateTimeValue(tag, datetime); @@ -96,8 +96,8 @@ public class IptcProfileTests public void IptcProfile_SetTimeValue_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); - var dateTimeUtc = new DateTime(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); + IptcProfile profile = new(); + DateTime dateTimeUtc = new(1994, 3, 17, 14, 15, 16, DateTimeKind.Utc); DateTimeOffset dateTimeOffset = new DateTimeOffset(dateTimeUtc).ToOffset(TimeSpan.FromHours(2)); // act @@ -116,7 +116,7 @@ public class IptcProfileTests using (Image image = provider.GetImage(JpegDecoder.Instance)) { Assert.NotNull(image.Metadata.IptcProfile); - var iptcValues = image.Metadata.IptcProfile.Values.ToList(); + List iptcValues = image.Metadata.IptcProfile.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -130,7 +130,7 @@ public class IptcProfileTests { IptcProfile iptc = image.Frames.RootFrame.Metadata.IptcProfile; Assert.NotNull(iptc); - var iptcValues = iptc.Values.ToList(); + List iptcValues = iptc.Values.ToList(); IptcProfileContainsExpectedValues(iptcValues); } } @@ -170,7 +170,7 @@ public class IptcProfileTests public void IptcProfile_ToAndFromByteArray_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; profile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -179,10 +179,10 @@ public class IptcProfileTests // act profile.UpdateData(); byte[] profileBytes = profile.Data; - var profileFromBytes = new IptcProfile(profileBytes); + IptcProfile profileFromBytes = new(profileBytes); // assert - var iptcValues = profileFromBytes.Values.ToList(); + List iptcValues = profileFromBytes.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -191,7 +191,7 @@ public class IptcProfileTests public void IptcProfile_CloneIsDeep() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string captionWriter = "unittest"; const string caption = "test"; profile.SetValue(IptcTag.CaptionWriter, captionWriter); @@ -203,7 +203,7 @@ public class IptcProfileTests // assert Assert.Equal(2, clone.Values.Count()); - var cloneValues = clone.Values.ToList(); + List cloneValues = clone.Values.ToList(); ContainsIptcValue(cloneValues, IptcTag.CaptionWriter, captionWriter); ContainsIptcValue(cloneValues, IptcTag.Caption, "changed"); ContainsIptcValue(profile.Values.ToList(), IptcTag.Caption, caption); @@ -213,7 +213,7 @@ public class IptcProfileTests public void IptcValue_CloneIsDeep() { // arrange - var iptcValue = new IptcValue(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); + IptcValue iptcValue = new(IptcTag.Caption, System.Text.Encoding.UTF8, "test", true); // act IptcValue clone = iptcValue.DeepClone(); @@ -228,7 +228,7 @@ public class IptcProfileTests { // arrange using Image image = new(1, 1); - image.Metadata.IptcProfile = new IptcProfile(); + image.Metadata.IptcProfile = new(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; image.Metadata.IptcProfile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -240,7 +240,7 @@ public class IptcProfileTests // assert IptcProfile actual = reloadedImage.Metadata.IptcProfile; Assert.NotNull(actual); - var iptcValues = actual.Values.ToList(); + List iptcValues = actual.Values.ToList(); ContainsIptcValue(iptcValues, IptcTag.CaptionWriter, expectedCaptionWriter); ContainsIptcValue(iptcValues, IptcTag.Caption, expectedCaption); } @@ -263,7 +263,7 @@ public class IptcProfileTests public void IptcProfile_AddRepeatable_Works(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue1 = "test"; const string expectedValue2 = "another one"; profile.SetValue(tag, expectedValue1, false); @@ -272,7 +272,7 @@ public class IptcProfileTests profile.SetValue(tag, expectedValue2, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(2, values.Count); ContainsIptcValue(values, tag, expectedValue1); ContainsIptcValue(values, tag, expectedValue2); @@ -315,7 +315,7 @@ public class IptcProfileTests public void IptcProfile_AddNoneRepeatable_DoesOverrideOldValue(IptcTag tag) { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); const string expectedValue = "another one"; profile.SetValue(tag, "test", false); @@ -323,7 +323,7 @@ public class IptcProfileTests profile.SetValue(tag, expectedValue, false); // assert - var values = profile.Values.ToList(); + List values = profile.Values.ToList(); Assert.Equal(1, values.Count); ContainsIptcValue(values, tag, expectedValue); } @@ -332,7 +332,7 @@ public class IptcProfileTests public void IptcProfile_RemoveByTag_RemovesAllEntrys() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -348,7 +348,7 @@ public class IptcProfileTests public void IptcProfile_RemoveByTagAndValue_Works() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); @@ -364,7 +364,7 @@ public class IptcProfileTests public void IptcProfile_GetValue_RetrievesAllEntries() { // arrange - var profile = new IptcProfile(); + IptcProfile profile = new(); profile.SetValue(IptcTag.Byline, "test"); profile.SetValue(IptcTag.Byline, "test2"); profile.SetValue(IptcTag.Caption, "test"); @@ -380,12 +380,12 @@ public class IptcProfileTests private static void ContainsIptcValue(List values, IptcTag tag, string value) { Assert.True(values.Any(val => val.Tag == tag), $"Missing iptc tag {tag}"); - Assert.True(values.Contains(new IptcValue(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); + Assert.True(values.Contains(new(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); } private static Image WriteAndReadJpeg(Image image) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.SaveAsJpeg(memStream); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index 5dc6ac6db..1c253bbbe 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -111,10 +111,10 @@ public class XmpProfileTests public void WritingGif_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new GifEncoder(); + GifEncoder encoder = new GifEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -129,10 +129,10 @@ public class XmpProfileTests public void WritingJpeg_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new JpegEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -147,10 +147,10 @@ public class XmpProfileTests public async Task WritingJpeg_PreservesExtendedXmpProfile() { // arrange - var provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); + TestImageProvider provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); using Image image = await provider.GetImageAsync(JpegDecoder.Instance); XmpProfile original = image.Metadata.XmpProfile; - var encoder = new JpegEncoder(); + JpegEncoder encoder = new JpegEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -165,10 +165,10 @@ public class XmpProfileTests public void WritingPng_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new PngEncoder(); + PngEncoder encoder = new PngEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -183,10 +183,10 @@ public class XmpProfileTests public void WritingTiff_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Frames.RootFrame.Metadata.XmpProfile = original; - var encoder = new TiffEncoder(); + TiffEncoder encoder = new TiffEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -201,10 +201,10 @@ public class XmpProfileTests public void WritingWebp_PreservesXmpProfile() { // arrange - using var image = new Image(1, 1); + using Image image = new Image(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - var encoder = new WebpEncoder(); + WebpEncoder encoder = new WebpEncoder(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -228,13 +228,13 @@ public class XmpProfileTests { string content = $" "; byte[] data = Encoding.UTF8.GetBytes(content); - var profile = new XmpProfile(data); + XmpProfile profile = new XmpProfile(data); return profile; } private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (var memStream = new MemoryStream()) + using (MemoryStream memStream = new MemoryStream()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index f9cefaddd..9e7e3b7a0 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -70,19 +70,19 @@ public class RationalTests Assert.Equal(7U, rational.Numerator); Assert.Equal(55U, rational.Denominator); - rational = new Rational(755, 100); + rational = new(755, 100); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(755, 100, false); + rational = new(755, 100, false); Assert.Equal(755U, rational.Numerator); Assert.Equal(100U, rational.Denominator); - rational = new Rational(-7.55); + rational = new(-7.55); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new Rational(7); + rational = new(7); Assert.Equal(7U, rational.Numerator); Assert.Equal(1U, rational.Denominator); } @@ -101,7 +101,7 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new Rational(2, 0); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); } @@ -111,19 +111,19 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new Rational(double.PositiveInfinity); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new Rational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new Rational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new Rational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs index 04183571b..275ba4d5f 100644 --- a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs @@ -14,15 +14,15 @@ public class SignedRationalTests [Fact] public void AreEqual() { - var r1 = new SignedRational(3, 2); - var r2 = new SignedRational(3, 2); + SignedRational r1 = new(3, 2); + SignedRational r2 = new(3, 2); Assert.Equal(r1, r2); Assert.True(r1 == r2); - var r3 = new SignedRational(7.55); - var r4 = new SignedRational(755, 100); - var r5 = new SignedRational(151, 20); + SignedRational r3 = new(7.55); + SignedRational r4 = new(755, 100); + SignedRational r5 = new(151, 20); Assert.Equal(r3, r4); Assert.Equal(r4, r5); @@ -34,8 +34,8 @@ public class SignedRationalTests [Fact] public void AreNotEqual() { - var first = new SignedRational(0, 100); - var second = new SignedRational(100, 100); + SignedRational first = new(0, 100); + SignedRational second = new(100, 100); Assert.NotEqual(first, second); Assert.True(first != second); @@ -47,27 +47,27 @@ public class SignedRationalTests [Fact] public void ConstructorAssignsProperties() { - var rational = new SignedRational(7, -55); + SignedRational rational = new(7, -55); Assert.Equal(7, rational.Numerator); Assert.Equal(-55, rational.Denominator); - rational = new SignedRational(-755, 100); + rational = new(-755, 100); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(-755, -100, false); + rational = new(-755, -100, false); Assert.Equal(-755, rational.Numerator); Assert.Equal(-100, rational.Denominator); - rational = new SignedRational(-151, -20); + rational = new(-151, -20); Assert.Equal(-151, rational.Numerator); Assert.Equal(-20, rational.Denominator); - rational = new SignedRational(-7.55); + rational = new(-7.55); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new SignedRational(7); + rational = new(7); Assert.Equal(7, rational.Numerator); Assert.Equal(1, rational.Denominator); } @@ -75,43 +75,43 @@ public class SignedRationalTests [Fact] public void Fraction() { - var first = new SignedRational(1.0 / 1600); - var second = new SignedRational(1.0 / 1600, true); + SignedRational first = new(1.0 / 1600); + SignedRational second = new(1.0 / 1600, true); Assert.False(first.Equals(second)); } [Fact] public void ToDouble() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new SignedRational(2, 0); + rational = new(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); - rational = new SignedRational(-2, 0); + rational = new(-2, 0); Assert.Equal(double.NegativeInfinity, rational.ToDouble()); } [Fact] public void ToStringRepresentation() { - var rational = new SignedRational(0, 0); + SignedRational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new SignedRational(double.PositiveInfinity); + rational = new(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new SignedRational(double.NegativeInfinity); + rational = new(double.NegativeInfinity); Assert.Equal("[ NegativeInfinity ]", rational.ToString()); - rational = new SignedRational(0, 1); + rational = new(0, 1); Assert.Equal("0", rational.ToString()); - rational = new SignedRational(2, 1); + rational = new(2, 1); Assert.Equal("2", rational.ToString()); - rational = new SignedRational(1, 2); + rational = new(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index 4b4e84b4b..4b348b88f 100644 --- a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -101,7 +101,7 @@ public class A8Tests const byte expected = byte.MaxValue; // act - A8 alpha = A8.FromBgra5551(new Bgra5551(0.0f, 0.0f, 0.0f, 1.0f)); + A8 alpha = A8.FromBgra5551(new(0.0f, 0.0f, 0.0f, 1.0f)); // assert Assert.Equal(expected, alpha.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs index 98fdce5db..415650321 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs @@ -96,7 +96,7 @@ public class Abgr32Tests [Fact] public void FromRgba32() { - Abgr32 abgr = Abgr32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Abgr32 abgr = Abgr32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, abgr.R); Assert.Equal(2, abgr.G); @@ -136,7 +136,7 @@ public class Abgr32Tests const uint expected = uint.MaxValue; // act - Abgr32 abgr = Abgr32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Abgr32 abgr = Abgr32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, abgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs index bcaf9265a..8e05c5ca0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs @@ -128,7 +128,7 @@ public class Argb32Tests const uint expected = uint.MaxValue; // act - Argb32 argb = Argb32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Argb32 argb = Argb32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, argb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index 362e20bba..a7e4a08f0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -80,7 +80,7 @@ public class Bgr24Tests [Fact] public void FromRgba32() { - Bgr24 rgb = Bgr24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgr24 rgb = Bgr24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -115,7 +115,7 @@ public class Bgr24Tests public void Bgr24_FromBgra5551() { // act - Bgr24 bgr = Bgr24.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Bgr24 bgr = Bgr24.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(255, bgr.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs index 3c4a10423..f74660731 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs @@ -17,8 +17,8 @@ public class Bgr565Tests public void AreEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(0.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 1.0f)); + Bgr565 color2 = new(new(0.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 1.0f)); Bgr565 color4 = new(1.0f, 0.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgr565Tests public void AreNotEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new Vector3(1.0f)); - Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 0.0f)); + Bgr565 color2 = new(new(1.0f)); + Bgr565 color3 = new(new(1.0f, 0.0f, 0.0f)); Bgr565 color4 = new(1.0f, 1.0f, 0.0f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr = Bgr565.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -115,8 +115,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -131,8 +131,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -159,7 +159,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -172,7 +172,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -185,7 +185,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -198,7 +198,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -211,7 +211,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL8(new L8(byte.MaxValue)); + Bgr565 bgr = Bgr565.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -224,7 +224,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL16(new L16(ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 277975896..d0150c808 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -96,7 +96,7 @@ public class Bgra32Tests [Fact] public void FromRgba32() { - Bgra32 bgra = Bgra32.FromRgba32(new Rgba32(1, 2, 3, 4)); + Bgra32 bgra = Bgra32.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, bgra.R); Assert.Equal(2, bgra.G); @@ -136,7 +136,7 @@ public class Bgra32Tests const uint expected = uint.MaxValue; // act - Bgra32 bgra = Bgra32.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra32 bgra = Bgra32.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs index 5d20b5cf1..166a06940 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs @@ -17,8 +17,8 @@ public class Bgra4444Tests public void AreEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(0.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 1.0f, 1.0f)); + Bgra4444 color2 = new(new(0.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 1.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 0.0f, 1.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra4444Tests public void AreNotEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new Vector4(1.0f)); - Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); + Bgra4444 color2 = new(new(1.0f)); + Bgra4444 color3 = new(new(1.0f, 0.0f, 0.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 1.0f, 0.0f, 1.0f); Assert.NotEqual(color1, color2); @@ -114,7 +114,7 @@ public class Bgra4444Tests const ushort expected = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra4444 pixel = Bgra4444.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -127,7 +127,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra4444 pixel = Bgra4444.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -141,8 +141,8 @@ public class Bgra4444Tests const ushort expectedPackedValue2 = 0xFF0F; // act - Bgra4444 bgra1 = Bgra4444.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra4444 bgra2 = Bgra4444.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra4444 bgra1 = Bgra4444.FromRgba32(new(255, 255, 255, 255)); + Bgra4444 bgra2 = Bgra4444.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -156,7 +156,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -169,7 +169,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -182,7 +182,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL16(new L16(ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -195,7 +195,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL8(new L8(byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -208,7 +208,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -221,7 +221,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs index 38f809e49..a19f0e9a1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs @@ -17,8 +17,8 @@ public class Bgra5551Tests public void AreEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(0.0f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(0.0f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 0.0f, 0.0f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra5551Tests public void AreNotEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new Vector4(1f)); - Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new(1f)); + Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -134,8 +134,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromRgba32(new Rgba32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromRgba32(new Rgba32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromRgba32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -150,8 +150,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromBgra32(new Bgra32(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromBgra32(new Bgra32(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromBgra32(new(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromBgra32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -165,7 +165,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromArgb32(new Argb32(255, 255, 255, 255)); + Bgra5551 pixel = Bgra5551.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -178,7 +178,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -191,7 +191,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -204,7 +204,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL16(new L16(ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -217,7 +217,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL8(new L8(byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -230,7 +230,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -243,7 +243,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs index e73d64640..51c7ec4db 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs @@ -17,8 +17,8 @@ public class Byte4Tests public void AreEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(0f)); - Byte4 color3 = new(new Vector4(1f, 0f, 1f, 1f)); + Byte4 color2 = new(new(0f)); + Byte4 color3 = new(new(1f, 0f, 1f, 1f)); Byte4 color4 = new(1f, 0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Byte4Tests public void AreNotEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new Vector4(1f)); - Byte4 color3 = new(new Vector4(1f, 0f, 0f, 1f)); + Byte4 color2 = new(new(1f)); + Byte4 color3 = new(new(1f, 0f, 0f, 1f)); Byte4 color4 = new(1f, 1f, 0f, 1f); Assert.NotEqual(color1, color2); @@ -111,7 +111,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromArgb32(new Argb32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -124,7 +124,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -137,7 +137,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL8(new L8(byte.MaxValue)); + Byte4 pixel = Byte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -150,7 +150,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL16(new L16(ushort.MaxValue)); + Byte4 pixel = Byte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -163,7 +163,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -176,7 +176,7 @@ public class Byte4Tests const uint expected = 0xFFFFFFFF; // act - Byte4 pixel = Byte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Byte4 pixel = Byte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -189,7 +189,7 @@ public class Byte4Tests const uint expectedPackedValue1 = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue1, pixel.PackedValue); @@ -202,7 +202,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -215,7 +215,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs index c5a89df1e..d723aac47 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs @@ -76,7 +76,7 @@ public class HalfVector2Tests public void HalfVector2_FromBgra5551() { // act - HalfVector2 pixel = HalfVector2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + HalfVector2 pixel = HalfVector2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Vector4 actual = pixel.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs index 16c78a23d..571711800 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs @@ -73,7 +73,7 @@ public class HalfVector4Tests Vector4 expected = Vector4.One; // act - HalfVector4 pixel = HalfVector4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + HalfVector4 pixel = HalfVector4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 7f0a4217c..5631bbc7e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -115,7 +115,7 @@ public class L16Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - L16 pixel = L16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L16 pixel = L16.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.PackedValue; // Assert @@ -149,7 +149,7 @@ public class L16Tests const ushort expected = ushort.MaxValue; // act - L16 pixel = L16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + L16 pixel = L16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index 1ca865ef4..b1c94c754 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -114,7 +114,7 @@ public class L8Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - L8 pixel = L8.FromRgba32(new Rgba32(rgb, rgb, rgb)); + L8 pixel = L8.FromRgba32(new(rgb, rgb, rgb)); byte actual = pixel.PackedValue; // Assert @@ -145,7 +145,7 @@ public class L8Tests const byte expected = byte.MaxValue; // act - L8 grey = L8.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + L8 grey = L8.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, grey.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index f6cbfc442..d82afdff1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -116,7 +116,7 @@ public class La16Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - La16 gray = La16.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La16 gray = La16.FromRgba32(new(rgb, rgb, rgb)); byte actual = gray.L; // Assert @@ -148,7 +148,7 @@ public class La16Tests const byte expected = byte.MaxValue; // act - La16 grey = La16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + La16 grey = La16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, grey.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs index fd5556d3b..571aa3fd0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -119,7 +119,7 @@ public class La32Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - La32 pixel = La32.FromRgba32(new Rgba32(rgb, rgb, rgb)); + La32 pixel = La32.FromRgba32(new(rgb, rgb, rgb)); ushort actual = pixel.L; // Assert @@ -154,7 +154,7 @@ public class La32Tests const ushort expected = ushort.MaxValue; // act - La32 pixel = La32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + La32 pixel = La32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs index ffbddb139..c6a14518a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs @@ -32,8 +32,8 @@ public class NormalizedByte2Tests [Fact] public void NormalizedByte2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); } [Fact] @@ -74,7 +74,7 @@ public class NormalizedByte2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs index 5a025f6c4..40d81cad6 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedByte4Tests public void AreEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(0.0f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedByte4 color2 = new(new(0.0f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedByte4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedByte4Tests public void AreNotEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new Vector4(1f)); - NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedByte4 color2 = new(new(1f)); + NormalizedByte4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedByte4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -98,7 +98,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -111,7 +111,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -124,7 +124,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL8(new L8(byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -137,7 +137,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL16(new L16(ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -150,7 +150,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -163,7 +163,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -176,7 +176,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); @@ -189,7 +189,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -202,7 +202,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs index be7b39052..f153f6aea 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs @@ -36,8 +36,8 @@ public class NormalizedShort2Tests [Fact] public void NormalizedShort2_ToVector4() { - Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); + Assert.Equal(new(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); } [Fact] @@ -78,7 +78,7 @@ public class NormalizedShort2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort2.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs index 281ae7ee5..cf0c3e819 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedShort4Tests public void AreEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(0.0f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + NormalizedShort4 color2 = new(new(0.0f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 1f, 1f)); NormalizedShort4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedShort4Tests public void AreNotEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new Vector4(1f)); - NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + NormalizedShort4 color2 = new(new(1f)); + NormalizedShort4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); NormalizedShort4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -99,7 +99,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new Argb32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -112,7 +112,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -125,7 +125,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL8(new L8(byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -138,7 +138,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL16(new L16(ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -151,7 +151,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -164,7 +164,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new Rgba32(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -177,7 +177,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -190,7 +190,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -216,7 +216,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort4.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs index 924e94d92..2e66115b0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs @@ -44,14 +44,14 @@ public class PixelBlenderTests public static TheoryData ColorBlendingExpectedResults = new() { { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Normal, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new Rgba32(0xFFC62D32) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new Rgba32(0xFFDDCEFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new Rgba32(0xFF701919) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new Rgba32(0xFFE1E4FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new Rgba32(0xFFFFFDFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new Rgba32(0xFF71CBE6) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new Rgba32(0xFF631619) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new(0xFFEEE7FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new(0xFFC62D32) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new(0xFFDDCEFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new(0xFF701919) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new(0xFFE1E4FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new(0xFFFFFDFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new(0xFF71CBE6) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new(0xFF631619) }, }; [Theory] @@ -67,17 +67,17 @@ public class PixelBlenderTests public static TheoryData AlphaCompositionExpectedResults = new() { - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Dest, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestAtop, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestIn, Color.MistyRose.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOver, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Src, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcAtop, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcIn, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOver, Color.MidnightBlue.ToPixel() }, }; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index 976a272eb..908625e17 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -16,8 +16,8 @@ public class PorterDuffFunctionsTests public static TheoryData NormalBlendFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) } }; [Theory] @@ -47,9 +47,9 @@ public class PorterDuffFunctionsTests public static TheoryData MultiplyFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, - { new TestVector4(0.9f, 0.9f, 0.9f, 0.9f), new TestVector4(0.4f, 0.4f, 0.4f, 0.4f), .5f, new TestVector4(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) }, + { new(0.9f, 0.9f, 0.9f, 0.9f), new(0.4f, 0.4f, 0.4f, 0.4f), .5f, new(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } }; [Theory] @@ -79,9 +79,9 @@ public class PorterDuffFunctionsTests public static TheoryData AddFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(0.24324325f, 0.24324325f, 0.24324325f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(0.24324325f, 0.24324325f, 0.24324325f, .37f) } }; [Theory] @@ -111,9 +111,9 @@ public class PorterDuffFunctionsTests public static TheoryData SubtractFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(0, 0, 0, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2027027f, .2027027f, .2027027f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(0, 0, 0, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2027027f, .2027027f, .2027027f, .37f) } }; [Theory] @@ -143,9 +143,9 @@ public class PorterDuffFunctionsTests public static TheoryData ScreenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2383784f, .2383784f, .2383784f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2383784f, .2383784f, .2383784f, .37f) } }; [Theory] @@ -175,9 +175,9 @@ public class PorterDuffFunctionsTests public static TheoryData DarkenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2189189f, .2189189f, .2189189f, .37f) } + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(.6f, .6f, .6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2189189f, .2189189f, .2189189f, .37f) } }; [Theory] @@ -207,9 +207,9 @@ public class PorterDuffFunctionsTests public static TheoryData LightenFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.227027f, .227027f, .227027f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.227027f, .227027f, .227027f, .37f) }, }; [Theory] @@ -239,9 +239,9 @@ public class PorterDuffFunctionsTests public static TheoryData OverlayFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] @@ -271,9 +271,9 @@ public class PorterDuffFunctionsTests public static TheoryData HardLightFunctionData { get; } = new() { - { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, - { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1f) }, - { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, + { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, + { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1f) }, + { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index d375a74c6..4c15fda31 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -12,10 +12,10 @@ public class PorterDuffFunctionsTestsTPixel private static Span AsSpan(T value) where T : struct { - return new Span(new[] { value }); + return new(new[] { value }); } - public static TheoryData NormalBlendFunctionData = new TheoryData + public static TheoryData NormalBlendFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) } @@ -46,12 +46,12 @@ public class PorterDuffFunctionsTestsTPixel public void NormalBlendFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.NormalSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData MultiplyFunctionData = new TheoryData + public static TheoryData MultiplyFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1) }, @@ -86,12 +86,12 @@ public class PorterDuffFunctionsTestsTPixel public void MultiplyFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.MultiplySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData AddFunctionData = new TheoryData + public static TheoryData AddFunctionData = new() { { new TestPixel(1, 1, 1, 1), @@ -136,12 +136,12 @@ public class PorterDuffFunctionsTestsTPixel public void AddFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.AddSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData SubtractFunctionData = new TheoryData + public static TheoryData SubtractFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(0, 0, 0, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -176,12 +176,12 @@ public class PorterDuffFunctionsTestsTPixel public void SubtractFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.SubtractSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData ScreenFunctionData = new TheoryData + public static TheoryData ScreenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -216,12 +216,12 @@ public class PorterDuffFunctionsTestsTPixel public void ScreenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.ScreenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData DarkenFunctionData = new TheoryData + public static TheoryData DarkenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(.6f, .6f, .6f, 1f) }, @@ -256,12 +256,12 @@ public class PorterDuffFunctionsTestsTPixel public void DarkenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.DarkenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData LightenFunctionData = new TheoryData + public static TheoryData LightenFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -296,12 +296,12 @@ public class PorterDuffFunctionsTestsTPixel public void LightenFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.LightenSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData OverlayFunctionData = new TheoryData + public static TheoryData OverlayFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(1, 1, 1, 1f) }, @@ -336,12 +336,12 @@ public class PorterDuffFunctionsTestsTPixel public void OverlayFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.OverlaySrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } - public static TheoryData HardLightFunctionData = new TheoryData + public static TheoryData HardLightFunctionData = new() { { new TestPixel(1, 1, 1, 1), new TestPixel(1, 1, 1, 1), 1, new TestPixel(1, 1, 1, 1) }, { new TestPixel(1, 1, 1, 1), new TestPixel(0, 0, 0, .8f), .5f, new TestPixel(0.6f, 0.6f, 0.6f, 1f) }, @@ -376,7 +376,7 @@ public class PorterDuffFunctionsTestsTPixel public void HardLightFunctionBlenderBulk(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : unmanaged, IPixel { - var dest = new Span(new TPixel[1]); + Span dest = new(new TPixel[1]); new DefaultPixelBlenders.HardLightSrcOver().Blend(this.Configuration, dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected.AsPixel(), dest[0], 2); } diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 32b62fc03..6d5013cde 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -117,7 +117,7 @@ public abstract class PixelOperationsTests : MeasureFixture const byte alpha = byte.MinValue; const byte noAlpha = byte.MaxValue; - TPixel pixel = TPixel.FromRgba32(new Rgba32(0, 0, 0, alpha)); + TPixel pixel = TPixel.FromRgba32(new(0, 0, 0, alpha)); Rgba32 dest = pixel.ToRgba32(); @@ -480,7 +480,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromArgb32(new Argb32(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); + expected[i] = TPixel.FromArgb32(new(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); } TestOperation( @@ -524,7 +524,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromBgr24(new Bgr24(source[i3 + 2], source[i3 + 1], source[i3])); + expected[i] = TPixel.FromBgr24(new(source[i3 + 2], source[i3 + 1], source[i3])); } TestOperation( @@ -566,7 +566,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromBgra32(new Bgra32(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); + expected[i] = TPixel.FromBgra32(new(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); } TestOperation( @@ -609,7 +609,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromAbgr32(new Abgr32(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); + expected[i] = TPixel.FromAbgr32(new(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); } TestOperation( @@ -863,7 +863,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromRgb24(new Rgb24(source[i3 + 0], source[i3 + 1], source[i3 + 2])); + expected[i] = TPixel.FromRgb24(new(source[i3 + 0], source[i3 + 1], source[i3 + 2])); } TestOperation( @@ -905,7 +905,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromRgba32(new Rgba32(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); + expected[i] = TPixel.FromRgba32(new(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); } TestOperation( diff --git a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs index b2790469a..c4e2fc7a2 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs @@ -69,7 +69,7 @@ public class Rg32Tests const uint expected = 0xFFFFFFFF; // act - Rg32 rg32 = Rg32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rg32 rg32 = Rg32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rg32.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index 6364378c1..22c977dcc 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -68,7 +68,7 @@ public class Rgb24Tests [Fact] public void FromRgba32() { - Rgb24 rgb = Rgb24.FromRgba32(new Rgba32(1, 2, 3, 4)); + Rgb24 rgb = Rgb24.FromRgba32(new(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -117,7 +117,7 @@ public class Rgb24Tests public void Rgb24_FromBgra5551() { // act - Rgb24 rgb = Rgb24.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgb24 rgb = Rgb24.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(255, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs index 764627ee3..cf8e2e7e9 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs @@ -65,7 +65,7 @@ public class Rgb48Tests const ushort expected = ushort.MaxValue; // act - Rgb48 rgb = Rgb48.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgb48 rgb = Rgb48.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs index 79a1aefc9..c342d0aa3 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs @@ -17,8 +17,8 @@ public class Rgba1010102Tests public void AreEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(0.0f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); + Rgba1010102 color2 = new(new(0.0f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 1f, 1f)); Rgba1010102 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Rgba1010102Tests public void AreNotEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new Vector4(1f)); - Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); + Rgba1010102 color2 = new(new(1f)); + Rgba1010102 color3 = new(new(1f, 0.0f, 0.0f, 1f)); Rgba1010102 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Rgba1010102Tests const uint expected = 0xFFFFFFFF; // act - Rgba1010102 rgba = Rgba1010102.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba1010102 rgba = Rgba1010102.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgba.PackedValue); @@ -114,7 +114,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromArgb32(new Argb32(255, 255, 255, 255)); + Rgba1010102 rgba = Rgba1010102.FromArgb32(new(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -128,8 +128,8 @@ public class Rgba1010102Tests const uint expectedPackedValue2 = 0xFFF003FF; // act - Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new Rgba32(255, 255, 255, 255)); - Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new Rgba32(255, 0, 255, 255)); + Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new(255, 255, 255, 255)); + Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, rgba1.PackedValue); @@ -143,7 +143,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -156,7 +156,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL8(new L8(byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -169,7 +169,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL16(new L16(ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -182,7 +182,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -195,7 +195,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -208,7 +208,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs index 6d56185ec..fafee5d3c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs @@ -286,7 +286,7 @@ public class Rgba32Tests const uint expected = 0xFFFFFFFF; // act - Rgba32 rgb = Rgba32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); + Rgba32 rgb = Rgba32.FromBgra5551(new(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs index 694d0ace1..e962b41fe 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs @@ -106,7 +106,7 @@ public class Rgba64Tests const ushort expected = ushort.MaxValue; // act - Rgba64 rgba = Rgba64.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Rgba64 rgba = Rgba64.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgba.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs index 5273482ef..daafabaa3 100644 --- a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs @@ -150,7 +150,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgb = RgbaVector.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + RgbaVector rgb = RgbaVector.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgb.ToScaledVector4()); @@ -163,7 +163,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL16(new L16(ushort.MaxValue)); + RgbaVector rgba = RgbaVector.FromL16(new(ushort.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); @@ -176,7 +176,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL8(new L8(byte.MaxValue)); + RgbaVector rgba = RgbaVector.FromL8(new(byte.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs index f23da0c7a..a9942220c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs @@ -36,9 +36,9 @@ public class Short2Tests [Fact] public void Short2_ToVector4() { - Assert.Equal(new Vector4(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); - Assert.Equal(new Vector4(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); - Assert.Equal(new Vector4(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); + Assert.Equal(new(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); + Assert.Equal(new(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); + Assert.Equal(new(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); } [Fact] @@ -140,7 +140,7 @@ public class Short2Tests public void Short2_FromBgra5551() { // act - Short2 short2 = Short2.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short2 short2 = Short2.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Vector4 actual = short2.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs index 819ff0e1e..fd25f5086 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs @@ -190,7 +190,7 @@ public class Short4Tests Vector4 expected = Vector4.One; // act - Short4 short4 = Short4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); + Short4 short4 = Short4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, short4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs index 9c0e83a7f..0ea429a77 100644 --- a/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/ColorMatrixTests.cs @@ -49,7 +49,7 @@ public class ColorMatrixTests ColorMatrix value1 = CreateAllTwos(); ColorMatrix value2 = CreateAllThrees(); - var m = default(ColorMatrix); + ColorMatrix m = default(ColorMatrix); // First row m.M11 = (value1.M11 * value2.M11) + (value1.M12 * value2.M21) + (value1.M13 * value2.M31) + (value1.M14 * value2.M41); diff --git a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs index ecc592326..e5162e23d 100644 --- a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -38,12 +38,12 @@ public class DenseMatrixTests [Fact] public void DenseMatrixReturnsCorrectDimensions() { - var dense = new DenseMatrix(FloydSteinbergMatrix); + DenseMatrix dense = new(FloydSteinbergMatrix); Assert.True(dense.Columns == FloydSteinbergMatrix.GetLength(1)); Assert.True(dense.Rows == FloydSteinbergMatrix.GetLength(0)); Assert.Equal(3, dense.Columns); Assert.Equal(2, dense.Rows); - Assert.Equal(new Size(3, 2), dense.Size); + Assert.Equal(new(3, 2), dense.Size); } [Fact] @@ -63,7 +63,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixGetSetReturnsCorrectResults() { - var dense = new DenseMatrix(4, 4); + DenseMatrix dense = new(4, 4); const int Val = 5; dense[3, 3] = Val; @@ -74,7 +74,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixCanFillAndClear() { - var dense = new DenseMatrix(9); + DenseMatrix dense = new(9); dense.Fill(4); for (int i = 0; i < dense.Data.Length; i++) @@ -100,7 +100,7 @@ public class DenseMatrixTests [Fact] public void DenseMatrixCanTranspose() { - var dense = new DenseMatrix(3, 1); + DenseMatrix dense = new(3, 1); dense[0, 0] = 1; dense[0, 1] = 2; dense[0, 2] = 3; @@ -117,9 +117,9 @@ public class DenseMatrixTests [Fact] public void DenseMatrixEquality() { - var dense = new DenseMatrix(3, 1); - var dense2 = new DenseMatrix(3, 1); - var dense3 = new DenseMatrix(1, 3); + DenseMatrix dense = new(3, 1); + DenseMatrix dense2 = new(3, 1); + DenseMatrix dense3 = new(1, 3); Assert.True(dense == dense2); Assert.False(dense != dense2); diff --git a/tests/ImageSharp.Tests/Primitives/PointFTests.cs b/tests/ImageSharp.Tests/Primitives/PointFTests.cs index c3d9e8176..772d8bd2d 100644 --- a/tests/ImageSharp.Tests/Primitives/PointFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointFTests.cs @@ -9,13 +9,12 @@ namespace SixLabors.ImageSharp.Tests; public class PointFTests { - private static readonly ApproximateFloatComparer ApproximateFloatComparer = - new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer ApproximateFloatComparer = new(1e-6f); [Fact] public void CanReinterpretCastFromVector2() { - var vector = new Vector2(1, 2); + Vector2 vector = new(1, 2); PointF point = Unsafe.As(ref vector); @@ -37,7 +36,7 @@ public class PointFTests [InlineData(0.0, 0.0)] public void NonDefaultConstructorTest(float x, float y) { - var p1 = new PointF(x, y); + PointF p1 = new(x, y); Assert.Equal(x, p1.X); Assert.Equal(y, p1.Y); @@ -67,7 +66,7 @@ public class PointFTests [InlineData(0, 0)] public void CoordinatesTest(float x, float y) { - var p = new PointF(x, y); + PointF p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); @@ -84,11 +83,11 @@ public class PointFTests [InlineData(0, 0, 0, 0)] public void ArithmeticTestWithSize(float x, float y, int x1, int y1) { - var p = new PointF(x, y); - var s = new Size(x1, y1); + PointF p = new(x, y); + Size s = new(x1, y1); - var addExpected = new PointF(x + x1, y + y1); - var subExpected = new PointF(x - x1, y - y1); + PointF addExpected = new(x + x1, y + y1); + PointF subExpected = new(x - x1, y - y1); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -101,11 +100,11 @@ public class PointFTests [InlineData(0, 0)] public void ArithmeticTestWithSizeF(float x, float y) { - var p = new PointF(x, y); - var s = new SizeF(y, x); + PointF p = new(x, y); + SizeF s = new(y, x); - var addExpected = new PointF(x + y, y + x); - var subExpected = new PointF(x - y, y - x); + PointF addExpected = new(x + y, y + x); + PointF subExpected = new(x - y, y - x); Assert.Equal(addExpected, p + s); Assert.Equal(subExpected, p - s); Assert.Equal(addExpected, PointF.Add(p, s)); @@ -115,10 +114,10 @@ public class PointFTests [Fact] public void RotateTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, PointF.Empty); - var pout = PointF.Transform(p, matrix); + PointF pout = PointF.Transform(p, matrix); Assert.Equal(-2.82842732F, pout.X, ApproximateFloatComparer); Assert.Equal(21.2132034F, pout.Y, ApproximateFloatComparer); @@ -127,11 +126,11 @@ public class PointFTests [Fact] public void SkewTest() { - var p = new PointF(13, 17); + PointF p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, PointF.Empty); - var pout = PointF.Transform(p, matrix); - Assert.Equal(new PointF(30, 30), pout); + PointF pout = PointF.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -142,8 +141,8 @@ public class PointFTests [InlineData(0, 0)] public void EqualityTest(float x, float y) { - var pLeft = new PointF(x, y); - var pRight = new PointF(y, x); + PointF pLeft = new(x, y); + PointF pRight = new(y, x); if (x == y) { @@ -164,7 +163,7 @@ public class PointFTests [Fact] public void EqualityTest_NotPointF() { - var point = new PointF(0, 0); + PointF point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); @@ -180,7 +179,7 @@ public class PointFTests [Fact] public void GetHashCodeTest() { - var point = new PointF(10, 10); + PointF point = new(10, 10); Assert.Equal(point.GetHashCode(), new PointF(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new PointF(10, 20).GetHashCode()); @@ -189,7 +188,7 @@ public class PointFTests [Fact] public void ToStringTest() { - var p = new PointF(5.1F, -5.123F); + PointF p = new(5.1F, -5.123F); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -200,7 +199,7 @@ public class PointFTests [InlineData(0, 0)] public void DeconstructTest(float x, float y) { - PointF p = new PointF(x, y); + PointF p = new(x, y); (float deconstructedX, float deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/PointTests.cs b/tests/ImageSharp.Tests/Primitives/PointTests.cs index f5c64abf5..8ade95eb1 100644 --- a/tests/ImageSharp.Tests/Primitives/PointTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointTests.cs @@ -21,8 +21,8 @@ public class PointTests [InlineData(0, 0)] public void NonDefaultConstructorTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(new Size(x, y)); + Point p1 = new(x, y); + Point p2 = new(new Size(x, y)); Assert.Equal(p1, p2); } @@ -33,8 +33,8 @@ public class PointTests [InlineData(0)] public void SingleIntConstructorTest(int x) { - var p1 = new Point(x); - var p2 = new Point(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); + Point p1 = new(x); + Point p2 = new(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); Assert.Equal(p1, p2); } @@ -63,7 +63,7 @@ public class PointTests [InlineData(0, 0)] public void CoordinatesTest(int x, int y) { - var p = new Point(x, y); + Point p = new(x, y); Assert.Equal(x, p.X); Assert.Equal(y, p.Y); } @@ -76,7 +76,7 @@ public class PointTests public void PointFConversionTest(int x, int y) { PointF p = new Point(x, y); - Assert.Equal(new PointF(x, y), p); + Assert.Equal(new(x, y), p); } [Theory] @@ -86,8 +86,8 @@ public class PointTests [InlineData(0, 0)] public void SizeConversionTest(int x, int y) { - var sz = (Size)new Point(x, y); - Assert.Equal(new Size(x, y), sz); + Size sz = (Size)new Point(x, y); + Assert.Equal(new(x, y), sz); } [Theory] @@ -97,13 +97,13 @@ public class PointTests [InlineData(0, 0)] public void ArithmeticTest(int x, int y) { - Point addExpected, subExpected, p = new Point(x, y); - var s = new Size(y, x); + Point addExpected, subExpected, p = new(x, y); + Size s = new(y, x); unchecked { - addExpected = new Point(x + y, y + x); - subExpected = new Point(x - y, y - x); + addExpected = new(x + y, y + x); + subExpected = new(x - y, y - x); } Assert.Equal(addExpected, p + s); @@ -119,14 +119,14 @@ public class PointTests [InlineData(0, 0)] public void PointFMathematicalTest(float x, float y) { - var pf = new PointF(x, y); + PointF pf = new(x, y); Point pCeiling, pTruncate, pRound; unchecked { - pCeiling = new Point((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); - pTruncate = new Point((int)x, (int)y); - pRound = new Point((int)MathF.Round(x), (int)MathF.Round(y)); + pCeiling = new((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); + pTruncate = new((int)x, (int)y); + pRound = new((int)MathF.Round(x), (int)MathF.Round(y)); } Assert.Equal(pCeiling, Point.Ceiling(pf)); @@ -141,8 +141,8 @@ public class PointTests [InlineData(0, 0)] public void OffsetTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point(y, x); + Point p1 = new(x, y); + Point p2 = new(y, x); p1.Offset(p2); @@ -156,22 +156,22 @@ public class PointTests [Fact] public void RotateTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateRotationDegrees(45, Point.Empty); - var pout = Point.Transform(p, matrix); + Point pout = Point.Transform(p, matrix); - Assert.Equal(new Point(-3, 21), pout); + Assert.Equal(new(-3, 21), pout); } [Fact] public void SkewTest() { - var p = new Point(13, 17); + Point p = new(13, 17); Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, Point.Empty); - var pout = Point.Transform(p, matrix); - Assert.Equal(new Point(30, 30), pout); + Point pout = Point.Transform(p, matrix); + Assert.Equal(new(30, 30), pout); } [Theory] @@ -181,9 +181,9 @@ public class PointTests [InlineData(0, 0)] public void EqualityTest(int x, int y) { - var p1 = new Point(x, y); - var p2 = new Point((x / 2) - 1, (y / 2) - 1); - var p3 = new Point(x, y); + Point p1 = new(x, y); + Point p2 = new((x / 2) - 1, (y / 2) - 1); + Point p3 = new(x, y); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -203,7 +203,7 @@ public class PointTests [Fact] public void EqualityTest_NotPoint() { - var point = new Point(0, 0); + Point point = new(0, 0); Assert.False(point.Equals(null)); Assert.False(point.Equals(0)); Assert.False(point.Equals(new PointF(0, 0))); @@ -212,7 +212,7 @@ public class PointTests [Fact] public void GetHashCodeTest() { - var point = new Point(10, 10); + Point point = new(10, 10); Assert.Equal(point.GetHashCode(), new Point(10, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(20, 10).GetHashCode()); Assert.NotEqual(point.GetHashCode(), new Point(10, 20).GetHashCode()); @@ -223,7 +223,7 @@ public class PointTests [InlineData(1, -2, 3, -4)] public void ConversionTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); + Rectangle rect = new(x, y, width, height); RectangleF rectF = rect; Assert.Equal(x, rectF.X); Assert.Equal(y, rectF.Y); @@ -234,7 +234,7 @@ public class PointTests [Fact] public void ToStringTest() { - var p = new Point(5, -5); + Point p = new(5, -5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); } @@ -245,7 +245,7 @@ public class PointTests [InlineData(0, 0)] public void DeconstructTest(int x, int y) { - Point p = new Point(x, y); + Point p = new(x, y); (int deconstructedX, int deconstructedY) = p; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs index a9b3251ca..0e8bf4f34 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs @@ -23,10 +23,10 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void NonDefaultConstructorTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); - var rect2 = new RectangleF(p, s); + RectangleF rect1 = new RectangleF(x, y, width, height); + PointF p = new PointF(x, y); + SizeF s = new SizeF(width, height); + RectangleF rect2 = new RectangleF(p, s); Assert.Equal(rect1, rect2); } @@ -38,8 +38,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void FromLTRBTest(float left, float top, float right, float bottom) { - var expected = new RectangleF(left, top, right - left, bottom - top); - var actual = RectangleF.FromLTRB(left, top, right, bottom); + RectangleF expected = new RectangleF(left, top, right - left, bottom - top); + RectangleF actual = RectangleF.FromLTRB(left, top, right, bottom); Assert.Equal(expected, actual); } @@ -51,9 +51,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void DimensionsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); + RectangleF rect = new RectangleF(x, y, width, height); + PointF p = new PointF(x, y); + SizeF s = new SizeF(width, height); Assert.Equal(p, rect.Location); Assert.Equal(s, rect.Size); @@ -84,8 +84,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void LocationSetTest(float x, float y) { - var point = new PointF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Location = point }; + PointF point = new PointF(x, y); + RectangleF rect = new RectangleF(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -96,8 +96,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void SizeSetTest(float x, float y) { - var size = new SizeF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Size = size }; + SizeF size = new SizeF(x, y); + RectangleF rect = new RectangleF(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -109,8 +109,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void EqualityTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(width, height, x, y); + RectangleF rect1 = new RectangleF(x, y, width, height); + RectangleF rect2 = new RectangleF(width, height, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -121,7 +121,7 @@ public class RectangleFTests [Fact] public void EqualityTestNotRectangleF() { - var rectangle = new RectangleF(0, 0, 0, 0); + RectangleF rectangle = new RectangleF(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); @@ -137,8 +137,8 @@ public class RectangleFTests [Fact] public void GetHashCodeTest() { - var rect1 = new RectangleF(10, 10, 10, 10); - var rect2 = new RectangleF(10, 10, 10, 10); + RectangleF rect1 = new RectangleF(10, 10, 10, 10); + RectangleF rect2 = new RectangleF(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 20, 10, 10).GetHashCode()); @@ -151,11 +151,11 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void ContainsTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new RectangleF(x, y, width, height); float x1 = (x + width) / 2; float y1 = (y + height) / 2; - var p = new PointF(x1, y1); - var r = new RectangleF(x1, y1, width / 2, height / 2); + PointF p = new PointF(x1, y1); + RectangleF r = new RectangleF(x1, y1, width / 2, height / 2); Assert.False(rect.Contains(x1, y1)); Assert.False(rect.Contains(p)); @@ -168,13 +168,13 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); - var inflatedRect = new RectangleF(x - width, y - height, width + (2 * width), height + (2 * height)); + RectangleF rect = new RectangleF(x, y, width, height); + RectangleF inflatedRect = new RectangleF(x - width, y - height, width + (2 * width), height + (2 * height)); rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new SizeF(x, y); + SizeF s = new SizeF(x, y); inflatedRect = RectangleF.Inflate(rect, x, y); rect.Inflate(s); @@ -186,9 +186,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(y, x, width, height); - var expectedRect = RectangleF.Intersect(rect1, rect2); + RectangleF rect1 = new RectangleF(x, y, width, height); + RectangleF rect2 = new RectangleF(y, x, width, height); + RectangleF expectedRect = RectangleF.Intersect(rect1, rect2); rect1.Intersect(rect2); Assert.Equal(expectedRect, rect1); Assert.False(rect1.IntersectsWith(expectedRect)); @@ -197,9 +197,9 @@ public class RectangleFTests [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new RectangleF(0, 0, 5, 5); - var rect2 = new RectangleF(1, 1, 3, 3); - var expected = new RectangleF(1, 1, 3, 3); + RectangleF rect1 = new RectangleF(0, 0, 5, 5); + RectangleF rect2 = new RectangleF(1, 1, 3, 3); + RectangleF expected = new RectangleF(1, 1, 3, 3); Assert.Equal(expected, RectangleF.Intersect(rect1, rect2)); } @@ -211,15 +211,15 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void UnionTest(float x, float y, float width, float height) { - var a = new RectangleF(x, y, width, height); - var b = new RectangleF(width, height, x, y); + RectangleF a = new RectangleF(x, y, width, height); + RectangleF b = new RectangleF(width, height, x, y); float x1 = Math.Min(a.X, b.X); float x2 = Math.Max(a.X + a.Width, b.X + b.Width); float y1 = Math.Min(a.Y, b.Y); float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); + RectangleF expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, RectangleF.Union(a, b)); } @@ -231,9 +231,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void OffsetTest(float x, float y, float width, float height) { - var r1 = new RectangleF(x, y, width, height); - var expectedRect = new RectangleF(x + width, y + height, width, height); - var p = new PointF(width, height); + RectangleF r1 = new RectangleF(x, y, width, height); + RectangleF expectedRect = new RectangleF(x + width, y + height, width, height); + PointF p = new PointF(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -246,7 +246,7 @@ public class RectangleFTests [Fact] public void ToStringTest() { - var r = new RectangleF(5, 5.1F, 1.3F, 1); + RectangleF r = new RectangleF(5, 5.1F, 1.3F, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } diff --git a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs index 2ba3a7731..2a4d64147 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs @@ -23,8 +23,8 @@ public class RectangleTests [InlineData(0, int.MinValue, 0, int.MaxValue)] public void NonDefaultConstructorTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(new Point(x, y), new Size(width, height)); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(new(x, y), new(width, height)); Assert.Equal(rect1, rect2); } @@ -36,8 +36,8 @@ public class RectangleTests [InlineData(0, int.MinValue, 0, int.MaxValue)] public void FromLTRBTest(int left, int top, int right, int bottom) { - var rect1 = new Rectangle(left, top, unchecked(right - left), unchecked(bottom - top)); - var rect2 = Rectangle.FromLTRB(left, top, right, bottom); + Rectangle rect1 = new(left, top, unchecked(right - left), unchecked(bottom - top)); + Rectangle rect2 = Rectangle.FromLTRB(left, top, right, bottom); Assert.Equal(rect1, rect2); } @@ -68,9 +68,9 @@ public class RectangleTests [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void DimensionsTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - Assert.Equal(new Point(x, y), rect.Location); - Assert.Equal(new Size(width, height), rect.Size); + Rectangle rect = new(x, y, width, height); + Assert.Equal(new(x, y), rect.Location); + Assert.Equal(new(width, height), rect.Size); Assert.Equal(x, rect.X); Assert.Equal(y, rect.Y); @@ -81,8 +81,8 @@ public class RectangleTests Assert.Equal(unchecked(x + width), rect.Right); Assert.Equal(unchecked(y + height), rect.Bottom); - var p = new Point(width, height); - var s = new Size(x, y); + Point p = new(width, height); + Size s = new(x, y); rect.Location = p; rect.Size = s; @@ -104,8 +104,8 @@ public class RectangleTests [InlineData(int.MaxValue, int.MinValue)] public void LocationSetTest(int x, int y) { - var point = new Point(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Location = point }; + Point point = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -116,8 +116,8 @@ public class RectangleTests [InlineData(int.MaxValue, int.MinValue)] public void SizeSetTest(int x, int y) { - var size = new Size(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Size = size }; + Size size = new(x, y); + Rectangle rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -130,8 +130,8 @@ public class RectangleTests [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] public void EqualityTest(int x, int y, int width, int height) { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(width / 2, height / 2, x, y); + Rectangle rect1 = new(x, y, width, height); + Rectangle rect2 = new(width / 2, height / 2, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -142,7 +142,7 @@ public class RectangleTests [Fact] public void EqualityTestNotRectangle() { - var rectangle = new Rectangle(0, 0, 0, 0); + Rectangle rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); Assert.False(rectangle.Equals(new RectangleF(0, 0, 0, 0))); @@ -151,8 +151,8 @@ public class RectangleTests [Fact] public void GetHashCodeTest() { - var rect1 = new Rectangle(10, 10, 10, 10); - var rect2 = new Rectangle(10, 10, 10, 10); + Rectangle rect1 = new(10, 10, 10, 10); + Rectangle rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 20, 10, 10).GetHashCode()); @@ -166,20 +166,20 @@ public class RectangleTests [InlineData(0, 0, 0, 0)] public void RectangleFConversionTest(float x, float y, float width, float height) { - var rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); Rectangle rCeiling, rTruncate, rRound; unchecked { - rCeiling = new Rectangle( + rCeiling = new( (int)Math.Ceiling(x), (int)Math.Ceiling(y), (int)Math.Ceiling(width), (int)Math.Ceiling(height)); - rTruncate = new Rectangle((int)x, (int)y, (int)width, (int)height); + rTruncate = new((int)x, (int)y, (int)width, (int)height); - rRound = new Rectangle( + rRound = new( (int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(width), @@ -196,9 +196,9 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void ContainsTest(int x, int y, int width, int height) { - var rect = new Rectangle(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); - var p = new Point(x, y); - var r = new Rectangle(x, y, width / 2, height / 2); + Rectangle rect = new(unchecked((2 * x) - width), unchecked((2 * y) - height), width, height); + Point p = new(x, y); + Rectangle r = new(x, y, width / 2, height / 2); Assert.False(rect.Contains(x, y)); Assert.False(rect.Contains(p)); @@ -211,10 +211,10 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void InflateTest(int x, int y, int width, int height) { - Rectangle inflatedRect, rect = new Rectangle(x, y, width, height); + Rectangle inflatedRect, rect = new(x, y, width, height); unchecked { - inflatedRect = new Rectangle(x - width, y - height, width + (2 * width), height + (2 * height)); + inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); } Assert.Equal(inflatedRect, Rectangle.Inflate(rect, width, height)); @@ -222,10 +222,10 @@ public class RectangleTests rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - var s = new Size(x, y); + Size s = new(x, y); unchecked { - inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); + inflatedRect = new(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); } rect.Inflate(s); @@ -238,8 +238,8 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void IntersectTest(int x, int y, int width, int height) { - var rect = new Rectangle(x, y, width, height); - var expectedRect = Rectangle.Intersect(rect, rect); + Rectangle rect = new(x, y, width, height); + Rectangle expectedRect = Rectangle.Intersect(rect, rect); rect.Intersect(rect); Assert.Equal(expectedRect, rect); Assert.False(rect.IntersectsWith(expectedRect)); @@ -248,9 +248,9 @@ public class RectangleTests [Fact] public void IntersectIntersectingRectsTest() { - var rect1 = new Rectangle(0, 0, 5, 5); - var rect2 = new Rectangle(1, 1, 3, 3); - var expected = new Rectangle(1, 1, 3, 3); + Rectangle rect1 = new(0, 0, 5, 5); + Rectangle rect2 = new(1, 1, 3, 3); + Rectangle expected = new(1, 1, 3, 3); Assert.Equal(expected, Rectangle.Intersect(rect1, rect2)); } @@ -262,15 +262,15 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void UnionTest(int x, int y, int width, int height) { - var a = new Rectangle(x, y, width, height); - var b = new Rectangle(width, height, x, y); + Rectangle a = new(x, y, width, height); + Rectangle b = new(width, height, x, y); int x1 = Math.Min(a.X, b.X); int x2 = Math.Max(a.X + a.Width, b.X + b.Width); int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - var expectedRectangle = new Rectangle(x1, y1, x2 - x1, y2 - y1); + Rectangle expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, Rectangle.Union(a, b)); } @@ -282,9 +282,9 @@ public class RectangleTests [InlineData(0, int.MinValue, int.MaxValue, 0)] public void OffsetTest(int x, int y, int width, int height) { - var r1 = new Rectangle(x, y, width, height); - var expectedRect = new Rectangle(x + width, y + height, width, height); - var p = new Point(width, height); + Rectangle r1 = new(x, y, width, height); + Rectangle expectedRect = new(x + width, y + height, width, height); + Point p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -297,7 +297,7 @@ public class RectangleTests [Fact] public void ToStringTest() { - var r = new Rectangle(5, -5, 0, 1); + Rectangle r = new(5, -5, 0, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -321,7 +321,7 @@ public class RectangleTests [InlineData(0, 0, 0, 0)] public void DeconstructTest(int x, int y, int width, int height) { - var r = new Rectangle(x, y, width, height); + Rectangle r = new(x, y, width, height); (int dx, int dy, int dw, int dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs index 1a36b4921..246f21b1e 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs @@ -20,13 +20,13 @@ public class SizeFTests [InlineData(0, 0)] public void NonDefaultConstructorAndDimensionsTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = new PointF(width, height); - var s2 = new SizeF(s1); + SizeF s1 = new(width, height); + PointF p1 = new(width, height); + SizeF s2 = new(s1); Assert.Equal(s1, s2); - Assert.Equal(s1, new SizeF(p1)); - Assert.Equal(s2, new SizeF(p1)); + Assert.Equal(s1, new(p1)); + Assert.Equal(s2, new(p1)); Assert.Equal(width, s1.Width); Assert.Equal(height, s1.Height); @@ -62,10 +62,10 @@ public class SizeFTests [InlineData(0, 0)] public void ArithmeticTest(float width, float height) { - var s1 = new SizeF(width, height); - var s2 = new SizeF(height, width); - var addExpected = new SizeF(width + height, width + height); - var subExpected = new SizeF(width - height, height - width); + SizeF s1 = new(width, height); + SizeF s2 = new(height, width); + SizeF addExpected = new(width + height, width + height); + SizeF subExpected = new(width - height, height - width); Assert.Equal(addExpected, s1 + s2); Assert.Equal(addExpected, SizeF.Add(s1, s2)); @@ -81,8 +81,8 @@ public class SizeFTests [InlineData(0, 0)] public void EqualityTest(float width, float height) { - var sLeft = new SizeF(width, height); - var sRight = new SizeF(height, width); + SizeF sLeft = new(width, height); + SizeF sRight = new(height, width); if (width == height) { @@ -103,7 +103,7 @@ public class SizeFTests [Fact] public void EqualityTest_NotSizeF() { - var size = new SizeF(0, 0); + SizeF size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); @@ -119,7 +119,7 @@ public class SizeFTests [Fact] public void GetHashCodeTest() { - var size = new SizeF(10, 10); + SizeF size = new(10, 10); Assert.Equal(size.GetHashCode(), new SizeF(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new SizeF(10, 20).GetHashCode()); @@ -132,11 +132,11 @@ public class SizeFTests [InlineData(0, 0)] public void ConversionTest(float width, float height) { - var s1 = new SizeF(width, height); - var p1 = (PointF)s1; - var s2 = new Size(unchecked((int)width), unchecked((int)height)); + SizeF s1 = new(width, height); + PointF p1 = (PointF)s1; + Size s2 = new(unchecked((int)width), unchecked((int)height)); - Assert.Equal(new PointF(width, height), p1); + Assert.Equal(new(width, height), p1); Assert.Equal(p1, (PointF)s1); Assert.Equal(s2, (Size)s1); } @@ -144,7 +144,7 @@ public class SizeFTests [Fact] public void ToStringTest() { - var sz = new SizeF(10, 5); + SizeF sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "SizeF [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -172,10 +172,10 @@ public class SizeFTests [InlineData(float.MinValue, float.MinValue)] public void MultiplicationTest(float dimension, float multiplier) { - SizeF sz1 = new SizeF(dimension, dimension); + SizeF sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -185,10 +185,10 @@ public class SizeFTests [InlineData(1111.1111f, 2222.2222f, 3333.3333f)] public void MultiplicationTestWidthHeightMultiplier(float width, float height, float multiplier) { - SizeF sz1 = new SizeF(width, height); + SizeF sz1 = new(width, height); SizeF mulExpected; - mulExpected = new SizeF(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -215,8 +215,8 @@ public class SizeFTests [InlineData(-1.0f, float.MaxValue)] public void DivideTestSizeFloat(float dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); - SizeF expected = new SizeF(dimension / divisor, dimension / divisor); + SizeF size = new(dimension, dimension); + SizeF expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -224,8 +224,8 @@ public class SizeFTests [InlineData(-111.111f, 222.222f, 333.333f)] public void DivideTestSizeFloatWidthHeightDivisor(float width, float height, float divisor) { - SizeF size = new SizeF(width, height); - SizeF expected = new SizeF(width / divisor, height / divisor); + SizeF size = new(width, height); + SizeF expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -236,7 +236,7 @@ public class SizeFTests [InlineData(0, 0)] public void DeconstructTest(float width, float height) { - SizeF s = new SizeF(width, height); + SizeF s = new(width, height); (float deconstructedWidth, float deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Primitives/SizeTests.cs b/tests/ImageSharp.Tests/Primitives/SizeTests.cs index eec1fb63b..6b366e183 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeTests.cs @@ -23,8 +23,8 @@ public class SizeTests [InlineData(0, 0)] public void NonDefaultConstructorTest(int width, int height) { - var s1 = new Size(width, height); - var s2 = new Size(new Point(width, height)); + Size s1 = new(width, height); + Size s2 = new(new Point(width, height)); Assert.Equal(s1, s2); @@ -59,7 +59,7 @@ public class SizeTests [InlineData(0, 0)] public void DimensionsTest(int width, int height) { - var p = new Size(width, height); + Size p = new(width, height); Assert.Equal(width, p.Width); Assert.Equal(height, p.Height); } @@ -72,7 +72,7 @@ public class SizeTests public void PointFConversionTest(int width, int height) { SizeF sz = new Size(width, height); - Assert.Equal(new SizeF(width, height), sz); + Assert.Equal(new(width, height), sz); } [Theory] @@ -82,8 +82,8 @@ public class SizeTests [InlineData(0, 0)] public void SizeConversionTest(int width, int height) { - var sz = (Point)new Size(width, height); - Assert.Equal(new Point(width, height), sz); + Point sz = (Point)new Size(width, height); + Assert.Equal(new(width, height), sz); } [Theory] @@ -93,14 +93,14 @@ public class SizeTests [InlineData(0, 0)] public void ArithmeticTest(int width, int height) { - var sz1 = new Size(width, height); - var sz2 = new Size(height, width); + Size sz1 = new(width, height); + Size sz2 = new(height, width); Size addExpected, subExpected; unchecked { - addExpected = new Size(width + height, height + width); - subExpected = new Size(width - height, height - width); + addExpected = new(width + height, height + width); + subExpected = new(width - height, height - width); } Assert.Equal(addExpected, sz1 + sz2); @@ -116,14 +116,14 @@ public class SizeTests [InlineData(0, 0)] public void PointFMathematicalTest(float width, float height) { - var szF = new SizeF(width, height); + SizeF szF = new(width, height); Size pCeiling, pTruncate, pRound; unchecked { - pCeiling = new Size((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); - pTruncate = new Size((int)width, (int)height); - pRound = new Size((int)MathF.Round(width), (int)MathF.Round(height)); + pCeiling = new((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); + pTruncate = new((int)width, (int)height); + pRound = new((int)MathF.Round(width), (int)MathF.Round(height)); } Assert.Equal(pCeiling, Size.Ceiling(szF)); @@ -138,9 +138,9 @@ public class SizeTests [InlineData(0, 0)] public void EqualityTest(int width, int height) { - var p1 = new Size(width, height); - var p2 = new Size(unchecked(width - 1), unchecked(height - 1)); - var p3 = new Size(width, height); + Size p1 = new(width, height); + Size p2 = new(unchecked(width - 1), unchecked(height - 1)); + Size p3 = new(width, height); Assert.True(p1 == p3); Assert.True(p1 != p2); @@ -160,7 +160,7 @@ public class SizeTests [Fact] public void EqualityTest_NotSize() { - var size = new Size(0, 0); + Size size = new(0, 0); Assert.False(size.Equals(null)); Assert.False(size.Equals(0)); Assert.False(size.Equals(new SizeF(0, 0))); @@ -169,7 +169,7 @@ public class SizeTests [Fact] public void GetHashCodeTest() { - var size = new Size(10, 10); + Size size = new(10, 10); Assert.Equal(size.GetHashCode(), new Size(10, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(20, 10).GetHashCode()); Assert.NotEqual(size.GetHashCode(), new Size(10, 20).GetHashCode()); @@ -178,7 +178,7 @@ public class SizeTests [Fact] public void ToStringTest() { - var sz = new Size(10, 5); + Size sz = new(10, 5); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Size [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); } @@ -206,12 +206,12 @@ public class SizeTests [InlineData(int.MinValue, int.MinValue)] public void MultiplicationTestSizeInt(int dimension, int multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); Size mulExpected; unchecked { - mulExpected = new Size(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -222,12 +222,12 @@ public class SizeTests [InlineData(1000, 2000, 3000)] public void MultiplicationTestSizeIntWidthHeightMultiplier(int width, int height, int multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); Size mulExpected; unchecked { - mulExpected = new Size(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -258,10 +258,10 @@ public class SizeTests [InlineData(int.MinValue, float.MinValue)] public void MultiplicationTestSizeFloat(int dimension, float multiplier) { - Size sz1 = new Size(dimension, dimension); + Size sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); + mulExpected = new(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -271,10 +271,10 @@ public class SizeTests [InlineData(1000, 2000, 30.33f)] public void MultiplicationTestSizeFloatWidthHeightMultiplier(int width, int height, float multiplier) { - Size sz1 = new Size(width, height); + Size sz1 = new(width, height); SizeF mulExpected; - mulExpected = new SizeF(width * multiplier, height * multiplier); + mulExpected = new(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -283,10 +283,10 @@ public class SizeTests [Fact] public void DivideByZeroChecks() { - Size size = new Size(100, 100); + Size size = new(100, 100); Assert.Throws(() => size / 0); - SizeF expectedSizeF = new SizeF(float.PositiveInfinity, float.PositiveInfinity); + SizeF expectedSizeF = new(float.PositiveInfinity, float.PositiveInfinity); Assert.Equal(expectedSizeF, size / 0.0f); } @@ -305,10 +305,10 @@ public class SizeTests [InlineData(int.MaxValue, -1)] public void DivideTestSizeInt(int dimension, int divisor) { - Size size = new Size(dimension, dimension); + Size size = new(dimension, dimension); Size expected; - expected = new Size(dimension / divisor, dimension / divisor); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -317,10 +317,10 @@ public class SizeTests [InlineData(1111, 2222, 3333)] public void DivideTestSizeIntWidthHeightDivisor(int width, int height, int divisor) { - Size size = new Size(width, height); + Size size = new(width, height); Size expected; - expected = new Size(width / divisor, height / divisor); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -341,10 +341,10 @@ public class SizeTests [InlineData(int.MinValue, -1.0f)] public void DivideTestSizeFloat(int dimension, float divisor) { - SizeF size = new SizeF(dimension, dimension); + SizeF size = new(dimension, dimension); SizeF expected; - expected = new SizeF(dimension / divisor, dimension / divisor); + expected = new(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -352,10 +352,10 @@ public class SizeTests [InlineData(1111, 2222, -333.33f)] public void DivideTestSizeFloatWidthHeightDivisor(int width, int height, float divisor) { - SizeF size = new SizeF(width, height); + SizeF size = new(width, height); SizeF expected; - expected = new SizeF(width / divisor, height / divisor); + expected = new(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -366,7 +366,7 @@ public class SizeTests [InlineData(0, 0)] public void DeconstructTest(int width, int height) { - Size s = new Size(width, height); + Size s = new(width, height); (int deconstructedWidth, int deconstructedHeight) = s; diff --git a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs index 5e5887c92..1b8388eba 100644 --- a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs @@ -18,10 +18,10 @@ public abstract class BaseImageOperationsExtensionTest : IDisposable public BaseImageOperationsExtensionTest() { - this.options = new GraphicsOptions { Antialias = false }; - this.source = new Image(91 + 324, 123 + 56); - this.rect = new Rectangle(91, 123, 324, 56); // make this random? - this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations(this.source.Configuration, this.source, false); + this.options = new() { Antialias = false }; + this.source = new(91 + 324, 123 + 56); + this.rect = new(91, 123, 324, 56); // make this random? + this.internalOperations = new(this.source.Configuration, this.source, false); this.internalOperations.SetGraphicsOptions(this.options); this.operations = this.internalOperations; } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index da2bc465f..2337e4567 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -13,7 +13,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(7, processor.Radius); } @@ -22,7 +22,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_amount_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(34); - var processor = this.Verify(); + BoxBlurProcessor processor = this.Verify(); Assert.Equal(34, processor.Radius); } @@ -31,7 +31,7 @@ public class BoxBlurTest : BaseImageOperationsExtensionTest public void BoxBlur_amount_rect_BoxBlurProcessorDefaultsSet() { this.operations.BoxBlur(5, this.rect); - var processor = this.Verify(this.rect); + BoxBlurProcessor processor = this.Verify(this.rect); Assert.Equal(5, processor.Radius); } diff --git a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs index 476e5b0a9..2cf1c744d 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs @@ -11,9 +11,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 0, 0, 0, 1, 2, @@ -30,9 +30,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 2, 1, 0, 1, 2, @@ -49,9 +49,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 1, 0, 0, 1, 2, @@ -68,9 +68,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 5, 6, 0, 1, 2, @@ -87,9 +87,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9BounceBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 3, 2, 1, 2, 3, @@ -108,9 +108,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9MirrorBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 2, 1, 1, 2, 3, @@ -129,9 +129,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9WrapBorder() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(1, 1, 9, 9); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(1, 1, 9, 9); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 8, 9, 1, 2, 3, @@ -150,9 +150,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 2, 2, 2, 3, 4, @@ -169,9 +169,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 4, 3, 2, 3, 4, @@ -188,9 +188,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 3, 2, 2, 3, 4, @@ -207,9 +207,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorderTile() { - var kernelSize = new Size(5, 5); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(5, 5); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 7, 8, 2, 3, 4, @@ -226,9 +226,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 0, 0, 1, @@ -245,9 +245,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7BounceBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 1, 0, 1, @@ -264,9 +264,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7MirrorBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 0, 0, 1, @@ -283,9 +283,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorder() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(0, 0, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(0, 0, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 6, 0, 1, @@ -302,9 +302,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Repeat; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { 2, 2, 3, @@ -321,9 +321,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7BounceBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Bounce; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { 3, 2, 3, @@ -340,9 +340,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7MirrorBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Mirror; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { 2, 2, 3, @@ -359,9 +359,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 7); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(2, 2, 7, 7); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { 8, 2, 3, @@ -378,9 +378,9 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x5WrapBorderTile() { - var kernelSize = new Size(3, 3); - var bounds = new Rectangle(2, 2, 7, 5); - var mode = BorderWrappingMode.Wrap; + Size kernelSize = new Size(3, 3); + Rectangle bounds = new Rectangle(2, 2, 7, 5); + BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] xExpected = { 8, 2, 3, @@ -405,15 +405,15 @@ public class KernelSamplingMapTest private void AssertOffsets(Size kernelSize, Rectangle bounds, BorderWrappingMode xBorderMode, BorderWrappingMode yBorderMode, int[] xExpected, int[] yExpected) { // Arrange - var map = new KernelSamplingMap(Configuration.Default.MemoryAllocator); + KernelSamplingMap map = new KernelSamplingMap(Configuration.Default.MemoryAllocator); // Act map.BuildSamplingOffsetMap(kernelSize.Height, kernelSize.Width, bounds, xBorderMode, yBorderMode); // Assert - var xOffsets = map.GetColumnOffsetSpan().ToArray(); + int[] xOffsets = map.GetColumnOffsetSpan().ToArray(); Assert.Equal(xExpected, xOffsets); - var yOffsets = map.GetRowOffsetSpan().ToArray(); + int[] yOffsets = map.GetRowOffsetSpan().ToArray(); Assert.Equal(yExpected, yOffsets); } } diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 6d5973dbb..b24ab6c81 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -13,7 +13,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -23,7 +23,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(10, processor.Levels); Assert.Equal(15, processor.BrushSize); @@ -33,7 +33,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_Levels_Brush_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(34, 65); - var processor = this.Verify(); + OilPaintingProcessor processor = this.Verify(); Assert.Equal(34, processor.Levels); Assert.Equal(65, processor.BrushSize); @@ -43,7 +43,7 @@ public class OilPaintTest : BaseImageOperationsExtensionTest public void OilPaint_Levels_Brush_rect_OilPaintingProcessorDefaultsSet() { this.operations.OilPaint(54, 43, this.rect); - var processor = this.Verify(this.rect); + OilPaintingProcessor processor = this.Verify(this.rect); Assert.Equal(54, processor.Levels); Assert.Equal(43, processor.BrushSize); diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 6531f7b44..f557183d6 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -13,7 +13,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_PixelateProcessorDefaultsSet() { this.operations.Pixelate(); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(4, processor.Size); } @@ -22,7 +22,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_Size_PixelateProcessorDefaultsSet() { this.operations.Pixelate(12); - var processor = this.Verify(); + PixelateProcessor processor = this.Verify(); Assert.Equal(12, processor.Size); } @@ -31,7 +31,7 @@ public class PixelateTest : BaseImageOperationsExtensionTest public void Pixelate_Size_rect_PixelateProcessorDefaultsSet() { this.operations.Pixelate(23, this.rect); - var processor = this.Verify(this.rect); + PixelateProcessor processor = this.Verify(this.rect); Assert.Equal(23, processor.Size); } diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 17f63384e..8b2411bf2 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing; internal class FakeImageOperationsProvider : IImageProcessingContextFactory { - private readonly List imageOperators = new List(); + private readonly List imageOperators = new(); public bool HasCreated(Image source) where TPixel : unmanaged, IPixel @@ -35,7 +35,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IInternalImageProcessingContext CreateImageProcessingContext(Configuration configuration, Image source, bool mutate) where TPixel : unmanaged, IPixel { - var op = new FakeImageOperations(configuration, source, mutate); + FakeImageOperations op = new(configuration, source, mutate); this.imageOperators.Add(op); return op; } @@ -51,7 +51,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public Image Source { get; } - public List Applied { get; } = new List(); + public List Applied { get; } = new(); public Configuration Configuration { get; } @@ -69,7 +69,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new AppliedOperation + this.Applied.Add(new() { NonGenericProcessor = processor }); diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 87436e4a3..9cfc3a3f0 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -31,28 +31,28 @@ public class BrightnessTest : BaseImageOperationsExtensionTest [Fact] public void Brightness_scaled_vector() { - var rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); + Image rgbImage = new(Configuration.Default, 100, 100, new Rgb24(0, 0, 0)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new Rgb24(0, 0, 0), rgbImage[0, 0]); + Assert.Equal(new(0, 0, 0), rgbImage[0, 0]); - rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); + rgbImage = new(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]); + Assert.Equal(new(20, 20, 20), rgbImage[0, 0]); - var halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-1)); + Image halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-1)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new HalfSingle(-1), halfSingleImage[0, 0]); + Assert.Equal(new(-1), halfSingleImage[0, 0]); - halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); + halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new HalfSingle(0), halfSingleImage[0, 0]); + Assert.Equal(new(0), halfSingleImage[0, 0]); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs index 0c197a96f..33deb715b 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/HueTest.cs @@ -13,7 +13,7 @@ public class HueTest : BaseImageOperationsExtensionTest public void Hue_amount_HueProcessorDefaultsSet() { this.operations.Hue(34f); - var processor = this.Verify(); + HueProcessor processor = this.Verify(); Assert.Equal(34f, processor.Degrees); } @@ -22,7 +22,7 @@ public class HueTest : BaseImageOperationsExtensionTest public void Hue_amount_rect_HueProcessorDefaultsSet() { this.operations.Hue(5f, this.rect); - var processor = this.Verify(this.rect); + HueProcessor processor = this.Verify(this.rect); Assert.Equal(5f, processor.Degrees); } diff --git a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs index e84bd243e..f68ecef08 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/LomographTest.cs @@ -13,7 +13,7 @@ public class LomographTest : BaseImageOperationsExtensionTest public void Lomograph_amount_LomographProcessorDefaultsSet() { this.operations.Lomograph(); - var processor = this.Verify(); + LomographProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public class LomographTest : BaseImageOperationsExtensionTest public void Lomograph_amount_rect_LomographProcessorDefaultsSet() { this.operations.Lomograph(this.rect); - var processor = this.Verify(this.rect); + LomographProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs index 7d3e0aed0..89d8d47bc 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/PolaroidTest.cs @@ -13,7 +13,7 @@ public class PolaroidTest : BaseImageOperationsExtensionTest public void Polaroid_amount_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(); - var processor = this.Verify(); + PolaroidProcessor processor = this.Verify(); Assert.Equal(processor.GraphicsOptions, this.options); } @@ -21,7 +21,7 @@ public class PolaroidTest : BaseImageOperationsExtensionTest public void Polaroid_amount_rect_PolaroidProcessorDefaultsSet() { this.operations.Polaroid(this.rect); - var processor = this.Verify(this.rect); + PolaroidProcessor processor = this.Verify(this.rect); Assert.Equal(processor.GraphicsOptions, this.options); } } diff --git a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs index 744e26d8f..d53dc74b9 100644 --- a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs @@ -22,13 +22,13 @@ public class ImageOperationTests : IDisposable public ImageOperationTests() { - this.provider = new FakeImageOperationsProvider(); + this.provider = new(); - var processorMock = new Mock(); + Mock processorMock = new(); this.processorDefinition = processorMock.Object; - this.image = new Image( - new Configuration + this.image = new( + new() { ImageOperationsProvider = this.provider }, @@ -103,7 +103,7 @@ public class ImageOperationTests : IDisposable [Fact] public void ApplyProcessors_ListOfProcessors_AppliesAllProcessorsToOperation() { - var operations = new FakeImageOperationsProvider.FakeImageOperations(Configuration.Default, null, false); + FakeImageOperationsProvider.FakeImageOperations operations = new(Configuration.Default, null, false); operations.ApplyProcessors(this.processorDefinition); Assert.Contains(this.processorDefinition, operations.Applied.Select(x => x.NonGenericProcessor)); } @@ -152,7 +152,7 @@ public class ImageOperationTests : IDisposable { try { - var img = new Image(1, 1); + Image img = new(1, 1); img.Dispose(); img.EnsureNotDisposed(); } diff --git a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs index 88707c60f..06eb90005 100644 --- a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs @@ -23,18 +23,18 @@ public class ImageProcessingContextTests : IDisposable private readonly Mock> cloningProcessorImpl; - private static readonly Rectangle Bounds = new Rectangle(3, 3, 5, 5); + private static readonly Rectangle Bounds = new(3, 3, 5, 5); public ImageProcessingContextTests() { - this.processorDefinition = new Mock(); - this.cloningProcessorDefinition = new Mock(); - this.regularProcessorImpl = new Mock>(); - this.cloningProcessorImpl = new Mock>(); + this.processorDefinition = new(); + this.cloningProcessorDefinition = new(); + this.regularProcessorImpl = new(); + this.cloningProcessorImpl = new(); } // bool throwException, bool useBounds - public static readonly TheoryData ProcessorTestData = new TheoryData() + public static readonly TheoryData ProcessorTestData = new() { { false, false }, { false, true }, diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index 60e33835a..e37cd5db1 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -32,14 +32,14 @@ public class HistogramEqualizationTests 70, 87, 69, 68, 65, 73, 78, 90 }; - using (var image = new Image(8, 8)) + using (Image image = new(8, 8)) { for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { byte luminance = pixels[(y * 8) + x]; - image[x, y] = new Rgba32(luminance, luminance, luminance); + image[x, y] = new(luminance, luminance, luminance); } } @@ -56,7 +56,7 @@ public class HistogramEqualizationTests }; // Act - image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions + image.Mutate(x => x.HistogramEqualization(new() { LuminanceLevels = luminanceLevels, Method = HistogramEqualizationMethod.Global @@ -83,7 +83,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.Global, LuminanceLevels = 256, @@ -101,7 +101,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveSlidingWindow, LuminanceLevels = 256, @@ -121,7 +121,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -141,7 +141,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -160,7 +160,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AutoLevel, LuminanceLevels = 256, @@ -187,7 +187,7 @@ public class HistogramEqualizationTests { using (Image image = provider.GetImage()) { - var options = new HistogramEqualizationOptions() + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 256, @@ -214,7 +214,7 @@ public class HistogramEqualizationTests // https://github.com/SixLabors/ImageSharp/discussions/1640 // Test using isolated memory to ensure clean buffers for reference provider.Configuration = Configuration.CreateDefaultInstance(); - var options = new HistogramEqualizationOptions + HistogramEqualizationOptions options = new() { Method = HistogramEqualizationMethod.AdaptiveTileInterpolation, LuminanceLevels = 4096, diff --git a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs index 2b609a9b2..50c177cc0 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs @@ -49,7 +49,7 @@ public class MagickCompareTests ?? throw new InvalidOperationException("CompareToMagick() works only with file providers!"); TestFile testFile = TestFile.Create(path); - return new FileStream(testFile.FullPath, FileMode.Open); + return new(testFile.FullPath, FileMode.Open); } private static Image ConvertImageFromMagick(MagickImage magickImage) diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index 7eec6eb0c..be9263334 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -45,7 +45,7 @@ public class GlowTest : BaseImageOperationsExtensionTest [Fact] public void Glow_Rect_GlowProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new Rectangle(12, 123, 43, 65); this.operations.Glow(rect); GlowProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 1602b5c7a..14dcc7438 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -48,7 +48,7 @@ public class VignetteTest : BaseImageOperationsExtensionTest [Fact] public void Vignette_Rect_VignetteProcessorWithDefaultValues() { - var rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new Rectangle(12, 123, 43, 65); this.operations.Vignette(rect); VignetteProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 9694aeb22..18f62c171 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -102,7 +102,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultDitherer, bounds)); image.DebugSave(provider); @@ -119,7 +119,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultErrorDiffuser, bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index ecbbb21ab..a94c75975 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -46,7 +46,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, bounds)); image.DebugSave(provider, value); @@ -76,7 +76,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.Saturation, bounds)); image.DebugSave(provider, value); @@ -96,7 +96,7 @@ public class BinaryThresholdTest if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else @@ -114,14 +114,14 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - var bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.MaxChroma, bounds)); image.DebugSave(provider, value); if (!TestEnvironment.Is64BitProcess && TestEnvironment.IsFramework) { - var comparer = ImageComparer.TolerantPercentage(0.0004F); + ImageComparer comparer = ImageComparer.TolerantPercentage(0.0004F); image.CompareToReferenceOutput(comparer, provider, value.ToString("0.00", NumberFormatInfo.InvariantInfo)); } else diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index f045c981e..9c1ffbbef 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -108,9 +108,9 @@ public class BokehBlurTest public static readonly TheoryData BokehBlurValues = new() { - new BokehBlurInfo { Radius = 8, Components = 1, Gamma = 1 }, - new BokehBlurInfo { Radius = 16, Components = 1, Gamma = 3 }, - new BokehBlurInfo { Radius = 16, Components = 2, Gamma = 3 } + new() { Radius = 8, Components = 1, Gamma = 1 }, + new() { Radius = 16, Components = 1, Gamma = 3 }, + new() { Radius = 16, Components = 2, Gamma = 3 } }; public static readonly string[] TestFiles = diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index d51012f9e..2da74377a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -55,7 +55,7 @@ public class DetectEdgesTest ctx => { Size size = ctx.GetCurrentSize(); - var bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); + Rectangle bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); ctx.DetectEdges(bounds); }, comparer: OpaqueComparer, @@ -158,7 +158,7 @@ public class DetectEdgesTest { using (Image image = provider.GetImage()) { - var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.DetectEdges(bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index b8e968f73..9e47f54cc 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -101,7 +101,7 @@ public class DitherTests } // Increased tolerance because of compatibility issues on .NET 4.6.2: - var comparer = ImageComparer.TolerantPercentage(1f); + ImageComparer comparer = ImageComparer.TolerantPercentage(1f); provider.RunValidatingProcessorTest(x => x.Dither(DefaultErrorDiffuser), comparer: comparer); } @@ -186,7 +186,7 @@ public class DitherTests { void Command() { - using var image = new Image(10, 10); + using Image image = new Image(10, 10); image.Mutate(x => x.Dither(dither)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 10811a559..06d3850a4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -11,8 +11,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class OilPaintTest { - public static readonly TheoryData OilPaintValues = new TheoryData - { + public static readonly TheoryData OilPaintValues = new() + { { 15, 10 }, { 6, 5 } }; @@ -49,7 +49,7 @@ public class OilPaintTest [Fact] public void Issue2518_PixelComponentOutsideOfRange_ThrowsImageProcessingException() { - using Image image = new(10, 10, new RgbaVector(1, 1, 100)); + using Image image = new(10, 10, new(1, 1, 100)); Assert.Throws(() => image.Mutate(ctx => ctx.OilPaint())); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index fd732f570..963394e7d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -24,7 +24,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }), appendPixelTypeToFileName: false); @@ -43,7 +43,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new Vector4(avg); + span[i] = new(avg); } }, rect)); @@ -71,7 +71,7 @@ public class PixelShaderTest Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } @@ -101,7 +101,7 @@ public class PixelShaderTest Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - var gray = new Vector4(avg, avg, avg, a); + Vector4 gray = new(avg, avg, avg, a); span[i] = Vector4.Clamp(gray, Vector4.Zero, Vector4.One); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs index c6880d3a8..cabfe3059 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs @@ -13,24 +13,24 @@ public class OctreeQuantizerTests [Fact] public void OctreeQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new OctreeQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + OctreeQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new OctreeQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -38,7 +38,7 @@ public class OctreeQuantizerTests [Fact] public void OctreeQuantizerCanCreateFrameQuantizer() { - var quantizer = new OctreeQuantizer(); + OctreeQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -46,14 +46,14 @@ public class OctreeQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index 91cf90bc4..ed9254605 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -15,24 +15,24 @@ public class PaletteQuantizerTests [Fact] public void PaletteQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new PaletteQuantizer(Palette, expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + PaletteQuantizer quantizer = new(Palette, expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = null }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new PaletteQuantizer(Palette, expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(Palette, expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -40,7 +40,7 @@ public class PaletteQuantizerTests [Fact] public void PaletteQuantizerCanCreateFrameQuantizer() { - var quantizer = new PaletteQuantizer(Palette); + PaletteQuantizer quantizer = new(Palette); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -48,14 +48,14 @@ public class PaletteQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = null }); + quantizer = new(Palette, new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(Palette, new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs index ab4304d89..6e43fe252 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs @@ -13,24 +13,24 @@ public class WuQuantizerTests [Fact] public void WuQuantizerConstructor() { - var expected = new QuantizerOptions { MaxColors = 128 }; - var quantizer = new WuQuantizer(expected); + QuantizerOptions expected = new() { MaxColors = 128 }; + WuQuantizer quantizer = new(expected); Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = null }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = null }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new WuQuantizer(expected); + expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -38,7 +38,7 @@ public class WuQuantizerTests [Fact] public void WuQuantizerCanCreateFrameQuantizer() { - var quantizer = new WuQuantizer(); + WuQuantizer quantizer = new(); IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); @@ -46,14 +46,14 @@ public class WuQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); + quantizer = new(new() { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new WuQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); + quantizer = new(new() { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index a7855e23a..34a8b1e58 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -213,7 +213,7 @@ public class AffineTransformTests public void Issue1911() { using Image image = new(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix3x2.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix3x2.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -227,7 +227,7 @@ public class AffineTransformTests using Image image = provider.GetImage(); AffineTransformBuilder builder = - new AffineTransformBuilder().AppendRotationDegrees(270, new Vector2(3.5f, 3.5f)); + new AffineTransformBuilder().AppendRotationDegrees(270, new(3.5f, 3.5f)); image.Mutate(x => x.BackgroundColor(Color.Red)); image.Mutate(x => x = x.Transform(builder)); @@ -246,7 +246,7 @@ public class AffineTransformTests Matrix3x2 m = Matrix3x2.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -260,9 +260,9 @@ public class AffineTransformTests { using Image image = provider.GetImage(); - Matrix3x2 m = Matrix3x2.CreateRotation(radians, new Vector2(50, 50)); + Matrix3x2 m = Matrix3x2.CreateRotation(radians, new(50, 50)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 6a61538ea..21e218d4c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -44,7 +44,7 @@ public class AutoOrientTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - image.Metadata.ExifProfile = new ExifProfile(); + image.Metadata.ExifProfile = new(); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); image.Mutate(x => x.AutoOrient()); @@ -57,7 +57,7 @@ public class AutoOrientTests public void AutoOrient_WorksWithCorruptExifData(TestImageProvider provider, ExifDataType dataType, byte[] orientation) where TPixel : unmanaged, IPixel { - var profile = new ExifProfile(); + ExifProfile profile = new(); profile.SetValue(ExifTag.JPEGTables, orientation); byte[] bytes = profile.ToByteArray(); @@ -79,7 +79,7 @@ public class AutoOrientTests using Image image = provider.GetImage(); using Image reference = image.Clone(); - image.Metadata.ExifProfile = new ExifProfile(bytes); + image.Metadata.ExifProfile = new(bytes); image.Mutate(x => x.AutoOrient()); image.DebugSave(provider, $"{dataType}-{orientationCode}", appendPixelTypeToFileName: false); ImageComparer.Exact.VerifySimilarity(image, reference); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 18a7a9bd0..619610cc2 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest public void Crop(TestImageProvider provider, int x, int y, int w, int h) where TPixel : unmanaged, IPixel { - var rect = new Rectangle(x, y, w, h); + Rectangle rect = new Rectangle(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; provider.RunValidatingProcessorTest( ctx => ctx.Crop(rect), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index ca4b00d8a..d587bc7e0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -35,8 +35,8 @@ public class EntropyCropTest { // arrange using Image image = provider.GetImage(); - var expectedHeight = image.Height; - var expectedWidth = image.Width; + int expectedHeight = image.Height; + int expectedWidth = image.Width; // act image.Mutate(img => img.EntropyCrop()); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs index 84d834cc5..96e7702d8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs @@ -34,33 +34,33 @@ public class ResizeHelperTests [Fact] public void CalculateMinRectangleWhenSourceIsSmallerThanTarget() { - var sourceSize = new Size(200, 100); - var target = new Size(400, 200); + Size sourceSize = new(200, 100); + Size target = new(400, 200); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Min, Size = target }); Assert.Equal(sourceSize, size); - Assert.Equal(new Rectangle(0, 0, sourceSize.Width, sourceSize.Height), rectangle); + Assert.Equal(new(0, 0, sourceSize.Width, sourceSize.Height), rectangle); } [Fact] public void MaxSizeAndRectangleAreCorrect() { - var sourceSize = new Size(5072, 6761); - var target = new Size(0, 450); + Size sourceSize = new(5072, 6761); + Size target = new(0, 450); - var expectedSize = new Size(338, 450); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(338, 450); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Max, Size = target @@ -73,15 +73,15 @@ public class ResizeHelperTests [Fact] public void CropSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(25, 50); + Size sourceSize = new(100, 100); + Size target = new(25, 50); - var expectedSize = new Size(25, 50); - var expectedRectangle = new Rectangle(-12, 0, 50, 50); + Size expectedSize = new(25, 50); + Rectangle expectedRectangle = new(-12, 0, 50, 50); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Crop, Size = target @@ -94,15 +94,15 @@ public class ResizeHelperTests [Fact] public void BoxPadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(10, 5, 100, 100); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(10, 5, 100, 100); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.BoxPad, Size = target @@ -115,15 +115,15 @@ public class ResizeHelperTests [Fact] public void PadSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(120, 110); + Size sourceSize = new(100, 100); + Size target = new(120, 110); - var expectedSize = new Size(120, 110); - var expectedRectangle = new Rectangle(5, 0, 110, 110); + Size expectedSize = new(120, 110); + Rectangle expectedRectangle = new(5, 0, 110, 110); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Pad, Size = target @@ -136,15 +136,15 @@ public class ResizeHelperTests [Fact] public void StretchSizeAndRectangleAreCorrect() { - var sourceSize = new Size(100, 100); - var target = new Size(57, 32); + Size sourceSize = new(100, 100); + Size target = new(57, 32); - var expectedSize = new Size(57, 32); - var expectedRectangle = new Rectangle(Point.Empty, expectedSize); + Size expectedSize = new(57, 32); + Rectangle expectedRectangle = new(Point.Empty, expectedSize); (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new ResizeOptions + new() { Mode = ResizeMode.Stretch, Size = target diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 290a3b37a..2c897588e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -39,7 +39,7 @@ public partial class ResizeKernelMapTests double radius = tolerantMath.Ceiling(scale * sampler.Radius); - var result = new List(); + List result = new(); for (int i = 0; i < destinationSize; i++) { @@ -80,10 +80,10 @@ public partial class ResizeKernelMapTests float[] floatVals = values.Select(v => (float)v).ToArray(); - result.Add(new ReferenceKernel(left, floatVals)); + result.Add(new(left, floatVals)); } - return new ReferenceKernelMap(result.ToArray()); + return new(result.ToArray()); } } @@ -103,7 +103,7 @@ public partial class ResizeKernelMapTests public static implicit operator ReferenceKernel(ResizeKernel orig) { - return new ReferenceKernel(orig.StartIndex, orig.Values.ToArray()); + return new(orig.StartIndex, orig.Values.ToArray()); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index c6da46ee2..f1309f331 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -88,7 +88,7 @@ public partial class ResizeKernelMapTests public void PrintNonNormalizedKernelMap(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); + ReferenceKernelMap kernelMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize, false); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); } @@ -116,15 +116,15 @@ public partial class ResizeKernelMapTests private void VerifyKernelMapContentIsCorrect(TResampler resampler, int srcSize, int destSize) where TResampler : struct, IResampler { - var referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); - var kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); + ReferenceKernelMap referenceMap = ReferenceKernelMap.Calculate(in resampler, destSize, srcSize); + ResizeKernelMap kernelMap = ResizeKernelMap.Calculate(in resampler, destSize, srcSize, Configuration.Default.MemoryAllocator); #if DEBUG this.Output.WriteLine(kernelMap.Info); this.Output.WriteLine($"Expected KernelMap:\n{PrintKernelMap(referenceMap)}\n"); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); #endif - var comparer = new ApproximateFloatComparer(1e-6f); + ApproximateFloatComparer comparer = new ApproximateFloatComparer(1e-6f); for (int i = 0; i < kernelMap.DestinationLength; i++) { @@ -163,7 +163,7 @@ public partial class ResizeKernelMapTests Func getDestinationSize, Func getKernel) { - var bld = new StringBuilder(); + StringBuilder bld = new StringBuilder(); if (kernelMap is ResizeKernelMap actualMap) { @@ -193,7 +193,7 @@ public partial class ResizeKernelMapTests private static TheoryData GenerateImageResizeData() { - var result = new TheoryData(); + TheoryData result = new TheoryData(); string[] resamplerNames = TestUtils.GetAllResamplerNames(false); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index d1b005ee4..b4cf08975 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -78,7 +78,7 @@ public class ResizeTests // resizing: (15, 12) -> (10, 6) // kernel dimensions: (3, 4) using Image image = provider.GetImage(); - Size destSize = new Size(image.Width * wN / wD, image.Height * hN / hD); + Size destSize = new(image.Width * wN / wD, image.Height * hN / hD); image.Mutate(x => x.Resize(destSize, KnownResamplers.Bicubic, false)); FormattableString outputInfo = $"({wN}÷{wD},{hN}÷{hD})"; image.DebugSave(provider, outputInfo, appendPixelTypeToFileName: false); @@ -106,7 +106,7 @@ public class ResizeTests Configuration configuration = Configuration.CreateDefaultInstance(); int workingBufferSizeHintInBytes = workingBufferLimitInRows * destSize.Width * SizeOfVector4; - TestMemoryAllocator allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.EnableNonThreadSafeLogging(); configuration.MemoryAllocator = allocator; configuration.WorkingBufferSizeHintInBytes = workingBufferSizeHintInBytes; @@ -211,7 +211,7 @@ public class ResizeTests provider.RunValidatingProcessorTest( x => { - ResizeOptions resizeOptions = new ResizeOptions() + ResizeOptions resizeOptions = new() { Size = x.GetCurrentSize() / 2, Mode = ResizeMode.Crop, @@ -346,7 +346,7 @@ public class ResizeTests "invalid dimensional input for Resize_WorksWithAllResamplers!"); } - newSize = new SizeF(specificDestWidth.Value, specificDestHeight.Value); + newSize = new(specificDestWidth.Value, specificDestHeight.Value); destSizeInfo = $"{newSize.Width}x{newSize.Height}"; } @@ -365,12 +365,12 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Rectangle sourceRectangle = new Rectangle( + Rectangle sourceRectangle = new( image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); - Rectangle destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); + Rectangle destRectangle = new(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); image.Mutate( x => x.Resize( @@ -437,9 +437,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height + 200), + Size = new(image.Width + 200, image.Height + 200), Mode = ResizeMode.BoxPad, PadColor = Color.HotPink }; @@ -456,7 +456,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width, image.Height / 2) }; + ResizeOptions options = new() { Size = new(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -470,7 +470,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(image.Width / 2, image.Height) }; + ResizeOptions options = new() { Size = new(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -484,9 +484,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(480, 600), + Size = new(480, 600), Mode = ResizeMode.Crop }; @@ -502,7 +502,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions { Size = new Size(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() { Size = new(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); @@ -516,9 +516,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), + Size = new((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min }; @@ -534,9 +534,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width + 200, image.Height), + Size = new(image.Width + 200, image.Height), Mode = ResizeMode.Pad, PadColor = Color.Lavender }; @@ -553,9 +553,9 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new ResizeOptions + ResizeOptions options = new() { - Size = new Size(image.Width / 2, image.Height), + Size = new(image.Width / 2, image.Height), Mode = ResizeMode.Stretch }; @@ -586,8 +586,8 @@ public class ResizeTests [Fact] public void Issue1195() { - using Image image = new Image(2, 300); - Size size = new Size(50, 50); + using Image image = new(2, 300); + Size size = new(50, 50); image.Mutate(x => x .Resize( new ResizeOptions @@ -605,8 +605,8 @@ public class ResizeTests [InlineData(3, 7)] public void Issue1342(int width, int height) { - using Image image = new Image(1, 1); - Size size = new Size(width, height); + using Image image = new(1, 1); + Size size = new(width, height); image.Mutate(x => x .Resize( new ResizeOptions diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index de02502e2..b831b0a6c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -16,13 +16,12 @@ public class SwizzleTests { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } - public Point Transform(Point point) - => new Point(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Theory] @@ -35,7 +34,7 @@ public class SwizzleTests using Image expectedImage = provider.GetImage(); using Image image = provider.GetImage(); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, @@ -43,7 +42,7 @@ public class SwizzleTests appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); image.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 30c89ec33..6e35fca29 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest : BaseImageOperationsExtensionTest this.operations.Crop(width, height); CropProcessor processor = this.Verify(); - Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle); + Assert.Equal(new(0, 0, width, height), processor.CropRectangle); } [Theory] @@ -25,7 +25,7 @@ public class CropTest : BaseImageOperationsExtensionTest [InlineData(12, 123, 6, 2)] public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, int height) { - var cropRectangle = new Rectangle(x, y, width, height); + Rectangle cropRectangle = new(x, y, width, height); this.operations.Crop(cropRectangle); CropProcessor processor = this.Verify(); @@ -35,7 +35,7 @@ public class CropTest : BaseImageOperationsExtensionTest [Fact] public void CropRectangleWithInvalidBoundsThrowsException() { - var cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); + Rectangle cropRectangle = Rectangle.Inflate(this.SourceBounds(), 5, 5); Assert.Throws(() => this.operations.Crop(cropRectangle)); } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index 6b6db69c1..0eb32dff7 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -20,7 +20,7 @@ public class ProjectiveTransformTests private ITestOutputHelper Output { get; } - public static readonly TheoryData ResamplerNames = new TheoryData + public static readonly TheoryData ResamplerNames = new() { nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), @@ -39,7 +39,7 @@ public class ProjectiveTransformTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData TaperMatrixData = new TheoryData + public static readonly TheoryData TaperMatrixData = new() { { TaperSide.Bottom, TaperCorner.Both }, { TaperSide.Bottom, TaperCorner.LeftOrTop }, @@ -57,10 +57,10 @@ public class ProjectiveTransformTests public static readonly TheoryData QuadDistortionData = new() { - { new PointF(0, 0), new PointF(150, 0), new PointF(150, 150), new PointF(0, 150) }, // source == destination - { new PointF(25, 50), new PointF(210, 25), new PointF(140, 210), new PointF(15, 125) }, // Distortion - { new PointF(-50, -50), new PointF(200, -50), new PointF(200, 200), new PointF(-50, 200) }, // Scaling - { new PointF(150, 0), new PointF(150, 150), new PointF(0, 150), new PointF(0, 0) }, // Rotation + { new(0, 0), new(150, 0), new(150, 150), new(0, 150) }, // source == destination + { new(25, 50), new(210, 25), new(140, 210), new(15, 125) }, // Distortion + { new(-50, -50), new(200, -50), new(200, 200), new(-50, 200) }, // Scaling + { new(150, 0), new(150, 150), new(0, 150), new(0, 0) }, // Rotation }; public ProjectiveTransformTests(ITestOutputHelper output) => this.Output = output; @@ -174,8 +174,8 @@ public class ProjectiveTransformTests [Fact] public void Issue1911() { - using var image = new Image(100, 100); - image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix4x4.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); + using Image image = new(100, 100); + image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix4x4.Identity, new(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -190,7 +190,7 @@ public class ProjectiveTransformTests Matrix4x4 m = Matrix4x4.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -204,9 +204,9 @@ public class ProjectiveTransformTests { using Image image = provider.GetImage(); - Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new Vector3(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new Vector3(50, 50, 1F)); + Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new(50, 50, 1F)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } @@ -246,7 +246,7 @@ public class ProjectiveTransformTests if (property is null) { - throw new Exception($"No resampler named {name}"); + throw new($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index f6c93ffd0..d38658bbd 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -64,9 +64,9 @@ public class ResizeTests : BaseImageOperationsExtensionTest bool compand = true; ResizeMode mode = ResizeMode.Stretch; - var resizeOptions = new ResizeOptions + ResizeOptions resizeOptions = new() { - Size = new Size(width, height), + Size = new(width, height), Sampler = sampler, Compand = compand, Mode = mode @@ -93,7 +93,7 @@ public class ResizeTests : BaseImageOperationsExtensionTest { static void RunTest() { - using var image = new Image(50, 50); + using Image image = new(50, 50); image.Mutate(img => img.Resize(25, 25)); Assert.Equal(25, image.Width); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs index 432bb5cac..a4f4f152b 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs @@ -13,13 +13,12 @@ public class SwizzleTests : BaseImageOperationsExtensionTest { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } - public Point Transform(Point point) - => new Point(point.Y, point.X); + public Point Transform(Point point) => new(point.Y, point.X); } [Fact] @@ -28,7 +27,7 @@ public class SwizzleTests : BaseImageOperationsExtensionTest int width = 5; int height = 10; - this.operations.Swizzle(new InvertXAndYSwizzler(new Size(width, height))); + this.operations.Swizzle(new InvertXAndYSwizzler(new(width, height))); SwizzleProcessor processor = this.Verify>(); Assert.Equal(processor.Swizzler.DestinationSize.Width, height); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index f046c2503..cdc49e2a3 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -10,16 +10,16 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public abstract class TransformBuilderTestBase { - private static readonly ApproximateFloatComparer Comparer = new ApproximateFloatComparer(1e-6f); + private static readonly ApproximateFloatComparer Comparer = new(1e-6f); public static readonly TheoryData ScaleTranslate_Data = - new TheoryData - { + new() + { // scale, translate, source, expectedDest { Vector2.One, Vector2.Zero, Vector2.Zero, Vector2.Zero }, - { Vector2.One, Vector2.Zero, new Vector2(10, 20), new Vector2(10, 20) }, - { Vector2.One, new Vector2(3, 1), new Vector2(10, 20), new Vector2(13, 21) }, - { new Vector2(2, 0.5f), new Vector2(3, 1), new Vector2(10, 20), new Vector2(23, 11) }, + { Vector2.One, Vector2.Zero, new(10, 20), new(10, 20) }, + { Vector2.One, new(3, 1), new(10, 20), new(13, 21) }, + { new(2, 0.5f), new(3, 1), new(10, 20), new(23, 11) }, }; [Theory] @@ -29,23 +29,23 @@ public abstract class TransformBuilderTestBase #pragma warning restore SA1300 // Element should begin with upper-case letter { // These operations should be size-agnostic: - var size = new Size(123, 321); + Size size = new(123, 321); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new SizeF(scale)); + this.AppendScale(builder, new(scale)); this.AppendTranslation(builder, translate); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.True(Comparer.Equals(expectedDest, actualDest)); } public static readonly TheoryData TranslateScale_Data = - new TheoryData - { + new() + { // translate, scale, source, expectedDest { Vector2.Zero, Vector2.One, Vector2.Zero, Vector2.Zero }, - { Vector2.Zero, Vector2.One, new Vector2(10, 20), new Vector2(10, 20) }, - { new Vector2(3, 1), new Vector2(2, 0.5f), new Vector2(10, 20), new Vector2(26, 10.5f) }, + { Vector2.Zero, Vector2.One, new(10, 20), new(10, 20) }, + { new(3, 1), new(2, 0.5f), new(10, 20), new(26, 10.5f) }, }; [Theory] @@ -55,13 +55,13 @@ public abstract class TransformBuilderTestBase #pragma warning restore SA1300 // Element should begin with upper-case letter { // Translate ans scale are size-agnostic: - var size = new Size(456, 432); + Size size = new(456, 432); TBuilder builder = this.CreateBuilder(); this.AppendTranslation(builder, translate); - this.AppendScale(builder, new SizeF(scale)); + this.AppendScale(builder, new(scale)); - Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); Assert.Equal(expectedDest, actualDest, Comparer); } @@ -70,10 +70,10 @@ public abstract class TransformBuilderTestBase [InlineData(-20, 10)] public void LocationOffsetIsPrepended(int locationX, int locationY) { - var rectangle = new Rectangle(locationX, locationY, 10, 10); + Rectangle rectangle = new(locationX, locationY, 10, 10); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new SizeF(2, 2)); + this.AppendScale(builder, new(2, 2)); Vector2 actual = this.Execute(builder, rectangle, Vector2.One); Vector2 expected = new Vector2(-locationX + 1, -locationY + 1) * 2; @@ -92,7 +92,7 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendRotationDegrees(builder, degrees); @@ -100,9 +100,9 @@ public abstract class TransformBuilderTestBase // TODO: We should also test CreateRotationMatrixDegrees() (and all TransformUtils stuff!) for correctness Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -120,17 +120,17 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendRotationDegrees(builder, degrees, centerPoint); - var matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateRotation(GeometryUtilities.DegreeToRadian(degrees), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -147,16 +147,16 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, degreesX, degreesY); Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size, TransformSpace.Pixel); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -174,17 +174,17 @@ public abstract class TransformBuilderTestBase float x, float y) { - var size = new Size(width, height); + Size size = new(width, height); TBuilder builder = this.CreateBuilder(); - var centerPoint = new Vector2(cx, cy); + Vector2 centerPoint = new(cx, cy); this.AppendSkewDegrees(builder, degreesX, degreesY, centerPoint); - var matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); + Matrix3x2 matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); - var position = new Vector2(x, y); - var expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); + Vector2 position = new(x, y); + Vector2 expected = Vector2.Transform(position, matrix); + Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -192,7 +192,7 @@ public abstract class TransformBuilderTestBase [Fact] public void AppendPrependOpposite() { - var rectangle = new Rectangle(-1, -1, 3, 3); + Rectangle rectangle = new(-1, -1, 3, 3); TBuilder b1 = this.CreateBuilder(); TBuilder b2 = this.CreateBuilder(); @@ -201,21 +201,21 @@ public abstract class TransformBuilderTestBase // Forwards this.AppendRotationRadians(b1, pi); this.AppendSkewRadians(b1, pi, pi); - this.AppendScale(b1, new SizeF(2, 0.5f)); - this.AppendRotationRadians(b1, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendSkewRadians(b1, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.AppendTranslation(b1, new PointF(123, 321)); + this.AppendScale(b1, new(2, 0.5f)); + this.AppendRotationRadians(b1, pi / 2, new(-0.5f, -0.1f)); + this.AppendSkewRadians(b1, pi, pi / 2, new(-0.5f, -0.1f)); + this.AppendTranslation(b1, new(123, 321)); // Backwards - this.PrependTranslation(b2, new PointF(123, 321)); - this.PrependSkewRadians(b2, pi, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependRotationRadians(b2, pi / 2, new Vector2(-0.5f, -0.1f)); - this.PrependScale(b2, new SizeF(2, 0.5f)); + this.PrependTranslation(b2, new(123, 321)); + this.PrependSkewRadians(b2, pi, pi / 2, new(-0.5f, -0.1f)); + this.PrependRotationRadians(b2, pi / 2, new(-0.5f, -0.1f)); + this.PrependScale(b2, new(2, 0.5f)); this.PrependSkewRadians(b2, pi, pi); this.PrependRotationRadians(b2, pi); - Vector2 p1 = this.Execute(b1, rectangle, new Vector2(32, 65)); - Vector2 p2 = this.Execute(b2, rectangle, new Vector2(32, 65)); + Vector2 p1 = this.Execute(b1, rectangle, new(32, 65)); + Vector2 p2 = this.Execute(b2, rectangle, new(32, 65)); Assert.Equal(p1, p2, Comparer); } @@ -226,13 +226,13 @@ public abstract class TransformBuilderTestBase [InlineData(-1, 0)] public void ThrowsForInvalidSizes(int width, int height) { - var size = new Size(width, height); + Size size = new(width, height); Assert.ThrowsAny( () => { TBuilder builder = this.CreateBuilder(); - this.Execute(builder, new Rectangle(Point.Empty, size), Vector2.Zero); + this.Execute(builder, new(Point.Empty, size), Vector2.Zero); }); } @@ -244,7 +244,7 @@ public abstract class TransformBuilderTestBase { TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, 45, 45); - this.Execute(builder, new Rectangle(0, 0, 150, 150), Vector2.Zero); + this.Execute(builder, new(0, 0, 150, 150), Vector2.Zero); }); } diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index a1d7e358b..fa3fcec41 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture [InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)] public void LoadResizeSave(string imagePath) { - var configuration = Configuration.CreateDefaultInstance(); + Configuration configuration = Configuration.CreateDefaultInstance(); configuration.MaxDegreeOfParallelism = 1; DecoderOptions options = new() @@ -28,12 +28,12 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture byte[] imageBytes = TestFile.Create(imagePath).Bytes; - using var ms = new MemoryStream(); + using MemoryStream ms = new MemoryStream(); this.Measure( 30, () => { - using (var image = Image.Load(options, imageBytes)) + using (Image image = Image.Load(options, imageBytes)) { image.Mutate(x => x.Resize(image.Size / 4)); image.SaveAsJpeg(ms); diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs index f20ca8ce1..df531ae4c 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs @@ -28,7 +28,7 @@ public class ResizeProfilingBenchmarks : MeasureFixture this.ExecutionCount, () => { - using (var image = new Image(this.configuration, width, height)) + using (Image image = new Image(this.configuration, width, height)) { image.Mutate(x => x.Resize(width / 5, height / 5)); } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index b59542482..18bcbffae 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -106,7 +106,7 @@ public class QuantizedImageTests { using Image image = provider.GetImage(); OctreeQuantizer octreeQuantizer = new(); - IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new QuantizerOptions() { MaxColors = 128 }); + IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new() { MaxColors = 128 }); ImageFrame frame = image.Frames[0]; quantizer.BuildPaletteAndQuantizeFrame(frame, frame.Bounds); } diff --git a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs index 28a7c49e5..d6960d778 100644 --- a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs @@ -12,7 +12,7 @@ public class WuQuantizerTests public void SinglePixelOpaque() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); using Image image = new(config, 1, 1, Color.Black.ToPixel()); ImageFrame frame = image.Frames.RootFrame; @@ -32,7 +32,7 @@ public class WuQuantizerTests public void SinglePixelTransparent() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); using Image image = new(config, 1, 1, default(Rgba32)); ImageFrame frame = image.Frames.RootFrame; @@ -49,19 +49,19 @@ public class WuQuantizerTests } [Fact] - public void GrayScale() => TestScale(c => new Rgba32(c, c, c, 128)); + public void GrayScale() => TestScale(c => new(c, c, c, 128)); [Fact] - public void RedScale() => TestScale(c => new Rgba32(c, 0, 0, 128)); + public void RedScale() => TestScale(c => new(c, 0, 0, 128)); [Fact] - public void GreenScale() => TestScale(c => new Rgba32(0, c, 0, 128)); + public void GreenScale() => TestScale(c => new(0, c, 0, 128)); [Fact] - public void BlueScale() => TestScale(c => new Rgba32(0, 0, c, 128)); + public void BlueScale() => TestScale(c => new(0, 0, c, 128)); [Fact] - public void AlphaScale() => TestScale(c => new Rgba32(0, 0, 0, c)); + public void AlphaScale() => TestScale(c => new(0, 0, 0, c)); [Fact] public void Palette256() @@ -75,11 +75,11 @@ public class WuQuantizerTests byte b = (byte)(((i / 16) % 4) * 85); byte a = (byte)((i / 64) * 85); - image[0, i] = new Rgba32(r, g, b, a); + image[0, i] = new(r, g, b, a); } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; @@ -125,7 +125,7 @@ public class WuQuantizerTests // See https://github.com/SixLabors/ImageSharp/issues/866 using Image image = provider.GetImage(); Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); + WuQuantizer quantizer = new(new() { Dither = null }); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -152,7 +152,7 @@ public class WuQuantizerTests } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; using (IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config)) diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index 40f54ea74..094ba7626 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -52,7 +52,7 @@ public class IccConversionDataLutEntry values[i] = 0.1f + (i / (float)length); } - return new IccLut(values); + return new(values); } private static IccLut CreateIdentityLut(float min, float max) => new([min, max]); diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index e4adba078..57618b957 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -48,14 +48,14 @@ public class IccConversionDataMultiProcessElement private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) { - var curve = new IccOneDimensionalCurve(new float[0], new[] { segment }); - return new IccCurveSetProcessElement(new[] { curve }); + IccOneDimensionalCurve curve = new(new float[0], new[] { segment }); + return new(new[] { curve }); } private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) { - var curve = new IccOneDimensionalCurve(breakPoints, segments); - return new IccCurveSetProcessElement(new[] { curve }); + IccOneDimensionalCurve curve = new(breakPoints, segments); + return new(new[] { curve }); } public static object[][] MpeCurveConversionTestData = diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 6cd99367a..cf7a99b63 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -12,11 +12,11 @@ public static class IccConversionDataTrc internal static IccCurveTagDataEntry Gamma2Curve = new(2); internal static IccCurveTagDataEntry LutCurve = new(new float[] { 0, 0.7f, 1 }); - internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new IccParametricCurve(2.2f)); - internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f)); - internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); - internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); - internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new(2.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new(2.2f, 1.5f, -0.5f)); + internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new(2.2f, 1.5f, -0.5f, 0.3f)); + internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); + internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); public static object[][] TrcArrayConversionTestData { get; } = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index 2bd47e449..c47f6357b 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -18,7 +18,7 @@ internal static class IccTestDataLut result[i] = i / 255f; } - return new IccLut(result); + return new(result); } private static byte[] CreateLut8() diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index 7441bede8..a31f1d05f 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -23,7 +23,7 @@ internal static class IccTestDataProfiles public static readonly IccProfileHeader HeaderRandomWrite = CreateHeaderRandomValue( 562, // should be overwritten - new IccProfileId(1, 2, 3, 4), // should be overwritten + new(1, 2, 3, 4), // should be overwritten "ijkl"); // should be overwritten to "acsp" public static readonly IccProfileHeader HeaderRandomRead = CreateHeaderRandomValue(132, HeaderRandomIdValue, "acsp"); @@ -34,7 +34,7 @@ internal static class IccTestDataProfiles { Class = IccProfileClass.DisplayDevice, CmmType = "abcd", - CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), + CreationDate = new(1990, 11, 26, 7, 21, 42), CreatorSignature = "dcba", DataColorSpace = IccColorSpaceType.Rgb, DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, @@ -43,12 +43,12 @@ internal static class IccTestDataProfiles FileSignature = "acsp", Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, Id = id, - PcsIlluminant = new Vector3(4, 5, 6), + PcsIlluminant = new(4, 5, 6), PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, ProfileConnectionSpace = IccColorSpaceType.CieXyz, RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, Size = size, - Version = new IccVersion(4, 3, 0), + Version = new(4, 3, 0), }; public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] profileId) => ArrayHelper.Concat( diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index a83dc3575..7e5294f85 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -339,7 +339,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new CultureInfo(language); + culture = new(language); } catch (CultureNotFoundException) { @@ -350,7 +350,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new CultureInfo($"{language}-{country}"); + culture = new($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -358,7 +358,7 @@ internal static class IccTestDataTagDataEntry } } - return new IccLocalizedString(culture, text); + return new(culture, text); } private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = new[] diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index a53e50806..01c5fdae3 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -79,7 +79,7 @@ public sealed class TestFile /// The . /// public static TestFile Create(string file) - => Cache.GetOrAdd(file, (string fileName) => new TestFile(GetInputFileFullPath(fileName))); + => Cache.GetOrAdd(file, (string fileName) => new(GetInputFileFullPath(fileName))); /// /// Gets the file name. diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index 01b1faa45..32cac0b05 100644 --- a/tests/ImageSharp.Tests/TestFontUtilities.cs +++ b/tests/ImageSharp.Tests/TestFontUtilities.cs @@ -37,7 +37,7 @@ public static class TestFontUtilities /// private static string GetFontsDirectory() { - List directories = new List + List directories = new() { "TestFonts/", // Here for code coverage tests. "tests/ImageSharp.Tests/TestFonts/", // from travis/build script @@ -59,7 +59,7 @@ public static class TestFontUtilities return directory; } - throw new System.Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); + throw new($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); } /// diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index d30ce7846..8b2a9a9be 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -24,8 +24,8 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestFormat() { - this.Encoder = new TestEncoder(this); - this.Decoder = new TestDecoder(this); + this.Encoder = new(this); + this.Decoder = new(this); } public List DecodeCalls { get; } = new(); @@ -38,7 +38,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public MemoryStream CreateStream(byte[] marker = null) { - var ms = new MemoryStream(); + MemoryStream ms = new(); byte[] data = this.header; ms.Write(data, 0, data.Length); if (marker != null) @@ -54,7 +54,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat { byte[] buffer = new byte[size]; this.header.CopyTo(buffer, 0); - var semaphoreStream = new SemaphoreReadMemoryStream(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); + SemaphoreReadMemoryStream semaphoreStream = new(buffer, waitAfterPosition, notifyWaitPositionReachedSemaphore, continueSemaphore); return seeakable ? semaphoreStream : new AsyncStreamWrapper(semaphoreStream, () => false); } @@ -220,7 +220,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat using MemoryStream ms = new(); stream.CopyTo(ms, configuration.StreamProcessingBufferSize); byte[] marker = ms.ToArray().Skip(this.testFormat.header.Length).ToArray(); - this.testFormat.DecodeCalls.Add(new DecodeOperation + this.testFormat.DecodeCalls.Add(new() { Marker = marker, Config = configuration, diff --git a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs index 8ff2abd90..90a98d1c8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ArrayHelper.cs @@ -13,7 +13,7 @@ public static class ArrayHelper /// The concatenated array public static T[] Concat(params T[][] arrays) { - var result = new T[arrays.Sum(t => t.Length)]; + T[] result = new T[arrays.Sum(t => t.Length)]; int offset = 0; for (int i = 0; i < arrays.Length; i++) { @@ -33,7 +33,7 @@ public static class ArrayHelper /// The created array filled with the given value public static T[] Fill(T value, int length) { - var result = new T[length]; + T[] result = new T[length]; for (int i = 0; i < length; i++) { result[i] = value; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs index 57949e7b1..87f6f0479 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileCollectionAttribute.cs @@ -58,7 +58,7 @@ public class WithFileCollectionAttribute : ImageDataAttributeBase Func accessor = this.GetPropertyAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); accessor = accessor ?? this.GetFieldAccessor(testMethod.DeclaringType, this.fileEnumeratorMemberName); - var files = (IEnumerable)accessor(); + IEnumerable files = (IEnumerable)accessor(); return files.Select(f => new object[] { f }); } diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs index 963c3c783..2fb75444e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteArrayUtility.cs @@ -11,7 +11,7 @@ public static class ByteArrayUtility { if (isLittleEndian != BitConverter.IsLittleEndian) { - var reversedBytes = new byte[bytes.Length]; + byte[] reversedBytes = new byte[bytes.Length]; Array.Copy(bytes, reversedBytes, bytes.Length); Array.Reverse(reversedBytes); return reversedBytes; diff --git a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs index c5ffdd648..45a5ab5f5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs +++ b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs @@ -31,7 +31,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(Configuration.Default, new MemoryStream(imageData)); Image image = Image.Load(stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public static EofHitCounter RunDecoder(byte[] imageData, T decoder, TO options) @@ -40,7 +40,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(options.GeneralOptions.Configuration, new MemoryStream(imageData)); Image image = decoder.Decode(options, stream); - return new EofHitCounter(stream, image); + return new(stream, image); } public void Dispose() diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index 63126dcbc..a02ea399f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -67,7 +67,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -109,7 +109,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -153,7 +153,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, BasicSerializer.Serialize(serializable), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -198,7 +198,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(serializable), intrinsic.Key.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -247,7 +247,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), BasicSerializer.Serialize(arg2), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -294,7 +294,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), arg2, - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -338,7 +338,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, serializable.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) @@ -385,7 +385,7 @@ public static class FeatureTestRunner action, arg0.ToString(), arg1.ToString(), - new RemoteInvokeOptions + new() { StartInfo = processStartInfo }) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 92fc06eff..12f8ef773 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; public class ExactImageComparer : ImageComparer { - public static ExactImageComparer Instance { get; } = new ExactImageComparer(); + public static ExactImageComparer Instance { get; } = new(); public override ImageSimilarityReport CompareImagesOrFrames( int index, @@ -23,10 +23,10 @@ public class ExactImageComparer : ImageComparer int width = actual.Width; // TODO: Comparing through Rgba64 may not be robust enough because of the existence of super high precision pixel types. - var aBuffer = new Rgba64[width]; - var bBuffer = new Rgba64[width]; + Rgba64[] aBuffer = new Rgba64[width]; + Rgba64[] bBuffer = new Rgba64[width]; - var differences = new List(); + List differences = new(); Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -46,12 +46,12 @@ public class ExactImageComparer : ImageComparer if (aPixel != bPixel) { - var diff = new PixelDifference(new Point(x, y), aPixel, bPixel); + PixelDifference diff = new(new(x, y), aPixel, bPixel); differences.Add(diff); } } } - return new ImageSimilarityReport(index, expected, actual, differences); + return new(index, expected, actual, differences); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index 7153674e6..dee12915b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -147,7 +147,7 @@ public static class ImageComparerExtensions IEnumerable> reports = comparer.CompareImages(expected, actual); if (reports.Any()) { - var cleanedReports = new List>(reports.Count()); + List> cleanedReports = new(reports.Count()); foreach (ImageSimilarityReport r in reports) { IEnumerable outsideChanges = r.Differences.Where( @@ -159,7 +159,7 @@ public static class ImageComparerExtensions if (outsideChanges.Any()) { - cleanedReports.Add(new ImageSimilarityReport(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); + cleanedReports.Add(new(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs index 05f65cfbb..410ada05a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs @@ -19,7 +19,7 @@ public static class ImageComparingUtils ?? throw new InvalidOperationException("CompareToOriginal() works only with file providers!"); TestFile testFile = TestFile.Create(path); - using Image magickImage = DecodeWithMagick(new FileInfo(testFile.FullPath)); + using Image magickImage = DecodeWithMagick(new(testFile.FullPath)); if (useExactComparer) { ImageComparer.Exact.VerifySimilarity(magickImage, image); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index c50ae5e21..8c72bbf54 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs @@ -61,7 +61,7 @@ public class ImageSimilarityReport private string PrintDifference() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); if (this.TotalNormalizedDifference.HasValue) { sb.AppendLine(); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index d057267da..004c26a8f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -65,12 +65,12 @@ public class TolerantImageComparer : ImageComparer int width = actual.Width; // TODO: Comparing through Rgba64 may not robust enough because of the existence of super high precision pixel types. - var aBuffer = new Rgba64[width]; - var bBuffer = new Rgba64[width]; + Rgba64[] aBuffer = new Rgba64[width]; + Rgba64[] bBuffer = new Rgba64[width]; float totalDifference = 0F; - var differences = new List(); + List differences = new(); Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; @@ -89,7 +89,7 @@ public class TolerantImageComparer : ImageComparer if (d > this.PerPixelManhattanThreshold) { - var diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new(new(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); totalDifference += d; @@ -102,7 +102,7 @@ public class TolerantImageComparer : ImageComparer if (normalizedDifference > this.ImageThreshold) { - return new ImageSimilarityReport(index, expected, actual, differences, normalizedDifference); + return new(index, expected, actual, differences, normalizedDifference); } else { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs index 813ed505d..d861d293b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs @@ -78,6 +78,6 @@ public abstract partial class TestImageProvider : IXunitSerializable return x < midX ? BottomLeftColor : BottomRightColor; } - private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new Vector4(1f, 0f, 1f, 0.5f)); + private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new(1f, 0f, 1f, 0.5f)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index 3652d77a1..caa54feae 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -32,7 +32,7 @@ public abstract partial class TestImageProvider : IXunitSerializable ISpecializedDecoderOptions specialized) { Type customType = customDecoder?.GetType(); - this.commonValues = new Tuple( + this.commonValues = new( pixelType, filePath, customType); @@ -45,7 +45,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { Type type = options.GetType(); - var data = new Dictionary(); + Dictionary data = new(); while (type != null && type != typeof(object)) { @@ -196,7 +196,7 @@ public abstract partial class TestImageProvider : IXunitSerializable return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options, null); + Key key = new(this.PixelType, this.FilePath, decoder, options, null); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -233,7 +233,7 @@ public abstract partial class TestImageProvider : IXunitSerializable return this.DecodeImage(decoder, options); } - var key = new Key(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); + Key key = new(this.PixelType, this.FilePath, decoder, options.GeneralOptions, options); Image cachedImage = Cache.GetOrAdd(key, _ => this.DecodeImage(decoder, options)); return cachedImage.Clone(this.Configuration); @@ -270,7 +270,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { options.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -280,7 +280,7 @@ public abstract partial class TestImageProvider : IXunitSerializable { options.GeneralOptions.SetConfiguration(this.Configuration); - var testFile = TestFile.Create(this.FilePath); + TestFile testFile = TestFile.Create(this.FilePath); using Stream stream = new MemoryStream(testFile.Bytes); return decoder.Decode(options, stream); } @@ -288,7 +288,7 @@ public abstract partial class TestImageProvider : IXunitSerializable public static string GetFilePathOrNull(ITestImageProvider provider) { - var fileProvider = provider as FileProvider; + FileProvider fileProvider = provider as FileProvider; return fileProvider?.FilePath; } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs index 390195274..6da5b75f0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs @@ -54,7 +54,7 @@ public abstract partial class TestImageProvider : IXunitSerializable private Func> GetFactory() { - var declaringType = Type.GetType(this.declaringTypeName); + Type declaringType = Type.GetType(this.declaringTypeName); MethodInfo m = declaringType.GetMethod(this.methodName); Type pixelType = typeof(TPixel); Type imgType = typeof(Image<>).MakeGenericType(pixelType); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 8f22fb2b2..88ebd6c7f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -152,7 +152,7 @@ public abstract partial class TestImageProvider : ITestImageProvider, IX this.MethodName = methodName; this.OutputSubfolderName = outputSubfolderName; - this.Utility = new ImagingTestCaseUtility + this.Utility = new() { SourceFileOrDescription = this.SourceFileOrDescription, PixelTypeName = this.PixelType.ToString() diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index de42ba0cc..b5fad3929 100644 --- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs +++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs @@ -30,7 +30,7 @@ public class MeasureFixture this.Output?.WriteLine($"{operationName} X {times} ..."); } - var sw = Stopwatch.StartNew(); + Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < times; i++) { diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs index d1149dd00..049fda727 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs @@ -92,9 +92,9 @@ public class PausedMemoryStream : MemoryStream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs index 42ed6b0d5..54aa77be2 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs @@ -94,9 +94,9 @@ public class PausedStream : Stream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 04f59979f..78014b7af 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -27,7 +27,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format32bppArgb) { @@ -37,7 +37,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new Image(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -86,7 +86,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format24bppRgb) { @@ -96,7 +96,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - var image = new Image(w, h); + Image image = new Image(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -138,8 +138,8 @@ public static class SystemDrawingBridge int w = image.Width; int h = image.Height; - var resultBitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb); - var fullRect = new System.Drawing.Rectangle(0, 0, w, h); + Bitmap resultBitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb); + System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); BitmapData data = resultBitmap.LockBits(fullRect, ImageLockMode.ReadWrite, resultBitmap.PixelFormat); try { diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index edae08ce1..873d5bfde 100644 --- a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs +++ b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs @@ -18,7 +18,7 @@ public class SixLaborsXunitTestFramework : XunitTestFramework public SixLaborsXunitTestFramework(IMessageSink messageSink) : base(messageSink) { - var message = new DiagnosticMessage(HostEnvironmentInfo.GetInformation()); + DiagnosticMessage message = new DiagnosticMessage(HostEnvironmentInfo.GetInformation()); messageSink.OnMessage(message); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs index 31de3909e..53f0f0648 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestDataGenerator.cs @@ -20,7 +20,7 @@ internal static class TestDataGenerator /// The . public static float[] GenerateRandomFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; RandomFill(rnd, values, minVal, maxVal); @@ -45,7 +45,7 @@ internal static class TestDataGenerator /// The . public static Vector4[] GenerateRandomVectorArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new Vector4[length]; + Vector4[] values = new Vector4[length]; for (int i = 0; i < length; i++) { @@ -69,7 +69,7 @@ internal static class TestDataGenerator /// The . public static float[] GenerateRandomRoundedFloatArray(this Random rnd, int length, float minVal, float maxVal) { - var values = new float[length]; + float[] values = new float[length]; for (int i = 0; i < length; i++) { @@ -87,14 +87,14 @@ internal static class TestDataGenerator /// The . public static byte[] GenerateRandomByteArray(this Random rnd, int length) { - var values = new byte[length]; + byte[] values = new byte[length]; rnd.NextBytes(values); return values; } public static short[] GenerateRandomInt16Array(this Random rnd, int length, short minVal, short maxVal) { - var values = new short[length]; + short[] values = new short[length]; for (int i = 0; i < values.Length; i++) { values[i] = (short)rnd.Next(minVal, maxVal); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 881883035..aa94ce469 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -19,9 +19,9 @@ public static partial class TestEnvironment private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools"; - private static readonly Lazy SolutionDirectoryFullPathLazy = new Lazy(GetSolutionDirectoryFullPathImpl); + private static readonly Lazy SolutionDirectoryFullPathLazy = new(GetSolutionDirectoryFullPathImpl); - private static readonly Lazy NetCoreVersionLazy = new Lazy(GetNetCoreVersion); + private static readonly Lazy NetCoreVersionLazy = new(GetNetCoreVersion); static TestEnvironment() => PrepareRemoteExecutor(); @@ -52,8 +52,7 @@ public static partial class TestEnvironment internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; - private static readonly FileInfo TestAssemblyFile = - new FileInfo(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); + private static readonly FileInfo TestAssemblyFile = new(typeof(TestEnvironment).GetTypeInfo().Assembly.Location); private static string GetSolutionDirectoryFullPathImpl() { @@ -199,7 +198,7 @@ public static partial class TestEnvironment "Microsoft SDKs", "Windows"); - FileInfo corFlagsFile = Find(new DirectoryInfo(windowsSdksDir), "CorFlags.exe"); + FileInfo corFlagsFile = Find(new(windowsSdksDir), "CorFlags.exe"); string remoteExecutorPath = Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe"); @@ -215,7 +214,7 @@ public static partial class TestEnvironment string args = $"{remoteExecutorTmpPath} /32Bit+ /Force"; - var si = new ProcessStartInfo() + ProcessStartInfo si = new() { FileName = corFlagsFile.FullName, Arguments = args, @@ -224,14 +223,14 @@ public static partial class TestEnvironment RedirectStandardError = true }; - using var proc = Process.Start(si); + using Process proc = Process.Start(si); proc.WaitForExit(); string standardOutput = proc.StandardOutput.ReadToEnd(); string standardError = proc.StandardError.ReadToEnd(); if (proc.ExitCode != 0) { - throw new Exception( + throw new( $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}"); } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 994aa670c..6a5f7f892 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -774,7 +774,7 @@ public static class TestImageExtensions { TestMemoryAllocator allocator = new(); provider.Configuration.MemoryAllocator = allocator; - return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf()); + return new(allocator, Unsafe.SizeOf()); } private class MakeOpaqueProcessor : IImageProcessor diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs index fe94cffc4..6ef2c1824 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs @@ -33,8 +33,8 @@ internal class TestMemoryAllocator : MemoryAllocator public void EnableNonThreadSafeLogging() { - this.allocationLog = new List(); - this.returnLog = new List(); + this.allocationLog = new(); + this.returnLog = new(); } public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) @@ -46,7 +46,7 @@ internal class TestMemoryAllocator : MemoryAllocator private T[] AllocateArray(int length, AllocationOptions options) where T : struct { - var array = new T[length + 42]; + T[] array = new T[length + 42]; this.allocationLog?.Add(AllocationRequest.Create(options, length, array)); if (options == AllocationOptions.None) @@ -61,7 +61,7 @@ internal class TestMemoryAllocator : MemoryAllocator private void Return(BasicArrayBuffer buffer) where T : struct { - this.returnLog?.Add(new ReturnRequest(buffer.Array.GetHashCode())); + this.returnLog?.Add(new(buffer.Array.GetHashCode())); } public struct AllocationRequest @@ -83,7 +83,7 @@ internal class TestMemoryAllocator : MemoryAllocator { Type type = typeof(T); int elementSize = Marshal.SizeOf(type); - return new AllocationRequest(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); + return new(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); } public Type ElementType { get; } @@ -150,7 +150,7 @@ internal class TestMemoryAllocator : MemoryAllocator } void* ptr = (void*)this.pinHandle.AddrOfPinnedObject(); - return new MemoryHandle(ptr, pinnable: this); + return new(ptr, pinnable: this); } public override void Unpin() diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs index 50e086d57..2604aa1de 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs @@ -34,9 +34,9 @@ public class TestMemoryManager : MemoryManager public static TestMemoryManager CreateAsCopyOf(Span copyThisBuffer) { - var pixelArray = new T[copyThisBuffer.Length]; + T[] pixelArray = new T[copyThisBuffer.Length]; copyThisBuffer.CopyTo(pixelArray); - return new TestMemoryManager(pixelArray); + return new(pixelArray); } protected override void Dispose(bool disposing) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index f0344e2b9..42b2b2a25 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -35,7 +35,7 @@ public class TestPixel : IXunitSerializable public float Alpha { get; set; } - public TPixel AsPixel() => TPixel.FromScaledVector4(new Vector4(this.Red, this.Green, this.Blue, this.Alpha)); + public TPixel AsPixel() => TPixel.FromScaledVector4(new(this.Red, this.Green, this.Blue, this.Alpha)); internal Span AsSpan() => new([this.AsPixel()]); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index fbdfb9d61..39c8c4c94 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -69,7 +69,7 @@ public static class TestUtils Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new La16(expected[cnt++], expected[cnt++]); + row[x] = new(expected[cnt++], expected[cnt++]); } } }); @@ -393,7 +393,7 @@ public static class TestUtils if (property is null) { - throw new Exception($"No dither named '{name}"); + throw new($"No dither named '{name}"); } return (IDither)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs index 350333965..4130d89da 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs @@ -35,7 +35,7 @@ public class TestVector4 : IXunitSerializable public Vector4 AsVector() { - return new Vector4(this.X, this.Y, this.Z, this.W); + return new(this.X, this.Y, this.Z, this.W); } public void Deserialize(IXunitSerializationInfo info) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index 52447b6c2..f4944992a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs @@ -51,7 +51,7 @@ public class BasicSerializerTests [Fact] public void SerializeDeserialize_ShouldPreserveValues() { - var obj = new DerivedObj() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; + DerivedObj obj = new DerivedObj() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; string str = BasicSerializer.Serialize(obj); BaseObj mirrorBase = BasicSerializer.Deserialize(str); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 4c1a740e2..649c626a1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -31,7 +31,7 @@ public class ImageComparerTests { using (Image clone = image.Clone()) { - var comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); + ImageComparer comparer = ImageComparer.Tolerant(imageThreshold, pixelThreshold); comparer.VerifySimilarity(image, clone); } } @@ -48,7 +48,7 @@ public class ImageComparerTests { ImagingTestCaseUtility.ModifyPixel(clone, 0, 0, 1); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); comparer.VerifySimilarity(image, clone); } } @@ -66,13 +66,13 @@ public class ImageComparerTests byte perChannelChange = 20; ImagingTestCaseUtility.ModifyPixel(clone, 3, 1, perChannelChange); - var comparer = ImageComparer.Tolerant(); + ImageComparer comparer = ImageComparer.Tolerant(); ImageDifferenceIsOverThresholdException ex = Assert.ThrowsAny( () => comparer.VerifySimilarity(image, clone)); PixelDifference diff = ex.Reports.Single().Differences.Single(); - Assert.Equal(new Point(3, 1), diff.Position); + Assert.Equal(new(3, 1), diff.Position); } } } @@ -90,7 +90,7 @@ public class ImageComparerTests ImagingTestCaseUtility.ModifyPixel(clone, 1, 0, 1); ImagingTestCaseUtility.ModifyPixel(clone, 2, 0, 1); - var comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); + ImageComparer comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 257 * 3); comparer.VerifySimilarity(image, clone); } } @@ -131,7 +131,7 @@ public class ImageComparerTests IEnumerable reports = ImageComparer.Exact.CompareImages(image, clone); PixelDifference difference = reports.Single().Differences.Single(); - Assert.Equal(new Point(42, 43), difference.Position); + Assert.Equal(new(42, 43), difference.Position); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 6e1eba28e..90e726194 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -76,7 +76,7 @@ public class ReferenceDecoderBenchmarks private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) { - var measure = new MeasureFixture(this.Output); + MeasureFixture measure = new MeasureFixture(this.Output); measure.Measure( times, () => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 460858379..4a88cfb1b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Drawing; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.PixelFormats; @@ -35,7 +36,7 @@ public class SystemDrawingReferenceCodecTests { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new System.Drawing.Bitmap(path); using Image image = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); image.DebugSave(dummyProvider); } @@ -49,7 +50,7 @@ public class SystemDrawingReferenceCodecTests sourceImage.Mutate(c => c.MakeOpaque()); } - var encoder = new PngEncoder { ColorType = pngColorType }; + PngEncoder encoder = new PngEncoder { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } @@ -65,7 +66,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.RgbWithAlpha); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new System.Drawing.Bitmap(path); using Image original = provider.GetImage(); using Image resaved = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; @@ -80,7 +81,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.Rgb); using Image original = provider.GetImage(); - using var sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new System.Drawing.Bitmap(path); using Image resaved = SystemDrawingBridge.From24bppRgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; comparer.VerifySimilarity(original, resaved); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 46fb7159e..520f40e72 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -83,7 +83,7 @@ public class TestUtilityExtensionsTests PixelTypes pt, IEnumerable> pixelTypesExp) { - Assert.Contains(new KeyValuePair(pt, typeof(T)), pixelTypesExp); + Assert.Contains(new(pt, typeof(T)), pixelTypesExp); } [Fact] From 946c0c468e0cfba361d54219e50044227e165270 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 21 Jun 2025 19:58:14 +0200 Subject: [PATCH 016/112] Also configure it for rider/resharper --- .editorconfig | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4aaab02c1..af1e5b44c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -161,9 +161,6 @@ csharp_style_deconstructed_variable_declaration = true:warning csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_implicit_object_creation_when_type_is_apparent = true:error -# Collection expression preferences -# dotnet_style_prefer_collection_expression = true:error - # "Null" checking preferences csharp_style_throw_expression = true:warning csharp_style_conditional_delegate_call = true:warning @@ -178,11 +175,6 @@ csharp_prefer_static_local_function = true:warning # Primary constructor preferences csharp_style_prefer_primary_constructors = false:none -# ReSharper inspection severities -resharper_arrange_object_creation_when_type_evident_highlighting = error -resharper_arrange_object_creation_when_type_not_evident_highlighting = error -# resharper_use_collection_expression_highlighting = error - ########################################## # Unnecessary Code Rules # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules From f7b9f2abb51332b2a5b94795ba7309af228e2be0 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 24 Jun 2025 22:11:35 +1000 Subject: [PATCH 017/112] Fix #2953 --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 5 +++++ .../Formats/Gif/GifDecoderTests.cs | 17 +++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/Gif/issues/issue_2953.gif | 3 +++ 4 files changed, 26 insertions(+) create mode 100644 tests/Images/Input/Gif/issues/issue_2953.gif diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index f6e3643d5..6a28c3403 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -414,6 +414,11 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowInvalidImageContentException($"Gif comment length '{length}' exceeds max '{GifConstants.MaxCommentSubBlockLength}' of a comment data block"); } + if (length == -1) + { + GifThrowHelper.ThrowInvalidImageContentException("Unexpected end of stream while reading gif comment"); + } + if (this.skipMetadata) { stream.Seek(length, SeekOrigin.Current); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 6593b8df7..9bf5a13c4 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -381,4 +381,21 @@ public class GifDecoderTests image.DebugSaveMultiFrame(provider); image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); } + + // https://github.com/SixLabors/ImageSharp/issues/2953 + [Theory] + [WithFile(TestImages.Gif.Issues.Issue2953, PixelTypes.Rgba32)] + public void Issue2953(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + // We should throw a InvalidImageContentException when trying to identify or load an invalid GIF file. + TestFile testFile = TestFile.Create(provider.SourceFileOrDescription); + + Assert.Throws(() => Image.Identify(testFile.FullPath)); + Assert.Throws(() => Image.Load(testFile.FullPath)); + + DecoderOptions options = new() { SkipMetadata = true }; + Assert.Throws(() => Image.Identify(options, testFile.FullPath)); + Assert.Throws(() => Image.Load(options, testFile.FullPath)); + } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 406283b97..021f02476 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -581,6 +581,7 @@ public static class TestImages public const string Issue2866 = "Gif/issues/issue_2866.gif"; public const string Issue2859_A = "Gif/issues/issue_2859_A.gif"; public const string Issue2859_B = "Gif/issues/issue_2859_B.gif"; + public const string Issue2953 = "Gif/issues/issue_2953.gif"; } public static readonly string[] Animated = diff --git a/tests/Images/Input/Gif/issues/issue_2953.gif b/tests/Images/Input/Gif/issues/issue_2953.gif new file mode 100644 index 000000000..98c06e5c5 --- /dev/null +++ b/tests/Images/Input/Gif/issues/issue_2953.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fa4a002b264a41677cc10f115f3572111852993a53ee8cea5f4ec0bf8dec195 +size 40 From 18b8b662e9c959f685bec92bfbae4c8b5daddb9e Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Wed, 25 Jun 2025 20:46:20 +0200 Subject: [PATCH 018/112] Use Target Type new only when apparent --- .editorconfig | 3 + .../Advanced/ParallelExecutionSettings.cs | 4 +- .../Advanced/ParallelRowIterator.Wrappers.cs | 4 +- src/ImageSharp/Color/Color.WernerPalette.cs | 2 +- src/ImageSharp/Color/Color.cs | 6 +- src/ImageSharp/ColorProfiles/CieLab.cs | 8 +- src/ImageSharp/ColorProfiles/CieLch.cs | 10 +- src/ImageSharp/ColorProfiles/CieLchuv.cs | 8 +- src/ImageSharp/ColorProfiles/CieLuv.cs | 4 +- src/ImageSharp/ColorProfiles/CieXyy.cs | 8 +- src/ImageSharp/ColorProfiles/CieXyz.cs | 8 +- src/ImageSharp/ColorProfiles/Cmyk.cs | 6 +- .../ColorProfiles/ColorProfileConverter.cs | 2 +- .../ColorProfileConverterExtensionsIcc.cs | 16 +-- src/ImageSharp/ColorProfiles/Hsl.cs | 8 +- src/ImageSharp/ColorProfiles/Hsv.cs | 10 +- src/ImageSharp/ColorProfiles/HunterLab.cs | 8 +- .../Icc/Calculators/ColorTrcCalculator.cs | 6 +- .../Icc/Calculators/CurveCalculator.cs | 2 +- .../Icc/Calculators/GrayTrcCalculator.cs | 2 +- .../Icc/Calculators/LutABCalculator.cs | 10 +- .../Icc/Calculators/LutEntryCalculator.cs | 4 +- .../Icc/Calculators/MatrixCalculator.cs | 2 +- .../ColorProfiles/Icc/CompactSrgbV4Profile.cs | 2 +- .../Icc/IccConverterbase.Conversions.cs | 4 +- .../KnownChromaticAdaptationMatrices.cs | 12 +- .../ColorProfiles/KnownRgbWorkingSpaces.cs | 38 +++--- .../ColorProfiles/KnownYCbCrMatrices.cs | 18 +-- src/ImageSharp/ColorProfiles/Lms.cs | 4 +- src/ImageSharp/ColorProfiles/Rgb.cs | 6 +- .../VonKriesChromaticAdaptation.cs | 6 +- src/ImageSharp/ColorProfiles/Y.cs | 2 +- src/ImageSharp/ColorProfiles/YCbCr.cs | 6 +- src/ImageSharp/ColorProfiles/YccK.cs | 6 +- .../Extensions/ConfigurationExtensions.cs | 2 +- src/ImageSharp/Common/Helpers/Numerics.cs | 2 +- .../Common/Helpers/SimdUtils.Pack.cs | 2 +- src/ImageSharp/Common/Helpers/SimdUtils.cs | 2 +- src/ImageSharp/Common/Helpers/TolerantMath.cs | 2 +- .../Common/Helpers/UnitConverter.cs | 4 +- src/ImageSharp/Compression/Zlib/Deflater.cs | 2 +- .../Compression/Zlib/DeflaterEngine.cs | 2 +- .../Compression/Zlib/DeflaterHuffman.cs | 8 +- .../Compression/Zlib/DeflaterOutputStream.cs | 2 +- .../Compression/Zlib/ZlibDeflateStream.cs | 2 +- .../Compression/Zlib/ZlibInflateStream.cs | 2 +- src/ImageSharp/Configuration.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoder.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 16 +-- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 6 +- src/ImageSharp/Formats/Bmp/BmpFormat.cs | 2 +- src/ImageSharp/Formats/Bmp/BmpMetadata.cs | 16 +-- .../Formats/Cur/CurFrameMetadata.cs | 8 +- src/ImageSharp/Formats/Cur/CurMetadata.cs | 4 +- src/ImageSharp/Formats/DecoderOptions.cs | 2 +- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 12 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 +- .../Formats/Gif/GifFrameMetadata.cs | 2 +- src/ImageSharp/Formats/Gif/GifMetadata.cs | 2 +- .../GifNetscapeLoopingApplicationExtension.cs | 2 +- .../Sections/GifXmpApplicationExtension.cs | 2 +- .../Formats/Ico/IcoFrameMetadata.cs | 8 +- src/ImageSharp/Formats/Ico/IcoMetadata.cs | 4 +- .../Formats/Icon/IconDecoderCore.cs | 12 +- .../Formats/Icon/IconEncoderCore.cs | 6 +- src/ImageSharp/Formats/ImageFormatManager.cs | 2 +- .../Formats/Jpeg/Components/Block8x8.cs | 2 +- .../Jpeg/Components/Block8x8F.ScaledCopy.cs | 8 +- .../JpegColorConverter.TiffYccKScalar.cs | 4 +- .../JpegColorConverter.YCbCrScalar.cs | 2 +- .../JpegColorConverter.YccKScalar.cs | 2 +- .../ColorConverters/JpegColorConverterBase.cs | 2 +- .../Jpeg/Components/Decoder/AdobeMarker.cs | 2 +- .../Decoder/ArithmeticScanDecoder.cs | 2 +- .../Components/Decoder/HuffmanScanDecoder.cs | 4 +- .../Jpeg/Components/Decoder/JFifMarker.cs | 2 +- .../Jpeg/Components/Decoder/JpegComponent.cs | 4 +- .../Components/Decoder/SpectralConverter.cs | 2 +- .../Jpeg/Components/Encoder/Component.cs | 4 +- .../Components/Encoder/ComponentProcessor.cs | 2 +- .../Components/Encoder/HuffmanScanEncoder.cs | 2 +- .../Jpeg/Components/Encoder/JpegFrame.cs | 2 +- .../Encoder/SpectralConverter{TPixel}.cs | 2 +- .../Formats/Jpeg/Components/SizeExtensions.cs | 2 +- src/ImageSharp/Formats/Jpeg/JpegDecoder.cs | 2 +- .../Formats/Jpeg/JpegDecoderCore.cs | 34 +++--- .../Jpeg/JpegEncoderCore.FrameConfig.cs | 84 +++++++------- src/ImageSharp/Formats/Jpeg/JpegFormat.cs | 2 +- src/ImageSharp/Formats/Jpeg/JpegMetadata.cs | 4 +- src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs | 8 +- src/ImageSharp/Formats/Pbm/PbmMetadata.cs | 4 +- src/ImageSharp/Formats/Pbm/PlainDecoder.cs | 8 +- .../Formats/Png/Chunks/PngPhysical.cs | 4 +- src/ImageSharp/Formats/Png/PngDecoder.cs | 2 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 34 +++--- .../Formats/Png/PngDecoderOptions.cs | 2 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 2 +- src/ImageSharp/Formats/Png/PngFormat.cs | 2 +- .../Formats/Png/PngFrameMetadata.cs | 6 +- src/ImageSharp/Formats/Png/PngMetadata.cs | 4 +- .../Formats/Png/PngScanlineProcessor.cs | 12 +- src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs | 4 +- src/ImageSharp/Formats/Qoi/QoiFormat.cs | 2 +- src/ImageSharp/Formats/Qoi/QoiMetadata.cs | 6 +- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 12 +- src/ImageSharp/Formats/Tga/TgaFormat.cs | 2 +- src/ImageSharp/Formats/Tga/TgaMetadata.cs | 10 +- .../Compressors/DeflateCompressor.cs | 4 +- .../Compression/Compressors/LzwCompressor.cs | 2 +- .../Compressors/TiffJpegCompressor.cs | 2 +- .../Decompressors/DeflateTiffCompression.cs | 2 +- .../Compression/Decompressors/LzwString.cs | 4 +- .../Decompressors/LzwTiffCompression.cs | 2 +- .../ModifiedHuffmanTiffCompression.cs | 2 +- .../Decompressors/T4TiffCompression.cs | 2 +- .../Decompressors/T6TiffCompression.cs | 2 +- .../Decompressors/TiffLzwDecoder.cs | 2 +- .../Decompressors/WebpTiffCompression.cs | 2 +- .../Tiff/Compression/HorizontalPredictor.cs | 6 +- .../Compression/TiffDecompressorsFactory.cs | 5 +- .../BlackIsZero16TiffColor{TPixel}.cs | 2 +- .../BlackIsZero32FloatTiffColor{TPixel}.cs | 4 +- .../BlackIsZero4TiffColor{TPixel}.cs | 6 +- .../BlackIsZeroTiffColor{TPixel}.cs | 3 +- .../CieLabPlanarTiffColor{TPixel}.cs | 3 +- .../CieLabTiffColor{TPixel}.cs | 3 +- .../CmykTiffColor{TPixel}.cs | 4 +- .../PaletteTiffColor{TPixel}.cs | 3 +- .../Rgb161616TiffColor{TPixel}.cs | 2 +- .../Rgb16PlanarTiffColor{TPixel}.cs | 4 +- .../RgbFloat323232TiffColor{TPixel}.cs | 5 +- .../RgbPlanarTiffColor{TPixel}.cs | 3 +- .../RgbTiffColor{TPixel}.cs | 2 +- .../Rgba16161616TiffColor{TPixel}.cs | 2 +- .../Rgba16PlanarTiffColor{TPixel}.cs | 4 +- .../RgbaFloat32323232TiffColor{TPixel}.cs | 5 +- .../WhiteIsZero16TiffColor{TPixel}.cs | 4 +- .../WhiteIsZero32FloatTiffColor{TPixel}.cs | 4 +- .../WhiteIsZero4TiffColor{TPixel}.cs | 6 +- .../WhiteIsZero8TiffColor{TPixel}.cs | 2 +- .../WhiteIsZeroTiffColor{TPixel}.cs | 2 +- .../YCbCrConverter.cs | 8 +- .../YCbCrPlanarTiffColor{TPixel}.cs | 2 +- .../YCbCrTiffColor{TPixel}.cs | 2 +- .../Formats/Tiff/TiffBitsPerSample.cs | 2 +- .../Formats/Tiff/TiffDecoderCore.cs | 6 +- .../Tiff/TiffDecoderMetadataCreator.cs | 4 +- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 6 +- .../Tiff/TiffEncoderEntriesCollector.cs | 4 +- src/ImageSharp/Formats/Tiff/TiffFormat.cs | 6 +- src/ImageSharp/Formats/Tiff/TiffMetadata.cs | 14 +-- .../Formats/Tiff/Utils/TiffUtilities.cs | 2 +- .../Tiff/Writers/TiffBiColorWriter{TPixel}.cs | 2 +- .../Tiff/Writers/TiffPaletteWriter{TPixel}.cs | 4 +- src/ImageSharp/Formats/Webp/AlphaDecoder.cs | 4 +- src/ImageSharp/Formats/Webp/AlphaEncoder.cs | 2 +- .../Formats/Webp/BitWriter/Vp8BitWriter.cs | 4 +- .../Formats/Webp/BitWriter/Vp8LBitWriter.cs | 2 +- .../Formats/Webp/Chunks/WebpFrameData.cs | 2 +- .../Webp/Lossless/BackwardReferenceEncoder.cs | 12 +- .../Formats/Webp/Lossless/CostManager.cs | 10 +- .../Formats/Webp/Lossless/CrunchConfig.cs | 2 +- .../Formats/Webp/Lossless/HTreeGroup.cs | 2 +- .../Formats/Webp/Lossless/HuffmanUtils.cs | 2 +- .../Formats/Webp/Lossless/Vp8LDecoder.cs | 2 +- .../Formats/Webp/Lossless/Vp8LEncoder.cs | 18 +-- .../Formats/Webp/Lossless/Vp8LHistogram.cs | 2 +- .../Formats/Webp/Lossless/Vp8LHistogramSet.cs | 8 +- .../Webp/Lossless/WebpLosslessDecoder.cs | 8 +- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 18 +-- .../Formats/Webp/Lossy/Vp8BandProbas.cs | 2 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs | 2 +- .../Formats/Webp/Lossy/Vp8Decoder.cs | 18 +-- .../Formats/Webp/Lossy/Vp8EncIterator.cs | 2 +- .../Formats/Webp/Lossy/Vp8EncProba.cs | 8 +- .../Formats/Webp/Lossy/Vp8Encoder.cs | 12 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs | 2 +- src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs | 2 +- .../Formats/Webp/Lossy/WebpLossyDecoder.cs | 6 +- .../Formats/Webp/WebpAnimationDecoder.cs | 4 +- .../Formats/Webp/WebpChunkParsingUtils.cs | 10 +- src/ImageSharp/Formats/Webp/WebpDecoder.cs | 2 +- .../Formats/Webp/WebpDecoderCore.cs | 10 +- .../Formats/Webp/WebpDecoderOptions.cs | 2 +- src/ImageSharp/Formats/Webp/WebpFormat.cs | 6 +- src/ImageSharp/Formats/Webp/WebpMetadata.cs | 4 +- .../GraphicOptionsDefaultsExtensions.cs | 2 +- src/ImageSharp/GraphicsOptions.cs | 2 +- src/ImageSharp/IO/ChunkedMemoryStream.cs | 2 +- src/ImageSharp/Image.Decode.cs | 2 +- src/ImageSharp/Image.WrapMemory.cs | 20 ++-- src/ImageSharp/Image.cs | 2 +- src/ImageSharp/ImageFrame.LoadPixelData.cs | 2 +- src/ImageSharp/ImageFrame.cs | 2 +- .../ImageFrameCollection{TPixel}.cs | 8 +- src/ImageSharp/ImageFrame{TPixel}.cs | 6 +- src/ImageSharp/Image{TPixel}.cs | 20 ++-- .../Allocators/Internals/ManagedBufferBase.cs | 2 +- .../Internals/SharedArrayPoolBuffer{T}.cs | 2 +- ...iformUnmanagedMemoryPool.LifetimeGuards.cs | 2 +- .../Internals/UniformUnmanagedMemoryPool.cs | 4 +- .../Internals/UnmanagedBuffer{T}.cs | 4 +- .../Internals/UnmanagedMemoryHandle.cs | 4 +- ...iformUnmanagedMemoryPoolMemoryAllocator.cs | 4 +- src/ImageSharp/Memory/Buffer2DExtensions.cs | 2 +- src/ImageSharp/Memory/Buffer2DRegion{T}.cs | 4 +- src/ImageSharp/Memory/ByteMemoryOwner{T}.cs | 2 +- .../MemoryGroupExtensions.cs | 12 +- .../MemoryGroupView{T}.cs | 4 +- .../MemoryGroup{T}.Consumed.cs | 4 +- .../MemoryGroup{T}.Owned.cs | 6 +- .../DiscontiguousBuffers/MemoryGroup{T}.cs | 4 +- .../Memory/MemoryAllocatorExtensions.cs | 4 +- src/ImageSharp/Memory/RowInterval.cs | 4 +- .../Memory/UnmanagedMemoryManager{T}.cs | 4 +- .../Profiles/Exif/ExifEncodedStringHelpers.cs | 6 +- .../Metadata/Profiles/Exif/ExifProfile.cs | 2 +- .../Metadata/Profiles/Exif/ExifReader.cs | 4 +- .../Profiles/Exif/Tags/ExifTag.Byte.cs | 6 +- .../Profiles/Exif/Tags/ExifTag.ByteArray.cs | 16 +-- .../Profiles/Exif/Tags/ExifTag.DoubleArray.cs | 8 +- .../Exif/Tags/ExifTag.EncodedString.cs | 6 +- .../Profiles/Exif/Tags/ExifTag.Long.cs | 42 +++---- .../Profiles/Exif/Tags/ExifTag.LongArray.cs | 22 ++-- .../Profiles/Exif/Tags/ExifTag.Number.cs | 18 +-- .../Profiles/Exif/Tags/ExifTag.NumberArray.cs | 10 +- .../Profiles/Exif/Tags/ExifTag.Rational.cs | 66 +++++------ .../Exif/Tags/ExifTag.RationalArray.cs | 20 ++-- .../Profiles/Exif/Tags/ExifTag.Short.cs | 94 +++++++-------- .../Profiles/Exif/Tags/ExifTag.ShortArray.cs | 40 +++---- .../Exif/Tags/ExifTag.SignedRational.cs | 12 +- .../Exif/Tags/ExifTag.SignedRationalArray.cs | 2 +- .../Exif/Tags/ExifTag.SignedShortArray.cs | 2 +- .../Profiles/Exif/Tags/ExifTag.String.cs | 108 +++++++++--------- .../Profiles/Exif/Tags/ExifTag.Ucs2String.cs | 10 +- .../Profiles/Exif/Tags/ExifTag.Undefined.cs | 28 ++--- .../Profiles/Exif/Values/ExifEncodedString.cs | 2 +- .../Profiles/Exif/Values/ExifRational.cs | 2 +- .../Profiles/Exif/Values/ExifRationalArray.cs | 4 +- .../ICC/DataReader/IccDataReader.Curves.cs | 18 +-- .../ICC/DataReader/IccDataReader.Lut.cs | 8 +- .../IccDataReader.MultiProcessElement.cs | 6 +- .../DataReader/IccDataReader.NonPrimitives.cs | 20 ++-- .../DataReader/IccDataReader.TagDataEntry.cs | 68 +++++------ .../DataWriter/IccDataWriter.NonPrimitives.cs | 4 +- .../DataWriter/IccDataWriter.TagDataEntry.cs | 6 +- .../Profiles/ICC/DataWriter/IccDataWriter.cs | 2 +- .../Metadata/Profiles/ICC/IccProfile.cs | 2 +- .../Metadata/Profiles/ICC/IccReader.cs | 6 +- .../Metadata/Profiles/ICC/IccWriter.cs | 2 +- .../TagDataEntries/IccLut16TagDataEntry.cs | 2 +- .../IccTextDescriptionTagDataEntry.cs | 12 +- .../Metadata/Profiles/IPTC/IptcProfile.cs | 4 +- .../Metadata/Profiles/IPTC/IptcValue.cs | 2 +- .../PixelBlenders/PorterDuffFunctions.cs | 4 +- .../PixelFormats/PixelComponentInfo.cs | 2 +- .../PixelImplementations/Abgr32.cs | 6 +- .../PixelImplementations/Argb32.cs | 6 +- .../PixelImplementations/Bgr24.cs | 6 +- .../PixelImplementations/Bgr565.cs | 4 +- .../PixelImplementations/Bgra32.cs | 6 +- .../PixelImplementations/Bgra4444.cs | 2 +- .../PixelImplementations/Bgra5551.cs | 2 +- .../PixelImplementations/Byte4.cs | 2 +- .../PixelImplementations/HalfSingle.cs | 4 +- .../PixelImplementations/HalfVector2.cs | 6 +- .../PixelImplementations/HalfVector4.cs | 2 +- .../PixelFormats/PixelImplementations/L16.cs | 4 +- .../PixelFormats/PixelImplementations/L8.cs | 4 +- .../PixelFormats/PixelImplementations/La16.cs | 4 +- .../PixelFormats/PixelImplementations/La32.cs | 18 +-- .../PixelImplementations/NormalizedByte2.cs | 8 +- .../PixelImplementations/NormalizedByte4.cs | 2 +- .../PixelImplementations/NormalizedShort2.cs | 8 +- .../PixelImplementations/NormalizedShort4.cs | 2 +- .../PixelFormats/PixelImplementations/Rg32.cs | 4 +- .../PixelImplementations/Rgb24.cs | 8 +- .../PixelImplementations/Rgb48.cs | 6 +- .../PixelImplementations/Rgba1010102.cs | 2 +- .../PixelImplementations/Rgba32.cs | 10 +- .../PixelImplementations/Rgba64.cs | 4 +- .../PixelImplementations/RgbaVector.cs | 2 +- .../PixelImplementations/Short2.cs | 8 +- .../PixelImplementations/Short4.cs | 2 +- src/ImageSharp/Primitives/ColorMatrix.Impl.cs | 10 +- src/ImageSharp/Primitives/Complex64.cs | 4 +- src/ImageSharp/Primitives/DenseMatrix{T}.cs | 6 +- src/ImageSharp/Primitives/LongRational.cs | 12 +- src/ImageSharp/Primitives/Number.cs | 6 +- src/ImageSharp/Primitives/Point.cs | 2 +- src/ImageSharp/Primitives/Rectangle.cs | 14 +-- src/ImageSharp/Primitives/RectangleF.cs | 8 +- src/ImageSharp/Primitives/SignedRational.cs | 4 +- src/ImageSharp/Primitives/Size.cs | 4 +- src/ImageSharp/Primitives/SizeF.cs | 4 +- src/ImageSharp/Primitives/ValueSize.cs | 6 +- .../HistogramEqualizationExtensions.cs | 2 +- .../Extensions/Transforms/CropExtensions.cs | 2 +- .../Extensions/Transforms/PadExtensions.cs | 2 +- .../Extensions/Transforms/ResizeExtensions.cs | 8 +- .../Transforms/TransformExtensions.cs | 4 +- .../Processing/KnownFilterMatrices.cs | 14 +-- .../CloningImageProcessor{TPixel}.cs | 4 +- .../Convolution/BoxBlurProcessor{TPixel}.cs | 2 +- .../Convolution2DRowOperation{TPixel}.cs | 4 +- .../Convolution/Convolution2DState.cs | 4 +- .../Convolution/ConvolutionState.cs | 2 +- .../EdgeDetector2DProcessor{TPixel}.cs | 2 +- .../Implementation/LaplacianKernelFactory.cs | 2 +- .../Convolution/MedianConvolutionState.cs | 2 +- .../Convolution/MedianRowOperation{TPixel}.cs | 4 +- .../Parameters/BokehBlurKernelDataProvider.cs | 4 +- .../Dithering/ErrorDither.KnownTypes.cs | 18 +-- .../Processors/Dithering/OrderedDither.cs | 2 +- .../Dithering/OrderedDitherFactory.cs | 2 +- .../PaletteDitherProcessor{TPixel}.cs | 2 +- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 4 +- .../Effects/OilPaintingProcessor{TPixel}.cs | 2 +- .../Effects/PixelRowDelegateProcessor.cs | 2 +- ...lRowDelegateProcessor{TPixel,TDelegate}.cs | 2 +- .../PositionAwarePixelRowDelegateProcessor.cs | 2 +- ...eHistogramEqualizationProcessor{TPixel}.cs | 12 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 2 +- .../AutoLevelProcessor{TPixel}.cs | 4 +- ...lHistogramEqualizationProcessor{TPixel}.cs | 2 +- .../Overlays/GlowProcessor{TPixel}.cs | 2 +- .../Overlays/VignetteProcessor{TPixel}.cs | 2 +- .../Quantization/OctreeQuantizer.cs | 2 +- .../Quantization/OctreeQuantizer{TPixel}.cs | 6 +- .../Quantization/PaletteQuantizer.cs | 2 +- .../Quantization/WebSafePaletteQuantizer.cs | 2 +- .../Quantization/WernerPaletteQuantizer.cs | 2 +- .../Processors/Quantization/WuQuantizer.cs | 2 +- .../Quantization/WuQuantizer{TPixel}.cs | 2 +- .../Transforms/CropProcessor{TPixel}.cs | 4 +- .../AffineTransformProcessor{TPixel}.cs | 4 +- .../Transforms/Resize/ResizeHelper.cs | 16 +-- .../Transforms/Resize/ResizeKernelMap.cs | 2 +- .../Resize/ResizeProcessor{TPixel}.cs | 6 +- .../Transforms/Resize/ResizeWorker.cs | 4 +- .../Processors/Transforms/TransformUtils.cs | 18 +-- .../Processing/ProjectiveTransformBuilder.cs | 26 ++--- .../Bulk/FromRgba32Bytes.cs | 2 +- .../Codecs/Bmp/DecodeBmp.cs | 2 +- .../Codecs/Gif/DecodeEncodeGif.cs | 4 +- .../Codecs/Gif/DecodeGif.cs | 2 +- .../Codecs/Gif/EncodeGif.cs | 4 +- .../Codecs/Gif/EncodeGifMultiple.cs | 2 +- .../BlockOperations/Block8x8F_CopyTo2x2.cs | 56 ++++----- .../BlockOperations/Block8x8F_DivideRound.cs | 4 +- .../ColorConversionBenchmark.cs | 2 +- .../Codecs/Jpeg/DecodeJpeg.cs | 2 +- .../Codecs/Jpeg/DecodeJpegParseStreamOnly.cs | 3 +- .../Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs | 4 +- .../Codecs/Jpeg/EncodeJpegComparison.cs | 6 +- .../Codecs/Jpeg/EncodeJpegFeatures.cs | 4 +- .../Codecs/MultiImageBenchmarkBase.cs | 2 +- .../Codecs/Png/EncodeIndexedPng.cs | 6 +- .../Codecs/Tga/EncodeTga.cs | 2 +- .../Codecs/Tiff/EncodeTiff.cs | 2 +- .../Codecs/Webp/EncodeWebp.cs | 2 +- .../Color/ColorEquality.cs | 2 +- .../Color/RgbWorkingSpaceAdapt.cs | 2 +- .../ImageSharp.Benchmarks/Color/YcbCrToRgb.cs | 4 +- .../General/Adler32Benchmark.cs | 2 +- .../ImageSharp.Benchmarks/General/Array2D.cs | 2 +- .../General/BasicMath/ClampSpan.cs | 2 +- .../General/BasicMath/ClampVector4.cs | 4 +- .../General/CopyBuffers.cs | 4 +- .../General/IO/BufferedStreams.cs | 32 +++--- .../PixelConversion_ConvertFromRgba32.cs | 6 +- .../PixelConversion_ConvertFromVector4.cs | 4 +- .../PixelConversion_ConvertToRgba32.cs | 4 +- ...vertToRgba32_AsPartOfCompositeOperation.cs | 4 +- .../PixelConversion_ConvertToVector4.cs | 2 +- ...ertToVector4_AsPartOfCompositeOperation.cs | 2 +- .../PixelConversion_Rgba32_To_Bgra32.cs | 4 +- .../General/PixelConversion/TestArgb.cs | 2 +- .../General/PixelConversion/TestRgba.cs | 2 +- .../General/Vector4Constants.cs | 8 +- .../General/Vectorization/BitwiseOrUint32.cs | 4 +- .../General/Vectorization/DivFloat.cs | 4 +- .../General/Vectorization/DivUInt32.cs | 4 +- .../General/Vectorization/Divide.cs | 2 +- .../General/Vectorization/MulFloat.cs | 6 +- .../General/Vectorization/MulUInt32.cs | 4 +- .../General/Vectorization/Multiply.cs | 2 +- .../General/Vectorization/Premultiply.cs | 6 +- .../Vectorization/ReinterpretUInt32AsFloat.cs | 2 +- .../General/Vectorization/UInt32ToSingle.cs | 14 +-- .../General/Vectorization/VectorFetching.cs | 12 +- .../LoadResizeSaveStressBenchmarks.cs | 2 +- .../LoadResizeSaveStressRunner.cs | 6 +- .../PixelBlenders/PorterDuffBulkVsPixel.cs | 4 +- .../ImageSharp.Benchmarks/Processing/Crop.cs | 4 +- .../Processing/HistogramEqualization.cs | 4 +- .../Processing/OilPaint.cs | 2 +- .../Processing/Resize.cs | 4 +- .../LoadResizeSaveParallelMemoryStress.cs | 4 +- .../Program.cs | 4 +- .../Color/ColorTests.CastTo.cs | 8 +- tests/ImageSharp.Tests/Color/ColorTests.cs | 16 +-- .../Color/ReferencePalette.cs | 2 +- tests/ImageSharp.Tests/Color/RgbaDouble.cs | 2 +- .../ColorProfiles/CieLabTests.cs | 4 +- .../ColorProfiles/CieLchTests.cs | 4 +- .../ColorProfiles/CieLchuvTests.cs | 4 +- .../ColorProfiles/CieLuvTests.cs | 4 +- .../CieXyChromaticityCoordinatesTests.cs | 4 +- .../ColorProfiles/CieXyyTests.cs | 4 +- .../ColorProfiles/CieXyzTests.cs | 4 +- .../ColorProfiles/CmykTests.cs | 4 +- .../ColorProfiles/CompandingTests.cs | 2 +- .../ColorProfiles/HslTests.cs | 4 +- .../ColorProfiles/HsvTests.cs | 4 +- .../ColorProfiles/HunterLabTests.cs | 4 +- .../Icc/ColorProfileConverterTests.Icc.cs | 16 +-- .../ColorProfiles/Icc/TestIccProfiles.cs | 5 +- .../ColorProfiles/LmsTests.cs | 4 +- .../ColorProfiles/RgbTests.cs | 4 +- .../StringRepresentationTests.cs | 2 +- .../ColorProfiles/YCbCrTests.cs | 4 +- .../ImageSharp.Tests/ColorProfiles/YTests.cs | 4 +- .../ColorProfiles/YccKTests.cs | 4 +- .../Common/EncoderExtensionsTests.cs | 2 +- .../ImageSharp.Tests/Common/NumericsTests.cs | 2 +- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 6 +- .../Common/StreamExtensionsTests.cs | 10 +- tests/ImageSharp.Tests/ConfigurationTests.cs | 2 +- .../Drawing/DrawImageTests.cs | 24 ++-- .../Formats/Bmp/BmpEncoderTests.cs | 2 +- .../Formats/Bmp/BmpFileHeaderTests.cs | 2 +- .../Formats/Bmp/ImageExtensionsTest.cs | 4 +- .../Formats/Gif/GifDecoderTests.cs | 10 +- .../Formats/Gif/GifEncoderTests.cs | 10 +- .../Formats/Gif/GifMetadataTests.cs | 4 +- .../Formats/Gif/ImageExtensionsTest.cs | 4 +- .../Formats/Icon/Ico/IcoDecoderTests.cs | 5 +- .../Formats/ImageFormatManagerTests.cs | 2 +- .../Formats/Jpg/Block8x8Tests.cs | 6 +- .../Formats/Jpg/HuffmanScanEncoderTests.cs | 2 +- .../Formats/Jpg/ImageExtensionsTest.cs | 4 +- .../Formats/Jpg/JpegColorConverterTests.cs | 24 ++-- .../Formats/Jpg/JpegDecoderTests.Metadata.cs | 12 +- .../Formats/Jpg/JpegDecoderTests.cs | 16 +-- .../Formats/Jpg/JpegEncoderTests.Metadata.cs | 4 +- .../Formats/Jpg/JpegFileMarkerTests.cs | 2 +- .../Formats/Jpg/JpegMetadataTests.cs | 16 +-- .../Formats/Jpg/ParseStreamTests.cs | 6 +- .../Formats/Jpg/SpectralJpegTests.cs | 6 +- .../Jpg/SpectralToPixelConversionTests.cs | 2 +- .../Formats/Jpg/Utils/JpegFixture.cs | 12 +- .../Formats/Jpg/Utils/LibJpegTools.cs | 6 +- ...ceImplementations.LLM_FloatingPoint_DCT.cs | 10 +- .../Formats/Jpg/Utils/VerifyJpeg.cs | 2 +- .../Formats/Pbm/ImageExtensionsTest.cs | 4 +- .../Formats/Pbm/PbmDecoderTests.cs | 6 +- .../Formats/Pbm/PbmEncoderTests.cs | 12 +- .../Formats/Pbm/PbmRoundTripTests.cs | 6 +- .../Formats/Png/Adler32Tests.cs | 2 +- .../Formats/Png/ImageExtensionsTest.cs | 4 +- .../Formats/Png/PngDecoderTests.Chunks.cs | 2 +- .../Formats/Png/PngDecoderTests.cs | 10 +- .../Formats/Png/PngEncoderFilterTests.cs | 28 ++--- .../Formats/Png/PngEncoderTests.cs | 6 +- .../Formats/Png/PngFrameMetadataTests.cs | 4 +- .../Formats/Png/PngMetadataTests.cs | 4 +- .../Formats/Png/PngTextDataTests.cs | 2 +- .../Formats/Qoi/ImageExtensionsTest.cs | 4 +- .../Formats/Tga/ImageExtensionsTest.cs | 4 +- .../Formats/Tga/TgaDecoderTests.cs | 2 +- .../Formats/Tiff/BigTiffMetadataTests.cs | 2 +- .../DeflateTiffCompressionTests.cs | 2 +- .../Compression/LzwTiffCompressionTests.cs | 2 +- .../Compression/NoneTiffCompressionTests.cs | 6 +- .../PackBitsTiffCompressionTests.cs | 6 +- .../Formats/Tiff/ImageExtensionsTest.cs | 4 +- .../BlackIsZeroTiffColorTests.cs | 2 +- .../PaletteTiffColorTests.cs | 4 +- .../PhotometricInterpretationTestBase.cs | 4 +- .../RgbPlanarTiffColorTests.cs | 78 ++++++------- .../RgbTiffColorTests.cs | 78 ++++++------- .../WhiteIsZeroTiffColorTests.cs | 2 +- .../Formats/Tiff/TiffDecoderTests.cs | 2 +- .../Formats/Tiff/TiffEncoderBaseTester.cs | 6 +- .../Tiff/TiffEncoderMultiframeTests.cs | 20 ++-- .../Formats/Tiff/TiffEncoderTests.cs | 2 +- .../Formats/Tiff/Utils/TiffWriterTests.cs | 32 +++--- .../Formats/WebP/ImageExtensionsTests.cs | 4 +- .../Formats/WebP/LosslessUtilsTests.cs | 4 +- .../Formats/WebP/PredictorEncoderTests.cs | 2 +- .../Formats/WebP/Vp8HistogramTests.cs | 12 +- .../Formats/WebP/Vp8ModeScoreTests.cs | 10 +- .../Formats/WebP/Vp8ResidualTests.cs | 6 +- .../Formats/WebP/WebpDecoderTests.cs | 6 +- .../Formats/WebP/WebpEncoderTests.cs | 4 +- .../Formats/WebP/WebpMetaDataTests.cs | 12 +- .../GraphicOptionsDefaultsExtensionsTests.cs | 46 ++++---- .../ImageSharp.Tests/GraphicsOptionsTests.cs | 8 +- .../Helpers/ColorNumericsTests.cs | 2 +- .../ImageSharp.Tests/Helpers/NumericsTests.cs | 8 +- .../Helpers/ParallelExecutionSettingsTests.cs | 2 +- .../Helpers/ParallelRowIteratorTests.cs | 2 +- .../Helpers/RowIntervalTests.cs | 14 +-- .../Helpers/TolerantMathTests.cs | 2 +- .../IO/ChunkedMemoryStreamTests.cs | 4 +- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 4 +- .../Image/ImageFrameCollectionTests.cs | 7 +- .../ImageSharp.Tests/Image/ImageFrameTests.cs | 18 +-- .../Image/ImageRotationTests.cs | 6 +- .../ImageSharp.Tests/Image/ImageSaveTests.cs | 10 +- .../Image/ImageTests.DetectFormat.cs | 4 +- .../Image/ImageTests.EncodeCancellation.cs | 28 ++--- .../Image/ImageTests.Identify.cs | 4 +- .../Image/ImageTests.ImageLoadTestBase.cs | 16 +-- ..._FileSystemPath_UseDefaultConfiguration.cs | 2 +- ...s.Load_FromBytes_UseGlobalConfiguration.cs | 2 +- ...ts.Load_FromStream_ThrowsRightException.cs | 2 +- ...Load_FromStream_UseDefaultConfiguration.cs | 6 +- .../Image/ImageTests.WrapMemory.cs | 4 +- .../Image/LargeImageIntegrationTests.cs | 2 +- .../Image/ProcessPixelRowsTestBase.cs | 6 +- tests/ImageSharp.Tests/Issues/Issue594.cs | 2 +- .../Memory/Allocators/BufferTestSuite.cs | 2 +- .../RefCountedLifetimeGuardTests.cs | 10 +- .../Allocators/SharedArrayPoolBufferTests.cs | 4 +- .../SimpleGcMemoryAllocatorTests.cs | 2 +- .../UniformUnmanagedMemoryPoolTests.Trim.cs | 18 +-- .../UniformUnmanagedMemoryPoolTests.cs | 54 ++++----- ...niformUnmanagedPoolMemoryAllocatorTests.cs | 8 +- .../Memory/Allocators/UnmanagedBufferTests.cs | 2 +- .../Allocators/UnmanagedMemoryHandleTests.cs | 2 +- .../Memory/Buffer2DTests.SwapOrCopyContent.cs | 4 +- .../ImageSharp.Tests/Memory/Buffer2DTests.cs | 12 +- .../Memory/BufferAreaTests.cs | 12 +- .../DiscontiguousBuffers/MemoryGroupIndex.cs | 6 +- .../MemoryGroupIndexTests.cs | 6 +- .../MemoryGroupTests.Allocate.cs | 6 +- .../DiscontiguousBuffers/MemoryGroupTests.cs | 10 +- .../MemoryGroupTestsBase.cs | 2 +- tests/ImageSharp.Tests/Memory/TestStructs.cs | 4 +- .../MemoryAllocatorValidator.cs | 2 +- .../Metadata/ImageFrameMetadataTests.cs | 2 +- .../Metadata/ImageMetadataTests.cs | 6 +- .../Profiles/CICP/CicpProfileTests.cs | 8 +- .../Profiles/Exif/ExifProfileTests.cs | 38 +++--- .../Metadata/Profiles/Exif/ExifReaderTests.cs | 4 +- .../Exif/ExifTagDescriptionAttributeTests.cs | 2 +- .../Profiles/Exif/Values/ExifValuesTests.cs | 44 +++---- .../DataReader/IccDataReaderCurvesTests.cs | 2 +- .../ICC/DataReader/IccDataReaderLutTests.cs | 2 +- .../IccDataReaderMultiProcessElementTests.cs | 2 +- .../IccDataReaderNonPrimitivesTests.cs | 2 +- .../IccDataReaderPrimitivesTests.cs | 2 +- .../IccDataReaderTagDataEntryTests.cs | 2 +- .../DataWriter/IccDataWriterCurvesTests.cs | 2 +- .../ICC/DataWriter/IccDataWriterLutTests.cs | 2 +- .../Metadata/Profiles/ICC/IccProfileTests.cs | 2 +- .../Metadata/Profiles/ICC/IccWriterTests.cs | 2 +- .../Profiles/ICC/Various/IccProfileIdTests.cs | 2 +- .../Profiles/IPTC/IptcProfileTests.cs | 6 +- .../Metadata/Profiles/XMP/XmpProfileTests.cs | 26 ++--- .../Numerics/RationalTests.cs | 20 ++-- .../Numerics/SignedRationalTests.cs | 24 ++-- .../ImageSharp.Tests/PixelFormats/A8Tests.cs | 2 +- .../PixelFormats/Abgr32Tests.cs | 4 +- .../PixelFormats/Argb32Tests.cs | 2 +- .../PixelFormats/Bgr24Tests.cs | 4 +- .../PixelFormats/Bgr565Tests.cs | 30 ++--- .../PixelFormats/Bgra32Tests.cs | 4 +- .../PixelFormats/Bgra4444Tests.cs | 28 ++--- .../PixelFormats/Bgra5551Tests.cs | 30 ++--- .../PixelFormats/Byte4Tests.cs | 26 ++--- .../PixelFormats/HalfVector2Tests.cs | 2 +- .../PixelFormats/HalfVector4Tests.cs | 2 +- .../ImageSharp.Tests/PixelFormats/L16Tests.cs | 4 +- .../ImageSharp.Tests/PixelFormats/L8Tests.cs | 4 +- .../PixelFormats/La16Tests.cs | 4 +- .../PixelFormats/La32Tests.cs | 4 +- .../PixelFormats/NormalizedByte2Tests.cs | 6 +- .../PixelFormats/NormalizedByte4Tests.cs | 26 ++--- .../PixelFormats/NormalizedShort2Tests.cs | 6 +- .../PixelFormats/NormalizedShort4Tests.cs | 26 ++--- .../PixelFormats/PixelBlenderTests.cs | 24 ++-- .../PixelBlenders/PorterDuffFunctionsTests.cs | 52 ++++----- .../PorterDuffFunctionsTestsTPixel.cs | 2 +- .../PixelOperations/PixelOperationsTests.cs | 14 +-- .../PixelFormats/Rg32Tests.cs | 2 +- .../PixelFormats/Rgb24Tests.cs | 4 +- .../PixelFormats/Rgb48Tests.cs | 2 +- .../PixelFormats/Rgba1010102Tests.cs | 28 ++--- .../PixelFormats/Rgba32Tests.cs | 2 +- .../PixelFormats/Rgba64Tests.cs | 2 +- .../PixelFormats/RgbaVectorTests.cs | 6 +- .../PixelFormats/Short2Tests.cs | 8 +- .../PixelFormats/Short4Tests.cs | 2 +- .../Primitives/DenseMatrixTests.cs | 2 +- .../Primitives/PointFTests.cs | 2 +- .../ImageSharp.Tests/Primitives/PointTests.cs | 18 +-- .../Primitives/RectangleFTests.cs | 72 ++++++------ .../Primitives/RectangleTests.cs | 16 +-- .../ImageSharp.Tests/Primitives/SizeFTests.cs | 10 +- .../ImageSharp.Tests/Primitives/SizeTests.cs | 30 ++--- .../BaseImageOperationsExtensionTest.cs | 8 +- .../Binarization/OrderedDitherFactoryTests.cs | 8 +- .../Convolution/KernelSamplingMapTest.cs | 82 ++++++------- .../Processors/LaplacianKernelFactoryTests.cs | 6 +- .../Processing/FakeImageOperationsProvider.cs | 4 +- .../Processing/Filters/BrightnessTest.cs | 12 +- .../Processing/ImageOperationTests.cs | 6 +- .../Processing/ImageProcessingContextTests.cs | 8 +- .../HistogramEqualizationTests.cs | 4 +- .../Normalization/MagickCompareTests.cs | 2 +- .../Processing/Overlays/GlowTest.cs | 2 +- .../Processing/Overlays/VignetteTest.cs | 2 +- .../Binarization/BinaryDitherTests.cs | 8 +- .../Binarization/BinaryThresholdTest.cs | 10 +- .../Basic1ParameterConvolutionTests.cs | 2 +- .../Processors/Convolution/BokehBlurTest.cs | 6 +- .../Convolution/ConvolutionTests.cs | 2 +- .../Processors/Convolution/DetectEdgesTest.cs | 16 +-- .../Processors/Dithering/DitherTests.cs | 8 +- .../Processors/Effects/OilPaintTest.cs | 2 +- .../Processors/Effects/PixelShaderTest.cs | 4 +- .../Processors/Effects/PixelateTest.cs | 2 +- .../Processors/Filters/BrightnessTest.cs | 2 +- .../Processors/Filters/ColorBlindnessTest.cs | 2 +- .../Processors/Filters/ContrastTest.cs | 2 +- .../Processors/Filters/GrayscaleTest.cs | 2 +- .../Processing/Processors/Filters/HueTest.cs | 2 +- .../Processors/Filters/LightnessTest.cs | 2 +- .../Processors/Filters/OpacityTest.cs | 2 +- .../Processors/Filters/SaturateTest.cs | 2 +- .../Quantization/OctreeQuantizerTests.cs | 16 +-- .../Quantization/PaletteQuantizerTests.cs | 16 +-- .../Quantization/WuQuantizerTests.cs | 16 +-- .../Transforms/AffineTransformTests.cs | 10 +- .../Processors/Transforms/AutoOrientTests.cs | 4 +- .../Processors/Transforms/CropTest.cs | 2 +- .../Processors/Transforms/EntropyCropTest.cs | 2 +- .../Processors/Transforms/FlipTests.cs | 4 +- .../Transforms/ResizeHelperTests.cs | 14 +-- ...ResizeKernelMapTests.ReferenceKernelMap.cs | 6 +- .../Transforms/ResizeKernelMapTests.cs | 10 +- .../Processors/Transforms/ResizeTests.cs | 18 +-- .../Processors/Transforms/RotateFlipTests.cs | 4 +- .../Processors/Transforms/RotateTests.cs | 8 +- .../Processors/Transforms/SkewTests.cs | 4 +- .../Processors/Transforms/SwizzleTests.cs | 6 +- .../Transforms/AffineTransformBuilderTests.cs | 3 +- .../Processing/Transforms/CropTest.cs | 2 +- .../ProjectiveTransformBuilderTests.cs | 3 +- .../Transforms/ProjectiveTransformTests.cs | 18 +-- .../Processing/Transforms/ResizeTests.cs | 2 +- .../Processing/Transforms/SwizzleTests.cs | 4 +- .../Transforms/TransformBuilderTestBase.cs | 52 ++++----- .../LoadResizeSaveProfilingBenchmarks.cs | 2 +- .../ResizeProfilingBenchmarks.cs | 2 +- .../Quantization/QuantizedImageTests.cs | 2 +- .../Quantization/WuQuantizerTests.cs | 22 ++-- .../Conversion/IccConversionDataLutEntry.cs | 2 +- .../IccConversionDataMultiProcessElement.cs | 4 +- .../Conversion/IccConversionDataTrc.cs | 10 +- .../TestDataIcc/IccTestDataLut.cs | 2 +- .../TestDataIcc/IccTestDataProfiles.cs | 8 +- .../TestDataIcc/IccTestDataTagDataEntry.cs | 6 +- tests/ImageSharp.Tests/TestFile.cs | 4 +- tests/ImageSharp.Tests/TestFontUtilities.cs | 2 +- tests/ImageSharp.Tests/TestFormat.cs | 8 +- .../TestUtilities/ByteBuffer.cs | 2 +- .../TestUtilities/EofHitCounter.cs | 4 +- .../FeatureTesting/FeatureTestRunner.cs | 16 +-- .../ImageComparison/ExactImageComparer.cs | 4 +- .../ImageComparison/ImageComparer.cs | 2 +- .../ImageComparison/ImageComparingUtils.cs | 2 +- .../ImageComparison/ImageSimilarityReport.cs | 4 +- .../ImageComparison/TolerantImageComparer.cs | 4 +- .../BasicTestPatternProvider.cs | 2 +- .../ImageProviders/BlankProvider.cs | 2 +- .../ImageProviders/FileProvider.cs | 2 +- .../ImageProviders/TestImageProvider.cs | 6 +- .../TestUtilities/MeasureFixture.cs | 2 +- .../TestUtilities/PausedMemoryStream.cs | 4 +- .../TestUtilities/PausedStream.cs | 4 +- .../ReferenceCodecs/MagickReferenceDecoder.cs | 14 +-- .../ReferenceCodecs/SystemDrawingBridge.cs | 12 +- .../SystemDrawingReferenceDecoder.cs | 6 +- .../SystemDrawingReferenceEncoder.cs | 4 +- .../SixLaborsXunitTestFramework.cs | 2 +- .../TestUtilities/TestEnvironment.cs | 4 +- .../TestUtilities/TestImageExtensions.cs | 2 +- .../TestUtilities/TestMemoryAllocator.cs | 10 +- .../TestUtilities/TestMemoryManager.cs | 2 +- .../TestUtilities/TestPixel.cs | 2 +- .../TestUtilities/TestUtils.cs | 4 +- .../TestUtilities/TestVector4.cs | 2 +- .../Tests/BasicSerializerTests.cs | 2 +- .../TestUtilities/Tests/ImageComparerTests.cs | 4 +- .../Tests/ReferenceDecoderBenchmarks.cs | 2 +- .../Tests/SemaphoreReadMemoryStreamTests.cs | 4 +- .../Tests/SystemDrawingReferenceCodecTests.cs | 8 +- .../Tests/TestImageProviderTests.cs | 4 +- .../Tests/TestUtilityExtensionsTests.cs | 2 +- 703 files changed, 2574 insertions(+), 2561 deletions(-) diff --git a/.editorconfig b/.editorconfig index af1e5b44c..74a363eef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -161,6 +161,9 @@ csharp_style_deconstructed_variable_declaration = true:warning csharp_style_prefer_index_operator = true:warning csharp_style_prefer_range_operator = true:warning csharp_style_implicit_object_creation_when_type_is_apparent = true:error +# ReSharper inspection severities +resharper_arrange_object_creation_when_type_evident_highlighting = error +resharper_arrange_object_creation_when_type_not_evident_highlighting = error # "Null" checking preferences csharp_style_throw_expression = true:warning csharp_style_conditional_delegate_call = true:warning diff --git a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs index f295ddb1b..fd9692f9a 100644 --- a/src/ImageSharp/Advanced/ParallelExecutionSettings.cs +++ b/src/ImageSharp/Advanced/ParallelExecutionSettings.cs @@ -79,7 +79,7 @@ public readonly struct ParallelExecutionSettings { Guard.MustBeGreaterThan(multiplier, 0, nameof(multiplier)); - return new( + return new ParallelExecutionSettings( this.MaxDegreeOfParallelism, this.MinimumPixelsProcessedPerTask * multiplier, this.MemoryAllocator); @@ -92,6 +92,6 @@ public readonly struct ParallelExecutionSettings /// The . public static ParallelExecutionSettings FromConfiguration(Configuration configuration) { - return new(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); + return new ParallelExecutionSettings(configuration.MaxDegreeOfParallelism, configuration.MemoryAllocator); } } diff --git a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs index b76f2948f..cbcd12aec 100644 --- a/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs +++ b/src/ImageSharp/Advanced/ParallelRowIterator.Wrappers.cs @@ -139,7 +139,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - RowInterval rows = new RowInterval(yMin, yMax); + RowInterval rows = new(yMin, yMax); // Skip the safety copy when invoking a potentially impure method on a readonly field Unsafe.AsRef(in this.operation).Invoke(in rows); @@ -185,7 +185,7 @@ public static partial class ParallelRowIterator } int yMax = Math.Min(yMin + this.stepY, this.maxY); - RowInterval rows = new RowInterval(yMin, yMax); + RowInterval rows = new(yMin, yMax); using IMemoryOwner buffer = this.allocator.Allocate(this.bufferLength); diff --git a/src/ImageSharp/Color/Color.WernerPalette.cs b/src/ImageSharp/Color/Color.WernerPalette.cs index 1058da654..6f0e3744f 100644 --- a/src/ImageSharp/Color/Color.WernerPalette.cs +++ b/src/ImageSharp/Color/Color.WernerPalette.cs @@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp; /// public partial struct Color { - private static readonly Lazy WernerPaletteLazy = new Lazy(CreateWernerPalette, true); + private static readonly Lazy WernerPaletteLazy = new(CreateWernerPalette, true); /// /// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821. diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 8f54680ec..1dfbf0a24 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -81,10 +81,10 @@ public readonly partial struct Color : IEquatable PixelTypeInfo info = TPixel.GetPixelTypeInfo(); if (info.ComponentInfo.HasValue && info.ComponentInfo.Value.GetMaximumComponentPrecision() <= (int)PixelComponentBitDepth.Bit32) { - return new(source.ToScaledVector4()); + return new Color(source.ToScaledVector4()); } - return new(source); + return new Color(source); } /// @@ -120,7 +120,7 @@ public readonly partial struct Color : IEquatable { for (int i = 0; i < destination.Length; i++) { - destination[i] = new(source[i]); + destination[i] = new Color(source[i]); } } } diff --git a/src/ImageSharp/ColorProfiles/CieLab.cs b/src/ImageSharp/ColorProfiles/CieLab.cs index c1f53c162..ebe163102 100644 --- a/src/ImageSharp/ColorProfiles/CieLab.cs +++ b/src/ImageSharp/ColorProfiles/CieLab.cs @@ -88,7 +88,7 @@ public readonly struct CieLab : IProfileConnectingSpace v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -97,7 +97,7 @@ public readonly struct CieLab : IProfileConnectingSpace Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new(v3); + return new CieLab(v3); } /// @@ -145,7 +145,7 @@ public readonly struct CieLab : IProfileConnectingSpace float a = 500F * (fx - fy); float b = 200F * (fy - fz); - return new(l, a, b); + return new CieLab(l, a, b); } /// @@ -182,7 +182,7 @@ public readonly struct CieLab : IProfileConnectingSpace Vector3 wxyz = new(whitePoint.X, whitePoint.Y, whitePoint.Z); Vector3 xyzr = new(xr, yr, zr); - return new(xyzr * wxyz); + return new CieXyz(xyzr * wxyz); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLch.cs b/src/ImageSharp/ColorProfiles/CieLch.cs index 53afc0053..e62aa2ba2 100644 --- a/src/ImageSharp/ColorProfiles/CieLch.cs +++ b/src/ImageSharp/ColorProfiles/CieLch.cs @@ -25,7 +25,7 @@ public readonly struct CieLch : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLch(float l, float c, float h) - : this(new(l, c, h)) + : this(new Vector3(l, c, h)) { } @@ -100,7 +100,7 @@ public readonly struct CieLch : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -109,7 +109,7 @@ public readonly struct CieLch : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new(v3, true); + return new CieLch(v3, true); } /// @@ -155,7 +155,7 @@ public readonly struct CieLch : IColorProfile hDegrees += 360; } - return new(l, c, hDegrees); + return new CieLch(l, c, hDegrees); } /// @@ -181,7 +181,7 @@ public readonly struct CieLch : IColorProfile float a = c * MathF.Cos(hRadians); float b = c * MathF.Sin(hRadians); - return new(l, a, b); + return new CieLab(l, a, b); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLchuv.cs b/src/ImageSharp/ColorProfiles/CieLchuv.cs index c08d6cc40..5478752dd 100644 --- a/src/ImageSharp/ColorProfiles/CieLchuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLchuv.cs @@ -25,7 +25,7 @@ public readonly struct CieLchuv : IColorProfile /// The hue in degrees. [MethodImpl(MethodImplOptions.AggressiveInlining)] public CieLchuv(float l, float c, float h) - : this(new(l, c, h)) + : this(new Vector3(l, c, h)) { } @@ -97,7 +97,7 @@ public readonly struct CieLchuv : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 200, 0); v3 /= new Vector3(100, 400, 360); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -106,7 +106,7 @@ public readonly struct CieLchuv : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100, 400, 360); v3 -= new Vector3(0, 200, 0); - return new(v3, true); + return new CieLchuv(v3, true); } /// @@ -154,7 +154,7 @@ public readonly struct CieLchuv : IColorProfile hDegrees += 360; } - return new(l, c, hDegrees); + return new CieLchuv(l, c, hDegrees); } /// diff --git a/src/ImageSharp/ColorProfiles/CieLuv.cs b/src/ImageSharp/ColorProfiles/CieLuv.cs index 58ec9048c..b17c43331 100644 --- a/src/ImageSharp/ColorProfiles/CieLuv.cs +++ b/src/ImageSharp/ColorProfiles/CieLuv.cs @@ -134,7 +134,7 @@ public readonly struct CieLuv : IColorProfile v = 0; } - return new((float)l, (float)u, (float)v); + return new CieLuv((float)l, (float)u, (float)v); } /// @@ -188,7 +188,7 @@ public readonly struct CieLuv : IColorProfile z = 0; } - return new((float)x, (float)y, (float)z); + return new CieXyz((float)x, (float)y, (float)z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyy.cs b/src/ImageSharp/ColorProfiles/CieXyy.cs index ef45f352d..744b6195e 100644 --- a/src/ImageSharp/ColorProfiles/CieXyy.cs +++ b/src/ImageSharp/ColorProfiles/CieXyy.cs @@ -122,10 +122,10 @@ public readonly struct CieXyy : IColorProfile if (float.IsNaN(x) || float.IsNaN(y)) { - return new(0, 0, source.Y); + return new CieXyy(0, 0, source.Y); } - return new(x, y, source.Y); + return new CieXyy(x, y, source.Y); } /// @@ -144,14 +144,14 @@ public readonly struct CieXyy : IColorProfile { if (MathF.Abs(this.Y) < Constants.Epsilon) { - return new(0, 0, this.Yl); + return new CieXyz(0, 0, this.Yl); } float x = (this.X * this.Yl) / this.Y; float y = this.Yl; float z = ((1 - this.X - this.Y) * y) / this.Y; - return new(x, y, z); + return new CieXyz(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/CieXyz.cs b/src/ImageSharp/ColorProfiles/CieXyz.cs index b14f01469..94fcfb21b 100644 --- a/src/ImageSharp/ColorProfiles/CieXyz.cs +++ b/src/ImageSharp/ColorProfiles/CieXyz.cs @@ -88,7 +88,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -97,13 +97,13 @@ public readonly struct CieXyz : IProfileConnectingSpace Vector3 v3 = default; v3 += this.AsVector3Unsafe(); v3 *= 32768F / 65535; - return new(v3, 1F); + return new Vector4(v3, 1F); } internal static CieXyz FromVector4(Vector4 source) { Vector3 v3 = source.AsVector3(); - return new(v3); + return new CieXyz(v3); } /// @@ -111,7 +111,7 @@ public readonly struct CieXyz : IProfileConnectingSpace { Vector3 v3 = source.AsVector3(); v3 *= 65535 / 32768F; - return new(v3); + return new CieXyz(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Cmyk.cs b/src/ImageSharp/ColorProfiles/Cmyk.cs index 3a2ffd6fb..ee81ff9f7 100644 --- a/src/ImageSharp/ColorProfiles/Cmyk.cs +++ b/src/ImageSharp/ColorProfiles/Cmyk.cs @@ -26,7 +26,7 @@ public readonly struct Cmyk : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Cmyk(float c, float m, float y, float k) - : this(new(c, m, y, k)) + : this(new Vector4(c, m, y, k)) { } @@ -138,12 +138,12 @@ public readonly struct Cmyk : IColorProfile if (k.X >= 1F - Constants.Epsilon) { - return new(0, 0, 0, 1F); + return new Cmyk(0, 0, 0, 1F); } cmy = (cmy - k) / (Vector3.One - k); - return new(cmy.X, cmy.Y, cmy.Z, k.X); + return new Cmyk(cmy.X, cmy.Y, cmy.Z, k.X); } /// diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs index d0afec4ab..7072537a4 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverter.cs @@ -12,7 +12,7 @@ public class ColorProfileConverter /// Initializes a new instance of the class. /// public ColorProfileConverter() - : this(new()) + : this(new ColorConversionOptions()) { } diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs index b00ff8200..c33f40001 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs @@ -57,11 +57,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new() + ColorProfileConverter pcsConverter = new(new ColorConversionOptions { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); // Normalize the source, then convert to the PCS space. @@ -101,11 +101,11 @@ internal static class ColorProfileConverterExtensionsIcc ConversionParams sourceParams = new(converter.Options.SourceIccProfile, toPcs: true); ConversionParams targetParams = new(converter.Options.TargetIccProfile, toPcs: false); - ColorProfileConverter pcsConverter = new(new() + ColorProfileConverter pcsConverter = new(new ColorConversionOptions { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), + TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), }); using IMemoryOwner pcsBuffer = converter.Options.MemoryAllocator.Allocate(source.Length); @@ -355,7 +355,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new(AdjustPcsFromV2BlackPoint(vector)); + xyz = new CieXyz(AdjustPcsFromV2BlackPoint(vector)); } // when converting from PCS to device with v2 perceptual intent @@ -371,7 +371,7 @@ internal static class ColorProfileConverterExtensionsIcc vector = Vector3.Max(vector, Vector3.Zero); } - xyz = new(vector); + xyz = new CieXyz(vector); } switch (targetParams.PcsType) diff --git a/src/ImageSharp/ColorProfiles/Hsl.cs b/src/ImageSharp/ColorProfiles/Hsl.cs index 2735b5513..7a9365fb7 100644 --- a/src/ImageSharp/ColorProfiles/Hsl.cs +++ b/src/ImageSharp/ColorProfiles/Hsl.cs @@ -24,7 +24,7 @@ public readonly struct Hsl : IColorProfile /// The l value (lightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsl(float h, float s, float l) - : this(new(h, s, l)) + : this(new Vector3(h, s, l)) { } @@ -141,7 +141,7 @@ public readonly struct Hsl : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new(0F, s, l); + return new Hsl(0F, s, l); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -172,7 +172,7 @@ public readonly struct Hsl : IColorProfile s = chroma / (2F - max - min); } - return new(h, s, l); + return new Hsl(h, s, l); } /// @@ -213,7 +213,7 @@ public readonly struct Hsl : IColorProfile } } - return new(r, g, b); + return new Rgb(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/Hsv.cs b/src/ImageSharp/ColorProfiles/Hsv.cs index d29b3023e..1e013fe1f 100644 --- a/src/ImageSharp/ColorProfiles/Hsv.cs +++ b/src/ImageSharp/ColorProfiles/Hsv.cs @@ -24,7 +24,7 @@ public readonly struct Hsv : IColorProfile /// The v value (brightness) component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public Hsv(float h, float s, float v) - : this(new(h, s, v)) + : this(new Vector3(h, s, v)) { } @@ -139,7 +139,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(chroma) < Constants.Epsilon) { - return new(0, s, v); + return new Hsv(0, s, v); } if (MathF.Abs(r - max) < Constants.Epsilon) @@ -163,7 +163,7 @@ public readonly struct Hsv : IColorProfile s = chroma / v; - return new(h, s, v); + return new Hsv(h, s, v); } /// @@ -185,7 +185,7 @@ public readonly struct Hsv : IColorProfile if (MathF.Abs(s) < Constants.Epsilon) { - return new(v, v, v); + return new Rgb(v, v, v); } float h = (MathF.Abs(this.H - 360) < Constants.Epsilon) ? 0 : this.H / 60; @@ -236,7 +236,7 @@ public readonly struct Hsv : IColorProfile break; } - return new(r, g, b); + return new Rgb(r, g, b); } /// diff --git a/src/ImageSharp/ColorProfiles/HunterLab.cs b/src/ImageSharp/ColorProfiles/HunterLab.cs index 341360b12..e978c6de2 100644 --- a/src/ImageSharp/ColorProfiles/HunterLab.cs +++ b/src/ImageSharp/ColorProfiles/HunterLab.cs @@ -87,7 +87,7 @@ public readonly struct HunterLab : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(0, 128F, 128F); v3 /= new Vector3(100F, 255F, 255F); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -96,7 +96,7 @@ public readonly struct HunterLab : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= new Vector3(100F, 255, 255); v3 -= new Vector3(0, 128F, 128F); - return new(v3); + return new HunterLab(v3); } /// @@ -151,7 +151,7 @@ public readonly struct HunterLab : IColorProfile b = 0; } - return new(l, a, b); + return new HunterLab(l, a, b); } /// @@ -184,7 +184,7 @@ public readonly struct HunterLab : IColorProfile float x = (((a / ka) * sqrtPow) + pow) * xn; float z = (((b / kb) * sqrtPow) - pow) * (-zn); - return new(x, y, z); + return new CieXyz(x, y, z); } /// diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs index e5d95d513..01c66881a 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/ColorTrcCalculator.cs @@ -23,12 +23,12 @@ internal class ColorTrcCalculator : IVector4Calculator bool toPcs) { this.toPcs = toPcs; - this.curveCalculator = new([redTrc, greenTrc, blueTrc], !toPcs); + this.curveCalculator = new TrcCalculator([redTrc, greenTrc, blueTrc], !toPcs); Vector3 mr = redMatrixColumn.Data[0]; Vector3 mg = greenMatrixColumn.Data[0]; Vector3 mb = blueMatrixColumn.Data[0]; - this.matrix = new(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); + this.matrix = new Matrix4x4(mr.X, mr.Y, mr.Z, 0, mg.X, mg.Y, mg.Z, 0, mb.X, mb.Y, mb.Z, 0, 0, 0, 0, 1); if (!toPcs) { @@ -58,7 +58,7 @@ internal class ColorTrcCalculator : IVector4Calculator // when data to PCS, upstream process provides scaled XYZ // but input to calculator is descaled XYZ // (see DemoMaxICC IccCmm.cpp : CIccXformMatrixTRC::Apply) - xyz = new(CieXyz.FromScaledVector4(xyz).AsVector3Unsafe(), 1); + xyz = new Vector4(CieXyz.FromScaledVector4(xyz).AsVector3Unsafe(), 1); return this.curveCalculator.Calculate(xyz); } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs index 9c7a18ae8..c39eaf958 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/CurveCalculator.cs @@ -31,7 +31,7 @@ internal partial class CurveCalculator : ISingleCalculator } else { - this.lutCalculator = new(entry.CurveData, inverted); + this.lutCalculator = new LutCalculator(entry.CurveData, inverted); this.type = CalculationType.Lut; } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs index f39f4da52..8d823c1e9 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/GrayTrcCalculator.cs @@ -12,7 +12,7 @@ internal class GrayTrcCalculator : IVector4Calculator private readonly TrcCalculator calculator; public GrayTrcCalculator(IccTagDataEntry grayTrc, bool toPcs) - => this.calculator = new(new IccTagDataEntry[] { grayTrc }, !toPcs); + => this.calculator = new TrcCalculator(new IccTagDataEntry[] { grayTrc }, !toPcs); [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 Calculate(Vector4 value) => this.calculator.Calculate(value); diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs index e0d1ad8d4..172d80639 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs @@ -109,27 +109,27 @@ internal partial class LutABCalculator : IVector4Calculator if (hasACurve) { - this.curveACalculator = new(curveA, false); + this.curveACalculator = new TrcCalculator(curveA, false); } if (hasBCurve) { - this.curveBCalculator = new(curveB, false); + this.curveBCalculator = new TrcCalculator(curveB, false); } if (hasMCurve) { - this.curveMCalculator = new(curveM, false); + this.curveMCalculator = new TrcCalculator(curveM, false); } if (hasMatrix) { - this.matrixCalculator = new(matrix3x3.Value, matrix3x1.Value); + this.matrixCalculator = new MatrixCalculator(matrix3x3.Value, matrix3x1.Value); } if (hasClut) { - this.clutCalculator = new(clut); + this.clutCalculator = new ClutCalculator(clut); } } } diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs index fbeae88f8..c97578ee3 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/LutEntryCalculator.cs @@ -61,7 +61,7 @@ internal class LutEntryCalculator : IVector4Calculator { this.inputCurve = InitLut(inputCurve); this.outputCurve = InitLut(outputCurve); - this.clutCalculator = new(clut); + this.clutCalculator = new ClutCalculator(clut); this.matrix = matrix; this.doTransform = !matrix.IsIdentity && inputCurve.Length == 3; @@ -72,7 +72,7 @@ internal class LutEntryCalculator : IVector4Calculator LutCalculator[] calculators = new LutCalculator[curves.Length]; for (int i = 0; i < curves.Length; i++) { - calculators[i] = new(curves[i].Values, false); + calculators[i] = new LutCalculator(curves[i].Values, false); } return calculators; diff --git a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs index 5eade1fc8..6be1fdbf9 100644 --- a/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs +++ b/src/ImageSharp/ColorProfiles/Icc/Calculators/MatrixCalculator.cs @@ -14,7 +14,7 @@ internal class MatrixCalculator : IVector4Calculator public MatrixCalculator(Matrix4x4 matrix3x3, Vector3 matrix3x1) { this.matrix2D = matrix3x3; - this.matrix1D = new(matrix3x1, 0); + this.matrix1D = new Vector4(matrix3x1, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs index f0ee4ba58..29e30b53e 100644 --- a/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs +++ b/src/ImageSharp/ColorProfiles/Icc/CompactSrgbV4Profile.cs @@ -37,6 +37,6 @@ internal static class CompactSrgbV4Profile { byte[] buffer = new byte[Data.Length]; Data.CopyTo(buffer); - return new(buffer); + return new IccProfile(buffer); } } diff --git a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs index 917be020b..20df08e37 100644 --- a/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs +++ b/src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs @@ -91,7 +91,7 @@ internal abstract partial class IccConverterBase throw new InvalidIccProfileException("Missing matrix column or channel."); } - return new( + return new ColorTrcCalculator( redMatrixColumn, greenMatrixColumn, blueMatrixColumn, @@ -104,6 +104,6 @@ internal abstract partial class IccConverterBase private static GrayTrcCalculator InitGrayTrc(IccProfile profile, bool toPcs) { IccTagDataEntry entry = GetTag(profile, IccProfileTag.GrayTrc); - return new(entry, toPcs); + return new GrayTrcCalculator(entry, toPcs); } } diff --git a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs index a5486580f..71d565f87 100644 --- a/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownChromaticAdaptationMatrices.cs @@ -24,7 +24,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez adjusted for D65) /// public static readonly Matrix4x4 VonKriesHPEAdjusted - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 0.40024F, M12 = 0.7076F, @@ -42,7 +42,7 @@ public static class KnownChromaticAdaptationMatrices /// von Kries chromatic adaptation transform matrix (Hunt-Pointer-Estevez for equal energy) /// public static readonly Matrix4x4 VonKriesHPE - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 0.3897F, M12 = 0.6890F, @@ -65,7 +65,7 @@ public static class KnownChromaticAdaptationMatrices /// Bradford chromatic adaptation transform matrix (used in CMCCAT97) /// public static readonly Matrix4x4 Bradford - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 0.8951F, M12 = 0.2664F, @@ -83,7 +83,7 @@ public static class KnownChromaticAdaptationMatrices /// Spectral sharpening and the Bradford transform /// public static readonly Matrix4x4 BradfordSharp - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 1.2694F, M12 = -0.0988F, @@ -101,7 +101,7 @@ public static class KnownChromaticAdaptationMatrices /// CMCCAT2000 (fitted from all available color data sets) /// public static readonly Matrix4x4 CMCCAT2000 - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 0.7982F, M12 = 0.3389F, @@ -119,7 +119,7 @@ public static class KnownChromaticAdaptationMatrices /// CAT02 (optimized for minimizing CIELAB differences) /// public static readonly Matrix4x4 CAT02 - = Matrix4x4.Transpose(new() + = Matrix4x4.Transpose(new Matrix4x4 { M11 = 0.7328F, M12 = 0.4296F, diff --git a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs index 1c5f1664c..916383936 100644 --- a/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs +++ b/src/ImageSharp/ColorProfiles/KnownRgbWorkingSpaces.cs @@ -18,96 +18,96 @@ public static class KnownRgbWorkingSpaces /// Uses proper companding function, according to: /// /// - public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgb = new SRgbWorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); /// /// Simplified sRgb working space (uses gamma companding instead of ). /// See also . /// - public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.3000F, 0.6000F), new(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace SRgbSimplified = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.3000F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); /// /// Rec. 709 (ITU-R Recommendation BT.709) working space. /// - public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new(new(0.64F, 0.33F), new(0.30F, 0.60F), new(0.15F, 0.06F))); + public static readonly RgbWorkingSpace Rec709 = new Rec709WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.64F, 0.33F), new CieXyChromaticityCoordinates(0.30F, 0.60F), new CieXyChromaticityCoordinates(0.15F, 0.06F))); /// /// Rec. 2020 (ITU-R Recommendation BT.2020F) working space. /// - public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new(new(0.708F, 0.292F), new(0.170F, 0.797F), new(0.131F, 0.046F))); + public static readonly RgbWorkingSpace Rec2020 = new Rec2020WorkingSpace(KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.708F, 0.292F), new CieXyChromaticityCoordinates(0.170F, 0.797F), new CieXyChromaticityCoordinates(0.131F, 0.046F))); /// /// ECI Rgb v2 working space. /// - public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace ECIRgbv2 = new LWorkingSpace(KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); /// /// Adobe Rgb (1998) working space. /// - public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2100F, 0.7100F), new(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace AdobeRgb1998 = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); /// /// Apple sRgb working space. /// - public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new(new(0.6250F, 0.3400F), new(0.2800F, 0.5950F), new(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace ApplesRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6250F, 0.3400F), new CieXyChromaticityCoordinates(0.2800F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); /// /// Best Rgb working space. /// - public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.2150F, 0.7750F), new(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace BestRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.2150F, 0.7750F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); /// /// Beta Rgb working space. /// - public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6888F, 0.3112F), new(0.1986F, 0.7551F), new(0.1265F, 0.0352F))); + public static readonly RgbWorkingSpace BetaRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6888F, 0.3112F), new CieXyChromaticityCoordinates(0.1986F, 0.7551F), new CieXyChromaticityCoordinates(0.1265F, 0.0352F))); /// /// Bruce Rgb working space. /// - public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2800F, 0.6500F), new(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace BruceRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2800F, 0.6500F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); /// /// CIE Rgb working space. /// - public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new(new(0.7350F, 0.2650F), new(0.2740F, 0.7170F), new(0.1670F, 0.0090F))); + public static readonly RgbWorkingSpace CIERgb = new GammaWorkingSpace(2.2F, KnownIlluminants.E, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.2740F, 0.7170F), new CieXyChromaticityCoordinates(0.1670F, 0.0090F))); /// /// ColorMatch Rgb working space. /// - public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.6300F, 0.3400F), new(0.2950F, 0.6050F), new(0.1500F, 0.0750F))); + public static readonly RgbWorkingSpace ColorMatchRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.2950F, 0.6050F), new CieXyChromaticityCoordinates(0.1500F, 0.0750F))); /// /// Don Rgb 4 working space. /// - public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6960F, 0.3000F), new(0.2150F, 0.7650F), new(0.1300F, 0.0350F))); + public static readonly RgbWorkingSpace DonRgb4 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6960F, 0.3000F), new CieXyChromaticityCoordinates(0.2150F, 0.7650F), new CieXyChromaticityCoordinates(0.1300F, 0.0350F))); /// /// Ekta Space PS5 working space. /// - public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.6950F, 0.3050F), new(0.2600F, 0.7000F), new(0.1100F, 0.0050F))); + public static readonly RgbWorkingSpace EktaSpacePS5 = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6950F, 0.3050F), new CieXyChromaticityCoordinates(0.2600F, 0.7000F), new CieXyChromaticityCoordinates(0.1100F, 0.0050F))); /// /// NTSC Rgb working space. /// - public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new(new(0.6700F, 0.3300F), new(0.2100F, 0.7100F), new(0.1400F, 0.0800F))); + public static readonly RgbWorkingSpace NTSCRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.C, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6700F, 0.3300F), new CieXyChromaticityCoordinates(0.2100F, 0.7100F), new CieXyChromaticityCoordinates(0.1400F, 0.0800F))); /// /// PAL/SECAM Rgb working space. /// - public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6400F, 0.3300F), new(0.2900F, 0.6000F), new(0.1500F, 0.0600F))); + public static readonly RgbWorkingSpace PALSECAMRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6400F, 0.3300F), new CieXyChromaticityCoordinates(0.2900F, 0.6000F), new CieXyChromaticityCoordinates(0.1500F, 0.0600F))); /// /// ProPhoto Rgb working space. /// - public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new(new(0.7347F, 0.2653F), new(0.1596F, 0.8404F), new(0.0366F, 0.0001F))); + public static readonly RgbWorkingSpace ProPhotoRgb = new GammaWorkingSpace(1.8F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7347F, 0.2653F), new CieXyChromaticityCoordinates(0.1596F, 0.8404F), new CieXyChromaticityCoordinates(0.0366F, 0.0001F))); /// /// SMPTE-C Rgb working space. /// - public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new(new(0.6300F, 0.3400F), new(0.3100F, 0.5950F), new(0.1550F, 0.0700F))); + public static readonly RgbWorkingSpace SMPTECRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D65, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.6300F, 0.3400F), new CieXyChromaticityCoordinates(0.3100F, 0.5950F), new CieXyChromaticityCoordinates(0.1550F, 0.0700F))); /// /// Wide Gamut Rgb working space. /// - public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new(new(0.7350F, 0.2650F), new(0.1150F, 0.8260F), new(0.1570F, 0.0180F))); + public static readonly RgbWorkingSpace WideGamutRgb = new GammaWorkingSpace(2.2F, KnownIlluminants.D50, new RgbPrimariesChromaticityCoordinates(new CieXyChromaticityCoordinates(0.7350F, 0.2650F), new CieXyChromaticityCoordinates(0.1150F, 0.8260F), new CieXyChromaticityCoordinates(0.1570F, 0.0180F))); } diff --git a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs index b838f9ddc..d32833a38 100644 --- a/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs +++ b/src/ImageSharp/ColorProfiles/KnownYCbCrMatrices.cs @@ -16,47 +16,47 @@ public static class KnownYCbCrMatrices /// ITU-R BT.601 (SD video standard). /// public static readonly YCbCrTransform BT601 = new( - new( + new Matrix4x4( 0.299000F, 0.587000F, 0.114000F, 0F, -0.168736F, -0.331264F, 0.500000F, 0F, 0.500000F, -0.418688F, -0.081312F, 0F, 0F, 0F, 0F, 1F), - new( + new Matrix4x4( 1.000000F, 0.000000F, 1.402000F, 0F, 1.000000F, -0.344136F, -0.714136F, 0F, 1.000000F, 1.772000F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new(0F, 0.5F, 0.5F)); + new Vector3(0F, 0.5F, 0.5F)); /// /// ITU-R BT.709 (HD video, sRGB standard). /// public static readonly YCbCrTransform BT709 = new( - new( + new Matrix4x4( 0.212600F, 0.715200F, 0.072200F, 0F, -0.114572F, -0.385428F, 0.500000F, 0F, 0.500000F, -0.454153F, -0.045847F, 0F, 0F, 0F, 0F, 1F), - new( + new Matrix4x4( 1.000000F, 0.000000F, 1.574800F, 0F, 1.000000F, -0.187324F, -0.468124F, 0F, 1.000000F, 1.855600F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new(0F, 0.5F, 0.5F)); + new Vector3(0F, 0.5F, 0.5F)); /// /// ITU-R BT.2020 (UHD/4K video standard). /// public static readonly YCbCrTransform BT2020 = new( - new( + new Matrix4x4( 0.262700F, 0.678000F, 0.059300F, 0F, -0.139630F, -0.360370F, 0.500000F, 0F, 0.500000F, -0.459786F, -0.040214F, 0F, 0F, 0F, 0F, 1F), - new( + new Matrix4x4( 1.000000F, 0.000000F, 1.474600F, 0F, 1.000000F, -0.164553F, -0.571353F, 0F, 1.000000F, 1.881400F, 0.000000F, 0F, 0F, 0F, 0F, 1F), - new(0F, 0.5F, 0.5F)); + new Vector3(0F, 0.5F, 0.5F)); } diff --git a/src/ImageSharp/ColorProfiles/Lms.cs b/src/ImageSharp/ColorProfiles/Lms.cs index 86cb7956b..3aa3d7255 100644 --- a/src/ImageSharp/ColorProfiles/Lms.cs +++ b/src/ImageSharp/ColorProfiles/Lms.cs @@ -89,7 +89,7 @@ public readonly struct Lms : IColorProfile v3 += this.AsVector3Unsafe(); v3 += new Vector3(1F); v3 /= 2F; - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -98,7 +98,7 @@ public readonly struct Lms : IColorProfile Vector3 v3 = source.AsVector3(); v3 *= 2F; v3 -= new Vector3(1F); - return new(v3); + return new Lms(v3); } /// diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 4d7788fcf..42e502592 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -154,7 +154,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(this.ToScaledVector4())); // Then convert to xyz - return new(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); + return new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), GetRgbToCieXyzMatrix(options.SourceRgbWorkingSpace))); } /// @@ -171,7 +171,7 @@ public readonly struct Rgb : IProfileConnectingSpace Rgb linear = FromScaledVector4(options.SourceRgbWorkingSpace.Expand(rgb.ToScaledVector4())); // Then convert to xyz - destination[i] = new(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); + destination[i] = new CieXyz(Vector3.Transform(linear.AsVector3Unsafe(), matrix)); } } @@ -274,7 +274,7 @@ public readonly struct Rgb : IProfileConnectingSpace Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.AsVector3Unsafe(), inverseXyzMatrix); // Use transposed Rows/Columns - return new() + return new Matrix4x4 { M11 = vector.X * mXr, M21 = vector.Y * mXg, diff --git a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs index 6f06ccf27..25604001f 100644 --- a/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs +++ b/src/ImageSharp/ColorProfiles/VonKriesChromaticAdaptation.cs @@ -31,7 +31,7 @@ public static class VonKriesChromaticAdaptation if (from.Equals(to)) { - return new(source.X, source.Y, source.Z); + return new CieXyz(source.X, source.Y, source.Z); } Vector3 sourceColorLms = Vector3.Transform(source.AsVector3Unsafe(), matrix); @@ -42,7 +42,7 @@ public static class VonKriesChromaticAdaptation Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); Matrix4x4.Invert(matrix, out Matrix4x4 inverseMatrix); - return new(Vector3.Transform(targetColorLms, inverseMatrix)); + return new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); } /// @@ -89,7 +89,7 @@ public static class VonKriesChromaticAdaptation Vector3 sourceColorLms = Vector3.Transform(sp.AsVector3Unsafe(), matrix); Vector3 targetColorLms = Vector3.Multiply(vector, sourceColorLms); - dp = new(Vector3.Transform(targetColorLms, inverseMatrix)); + dp = new CieXyz(Vector3.Transform(targetColorLms, inverseMatrix)); } } } diff --git a/src/ImageSharp/ColorProfiles/Y.cs b/src/ImageSharp/ColorProfiles/Y.cs index 62cef7814..2be34fc31 100644 --- a/src/ImageSharp/ColorProfiles/Y.cs +++ b/src/ImageSharp/ColorProfiles/Y.cs @@ -92,7 +92,7 @@ public readonly struct Y : IColorProfile { Matrix4x4 m = options.YCbCrTransform.Forward; float offset = options.YCbCrTransform.Offset.X; - return new(Vector3.Dot(source.AsVector3Unsafe(), new(m.M11, m.M12, m.M13)) + offset); + return new Y(Vector3.Dot(source.AsVector3Unsafe(), new Vector3(m.M11, m.M12, m.M13)) + offset); } /// diff --git a/src/ImageSharp/ColorProfiles/YCbCr.cs b/src/ImageSharp/ColorProfiles/YCbCr.cs index e112ef799..22d629373 100644 --- a/src/ImageSharp/ColorProfiles/YCbCr.cs +++ b/src/ImageSharp/ColorProfiles/YCbCr.cs @@ -24,7 +24,7 @@ public readonly struct YCbCr : IColorProfile /// The cr chroma component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YCbCr(float y, float cb, float cr) - : this(new(y, cb, cr)) + : this(new Vector3(y, cb, cr)) { } @@ -95,7 +95,7 @@ public readonly struct YCbCr : IColorProfile { Vector3 v3 = default; v3 += this.AsVector3Unsafe(); - return new(v3, 1F); + return new Vector4(v3, 1F); } /// @@ -133,7 +133,7 @@ public readonly struct YCbCr : IColorProfile Matrix4x4 m = options.TransposedYCbCrTransform.Forward; Vector3 offset = options.TransposedYCbCrTransform.Offset; - return new(Vector3.Transform(rgb, m) + offset, true); + return new YCbCr(Vector3.Transform(rgb, m) + offset, true); } /// diff --git a/src/ImageSharp/ColorProfiles/YccK.cs b/src/ImageSharp/ColorProfiles/YccK.cs index d0966a6d1..df5eb4894 100644 --- a/src/ImageSharp/ColorProfiles/YccK.cs +++ b/src/ImageSharp/ColorProfiles/YccK.cs @@ -27,7 +27,7 @@ public readonly struct YccK : IColorProfile /// The keyline black component. [MethodImpl(MethodImplOptions.AggressiveInlining)] public YccK(float y, float cb, float cr, float k) - : this(new(y, cb, cr, k)) + : this(new Vector4(y, cb, cr, k)) { } @@ -149,11 +149,11 @@ public readonly struct YccK : IColorProfile if (k >= 1F - Constants.Epsilon) { - return new(new(0F, 0.5F, 0.5F, 1F), true); + return new YccK(new Vector4(0F, 0.5F, 0.5F, 1F), true); } rgb /= 1F - k; - return new(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); + return new YccK(new Vector4(Vector3.Transform(rgb, m), k) + new Vector4(offset, 0F)); } /// diff --git a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs index c20c6e9c9..6ed83a0d8 100644 --- a/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs +++ b/src/ImageSharp/Common/Extensions/ConfigurationExtensions.cs @@ -14,6 +14,6 @@ internal static class ConfigurationExtensions /// public static ParallelOptions GetParallelOptions(this Configuration configuration) { - return new() { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; + return new ParallelOptions { MaxDegreeOfParallelism = configuration.MaxDegreeOfParallelism }; } } diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs index 0aa8e4a41..ff28063f0 100644 --- a/src/ImageSharp/Common/Helpers/Numerics.cs +++ b/src/ImageSharp/Common/Helpers/Numerics.cs @@ -656,7 +656,7 @@ internal static class Numerics return Sse.Shuffle(value.AsVector128(), value.AsVector128(), ShuffleAlphaControl).AsVector4(); } - return new(value.W); + return new Vector4(value.W); } /// diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs index 80bfa29ca..f471d0231 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.Pack.cs @@ -134,7 +134,7 @@ internal static partial class SimdUtils ref Rgba32 rgb = ref MemoryMarshal.GetReference(destination); nuint count = (uint)redChannel.Length / 4; - destination.Fill(new(0, 0, 0, 255)); + destination.Fill(new Rgba32(0, 0, 0, 255)); for (nuint i = 0; i < count; i++) { ref Rgba32 d0 = ref Unsafe.Add(ref rgb, i * 4); diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.cs b/src/ImageSharp/Common/Helpers/SimdUtils.cs index 883e18ae7..7f98c8375 100644 --- a/src/ImageSharp/Common/Helpers/SimdUtils.cs +++ b/src/ImageSharp/Common/Helpers/SimdUtils.cs @@ -29,7 +29,7 @@ internal static partial class SimdUtils [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Vector4 PseudoRound(this Vector4 v) { - Vector4 sign = Numerics.Clamp(v, new(-1), new(1)); + Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1)); return v + (sign * 0.5f); } diff --git a/src/ImageSharp/Common/Helpers/TolerantMath.cs b/src/ImageSharp/Common/Helpers/TolerantMath.cs index b4ed9ee2f..2c622d167 100644 --- a/src/ImageSharp/Common/Helpers/TolerantMath.cs +++ b/src/ImageSharp/Common/Helpers/TolerantMath.cs @@ -20,7 +20,7 @@ internal readonly struct TolerantMath /// It is a field so it can be passed as an 'in' parameter. /// Does not necessarily fit all use cases! /// - public static readonly TolerantMath Default = new TolerantMath(1e-8); + public static readonly TolerantMath Default = new(1e-8); public TolerantMath(double epsilon) { diff --git a/src/ImageSharp/Common/Helpers/UnitConverter.cs b/src/ImageSharp/Common/Helpers/UnitConverter.cs index c50766ec2..45dbe41cb 100644 --- a/src/ImageSharp/Common/Helpers/UnitConverter.cs +++ b/src/ImageSharp/Common/Helpers/UnitConverter.cs @@ -131,9 +131,9 @@ internal static class UnitConverter ushort exifUnit = (ushort)(unit + 1); if (unit == PixelResolutionUnit.AspectRatio) { - return new(exifUnit, null, null); + return new ExifResolutionValues(exifUnit, null, null); } - return new(exifUnit, horizontal, vertical); + return new ExifResolutionValues(exifUnit, horizontal, vertical); } } diff --git a/src/ImageSharp/Compression/Zlib/Deflater.cs b/src/ImageSharp/Compression/Zlib/Deflater.cs index 2e39d435d..f642ec85a 100644 --- a/src/ImageSharp/Compression/Zlib/Deflater.cs +++ b/src/ImageSharp/Compression/Zlib/Deflater.cs @@ -79,7 +79,7 @@ internal sealed class Deflater : IDisposable } // TODO: Possibly provide DeflateStrategy as an option. - this.engine = new(memoryAllocator, DeflateStrategy.Default); + this.engine = new DeflaterEngine(memoryAllocator, DeflateStrategy.Default); this.SetLevel(level); this.Reset(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs index c9613610d..6009fdfbc 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterEngine.cs @@ -147,7 +147,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable /// The deflate strategy to use. public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy) { - this.huffman = new(memoryAllocator); + this.huffman = new DeflaterHuffman(memoryAllocator); this.Pending = this.huffman.Pending; this.strategy = strategy; diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index a05320a09..e4dc1945a 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -58,11 +58,11 @@ internal sealed unsafe class DeflaterHuffman : IDisposable /// The memory allocator to use for buffer allocations. public DeflaterHuffman(MemoryAllocator memoryAllocator) { - this.Pending = new(memoryAllocator); + this.Pending = new DeflaterPendingBuffer(memoryAllocator); - this.literalTree = new(memoryAllocator, LiteralNumber, 257, 15); - this.distTree = new(memoryAllocator, DistanceNumber, 1, 15); - this.blTree = new(memoryAllocator, BitLengthNumber, 4, 7); + this.literalTree = new Tree(memoryAllocator, LiteralNumber, 257, 15); + this.distTree = new Tree(memoryAllocator, DistanceNumber, 1, 15); + this.blTree = new Tree(memoryAllocator, BitLengthNumber, 4, 7); this.distanceMemoryOwner = memoryAllocator.Allocate(BufferSize); this.distanceBufferHandle = this.distanceMemoryOwner.Memory.Pin(); diff --git a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs index 76a5a045e..de818fd8f 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterOutputStream.cs @@ -30,7 +30,7 @@ internal sealed class DeflaterOutputStream : Stream this.rawStream = rawStream; this.memoryOwner = memoryAllocator.Allocate(BufferLength); this.buffer = this.memoryOwner.Memory; - this.deflater = new(memoryAllocator, compressionLevel); + this.deflater = new Deflater(memoryAllocator, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs index 936444406..2e52f84d7 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibDeflateStream.cs @@ -101,7 +101,7 @@ internal sealed class ZlibDeflateStream : Stream this.rawStream.WriteByte(Cmf); this.rawStream.WriteByte((byte)flg); - this.deflateStream = new(memoryAllocator, this.rawStream, compressionLevel); + this.deflateStream = new DeflaterOutputStream(memoryAllocator, this.rawStream, compressionLevel); } /// diff --git a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs index aa4beba18..1d743bf3a 100644 --- a/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs +++ b/src/ImageSharp/Compression/Zlib/ZlibInflateStream.cs @@ -270,7 +270,7 @@ internal sealed class ZlibInflateStream : Stream } // Initialize the deflate BufferedReadStream. - this.CompressedStream = new(this, CompressionMode.Decompress, true); + this.CompressedStream = new DeflateStream(this, CompressionMode.Decompress, true); return true; } diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index 1d9f3bb85..c2b02dedd 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -122,7 +122,7 @@ public sealed class Configuration /// /// Gets or the that is currently in use. /// - public ImageFormatManager ImageFormatsManager { get; private set; } = new ImageFormatManager(); + public ImageFormatManager ImageFormatsManager { get; private set; } = new(); /// /// Gets or sets the that is currently in use. diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs index da6556b36..d98f7bccb 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs @@ -25,7 +25,7 @@ public sealed class BmpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new BmpDecoderCore(new() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new BmpDecoderCore(new BmpDecoderOptions { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index acf69529a..17c1f545b 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -132,7 +132,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore { int bytesPerColorMapEntry = this.ReadImageHeaders(stream, out bool inverted, out byte[] palette); - image = new(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); + image = new Image(this.configuration, this.infoHeader.Width, this.infoHeader.Height, this.metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); @@ -220,7 +220,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadImageHeaders(stream, out _, out _); - return new(new(this.infoHeader.Width, this.infoHeader.Height), this.metadata); + return new ImageInfo(new Size(this.infoHeader.Width, this.infoHeader.Height), this.metadata); } /// @@ -343,7 +343,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -404,7 +404,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore RleSkippedPixelHandling.Transparent => TPixel.FromScaledVector4(Vector4.Zero), // Default handling for skipped pixels is black (which is what System.Drawing is also doing). - _ => TPixel.FromScaledVector4(new(0.0f, 0.0f, 0.0f, 1.0f)), + _ => TPixel.FromScaledVector4(new Vector4(0.0f, 0.0f, 0.0f, 1.0f)), }; } else @@ -1270,7 +1270,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore byte g = (byte)((temp & greenMask) >> rightShiftGreenMask); byte b = (byte)((temp & blueMask) >> rightShiftBlueMask); byte a = alphaMask != 0 ? (byte)((temp & alphaMask) >> rightShiftAlphaMask) : byte.MaxValue; - pixelRow[x] = TPixel.FromRgba32(new(r, g, b, a)); + pixelRow[x] = TPixel.FromRgba32(new Rgba32(r, g, b, a)); } offset += 4; @@ -1332,7 +1332,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore long infoHeaderStart = stream.Position; // Resolution is stored in PPM. - this.metadata = new() + this.metadata = new ImageMetadata { ResolutionUnits = PixelResolutionUnit.PixelsPerMeter }; @@ -1426,7 +1426,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore byte[] iccProfileData = new byte[this.infoHeader.ProfileSize]; stream.Position = infoHeaderStart + this.infoHeader.ProfileData; stream.Read(iccProfileData); - this.metadata.IccProfile = new(iccProfileData); + this.metadata.IccProfile = new IccProfile(iccProfileData); stream.Position = streamPosition; } } @@ -1457,7 +1457,7 @@ internal sealed class BmpDecoderCore : ImageDecoderCore this.bmpMetadata.InfoHeaderType = infoHeaderType; this.bmpMetadata.BitsPerPixel = (BmpBitsPerPixel)bitsPerPixel; - this.Dimensions = new(this.infoHeader.Width, this.infoHeader.Height); + this.Dimensions = new Size(this.infoHeader.Width, this.infoHeader.Height); } /// diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index ba9a0dc23..ccc620d6c 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -655,7 +655,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 16, Dither = this.quantizer.Options.Dither, @@ -712,7 +712,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 4, Dither = this.quantizer.Options.Dither, @@ -778,7 +778,7 @@ internal sealed class BmpEncoderCore CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new() + using IQuantizer frameQuantizer = this.quantizer.CreatePixelSpecificQuantizer(configuration, new QuantizerOptions { MaxColors = 2, Dither = this.quantizer.Options.Dither, diff --git a/src/ImageSharp/Formats/Bmp/BmpFormat.cs b/src/ImageSharp/Formats/Bmp/BmpFormat.cs index a67b06cb8..5dec4a674 100644 --- a/src/ImageSharp/Formats/Bmp/BmpFormat.cs +++ b/src/ImageSharp/Formats/Bmp/BmpFormat.cs @@ -15,7 +15,7 @@ public sealed class BmpFormat : IImageFormat /// /// Gets the shared instance. /// - public static BmpFormat Instance { get; } = new BmpFormat(); + public static BmpFormat Instance { get; } = new(); /// public string Name => "BMP"; diff --git a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs index 3514a7ed5..1dac74ba3 100644 --- a/src/ImageSharp/Formats/Bmp/BmpMetadata.cs +++ b/src/ImageSharp/Formats/Bmp/BmpMetadata.cs @@ -54,21 +54,21 @@ public class BmpMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new() { BitsPerPixel = BmpBitsPerPixel.Bit1 }, - 2 => new() { BitsPerPixel = BmpBitsPerPixel.Bit2 }, - <= 4 => new() { BitsPerPixel = BmpBitsPerPixel.Bit4 }, - <= 8 => new() { BitsPerPixel = BmpBitsPerPixel.Bit8 }, - <= 16 => new() + 1 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit1 }, + 2 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit2 }, + <= 4 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit4 }, + <= 8 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit8 }, + <= 16 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit16, InfoHeaderType = BmpInfoHeaderType.WinVersion3 }, - <= 24 => new() + <= 24 => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit24, InfoHeaderType = BmpInfoHeaderType.WinVersion4 }, - _ => new() + _ => new BmpMetadata { BitsPerPixel = BmpBitsPerPixel.Bit32, InfoHeaderType = BmpInfoHeaderType.WinVersion5 @@ -131,7 +131,7 @@ public class BmpMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs index 454f15b86..b4f017253 100644 --- a/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurFrameMetadata.cs @@ -73,7 +73,7 @@ public class CurFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new() + return new CurFrameMetadata { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -98,7 +98,7 @@ public class CurFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new() + return new CurFrameMetadata { BmpBitsPerPixel = bbpp, Compression = compression, @@ -147,7 +147,7 @@ public class CurFrameMetadata : IFormatFrameMetadata ? (byte)0 : (byte)ColorNumerics.GetColorCountForBitDepth((int)this.BmpBitsPerPixel); - return new() + return new IconDirEntry { Width = ClampEncodingDimension(this.EncodingWidth ?? size.Width), Height = ClampEncodingDimension(this.EncodingHeight ?? size.Height), @@ -210,7 +210,7 @@ public class CurFrameMetadata : IFormatFrameMetadata } } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Cur/CurMetadata.cs b/src/ImageSharp/Formats/Cur/CurMetadata.cs index 6499c5b42..d8fdb3290 100644 --- a/src/ImageSharp/Formats/Cur/CurMetadata.cs +++ b/src/ImageSharp/Formats/Cur/CurMetadata.cs @@ -68,7 +68,7 @@ public class CurMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new() + return new CurMetadata { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class CurMetadata : IFormatMetadata } } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index 8a365682a..2511cffdb 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats; /// public sealed class DecoderOptions { - private static readonly Lazy LazyOptions = new(() => new()); + private static readonly Lazy LazyOptions = new(() => new DecoderOptions()); private uint maxFrames = int.MaxValue; diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 4817edcf7..ca28bc771 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -266,8 +266,8 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowNoHeader(); } - return new( - new(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), + return new ImageInfo( + new Size(this.logicalScreenDescriptor.Width, this.logicalScreenDescriptor.Height), this.metadata, framesMetadata); } @@ -305,7 +305,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifThrowHelper.ThrowInvalidImageContentException("Width or height should not be 0"); } - this.Dimensions = new(this.imageDescriptor.Width, this.imageDescriptor.Height); + this.Dimensions = new Size(this.imageDescriptor.Width, this.imageDescriptor.Height); } /// @@ -344,7 +344,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifXmpApplicationExtension extension = GifXmpApplicationExtension.Read(stream, this.memoryAllocator); if (extension.Data.Length > 0) { - this.metadata!.XmpProfile = new(extension.Data); + this.metadata!.XmpProfile = new XmpProfile(extension.Data); } else { @@ -554,7 +554,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (previousFrame is null && previousDisposalMode is null) { image = transFlag - ? new(this.configuration, imageWidth, imageHeight, this.metadata) + ? new Image(this.configuration, imageWidth, imageHeight, this.metadata) : new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata); this.SetFrameMetadata(image.Frames.RootFrame.Metadata); @@ -597,7 +597,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (disposalMethod == FrameDisposalMode.RestoreToBackground) { - this.restoreArea = Rectangle.Intersect(image.Bounds, new(descriptor.Left, descriptor.Top, descriptor.Width, descriptor.Height)); + this.restoreArea = Rectangle.Intersect(image.Bounds, new Rectangle(descriptor.Left, descriptor.Top, descriptor.Width, descriptor.Height)); } if (colorTable.Length == 0) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 43af476f2..ffe318063 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -113,7 +113,7 @@ internal sealed class GifEncoderCore TransparentColorMode mode = this.transparentColorMode; // Create a new quantizer options instance augmenting the transparent color mode to match the encoder. - QuantizerOptions options = (this.encoder.Quantizer?.Options ?? new()).DeepClone(o => o.TransparentColorMode = mode); + QuantizerOptions options = (this.encoder.Quantizer?.Options ?? new QuantizerOptions()).DeepClone(o => o.TransparentColorMode = mode); if (globalQuantizer is null) { diff --git a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs index e1b3354ad..8ea607df6 100644 --- a/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifFrameMetadata.cs @@ -93,7 +93,7 @@ public class GifFrameMetadata : IFormatFrameMetadata // If the color table is global and frame has no transparency. Consider it 'Source' also. blendSource |= this.ColorTableMode == FrameColorTableMode.Global && !this.HasTransparency; - return new() + return new FormatConnectingFrameMetadata { ColorTableMode = this.ColorTableMode, Duration = TimeSpan.FromMilliseconds(this.FrameDelay * 10), diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs index d6e9c780b..77f600633 100644 --- a/src/ImageSharp/Formats/Gif/GifMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs @@ -87,7 +87,7 @@ public class GifMetadata : IFormatMetadata ? Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.GlobalColorTable.Value.Length), 1, 8) : 8; - return new(bpp) + return new PixelTypeInfo(bpp) { ColorType = PixelColorType.Indexed, ComponentInfo = PixelComponentInfo.Create(1, bpp, bpp), diff --git a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs index 4c2ffbe4d..e41389675 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifNetscapeLoopingApplicationExtension.cs @@ -22,7 +22,7 @@ internal readonly struct GifNetscapeLoopingApplicationExtension : IGifExtension public static GifNetscapeLoopingApplicationExtension Parse(ReadOnlySpan buffer) { ushort repeatCount = BinaryPrimitives.ReadUInt16LittleEndian(buffer[..2]); - return new(repeatCount); + return new GifNetscapeLoopingApplicationExtension(repeatCount); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs index b32f91205..1c1127c3b 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs @@ -42,7 +42,7 @@ internal readonly struct GifXmpApplicationExtension : IGifExtension stream.Skip(1); // Skip the terminator. } - return new(buffer); + return new GifXmpApplicationExtension(buffer); } public int WriteTo(Span buffer) diff --git a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs index 3afb02456..266a3457a 100644 --- a/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoFrameMetadata.cs @@ -66,7 +66,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata { if (!metadata.PixelTypeInfo.HasValue) { - return new() + return new IcoFrameMetadata { BmpBitsPerPixel = BmpBitsPerPixel.Bit32, Compression = IconFrameCompression.Png @@ -91,7 +91,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata compression = IconFrameCompression.Png; } - return new() + return new IcoFrameMetadata { BmpBitsPerPixel = bbpp, Compression = compression, @@ -138,7 +138,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata ? (byte)0 : (byte)ColorNumerics.GetColorCountForBitDepth((int)this.BmpBitsPerPixel); - return new() + return new IconDirEntry { Width = ClampEncodingDimension(this.EncodingWidth ?? size.Width), Height = ClampEncodingDimension(this.EncodingHeight ?? size.Height), @@ -205,7 +205,7 @@ public class IcoFrameMetadata : IFormatFrameMetadata } } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Ico/IcoMetadata.cs b/src/ImageSharp/Formats/Ico/IcoMetadata.cs index 4436dce85..f8c2ff40f 100644 --- a/src/ImageSharp/Formats/Ico/IcoMetadata.cs +++ b/src/ImageSharp/Formats/Ico/IcoMetadata.cs @@ -68,7 +68,7 @@ public class IcoMetadata : IFormatMetadata compression = IconFrameCompression.Png; } - return new() + return new IcoMetadata { BmpBitsPerPixel = bbpp, Compression = compression @@ -129,7 +129,7 @@ public class IcoMetadata : IFormatMetadata } } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Icon/IconDecoderCore.cs b/src/ImageSharp/Formats/Icon/IconDecoderCore.cs index caed2dd90..bc3258e6b 100644 --- a/src/ImageSharp/Formats/Icon/IconDecoderCore.cs +++ b/src/ImageSharp/Formats/Icon/IconDecoderCore.cs @@ -63,7 +63,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore // Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data // which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft. - this.Dimensions = new(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height)); + this.Dimensions = new Size(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height)); } ImageMetadata metadata = new(); @@ -208,7 +208,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore // Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data // which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft. - this.Dimensions = new(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height)); + this.Dimensions = new Size(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height)); } // Copy the format specific metadata to the image. @@ -222,7 +222,7 @@ internal abstract class IconDecoderCore : ImageDecoderCore metadata.SetFormatMetadata(PngFormat.Instance, pngMetadata); } - return new(this.Dimensions, metadata, frames); + return new ImageInfo(this.Dimensions, metadata, frames); } protected abstract void SetFrameMetadata( @@ -276,20 +276,20 @@ internal abstract class IconDecoderCore : ImageDecoderCore height = Math.Max(height, entry.Height); } - this.Dimensions = new(width, height); + this.Dimensions = new Size(width, height); } private ImageDecoderCore GetDecoder(bool isPng) { if (isPng) { - return new PngDecoderCore(new() + return new PngDecoderCore(new PngDecoderOptions { GeneralOptions = this.Options, }); } - return new BmpDecoderCore(new() + return new BmpDecoderCore(new BmpDecoderOptions { GeneralOptions = this.Options, ProcessedAlphaMask = true, diff --git a/src/ImageSharp/Formats/Icon/IconEncoderCore.cs b/src/ImageSharp/Formats/Icon/IconEncoderCore.cs index 76b14832a..479cf9f1b 100644 --- a/src/ImageSharp/Formats/Icon/IconEncoderCore.cs +++ b/src/ImageSharp/Formats/Icon/IconEncoderCore.cs @@ -116,7 +116,7 @@ internal abstract class IconEncoderCore [MemberNotNull(nameof(entries))] private void InitHeader(Image image) { - this.fileHeader = new(this.iconFileType, (ushort)image.Frames.Count); + this.fileHeader = new IconDir(this.iconFileType, (ushort)image.Frames.Count); this.entries = this.iconFileType switch { IconFileType.ICO => @@ -155,14 +155,14 @@ internal abstract class IconEncoderCore count = 256; } - return new WuQuantizer(new() + return new WuQuantizer(new QuantizerOptions { MaxColors = count }); } // Don't dither if we have a palette. We want to preserve as much information as possible. - return new PaletteQuantizer(metadata.ColorTable.Value, new() { Dither = null }); + return new PaletteQuantizer(metadata.ColorTable.Value, new QuantizerOptions { Dither = null }); } internal sealed class EncodingFrameMetadata diff --git a/src/ImageSharp/Formats/ImageFormatManager.cs b/src/ImageSharp/Formats/ImageFormatManager.cs index b6b5f8779..ecf96855e 100644 --- a/src/ImageSharp/Formats/ImageFormatManager.cs +++ b/src/ImageSharp/Formats/ImageFormatManager.cs @@ -161,7 +161,7 @@ public class ImageFormatManager /// /// Removes all the registered image format detectors. /// - public void ClearImageFormatDetectors() => this.imageFormatDetectors = new(); + public void ClearImageFormatDetectors() => this.imageFormatDetectors = new ConcurrentBag(); /// /// Adds a new detector for detecting mime types. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs index 754f1f8b4..d2c383132 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs @@ -140,7 +140,7 @@ internal partial struct Block8x8 /// public override string ToString() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); sb.Append('['); for (int i = 0; i < Size; i++) { diff --git a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs index 1c0615ef5..179f9aa28 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.ScaledCopy.cs @@ -57,19 +57,19 @@ internal partial struct Block8x8F ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, offset + destStride)); - Vector4 xyLeft = new Vector4(sLeft.X); + Vector4 xyLeft = new(sLeft.X); xyLeft.Z = sLeft.Y; xyLeft.W = sLeft.Y; - Vector4 zwLeft = new Vector4(sLeft.Z); + Vector4 zwLeft = new(sLeft.Z); zwLeft.Z = sLeft.W; zwLeft.W = sLeft.W; - Vector4 xyRight = new Vector4(sRight.X); + Vector4 xyRight = new(sRight.X); xyRight.Z = sRight.Y; xyRight.W = sRight.Y; - Vector4 zwRight = new Vector4(sRight.Z); + Vector4 zwRight = new(sRight.Z); zwRight.Z = sRight.W; zwRight.W = sRight.W; diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs index 495a20831..01bfc0875 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.TiffYccKScalar.cs @@ -128,7 +128,7 @@ internal abstract partial class JpegColorConverterBase ColorProfileConverter converter = new(); Span source = MemoryMarshal.Cast(packed); - // YccK is not a defined ICC color space — it's a JPEG-specific encoding used in Adobe-style CMYK JPEGs. + // YccK is not a defined ICC color space � it's a JPEG-specific encoding used in Adobe-style CMYK JPEGs. // ICC profiles expect colorimetric CMYK values, so we must first convert YccK to CMYK using a hardcoded inverse transform. // This transform assumes Rec.601 YCbCr coefficients and an inverted K channel. // @@ -144,7 +144,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(source, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs index 4fa18b88a..2b1c1dca3 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YCbCrScalar.cs @@ -91,7 +91,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(destination, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs index 8cd715eb3..3368e52bf 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverter.YccKScalar.cs @@ -116,7 +116,7 @@ internal abstract partial class JpegColorConverterBase SourceIccProfile = profile, TargetIccProfile = CompactSrgbV4Profile.Profile, }; - converter = new(options); + converter = new ColorProfileConverter(options); converter.Convert(source, destination); UnpackDeinterleave3(MemoryMarshal.Cast(packed)[..source.Length], c0, c1, c2); diff --git a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs index 7d236eeae..74227c7a6 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ColorConverters/JpegColorConverterBase.cs @@ -514,7 +514,7 @@ internal abstract partial class JpegColorConverterBase Span c2 = this.Component2.Length > 0 ? this.Component2.Slice(start, length) : []; Span c3 = this.Component3.Length > 0 ? this.Component3.Slice(start, length) : []; - return new(this.ComponentCount, c0, c1, c2, c3); + return new ComponentValues(this.ComponentCount, c0, c1, c2, c3); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs index 5109b1862..cf2369b2c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/AdobeMarker.cs @@ -71,7 +71,7 @@ internal readonly struct AdobeMarker : IEquatable short app14Flags1 = (short)((bytes[9] << 8) | bytes[10]); byte colorTransform = bytes[11]; - marker = new(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); + marker = new AdobeMarker(dctEncodeVersion, app14Flags0, app14Flags1, colorTransform); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs index ba6276a5c..6e83f5b2b 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ArithmeticScanDecoder.cs @@ -242,7 +242,7 @@ internal class ArithmeticScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new(this.stream); + this.scanBuffer = new JpegBitReader(this.stream); this.frame.AllocateComponents(); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs index b43df4d97..9ee43a2c8 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanScanDecoder.cs @@ -116,7 +116,7 @@ internal class HuffmanScanDecoder : IJpegScanDecoder this.scanComponentCount = scanComponentCount; - this.scanBuffer = new(this.stream); + this.scanBuffer = new JpegBitReader(this.stream); this.frame.AllocateComponents(); @@ -784,6 +784,6 @@ internal class HuffmanScanDecoder : IJpegScanDecoder public void BuildHuffmanTable(int type, int index, ReadOnlySpan codeLengths, ReadOnlySpan values, Span workspace) { HuffmanTable[] tables = type == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[index] = new(codeLengths, values, workspace); + tables[index] = new HuffmanTable(codeLengths, values, workspace); } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs index b31376992..7e25e945a 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs @@ -80,7 +80,7 @@ internal readonly struct JFifMarker : IEquatable byte densityUnits = bytes[7]; short xDensity = (short)((bytes[8] << 8) | bytes[9]); short yDensity = (short)((bytes[10] << 8) | bytes[11]); - marker = new(majorVersion, minorVersion, densityUnits, xDensity, yDensity); + marker = new JFifMarker(majorVersion, minorVersion, densityUnits, xDensity, yDensity); return true; } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs index 7e4a06d41..b2debf393 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegComponent.cs @@ -21,7 +21,7 @@ internal class JpegComponent : IDisposable, IJpegComponent this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); + this.SamplingFactors = new Size(this.HorizontalSamplingFactor, this.VerticalSamplingFactor); this.QuantizationTableIndex = quantizationTableIndex; this.Index = index; @@ -109,7 +109,7 @@ internal class JpegComponent : IDisposable, IJpegComponent int blocksPerLineForMcu = this.Frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs index 5b77ab153..0703e4d9e 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter.cs @@ -121,7 +121,7 @@ internal abstract class SpectralConverter if (scaledWidth >= tSize.Width && scaledHeight >= tSize.Height) { blockPixelSize = blockSize; - return new(scaledWidth, scaledHeight); + return new Size(scaledWidth, scaledHeight); } } } diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs index 7398e97a0..cc565c4d8 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/Component.cs @@ -19,7 +19,7 @@ internal class Component : IDisposable this.HorizontalSamplingFactor = horizontalFactor; this.VerticalSamplingFactor = verticalFactor; - this.SamplingFactors = new(horizontalFactor, verticalFactor); + this.SamplingFactors = new Size(horizontalFactor, verticalFactor); this.QuantizationTableIndex = quantizationTableIndex; } @@ -95,7 +95,7 @@ internal class Component : IDisposable int blocksPerLineForMcu = frame.McusPerLine * this.HorizontalSamplingFactor; int blocksPerColumnForMcu = frame.McusPerColumn * this.VerticalSamplingFactor; - this.SizeInBlocks = new(blocksPerLineForMcu, blocksPerColumnForMcu); + this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu); this.SubSamplingDivisors = new Size(maxSubFactorH, maxSubFactorV).DivideBy(this.SamplingFactors); diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs index 1704ae1e7..1b0a17704 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs @@ -241,7 +241,7 @@ internal class ComponentProcessor : IDisposable ref Vector targetVectorRef = ref Unsafe.As>(ref MemoryMarshal.GetReference(target)); nuint count = target.VectorCount(); - Vector multiplierVector = new Vector(multiplier); + Vector multiplierVector = new(multiplier); for (nuint i = 0; i < count; i++) { Unsafe.Add(ref targetVectorRef, i) *= multiplierVector; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs index 857f2a1fe..4815fce0c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs @@ -134,7 +134,7 @@ internal class HuffmanScanEncoder public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig) { HuffmanLut[] tables = tableConfig.Class == 0 ? this.dcHuffmanTables : this.acHuffmanTables; - tables[tableConfig.DestinationIndex] = new(tableConfig.Table); + tables[tableConfig.DestinationIndex] = new HuffmanLut(tableConfig.Table); } /// diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs index f8a3d6dd2..6ba0b8272 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/JpegFrame.cs @@ -27,7 +27,7 @@ internal sealed class JpegFrame : IDisposable for (int i = 0; i < this.Components.Length; i++) { JpegComponentConfig componentConfig = componentConfigs[i]; - this.Components[i] = new(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) + this.Components[i] = new Component(allocator, componentConfig.HorizontalSampleFactor, componentConfig.VerticalSampleFactor, componentConfig.QuantizatioTableIndex) { DcTableId = componentConfig.DcTableSelector, AcTableId = componentConfig.AcTableSelector, diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs index e97c57cd9..b60ef68f1 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/SpectralConverter{TPixel}.cs @@ -51,7 +51,7 @@ internal class SpectralConverter : SpectralConverter, IDisposable for (int i = 0; i < this.componentProcessors.Length; i++) { Component component = frame.Components[i]; - this.componentProcessors[i] = new( + this.componentProcessors[i] = new ComponentProcessor( allocator, component, postProcessorBufferSize, diff --git a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs index c92c2e7bd..b5d01fa5c 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/SizeExtensions.cs @@ -32,7 +32,7 @@ internal static class SizeExtensions sizeVect.X = MathF.Ceiling(sizeVect.X); sizeVect.Y = MathF.Ceiling(sizeVect.Y); - return new((int)sizeVect.X, (int)sizeVect.Y); + return new Size((int)sizeVect.X, (int)sizeVect.Y); } /// diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs index 026c542dd..c013cdc9c 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs @@ -25,7 +25,7 @@ public sealed class JpegDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using JpegDecoderCore decoder = new(new() { GeneralOptions = options }); + using JpegDecoderCore decoder = new(new JpegDecoderOptions { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index c9ac1e6bb..0ad78b903 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -167,7 +167,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData int b = stream.ReadByte(); if (b == -1) { - return new(JpegConstants.Markers.EOI, stream.Length - 2); + return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); } // Found a marker. @@ -179,14 +179,14 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData b = stream.ReadByte(); if (b == -1) { - return new(JpegConstants.Markers.EOI, stream.Length - 2); + return new JpegFileMarker(JpegConstants.Markers.EOI, stream.Length - 2); } } // Found a valid marker. Exit loop if (b is not 0 and (< JpegConstants.Markers.RST0 or > JpegConstants.Markers.RST7)) { - return new((byte)(uint)b, stream.Position - 2); + return new JpegFileMarker((byte)(uint)b, stream.Position - 2); } } } @@ -205,7 +205,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData _ = this.Options.TryGetIccProfileForColorConversion(this.Metadata.IccProfile, out IccProfile profile); - return new( + return new Image( this.configuration, spectralConverter.GetPixelBuffer(profile, cancellationToken), this.Metadata); @@ -222,7 +222,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.InitDerivedMetadataProperties(); Size pixelSize = this.Frame.PixelSize; - return new(new(pixelSize.Width, pixelSize.Height), this.Metadata); + return new ImageInfo(new Size(pixelSize.Width, pixelSize.Height), this.Metadata); } /// @@ -233,7 +233,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The scan decoder. public void LoadTables(byte[] tableBytes, IJpegScanDecoder scanDecoder) { - this.Metadata ??= new(); + this.Metadata ??= new ImageMetadata(); this.QuantizationTables = new Block8x8F[4]; this.scanDecoder = scanDecoder; if (tableBytes.Length < 4) @@ -256,7 +256,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData // Read next marker. bytesRead = stream.Read(markerBuffer); - fileMarker = new(markerBuffer[1], (int)stream.Position - 2); + fileMarker = new JpegFileMarker(markerBuffer[1], (int)stream.Position - 2); while (fileMarker.Marker != JpegConstants.Markers.EOI || (fileMarker.Marker == JpegConstants.Markers.EOI && fileMarker.Invalid)) { @@ -300,7 +300,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowInvalidImageContentException("Not enough data to read marker"); } - fileMarker = new(markerBuffer[1], 0); + fileMarker = new JpegFileMarker(markerBuffer[1], 0); } } @@ -316,7 +316,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData this.scanDecoder ??= new HuffmanScanDecoder(stream, spectralConverter, cancellationToken); - this.Metadata ??= new(); + this.Metadata ??= new ImageMetadata(); Span markerBuffer = stackalloc byte[2]; @@ -529,7 +529,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData chars[i] = (char)read; } - metadata.Comments.Add(new(chars)); + metadata.Comments.Add(new JpegComData(chars)); } /// @@ -661,7 +661,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasExif) { - this.Metadata.ExifProfile = new(this.exifData); + this.Metadata.ExifProfile = new ExifProfile(this.exifData); } } @@ -685,7 +685,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData if (!this.skipMetadata && profile?.CheckIsValid() == true) { this.hasIcc = true; - this.Metadata ??= new(); + this.Metadata ??= new ImageMetadata(); this.Metadata.IccProfile = profile; } } @@ -697,7 +697,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasIptc) { - this.Metadata.IptcProfile = new(this.iptcData); + this.Metadata.IptcProfile = new IptcProfile(this.iptcData); } } @@ -708,7 +708,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { if (this.hasXmp) { - this.Metadata.XmpProfile = new(this.xmpData); + this.Metadata.XmpProfile = new XmpProfile(this.xmpData); } } @@ -992,7 +992,7 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// The remaining bytes in the segment block. private void ProcessArithmeticTable(BufferedReadStream stream, int remaining) { - this.arithmeticDecodingTables ??= new(4); + this.arithmeticDecodingTables ??= new List(4); while (remaining > 0) { @@ -1242,8 +1242,8 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData JpegThrowHelper.ThrowNotSupportedComponentCount(componentCount); } - this.Frame = new(frameMarker, precision, frameWidth, frameHeight, componentCount); - this.Dimensions = new(frameWidth, frameHeight); + this.Frame = new JpegFrame(frameMarker, precision, frameWidth, frameHeight, componentCount); + this.Dimensions = new Size(frameWidth, frameHeight); this.Metadata.GetJpegMetadata().Progressive = this.Frame.Progressive; remaining -= length; diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs index 9a89eced2..98b6dd30a 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs @@ -13,13 +13,13 @@ internal sealed unsafe partial class JpegEncoderCore { private static JpegFrameConfig[] CreateFrameConfigs() { - JpegHuffmanTableConfig defaultLuminanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); - JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); - JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new JpegHuffmanTableConfig(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); - JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new JpegHuffmanTableConfig(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); + JpegHuffmanTableConfig defaultLuminanceHuffmanDC = new(@class: 0, destIndex: 0, HuffmanSpec.LuminanceDC); + JpegHuffmanTableConfig defaultLuminanceHuffmanAC = new(@class: 1, destIndex: 0, HuffmanSpec.LuminanceAC); + JpegHuffmanTableConfig defaultChrominanceHuffmanDC = new(@class: 0, destIndex: 1, HuffmanSpec.ChrominanceDC); + JpegHuffmanTableConfig defaultChrominanceHuffmanAC = new(@class: 1, destIndex: 1, HuffmanSpec.ChrominanceAC); - JpegQuantizationTableConfig defaultLuminanceQuantTable = new JpegQuantizationTableConfig(0, Quantization.LuminanceTable); - JpegQuantizationTableConfig defaultChrominanceQuantTable = new JpegQuantizationTableConfig(1, Quantization.ChrominanceTable); + JpegQuantizationTableConfig defaultLuminanceQuantTable = new(0, Quantization.LuminanceTable); + JpegQuantizationTableConfig defaultChrominanceQuantTable = new(1, Quantization.ChrominanceTable); JpegHuffmanTableConfig[] yCbCrHuffmanConfigs = new JpegHuffmanTableConfig[] { @@ -38,77 +38,77 @@ internal sealed unsafe partial class JpegEncoderCore return new JpegFrameConfig[] { // YCbCr 4:4:4 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio444, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:2 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio422, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:2:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio420, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:1 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio411, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // YCbCr 4:1:0 - new JpegFrameConfig( + new( JpegColorSpace.YCbCr, JpegColorType.YCbCrRatio410, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 1, dcIndex: 1, acIndex: 1), }, yCbCrHuffmanConfigs, yCbCrQuantTableConfigs), // Luminance - new JpegFrameConfig( + new( JpegColorSpace.Grayscale, JpegColorType.Luminance, new JpegComponentConfig[] { - new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -121,14 +121,14 @@ internal sealed unsafe partial class JpegEncoderCore }), // Rgb - new JpegFrameConfig( + new( JpegColorSpace.RGB, JpegColorType.Rgb, new JpegComponentConfig[] { - new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 71, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 66, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -144,15 +144,15 @@ internal sealed unsafe partial class JpegEncoderCore }, // Cmyk - new JpegFrameConfig( + new( JpegColorSpace.Cmyk, JpegColorType.Cmyk, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { @@ -168,15 +168,15 @@ internal sealed unsafe partial class JpegEncoderCore }, // YccK - new JpegFrameConfig( + new( JpegColorSpace.Ycck, JpegColorType.Ycck, new JpegComponentConfig[] { - new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), - new JpegComponentConfig(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 2, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 3, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), + new(id: 4, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0), }, new JpegHuffmanTableConfig[] { diff --git a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs index a07be33fc..9d5a29981 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegFormat.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs @@ -15,7 +15,7 @@ public sealed class JpegFormat : IImageFormat /// /// Gets the shared instance. /// - public static JpegFormat Instance { get; } = new JpegFormat(); + public static JpegFormat Instance { get; } = new(); /// public string Name => "JPEG"; diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs index 88bea3dc9..fe4855dc7 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs @@ -139,7 +139,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new() + return new JpegMetadata { ColorType = color, ChrominanceQuality = metadata.Quality, @@ -182,7 +182,7 @@ public class JpegMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs index d2a2f661f..989eadda7 100644 --- a/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs +++ b/src/ImageSharp/Formats/Pbm/PbmDecoderCore.cs @@ -79,8 +79,8 @@ internal sealed class PbmDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ProcessHeader(stream); - return new( - new(this.pixelSize.Width, this.pixelSize.Height), + return new ImageInfo( + new Size(this.pixelSize.Width, this.pixelSize.Height), this.metadata); } @@ -171,9 +171,9 @@ internal sealed class PbmDecoderCore : ImageDecoderCore this.componentType = PbmComponentType.Bit; } - this.pixelSize = new(width, height); + this.pixelSize = new Size(width, height); this.Dimensions = this.pixelSize; - this.metadata = new(); + this.metadata = new ImageMetadata(); PbmMetadata meta = this.metadata.GetPbmMetadata(); meta.Encoding = this.encoding; meta.ColorType = this.colorType; diff --git a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs index 9045671fb..d852f3c8e 100644 --- a/src/ImageSharp/Formats/Pbm/PbmMetadata.cs +++ b/src/ImageSharp/Formats/Pbm/PbmMetadata.cs @@ -77,7 +77,7 @@ public class PbmMetadata : IFormatMetadata _ => PbmComponentType.Short }; - return new() + return new PbmMetadata { ColorType = color, ComponentType = componentType @@ -114,7 +114,7 @@ public class PbmMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = PixelAlphaRepresentation.None, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs index 4ffd824c5..8748d90fa 100644 --- a/src/ImageSharp/Formats/Pbm/PlainDecoder.cs +++ b/src/ImageSharp/Formats/Pbm/PlainDecoder.cs @@ -71,7 +71,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new((byte)value); + rowSpan[x] = new L8((byte)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -107,7 +107,7 @@ internal class PlainDecoder for (int x = 0; x < width; x++) { stream.ReadDecimal(out int value); - rowSpan[x] = new((ushort)value); + rowSpan[x] = new L16((ushort)value); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -154,7 +154,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new((byte)red, (byte)green, (byte)blue); + rowSpan[x] = new Rgb24((byte)red, (byte)green, (byte)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { @@ -201,7 +201,7 @@ internal class PlainDecoder stream.ReadDecimal(out int blue); - rowSpan[x] = new((ushort)red, (ushort)green, (ushort)blue); + rowSpan[x] = new Rgb48((ushort)red, (ushort)green, (ushort)blue); eofReached = !stream.SkipWhitespaceAndComments(); if (eofReached) { diff --git a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs index a68b1cab4..8af0ac8ca 100644 --- a/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs +++ b/src/ImageSharp/Formats/Png/Chunks/PngPhysical.cs @@ -50,7 +50,7 @@ internal readonly struct PngPhysical uint vResolution = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(4, 4)); byte unit = data[8]; - return new(hResolution, vResolution, unit); + return new PngPhysical(hResolution, vResolution, unit); } /// @@ -92,7 +92,7 @@ internal readonly struct PngPhysical break; } - return new(x, y, unitSpecifier); + return new PngPhysical(x, y, unitSpecifier); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs index b0adbe6c5..df3995294 100644 --- a/src/ImageSharp/Formats/Png/PngDecoder.cs +++ b/src/ImageSharp/Formats/Png/PngDecoder.cs @@ -25,7 +25,7 @@ public sealed class PngDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - return new PngDecoderCore(new() { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); + return new PngDecoderCore(new PngDecoderOptions { GeneralOptions = options }).Identify(options.Configuration, stream, cancellationToken); } /// diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 577c15272..38f964d37 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -248,7 +248,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore break; case PngChunkType.Data: pngMetadata.AnimateRootFrame = currentFrameControl != null; - currentFrameControl ??= new((uint)this.header.Width, (uint)this.header.Height); + currentFrameControl ??= new FrameControl((uint)this.header.Width, (uint)this.header.Height); if (image is null) { this.InitializeImage(metadata, currentFrameControl.Value, out image); @@ -297,7 +297,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); } break; @@ -433,7 +433,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore } pngMetadata.AnimateRootFrame = currentFrameControl != null; - currentFrameControl ??= new((uint)this.header.Width, (uint)this.header.Height); + currentFrameControl ??= new FrameControl((uint)this.header.Width, (uint)this.header.Height); if (framesMetadata.Count == 0) { InitializeFrameMetadata(framesMetadata, currentFrameControl.Value); @@ -497,7 +497,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { byte[] exifData = new byte[chunk.Length]; chunk.Data.GetSpan().CopyTo(exifData); - MergeOrSetExifProfile(metadata, new(exifData), replaceExistingKeys: true); + MergeOrSetExifProfile(metadata, new ExifProfile(exifData), replaceExistingKeys: true); } break; @@ -525,7 +525,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowInvalidHeader(); } - return new(new(this.header.Width, this.header.Height), metadata, framesMetadata); + return new ImageInfo(new Size(this.header.Width, this.header.Height), metadata, framesMetadata); } finally { @@ -626,7 +626,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void InitializeImage(ImageMetadata metadata, FrameControl frameControl, out Image image) where TPixel : unmanaged, IPixel { - image = new(this.configuration, this.header.Width, this.header.Height, metadata); + image = new Image(this.configuration, this.header.Width, this.header.Height, metadata); PngFrameMetadata frameMetadata = image.Frames.RootFrame.Metadata.GetPngMetadata(); frameMetadata.FromChunk(in frameControl); @@ -1343,7 +1343,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore pngMetadata.InterlaceMethod = this.header.InterlaceMethod; this.pngColorType = this.header.ColorType; - this.Dimensions = new(this.header.Width, this.header.Height); + this.Dimensions = new Size(this.header.Width, this.header.Height); } /// @@ -1377,7 +1377,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (!TryReadTextChunkMetadata(baseMetadata, name, value)) { - metadata.TextData.Add(new(name, value, string.Empty, string.Empty)); + metadata.TextData.Add(new PngTextData(name, value, string.Empty, string.Empty)); } } @@ -1418,7 +1418,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.Encoding, out string? uncompressed) && !TryReadTextChunkMetadata(baseMetadata, name, uncompressed)) { - metadata.TextData.Add(new(name, uncompressed, string.Empty, string.Empty)); + metadata.TextData.Add(new PngTextData(name, uncompressed, string.Empty, string.Empty)); } } @@ -1476,7 +1476,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore fullRange = null; } - metadata.CicpProfile = new(colorPrimaries, transferFunction, matrixCoefficients, fullRange); + metadata.CicpProfile = new CicpProfile(colorPrimaries, transferFunction, matrixCoefficients, fullRange); } /// @@ -1560,7 +1560,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore return false; } - MergeOrSetExifProfile(metadata, new(exifBlob), replaceExistingKeys: false); + MergeOrSetExifProfile(metadata, new ExifProfile(exifBlob), replaceExistingKeys: false); return true; } @@ -1594,7 +1594,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressZlibData(compressedData, this.maxUncompressedLength, out byte[] iccpProfileBytes)) { - metadata.IccProfile = new(iccpProfileBytes); + metadata.IccProfile = new IccProfile(iccpProfileBytes); } } @@ -1750,17 +1750,17 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.TryDecompressTextData(compressedData, PngConstants.TranslatedEncoding, out string? uncompressed)) { - pngMetadata.TextData.Add(new(keyword, uncompressed, language, translatedKeyword)); + pngMetadata.TextData.Add(new PngTextData(keyword, uncompressed, language, translatedKeyword)); } } else if (IsXmpTextData(keywordBytes)) { - metadata.XmpProfile = new(data[dataStartIdx..].ToArray()); + metadata.XmpProfile = new XmpProfile(data[dataStartIdx..].ToArray()); } else { string value = PngConstants.TranslatedEncoding.GetString(data[dataStartIdx..]); - pngMetadata.TextData.Add(new(keyword, value, language, translatedKeyword)); + pngMetadata.TextData.Add(new PngTextData(keyword, value, language, translatedKeyword)); } } @@ -1950,14 +1950,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore type != PngChunkType.AnimationControl && type != PngChunkType.FrameControl) { - chunk = new(length, type); + chunk = new PngChunk(length, type); return true; } // A chunk might report a length that exceeds the length of the stream. // Take the minimum of the two values to ensure we don't read past the end of the stream. position = this.currentStream.Position; - chunk = new( + chunk = new PngChunk( length: (int)Math.Min(length, this.currentStream.Length - position), type: type, data: this.ReadChunkData(length)); diff --git a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs index a73db8777..e4aeded15 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderOptions.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Png; public sealed class PngDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the maximum memory in bytes that a zTXt, sPLT, iTXt, iCCP, or unknown chunk can occupy when decompressed. diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index e9b76522c..2b01affea 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -265,7 +265,7 @@ internal sealed class PngEncoderCore : IDisposable { // Use the previously derived global palette and a shared quantizer to // quantize the subsequent frames. This allows us to cache the color matching resolution. - paletteQuantizer ??= new( + paletteQuantizer ??= new PaletteQuantizer( this.configuration, this.quantizer!.Options, previousPalette); diff --git a/src/ImageSharp/Formats/Png/PngFormat.cs b/src/ImageSharp/Formats/Png/PngFormat.cs index e5852affa..e49b89631 100644 --- a/src/ImageSharp/Formats/Png/PngFormat.cs +++ b/src/ImageSharp/Formats/Png/PngFormat.cs @@ -15,7 +15,7 @@ public sealed class PngFormat : IImageFormat /// /// Gets the shared instance. /// - public static PngFormat Instance { get; } = new PngFormat(); + public static PngFormat Instance { get; } = new(); /// public string Name => "PNG"; diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index dd642cf6d..b2f993da4 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -53,7 +53,7 @@ public class PngFrameMetadata : IFormatFrameMetadata /// The chunk to create an instance from. internal void FromChunk(in FrameControl frameControl) { - this.FrameDelay = new(frameControl.DelayNumerator, frameControl.DelayDenominator); + this.FrameDelay = new Rational(frameControl.DelayNumerator, frameControl.DelayDenominator); this.DisposalMode = frameControl.DisposalMode; this.BlendMode = frameControl.BlendMode; } @@ -62,7 +62,7 @@ public class PngFrameMetadata : IFormatFrameMetadata public static PngFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectingFrameMetadata metadata) => new() { - FrameDelay = new(metadata.Duration.TotalMilliseconds / 1000), + FrameDelay = new Rational(metadata.Duration.TotalMilliseconds / 1000), DisposalMode = GetMode(metadata.DisposalMode), BlendMode = metadata.BlendMode, }; @@ -76,7 +76,7 @@ public class PngFrameMetadata : IFormatFrameMetadata delay = 0; } - return new() + return new FormatConnectingFrameMetadata { ColorTableMode = FrameColorTableMode.Global, Duration = TimeSpan.FromMilliseconds(delay * 1000), diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index fcbb93bf0..3bdbf00ad 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -129,7 +129,7 @@ public class PngMetadata : IFormatMetadata 4 => PngBitDepth.Bit4, _ => (bpc <= 8) ? PngBitDepth.Bit8 : PngBitDepth.Bit16, }; - return new() + return new PngMetadata { ColorType = color, BitDepth = bitDepth, @@ -209,7 +209,7 @@ public class PngMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 820fc0b5c..33ba58f54 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -133,7 +133,7 @@ internal static class PngScanlineProcessor ushort l = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, 2)); ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + 2, 2)); - Unsafe.Add(ref rowSpanRef, (uint)x) = TPixel.FromLa32(new(l, a)); + Unsafe.Add(ref rowSpanRef, (uint)x) = TPixel.FromLa32(new La32(l, a)); } } else @@ -143,7 +143,7 @@ internal static class PngScanlineProcessor { byte l = Unsafe.Add(ref scanlineSpanRef, offset2); byte a = Unsafe.Add(ref scanlineSpanRef, offset2 + bytesPerSample); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromLa16(new(l, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromLa16(new La16(l, a)); offset2 += bytesPerPixel; } } @@ -239,7 +239,7 @@ internal static class PngScanlineProcessor ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb48(new(r, g, b)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else if (pixelOffset == 0 && increment == 1) @@ -258,7 +258,7 @@ internal static class PngScanlineProcessor byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb24(new(r, g, b)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgb24(new Rgb24(r, g, b)); } } @@ -339,7 +339,7 @@ internal static class PngScanlineProcessor ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new(r, g, b, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else if (pixelOffset == 0 && increment == 1) @@ -360,7 +360,7 @@ internal static class PngScanlineProcessor byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new(r, g, b, a)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs index 45f79c040..85fac7ea2 100644 --- a/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs +++ b/src/ImageSharp/Formats/Qoi/QoiDecoderCore.cs @@ -68,7 +68,7 @@ internal class QoiDecoderCore : ImageDecoderCore qoiMetadata.Channels = this.header.Channels; qoiMetadata.ColorSpace = this.header.ColorSpace; - return new(size, metadata); + return new ImageInfo(size, metadata); } /// @@ -124,7 +124,7 @@ internal class QoiDecoderCore : ImageDecoderCore ThrowInvalidImageContentException(); } - this.header = new(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); + this.header = new QoiHeader(width, height, (QoiChannels)channels, (QoiColorSpace)colorSpace); } [DoesNotReturn] diff --git a/src/ImageSharp/Formats/Qoi/QoiFormat.cs b/src/ImageSharp/Formats/Qoi/QoiFormat.cs index ca2d7ae45..fbee2bc3f 100644 --- a/src/ImageSharp/Formats/Qoi/QoiFormat.cs +++ b/src/ImageSharp/Formats/Qoi/QoiFormat.cs @@ -15,7 +15,7 @@ public sealed class QoiFormat : IImageFormat /// /// Gets the shared instance. /// - public static QoiFormat Instance { get; } = new QoiFormat(); + public static QoiFormat Instance { get; } = new(); /// public string DefaultMimeType => "image/qoi"; diff --git a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs index 8f71ebeee..e463d511d 100644 --- a/src/ImageSharp/Formats/Qoi/QoiMetadata.cs +++ b/src/ImageSharp/Formats/Qoi/QoiMetadata.cs @@ -44,10 +44,10 @@ public class QoiMetadata : IFormatMetadata if (color.HasFlag(PixelColorType.Alpha)) { - return new() { Channels = QoiChannels.Rgba }; + return new QoiMetadata { Channels = QoiChannels.Rgba }; } - return new() { Channels = QoiChannels.Rgb }; + return new QoiMetadata { Channels = QoiChannels.Rgb }; } /// @@ -73,7 +73,7 @@ public class QoiMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index 59977ecbc..ead157986 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -622,7 +622,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore else { byte alpha = alphaBits == 0 ? byte.MaxValue : bufferSpan[idx + 3]; - color = TPixel.FromBgra32(new(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); + color = TPixel.FromBgra32(new Bgra32(bufferSpan[idx + 2], bufferSpan[idx + 1], bufferSpan[idx], alpha)); } break; @@ -638,8 +638,8 @@ internal sealed class TgaDecoderCore : ImageDecoderCore protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ReadFileHeader(stream); - return new( - new(this.fileHeader.Width, this.fileHeader.Height), + return new ImageInfo( + new Size(this.fileHeader.Width, this.fileHeader.Height), this.metadata); } @@ -705,7 +705,7 @@ internal sealed class TgaDecoderCore : ImageDecoderCore Guard.NotNull(this.tgaMetadata); byte alpha = this.tgaMetadata.AlphaChannelBits == 0 ? byte.MaxValue : scratchBuffer[3]; - pixelRow[x] = TPixel.FromBgra32(new(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); + pixelRow[x] = TPixel.FromBgra32(new Bgra32(scratchBuffer[2], scratchBuffer[1], scratchBuffer[0], alpha)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -907,9 +907,9 @@ internal sealed class TgaDecoderCore : ImageDecoderCore stream.Read(buffer, 0, TgaFileHeader.Size); this.fileHeader = TgaFileHeader.Parse(buffer); - this.Dimensions = new(this.fileHeader.Width, this.fileHeader.Height); + this.Dimensions = new Size(this.fileHeader.Width, this.fileHeader.Height); - this.metadata = new(); + this.metadata = new ImageMetadata(); this.tgaMetadata = this.metadata.GetTgaMetadata(); this.tgaMetadata.BitsPerPixel = (TgaBitsPerPixel)this.fileHeader.PixelDepth; diff --git a/src/ImageSharp/Formats/Tga/TgaFormat.cs b/src/ImageSharp/Formats/Tga/TgaFormat.cs index e024dfc62..f5bf76fb4 100644 --- a/src/ImageSharp/Formats/Tga/TgaFormat.cs +++ b/src/ImageSharp/Formats/Tga/TgaFormat.cs @@ -11,7 +11,7 @@ public sealed class TgaFormat : IImageFormat /// /// Gets the shared instance. /// - public static TgaFormat Instance { get; } = new TgaFormat(); + public static TgaFormat Instance { get; } = new(); /// public string Name => "TGA"; diff --git a/src/ImageSharp/Formats/Tga/TgaMetadata.cs b/src/ImageSharp/Formats/Tga/TgaMetadata.cs index a7be538ec..8d40f8646 100644 --- a/src/ImageSharp/Formats/Tga/TgaMetadata.cs +++ b/src/ImageSharp/Formats/Tga/TgaMetadata.cs @@ -41,10 +41,10 @@ public class TgaMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - <= 8 => new() { BitsPerPixel = TgaBitsPerPixel.Bit8 }, - <= 16 => new() { BitsPerPixel = TgaBitsPerPixel.Bit16 }, - <= 24 => new() { BitsPerPixel = TgaBitsPerPixel.Bit24 }, - _ => new() { BitsPerPixel = TgaBitsPerPixel.Bit32 } + <= 8 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit8 }, + <= 16 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit16 }, + <= 24 => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit24 }, + _ => new TgaMetadata { BitsPerPixel = TgaBitsPerPixel.Bit32 } }; } @@ -79,7 +79,7 @@ public class TgaMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs index 1d7de583f..3debd373c 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs @@ -11,7 +11,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor { private readonly DeflateCompressionLevel compressionLevel; - private readonly MemoryStream memoryStream = new MemoryStream(); + private readonly MemoryStream memoryStream = new(); public DeflateCompressor(Stream output, MemoryAllocator allocator, int width, int bitsPerPixel, TiffPredictor predictor, DeflateCompressionLevel compressionLevel) : base(output, allocator, width, bitsPerPixel, predictor) @@ -29,7 +29,7 @@ internal sealed class DeflateCompressor : TiffBaseCompressor public override void CompressStrip(Span rows, int height) { this.memoryStream.Seek(0, SeekOrigin.Begin); - using (ZlibDeflateStream stream = new ZlibDeflateStream(this.Allocator, this.memoryStream, this.compressionLevel)) + using (ZlibDeflateStream stream = new(this.Allocator, this.memoryStream, this.compressionLevel)) { if (this.Predictor == TiffPredictor.Horizontal) { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs index 7dfb60bad..a6242114e 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/LzwCompressor.cs @@ -20,7 +20,7 @@ internal sealed class LzwCompressor : TiffBaseCompressor public override TiffCompression Method => TiffCompression.Lzw; /// - public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new(this.Allocator); + public override void Initialize(int rowsPerStrip) => this.lzwEncoder = new TiffLzwEncoder(this.Allocator); /// public override void CompressStrip(Span rows, int height) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs index a2a83be0a..1ad69b2c8 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs @@ -29,7 +29,7 @@ internal class TiffJpegCompressor : TiffBaseCompressor int pixelCount = rows.Length / 3; int width = pixelCount / height; - using MemoryStream memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); Image image = Image.LoadPixelData(rows, width, height); image.Save(memoryStream, new JpegEncoder() { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs index 39c392815..4e176f28d 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs @@ -54,7 +54,7 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { long pos = stream.Position; - using (ZlibInflateStream deframeStream = new ZlibInflateStream( + using (ZlibInflateStream deframeStream = new( stream, () => { diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index cad46e987..e6895d67c 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -50,10 +50,10 @@ public class LzwString { if (this == Empty) { - return new(other); + return new LzwString(other); } - return new(other, this.FirstChar, this.Length + 1, this); + return new LzwString(other, this.FirstChar, this.Length + 1, this); } /// diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs index beb22a2bb..f00c5aa81 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs @@ -48,7 +48,7 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - TiffLzwDecoder decoder = new TiffLzwDecoder(stream); + TiffLzwDecoder decoder = new(stream); decoder.DecodePixels(buffer); if (this.Predictor == TiffPredictor.Horizontal) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs index f0ed12c41..ccdf9b0b7 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs @@ -41,7 +41,7 @@ internal sealed class ModifiedHuffmanTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - ModifiedHuffmanBitReader bitReader = new ModifiedHuffmanBitReader(stream, this.FillOrder, byteCount); + ModifiedHuffmanBitReader bitReader = new(stream, this.FillOrder, byteCount); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs index 4d09f7b4e..d9e49aa75 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs @@ -60,7 +60,7 @@ internal sealed class T4TiffCompression : TiffBaseDecompressor } bool eolPadding = this.faxCompressionOptions.HasFlag(FaxCompressionOptions.EolPadding); - T4BitReader bitReader = new T4BitReader(stream, this.FillOrder, byteCount, eolPadding); + T4BitReader bitReader = new(stream, this.FillOrder, byteCount, eolPadding); buffer.Clear(); nint bitsWritten = 0; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs index c0ec49d8e..2020dce47 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs @@ -69,7 +69,7 @@ internal sealed class T6TiffCompression : TiffBaseDecompressor bitsWritten = this.WriteScanLine(buffer, scanLine, bitsWritten); scanLine.CopyTo(referenceScanLineSpan); - referenceScanLine = new(this.isWhiteZero, referenceScanLineSpan); + referenceScanLine = new CcittReferenceScanline(this.isWhiteZero, referenceScanLineSpan); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs index 40278dca2..a53e1bc74 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/TiffLzwDecoder.cs @@ -103,7 +103,7 @@ internal sealed class TiffLzwDecoder this.table = new LzwString[TableSize]; for (int i = 0; i < 256; i++) { - this.table[i] = new((byte)i); + this.table[i] = new LzwString((byte)i); } this.Init(); diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs index 5f4ca12bd..c0affc50a 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/WebpTiffCompression.cs @@ -32,7 +32,7 @@ internal class WebpTiffCompression : TiffBaseDecompressor /// protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) { - using WebpDecoderCore decoder = new(new() { GeneralOptions = this.options }); + using WebpDecoderCore decoder = new(new WebpDecoderOptions { GeneralOptions = this.options }); using Image image = decoder.Decode(this.options.Configuration, stream, cancellationToken); CopyImageBytesToBuffer(buffer, image.Frames.RootFrame.PixelBuffer); } diff --git a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs index ebf4042e2..706e6a38c 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/HorizontalPredictor.cs @@ -222,7 +222,7 @@ internal static class HorizontalPredictor byte r = (byte)(rowRgb[x].R - rowRgb[x - 1].R); byte g = (byte)(rowRgb[x].G - rowRgb[x - 1].G); byte b = (byte)(rowRgb[x].B - rowRgb[x - 1].B); - rowRgb[x] = new(r, g, b); + rowRgb[x] = new Rgb24(r, g, b); } } } @@ -429,7 +429,7 @@ internal static class HorizontalPredictor r += pixel.R; g += pixel.G; b += pixel.B; - pixel = new(r, g, b); + pixel = new Rgb24(r, g, b); } } @@ -462,7 +462,7 @@ internal static class HorizontalPredictor g += pixel.G; b += pixel.B; a += pixel.A; - pixel = new(r, g, b, a); + pixel = new Rgba32(r, g, b, a); } } diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs index 0bc2e7343..aa207e2b6 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffDecompressorsFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; @@ -64,11 +65,11 @@ internal static class TiffDecompressorsFactory case TiffDecoderCompressionType.Jpeg: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); - return new JpegTiffCompression(new() { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, jpegTables, photometricInterpretation); + return new JpegTiffCompression(new JpegDecoderOptions { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, jpegTables, photometricInterpretation); case TiffDecoderCompressionType.OldJpeg: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); - return new OldJpegTiffCompression(new() { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, oldJpegStartOfImageMarker, photometricInterpretation); + return new OldJpegTiffCompression(new JpegDecoderOptions { GeneralOptions = options }, allocator, width, bitsPerPixel, metadata, oldJpegStartOfImageMarker, photometricInterpretation); case TiffDecoderCompressionType.Webp: DebugGuard.IsTrue(predictor == TiffPredictor.None, "Predictor should only be used with lzw or deflate compression"); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs index 2ef261811..d818aef1b 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero16TiffColor{TPixel}.cs @@ -47,7 +47,7 @@ internal class BlackIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs index b30700adb..ac316459d 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ internal class BlackIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder : TiffBaseColorDecoder for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; - pixelRowSpan[x++] = TPixel.FromL8(new((byte)(((byteData & 0xF0) >> 4) * 17))); - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((byteData & 0x0F) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)(((byteData & 0xF0) >> 4) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((byteData & 0x0F) * 17))); } if (isOddWidth) { byte byteData = data[offset++]; - pixelRowSpan[left + width - 1] = TPixel.FromL8(new((byte)(((byteData & 0xF0) >> 4) * 17))); + pixelRowSpan[left + width - 1] = TPixel.FromL8(new L8((byte)(((byteData & 0xF0) >> 4) * 17))); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs index 709c2bf64..7428ef057 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -35,7 +36,7 @@ internal class BlackIsZeroTiffColor : TiffBaseColorDecoder { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = value / this.factor; - pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs index d6fc7c487..d23d1e290 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Numerics; using SixLabors.ImageSharp.ColorProfiles; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -34,7 +35,7 @@ internal class CieLabPlanarTiffColor : TiffBasePlanarColorDecoder(in lab); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1.0f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); offset++; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs index b0236022b..b10d27ccd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.ColorProfiles; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -30,7 +31,7 @@ internal class CieLabTiffColor : TiffBaseColorDecoder float l = (data[offset] & 0xFF) * 100f * Inv255; CieLab lab = new(l, (sbyte)data[offset + 1], (sbyte)data[offset + 2]); Rgb rgb = ColorProfileConverter.Convert(in lab); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1f)); offset += 3; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs index 86e584193..2e22fcde0 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs @@ -31,7 +31,7 @@ internal class CmykTiffColor : TiffBaseColorDecoder Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); for (int x = 0; x < pixelRow.Length; x++) { - pixelRow[x] = TPixel.FromVector4(new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); + pixelRow[x] = TPixel.FromVector4(new Vector4(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, 1.0f)); offset += 3; } @@ -47,7 +47,7 @@ internal class CmykTiffColor : TiffBaseColorDecoder { Cmyk cmyk = new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, data[offset + 3] * Inv255); Rgb rgb = ColorProfileConverter.Convert(in cmyk); - pixelRow[x] = TPixel.FromScaledVector4(new(rgb.R, rgb.G, rgb.B, 1.0f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); offset += 4; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs index 745e5846a..69113cf93 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -63,7 +64,7 @@ internal class PaletteTiffColor : TiffBaseColorDecoder float r = colorMap[rOffset + i] * InvMax; float g = colorMap[gOffset + i] * InvMax; float b = colorMap[bOffset + i] * InvMax; - palette[i] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + palette[i] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } return palette; diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs index d8520e307..c1420b4f4 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb161616TiffColor{TPixel}.cs @@ -48,7 +48,7 @@ internal class Rgb161616TiffColor : TiffBaseColorDecoder ushort b = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs index f55d7225e..84efb9021 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgb16PlanarTiffColor{TPixel}.cs @@ -44,7 +44,7 @@ internal class Rgb16PlanarTiffColor : TiffBasePlanarColorDecoder offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } else @@ -57,7 +57,7 @@ internal class Rgb16PlanarTiffColor : TiffBasePlanarColorDecoder offset += 2; - pixelRow[x] = TPixel.FromRgb48(new(r, g, b)); + pixelRow[x] = TPixel.FromRgb48(new Rgb48(r, g, b)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs index 37605ef80..f9c17eb2f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbFloat323232TiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -50,7 +51,7 @@ internal class RgbFloat323232TiffColor : TiffBaseColorDecoder float b = BitConverter.ToSingle(buffer); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } } else @@ -66,7 +67,7 @@ internal class RgbFloat323232TiffColor : TiffBaseColorDecoder float b = BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs index 844b08d3c..a013abfbd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColor{TPixel}.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Numerics; using SixLabors.ImageSharp.Formats.Tiff.Utils; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -62,7 +63,7 @@ internal class RgbPlanarTiffColor : TiffBasePlanarColorDecoder float g = gBitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bBitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } rBitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs index 2b85c2fd6..3c205d147 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbTiffColor{TPixel}.cs @@ -52,7 +52,7 @@ internal class RgbTiffColor : TiffBaseColorDecoder float g = bitReader.ReadBits(this.bitsPerSampleG) / this.gFactor; float b = bitReader.ReadBits(this.bitsPerSampleB) / this.bFactor; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs index e4965887d..9847f45b5 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs @@ -67,7 +67,7 @@ internal class Rgba16161616TiffColor : TiffBaseColorDecoder pixelRow[x] = hasAssociatedAlpha ? TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs index 3d36db17d..12357adc1 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16PlanarTiffColor{TPixel}.cs @@ -56,7 +56,7 @@ internal class Rgba16PlanarTiffColor : TiffBasePlanarColorDecoder(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } else @@ -72,7 +72,7 @@ internal class Rgba16PlanarTiffColor : TiffBasePlanarColorDecoder(r, g, b, a) - : TPixel.FromRgba64(new(r, g, b, a)); + : TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs index 12f1b75b4..87a019641 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/RgbaFloat32323232TiffColor{TPixel}.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Numerics; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; @@ -55,7 +56,7 @@ internal class RgbaFloat32323232TiffColor : TiffBaseColorDecoder float a = BitConverter.ToSingle(buffer); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, a)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); } } else @@ -74,7 +75,7 @@ internal class RgbaFloat32323232TiffColor : TiffBaseColorDecoder float a = BitConverter.ToSingle(data.Slice(offset, 4)); offset += 4; - pixelRow[x] = TPixel.FromScaledVector4(new(r, g, b, a)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs index 6f1672e1b..d70873634 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero16TiffColor{TPixel}.cs @@ -36,7 +36,7 @@ internal class WhiteIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = (ushort)(ushort.MaxValue - TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2))); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } else @@ -46,7 +46,7 @@ internal class WhiteIsZero16TiffColor : TiffBaseColorDecoder ushort intensity = (ushort)(ushort.MaxValue - TiffUtilities.ConvertToUShortLittleEndian(data.Slice(offset, 2))); offset += 2; - pixelRow[x] = TPixel.FromL16(new(intensity)); + pixelRow[x] = TPixel.FromL16(new L16(intensity)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs index 0db555cbb..6986f25eb 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero32FloatTiffColor{TPixel}.cs @@ -40,7 +40,7 @@ internal class WhiteIsZero32FloatTiffColor : TiffBaseColorDecoder : TiffBaseColorDecoder : TiffBaseColorDecoder for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); - pixelRowSpan[x++] = TPixel.FromL8(new((byte)((15 - (byteData & 0x0F)) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); + pixelRowSpan[x++] = TPixel.FromL8(new L8((byte)((15 - (byteData & 0x0F)) * 17))); } if (isOddWidth) { byte byteData = data[offset++]; - pixelRowSpan[left + width - 1] = TPixel.FromL8(new((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); + pixelRowSpan[left + width - 1] = TPixel.FromL8(new L8((byte)((15 - ((byteData & 0xF0) >> 4)) * 17))); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs index 5429dbd3b..ae0dcb753 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero8TiffColor{TPixel}.cs @@ -23,7 +23,7 @@ internal class WhiteIsZero8TiffColor : TiffBaseColorDecoder for (int x = 0; x < pixelRow.Length; x++) { byte intensity = (byte)(byte.MaxValue - data[offset++]); - pixelRow[x] = TPixel.FromL8(new(intensity)); + pixelRow[x] = TPixel.FromL8(new L8(intensity)); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs index 06212eff3..0cd01a619 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColor{TPixel}.cs @@ -36,7 +36,7 @@ internal class WhiteIsZeroTiffColor : TiffBaseColorDecoder { int value = bitReader.ReadBits(this.bitsPerSample0); float intensity = 1f - (value / this.factor); - pixelRow[x] = TPixel.FromScaledVector4(new(intensity, intensity, intensity, 1f)); + pixelRow[x] = TPixel.FromScaledVector4(new Vector4(intensity, intensity, intensity, 1f)); } bitReader.NextRow(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 754cbd005..d41749be6 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -45,10 +45,10 @@ internal class YCbCrConverter TiffThrowHelper.ThrowImageFormatException("luma coefficients array should have 6 entry's"); } - this.yExpander = new(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); - this.cbExpander = new(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); - this.crExpander = new(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); - this.converter = new(coefficients[0], coefficients[1], coefficients[2]); + this.yExpander = new CodingRangeExpander(referenceBlackAndWhite[0], referenceBlackAndWhite[1], 255); + this.cbExpander = new CodingRangeExpander(referenceBlackAndWhite[2], referenceBlackAndWhite[3], 127); + this.crExpander = new CodingRangeExpander(referenceBlackAndWhite[4], referenceBlackAndWhite[5], 127); + this.converter = new YCbCrToRgbConverter(coefficients[0], coefficients[1], coefficients[2]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs index ebae82430..768177bfc 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrPlanarTiffColor{TPixel}.cs @@ -20,7 +20,7 @@ internal class YCbCrPlanarTiffColor : TiffBasePlanarColorDecoder public YCbCrPlanarTiffColor(Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { - this.converter = new(referenceBlackAndWhite, coefficients); + this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs index 3bf550fe5..5a1389035 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrTiffColor{TPixel}.cs @@ -24,7 +24,7 @@ internal class YCbCrTiffColor : TiffBaseColorDecoder public YCbCrTiffColor(MemoryAllocator memoryAllocator, Rational[] referenceBlackAndWhite, Rational[] coefficients, ushort[] ycbcrSubSampling) { this.memoryAllocator = memoryAllocator; - this.converter = new(referenceBlackAndWhite, coefficients); + this.converter = new YCbCrConverter(referenceBlackAndWhite, coefficients); this.ycbcrSubSampling = ycbcrSubSampling; } diff --git a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs index e9b620ea2..2bfd9a626 100644 --- a/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs +++ b/src/ImageSharp/Formats/Tiff/TiffBitsPerSample.cs @@ -120,7 +120,7 @@ public readonly struct TiffBitsPerSample : IEquatable break; } - sample = new(c0, c1, c2, c3); + sample = new TiffBitsPerSample(c0, c1, c2, c3); return true; } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 73f66a062..fbff35297 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -191,7 +191,7 @@ internal class TiffDecoderCore : ImageDecoderCore this.Dimensions = frames[0].Size; ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new(this.configuration, metadata, frames); + return new Image(this.configuration, metadata, frames); } catch { @@ -228,7 +228,7 @@ internal class TiffDecoderCore : ImageDecoderCore ImageMetadata metadata = TiffDecoderMetadataCreator.Create(framesMetadata, this.skipMetadata, reader.ByteOrder, reader.IsBigTiff); - return new(new(width, height), metadata, framesMetadata); + return new ImageInfo(new Size(width, height), metadata, framesMetadata); } /// @@ -285,7 +285,7 @@ internal class TiffDecoderCore : ImageDecoderCore // We resolve the ICC profile early so that we can use it for color conversion if needed. if (tags.TryGetValue(ExifTag.IccProfile, out IExifValue iccProfileBytes)) { - imageFrameMetaData.IccProfile = new(iccProfileBytes.Value); + imageFrameMetaData.IccProfile = new IccProfile(iccProfileBytes.Value); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs index db27854a1..ebf407f9b 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs @@ -33,12 +33,12 @@ internal static class TiffDecoderMetadataCreator ImageFrameMetadata frameMetaData = frames[i]; if (TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes)) { - frameMetaData.IptcProfile = new(iptcBytes); + frameMetaData.IptcProfile = new IptcProfile(iptcBytes); } if (frameMetaData.ExifProfile.TryGetValue(ExifTag.XMP, out IExifValue xmpProfileBytes)) { - frameMetaData.XmpProfile = new(xmpProfileBytes.Value); + frameMetaData.XmpProfile = new XmpProfile(xmpProfileBytes.Value); } } } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 958399454..7519871b7 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -531,7 +531,7 @@ internal static class TiffDecoderOptionsParser // Some encoders do not set the BitsPerSample correctly, so we set those values here to the required values: // https://github.com/SixLabors/ImageSharp/issues/2587 - options.BitsPerSample = new(1, 0, 0); + options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); options.BitsPerPixel = 1; break; @@ -549,7 +549,7 @@ internal static class TiffDecoderOptionsParser options.FaxCompressionOptions = FaxCompressionOptions.None; } - options.BitsPerSample = new(1, 0, 0); + options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); options.BitsPerPixel = 1; break; @@ -557,7 +557,7 @@ internal static class TiffDecoderOptionsParser case TiffCompression.Ccitt1D: options.CompressionType = TiffDecoderCompressionType.HuffmanRle; - options.BitsPerSample = new(1, 0, 0); + options.BitsPerSample = new TiffBitsPerSample(1, 0, 0); options.BitsPerPixel = 1; break; diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index 8890c61a5..eeb4afebf 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs @@ -298,12 +298,12 @@ internal class TiffEncoderEntriesCollector { this.Collector.AddOrReplace(new ExifRational(ExifTagValue.XResolution) { - Value = new(resolution.HorizontalResolution.Value) + Value = new Rational(resolution.HorizontalResolution.Value) }); this.Collector.AddOrReplace(new ExifRational(ExifTagValue.YResolution) { - Value = new(resolution.VerticalResolution.Value) + Value = new Rational(resolution.VerticalResolution.Value) }); } } diff --git a/src/ImageSharp/Formats/Tiff/TiffFormat.cs b/src/ImageSharp/Formats/Tiff/TiffFormat.cs index 76a06d013..eb052d1bf 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFormat.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFormat.cs @@ -17,7 +17,7 @@ public sealed class TiffFormat : IImageFormat /// /// Gets the shared instance. /// - public static TiffFormat Instance { get; } = new TiffFormat(); + public static TiffFormat Instance { get; } = new(); /// public string Name => "TIFF"; @@ -32,8 +32,8 @@ public sealed class TiffFormat : IImageFormat public IEnumerable FileExtensions => TiffConstants.FileExtensions; /// - public TiffMetadata CreateDefaultFormatMetadata() => new TiffMetadata(); + public TiffMetadata CreateDefaultFormatMetadata() => new(); /// - public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new TiffFrameMetadata(); + public TiffFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs index 7d2056469..e965fcb4f 100644 --- a/src/ImageSharp/Formats/Tiff/TiffMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffMetadata.cs @@ -75,7 +75,7 @@ public class TiffMetadata : IFormatMetadata int bpp = metadata.PixelTypeInfo.BitsPerPixel; return bpp switch { - 1 => new() + 1 => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit1, BitsPerSample = TiffConstants.BitsPerSample1Bit, @@ -83,7 +83,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.CcittGroup4Fax, Predictor = TiffPredictor.None }, - <= 4 => new() + <= 4 => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit4, BitsPerSample = TiffConstants.BitsPerSample4Bit, @@ -91,7 +91,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.None // Best match for low bit depth }, - 8 => new() + 8 => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit8, BitsPerSample = TiffConstants.BitsPerSample8Bit, @@ -99,7 +99,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 16 => new() + 16 => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit16, BitsPerSample = TiffConstants.BitsPerSample16Bit, @@ -107,7 +107,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - 32 or 64 => new() + 32 or 64 => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit32, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -115,7 +115,7 @@ public class TiffMetadata : IFormatMetadata Compression = TiffCompression.Deflate, Predictor = TiffPredictor.Horizontal }, - _ => new() + _ => new TiffMetadata { BitsPerPixel = TiffBitsPerPixel.Bit24, BitsPerSample = TiffConstants.BitsPerSampleRgb8Bit, @@ -165,7 +165,7 @@ public class TiffMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { ColorType = colorType, ComponentInfo = info, diff --git a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs index 8b5e04f27..e30765b1f 100644 --- a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs +++ b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs @@ -45,7 +45,7 @@ internal static class TiffUtilities return TPixel.FromRgba64(default); } - return TPixel.FromRgba64(new((ushort)(r / a), (ushort)(g / a), (ushort)(b / a), a)); + return TPixel.FromRgba64(new Rgba64((ushort)(r / a), (ushort)(g / a), (ushort)(b / a), a)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs index 8ede73279..647ff8a1a 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffBiColorWriter{TPixel}.cs @@ -30,7 +30,7 @@ internal sealed class TiffBiColorWriter : TiffBaseColorWriter : base(image, encodingSize, memoryAllocator, configuration, entriesCollector) { // Convert image to black and white. - this.imageBlackWhite = new(configuration, new(), [image.Clone()]); + this.imageBlackWhite = new Image(configuration, new ImageMetadata(), [image.Clone()]); this.imageBlackWhite.Mutate(img => img.BinaryDither(KnownDitherings.FloydSteinberg)); } diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs index a6106ae85..ebf75efe8 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffPaletteWriter{TPixel}.cs @@ -44,13 +44,13 @@ internal sealed class TiffPaletteWriter : TiffBaseColorWriter this.colorPaletteBytes = this.colorPaletteSize * 2; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer( this.Configuration, - new() + new QuantizerOptions { MaxColors = this.maxColors }); frameQuantizer.BuildPalette(pixelSamplingStrategy, frame); - this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new(Point.Empty, encodingSize)); + this.quantizedFrame = frameQuantizer.QuantizeFrame(frame, new Rectangle(Point.Empty, encodingSize)); this.AddColorMapTag(); } diff --git a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs index f374daba4..accfea948 100644 --- a/src/ImageSharp/Formats/Webp/AlphaDecoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaDecoder.cs @@ -56,12 +56,12 @@ internal class AlphaDecoder : IDisposable this.Alpha = memoryAllocator.Allocate(totalPixels); this.AlphaFilterType = (WebpAlphaFilterType)filter; - this.Vp8LDec = new(width, height, memoryAllocator); + this.Vp8LDec = new Vp8LDecoder(width, height, memoryAllocator); if (this.Compressed) { Vp8LBitReader bitReader = new(data); - this.LosslessDecoder = new(bitReader, memoryAllocator, configuration); + this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration); this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true); // Special case: if alpha data uses only the color indexing transform and diff --git a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs index 56587da18..fd6f508e4 100644 --- a/src/ImageSharp/Formats/Webp/AlphaEncoder.cs +++ b/src/ImageSharp/Formats/Webp/AlphaEncoder.cs @@ -92,7 +92,7 @@ internal static class AlphaEncoder for (int x = 0; x < width; x++) { // Leave A/R/B channels zero'd. - pixelRow[x] = new(0, alphaRow[x], 0, 0); + pixelRow[x] = new Bgra32(0, alphaRow[x], 0, 0); } } diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs index 505f54312..e9f50fb49 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs @@ -399,7 +399,7 @@ internal class Vp8BitWriter : BitWriterBase int mbSize = this.enc.Mbw * this.enc.Mbh; int expectedSize = (int)((uint)mbSize * 7 / 8); - Vp8BitWriter bitWriterPartZero = new Vp8BitWriter(expectedSize, this.enc); + Vp8BitWriter bitWriterPartZero = new(expectedSize, this.enc); // Partition #0 with header and partition sizes. uint size0 = bitWriterPartZero.GeneratePartition0(); @@ -545,7 +545,7 @@ internal class Vp8BitWriter : BitWriterBase // Writes the partition #0 modes (that is: all intra modes) private void CodeIntraModes() { - Vp8EncIterator it = new Vp8EncIterator(this.enc); + Vp8EncIterator it = new(this.enc); int predsWidth = this.enc.PredsWidth; do diff --git a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs index 0b71a3ed0..dc867fa85 100644 --- a/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs +++ b/src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs @@ -102,7 +102,7 @@ internal class Vp8LBitWriter : BitWriterBase { byte[] clonedBuffer = new byte[this.Buffer.Length]; System.Buffer.BlockCopy(this.Buffer, 0, clonedBuffer, 0, this.cur); - return new(clonedBuffer, this.bits, this.used, this.cur); + return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur); } /// diff --git a/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs b/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs index 66662569c..7d22f7f2b 100644 --- a/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs +++ b/src/ImageSharp/Formats/Webp/Chunks/WebpFrameData.cs @@ -124,7 +124,7 @@ internal readonly struct WebpFrameData { Span buffer = stackalloc byte[4]; - return new( + return new WebpFrameData( dataSize: WebpChunkParsingUtils.ReadChunkSize(stream, buffer), x: WebpChunkParsingUtils.ReadUInt24LittleEndian(stream, buffer) * 2, y: WebpChunkParsingUtils.ReadUInt24LittleEndian(stream, buffer) * 2, diff --git a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs index bac6d5167..274d4426f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs @@ -72,7 +72,7 @@ internal static class BackwardReferenceEncoder BackwardReferencesLz77(width, height, bgra, 0, hashChain, worst); break; case Vp8LLz77Type.Lz77Box: - hashChainBox = new(memoryAllocator, width * height); + hashChainBox = new Vp8LHashChain(memoryAllocator, width * height); BackwardReferencesLz77Box(width, height, bgra, 0, hashChain, hashChainBox, worst); break; } @@ -145,7 +145,7 @@ internal static class BackwardReferenceEncoder for (int i = 0; i < colorCache.Length; i++) { histos[i].PaletteCodeBits = i; - colorCache[i] = new(i); + colorCache[i] = new ColorCache(i); } // Find the cacheBits giving the lowest entropy. @@ -281,7 +281,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new(cacheBits); + colorCache = new ColorCache(cacheBits); } costModel.Build(xSize, cacheBits, refs); @@ -383,7 +383,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new(cacheBits); + colorCache = new ColorCache(cacheBits); } backwardRefs.Clear(); @@ -475,7 +475,7 @@ internal static class BackwardReferenceEncoder ColorCache? colorCache = null; if (useColorCache) { - colorCache = new(cacheBits); + colorCache = new ColorCache(cacheBits); } refs.Clear(); @@ -730,7 +730,7 @@ internal static class BackwardReferenceEncoder if (useColorCache) { - colorCache = new(cacheBits); + colorCache = new ColorCache(cacheBits); } refs.Clear(); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs index 2b2286e04..4ab9d7b94 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CostManager.cs @@ -23,15 +23,15 @@ internal sealed class CostManager : IDisposable { int costCacheSize = pixCount > BackwardReferenceEncoder.MaxLength ? BackwardReferenceEncoder.MaxLength : pixCount; - this.CacheIntervals = new(); - this.CostCache = new(); + this.CacheIntervals = new List(); + this.CostCache = new List(); this.Costs = memoryAllocator.Allocate(pixCount); this.DistArray = distArray; this.Count = 0; for (int i = 0; i < FreeIntervalsStartCount; i++) { - this.freeIntervals.Push(new()); + this.freeIntervals.Push(new CostInterval()); } // Fill in the cost cache. @@ -62,7 +62,7 @@ internal sealed class CostManager : IDisposable double costVal = this.CostCache[i]; if (costVal != cur.Cost) { - cur = new() + cur = new CostCacheInterval { Start = i, Cost = costVal @@ -258,7 +258,7 @@ internal sealed class CostManager : IDisposable } else { - intervalNew = new() { Cost = cost, Start = start, End = end, Index = position }; + intervalNew = new CostInterval { Cost = cost, Start = start, End = end, Index = position }; } this.PositionOrphanInterval(intervalNew, intervalIn); diff --git a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs index 7488f03ca..58394c212 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/CrunchConfig.cs @@ -7,5 +7,5 @@ internal class CrunchConfig { public EntropyIx EntropyIdx { get; set; } - public List SubConfigs { get; } = new List(); + public List SubConfigs { get; } = new(); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs index 1375218da..5806ee5b5 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HTreeGroup.cs @@ -15,7 +15,7 @@ internal struct HTreeGroup { public HTreeGroup(uint packedTableSize) { - this.HTrees = new(WebpConstants.HuffmanCodesPerMetaCode); + this.HTrees = new List(WebpConstants.HuffmanCodesPerMetaCode); this.PackedTable = new HuffmanCode[packedTableSize]; this.IsTrivialCode = false; this.IsTrivialLiteral = false; diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index fd5d1dd94..027d4f7ee 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -425,7 +425,7 @@ internal static class HuffmanUtils tableSize = 1 << tableBits; totalSize += tableSize; low = key & mask; - table[low] = new() + table[low] = new HuffmanCode { BitsUsed = tableBits + rootBits, Value = (uint)(tablePos - low) diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs index c22abd83e..374465cf7 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LDecoder.cs @@ -22,7 +22,7 @@ internal class Vp8LDecoder : IDisposable { this.Width = width; this.Height = height; - this.Metadata = new(); + this.Metadata = new Vp8LMetadata(); this.Pixels = memoryAllocator.Allocate(width * height, AllocationOptions.Clean); } diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs index 2cbe4bbb6..b398554eb 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs @@ -124,16 +124,16 @@ internal class Vp8LEncoder : IDisposable this.transparentColorMode = transparentColorMode; this.nearLossless = nearLossless; this.nearLosslessQuality = Numerics.Clamp(nearLosslessQuality, 0, 100); - this.bitWriter = new(initialSize); + this.bitWriter = new Vp8LBitWriter(initialSize); this.Bgra = memoryAllocator.Allocate(pixelCount); this.EncodedData = memoryAllocator.Allocate(pixelCount); this.Palette = memoryAllocator.Allocate(WebpConstants.MaxPaletteSize); this.Refs = new Vp8LBackwardRefs[3]; - this.HashChain = new(memoryAllocator, pixelCount); + this.HashChain = new Vp8LHashChain(memoryAllocator, pixelCount); for (int i = 0; i < this.Refs.Length; i++) { - this.Refs[i] = new(memoryAllocator, pixelCount); + this.Refs[i] = new Vp8LBackwardRefs(memoryAllocator, pixelCount); } } @@ -549,14 +549,14 @@ internal class Vp8LEncoder : IDisposable // We can only apply kPalette or kPaletteAndSpatial if we can indeed use a palette. if ((entropyIx != EntropyIx.Palette && entropyIx != EntropyIx.PaletteAndSpatial) || usePalette) { - crunchConfigs.Add(new() { EntropyIdx = entropyIx }); + crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIx }); } } } else { // Only choose the guessed best transform. - crunchConfigs.Add(new() { EntropyIdx = entropyIdx }); + crunchConfigs.Add(new CrunchConfig { EntropyIdx = entropyIdx }); if (this.quality >= 75 && this.method == WebpEncodingMethod.Level5) { // Test with and without color cache. @@ -565,7 +565,7 @@ internal class Vp8LEncoder : IDisposable // If we have a palette, also check in combination with spatial. if (entropyIdx == EntropyIx.Palette) { - crunchConfigs.Add(new() { EntropyIdx = EntropyIx.PaletteAndSpatial }); + crunchConfigs.Add(new CrunchConfig { EntropyIdx = EntropyIx.PaletteAndSpatial }); } } } @@ -575,7 +575,7 @@ internal class Vp8LEncoder : IDisposable { for (int j = 0; j < nlz77s; j++) { - crunchConfig.SubConfigs.Add(new() + crunchConfig.SubConfigs.Add(new CrunchSubConfig { Lz77 = j == 0 ? (int)Vp8LLz77Type.Lz77Standard | (int)Vp8LLz77Type.Lz77Rle : (int)Vp8LLz77Type.Lz77Box, DoNotCache = doNotCache @@ -712,7 +712,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new(); + tokens[i] = new HuffmanTreeToken(); } for (int i = 0; i < 5 * histogramImageSize; i++) @@ -858,7 +858,7 @@ internal class Vp8LEncoder : IDisposable HuffmanTreeToken[] tokens = new HuffmanTreeToken[maxTokens]; for (int i = 0; i < tokens.Length; i++) { - tokens[i] = new(); + tokens[i] = new HuffmanTreeToken(); } // Store Huffman codes. diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs index 5b3ecc7f5..03bedfe67 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogram.cs @@ -613,7 +613,7 @@ internal sealed unsafe class OwnedVp8LHistogram : Vp8LHistogram, IDisposable { IMemoryOwner bufferOwner = memoryAllocator.Allocate(BufferSize, AllocationOptions.Clean); MemoryHandle bufferHandle = bufferOwner.Memory.Pin(); - return new(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); + return new OwnedVp8LHistogram(bufferOwner, ref bufferHandle, (uint*)bufferHandle.Pointer, paletteCodeBits); } /// diff --git a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs index 68b52f22b..817641393 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/Vp8LHistogramSet.cs @@ -25,7 +25,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new(capacity); + this.items = new List(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), cacheBits)); @@ -41,7 +41,7 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable unsafe { uint* basePointer = (uint*)this.bufferHandle.Pointer; - this.items = new(capacity); + this.items = new List(capacity); for (int i = 0; i < capacity; i++) { this.items.Add(new MemberVp8LHistogram(basePointer + (Vp8LHistogram.BufferSize * i), refs, cacheBits)); @@ -49,9 +49,9 @@ internal sealed class Vp8LHistogramSet : IEnumerable, IDisposable } } - public Vp8LHistogramSet(int capacity) => this.items = new(capacity); + public Vp8LHistogramSet(int capacity) => this.items = new List(capacity); - public Vp8LHistogramSet() => this.items = new(); + public Vp8LHistogramSet() => this.items = new List(); public int Count => this.items.Count; diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index af26616cc..6de3ae749 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -108,7 +108,7 @@ internal sealed class WebpLosslessDecoder int numberOfTransformsPresent = 0; if (isLevel0) { - decoder.Transforms = new(WebpConstants.MaxNumberOfTransforms); + decoder.Transforms = new List(WebpConstants.MaxNumberOfTransforms); // Next bit indicates, if a transformation is present. while (this.bitReader.ReadBit()) @@ -129,7 +129,7 @@ internal sealed class WebpLosslessDecoder } else { - decoder.Metadata = new(); + decoder.Metadata = new Vp8LMetadata(); } // Color cache. @@ -156,7 +156,7 @@ internal sealed class WebpLosslessDecoder // Finish setting up the color-cache. if (isColorCachePresent) { - decoder.Metadata.ColorCache = new(colorCacheBits); + decoder.Metadata.ColorCache = new ColorCache(colorCacheBits); colorCacheSize = 1 << colorCacheBits; decoder.Metadata.ColorCacheSize = colorCacheSize; } @@ -416,7 +416,7 @@ internal sealed class WebpLosslessDecoder int[] codeLengths = new int[maxAlphabetSize]; for (int i = 0; i < numHTreeGroupsMax; i++) { - hTreeGroups[i] = new(HuffmanUtils.HuffmanPackedTableSize); + hTreeGroups[i] = new HTreeGroup(HuffmanUtils.HuffmanPackedTableSize); HTreeGroup hTreeGroup = hTreeGroups[i]; int totalSize = 0; bool isTrivialLiteral = true; diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index 31030adb0..ed1ed52ab 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -36,8 +36,8 @@ internal static unsafe class QuantEnc int tlambda = dqm.TLambda; Span src = it.YuvIn.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; - Vp8ModeScore rdTmp = new Vp8ModeScore(); - Vp8Residual res = new Vp8Residual(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Vp8ModeScore rdCur = rdTmp; Vp8ModeScore rdBest = rd; int mode; @@ -107,7 +107,7 @@ internal static unsafe class QuantEnc Span bestBlocks = it.YuvOut2.AsSpan(Vp8EncIterator.YOffEnc); Span scratch = it.Scratch3; int totalHeaderBits = 0; - Vp8ModeScore rdBest = new Vp8ModeScore(); + Vp8ModeScore rdBest = new(); if (maxI4HeaderBits == 0) { @@ -118,9 +118,9 @@ internal static unsafe class QuantEnc rdBest.H = 211; // '211' is the value of VP8BitCost(0, 145) rdBest.SetRdScore(dqm.LambdaMode); it.StartI4(); - Vp8ModeScore rdi4 = new Vp8ModeScore(); - Vp8ModeScore rdTmp = new Vp8ModeScore(); - Vp8Residual res = new Vp8Residual(); + Vp8ModeScore rdi4 = new(); + Vp8ModeScore rdTmp = new(); + Vp8Residual res = new(); Span tmpLevels = stackalloc short[16]; do { @@ -220,9 +220,9 @@ internal static unsafe class QuantEnc Span tmpDst = it.YuvOut2.AsSpan(Vp8EncIterator.UOffEnc); Span dst0 = it.YuvOut.AsSpan(Vp8EncIterator.UOffEnc); Span dst = dst0; - Vp8ModeScore rdBest = new Vp8ModeScore(); - Vp8ModeScore rdUv = new Vp8ModeScore(); - Vp8Residual res = new Vp8Residual(); + Vp8ModeScore rdBest = new(); + Vp8ModeScore rdUv = new(); + Vp8Residual res = new(); int mode; rd.ModeUv = -1; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs index 0c25fb4e4..90506efb8 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8BandProbas.cs @@ -16,7 +16,7 @@ internal class Vp8BandProbas this.Probabilities = new Vp8ProbaArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Probabilities[i] = new(); + this.Probabilities[i] = new Vp8ProbaArray(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs index a0fe03486..eee22159e 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Costs.cs @@ -13,7 +13,7 @@ internal class Vp8Costs this.Costs = new Vp8CostArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Costs[i] = new(); + this.Costs[i] = new Vp8CostArray(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs index cd9a0dea2..3c8bafa1b 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs @@ -25,7 +25,7 @@ internal class Vp8Decoder : IDisposable /// Used for allocating memory for the pixel data output and the temporary buffers. public Vp8Decoder(Vp8FrameHeader frameHeader, Vp8PictureHeader pictureHeader, Vp8SegmentHeader segmentHeader, Vp8Proba probabilities, MemoryAllocator memoryAllocator) { - this.FilterHeader = new(); + this.FilterHeader = new Vp8FilterHeader(); this.FrameHeader = frameHeader; this.PictureHeader = pictureHeader; this.SegmentHeader = segmentHeader; @@ -41,22 +41,22 @@ internal class Vp8Decoder : IDisposable this.FilterInfo = new Vp8FilterInfo[this.MbWidth]; for (int i = 0; i < this.MbWidth; i++) { - this.MacroBlockInfo[i] = new(); - this.MacroBlockData[i] = new(); - this.YuvTopSamples[i] = new(); - this.FilterInfo[i] = new(); + this.MacroBlockInfo[i] = new Vp8MacroBlock(); + this.MacroBlockData[i] = new Vp8MacroBlockData(); + this.YuvTopSamples[i] = new Vp8TopSamples(); + this.FilterInfo[i] = new Vp8FilterInfo(); } - this.MacroBlockInfo[this.MbWidth] = new(); + this.MacroBlockInfo[this.MbWidth] = new Vp8MacroBlock(); this.DeQuantMatrices = new Vp8QuantMatrix[WebpConstants.NumMbSegments]; this.FilterStrength = new Vp8FilterInfo[WebpConstants.NumMbSegments, 2]; for (int i = 0; i < WebpConstants.NumMbSegments; i++) { - this.DeQuantMatrices[i] = new(); + this.DeQuantMatrices[i] = new Vp8QuantMatrix(); for (int j = 0; j < 2; j++) { - this.FilterStrength[i, j] = new(); + this.FilterStrength[i, j] = new Vp8FilterInfo(); } } @@ -245,7 +245,7 @@ internal class Vp8Decoder : IDisposable public Vp8MacroBlock CurrentMacroBlock => this.MacroBlockInfo[this.MbX]; - public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new(); + public Vp8MacroBlock LeftMacroBlock => this.leftMacroBlock ??= new Vp8MacroBlock(); public Vp8MacroBlockData CurrentBlockData => this.MacroBlockData[this.MbX]; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index 7f57c81f8..a7c96edb7 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -427,7 +427,7 @@ internal class Vp8EncIterator this.MakeIntra4Preds(); for (mode = 0; mode < maxMode; ++mode) { - histos[curHisto] = new(); + histos[curHisto] = new Vp8Histogram(); histos[curHisto].CollectHistogram(src, this.YuvP.AsSpan(Vp8Encoding.Vp8I4ModeOffsets[mode]), 0, 1); int alpha = histos[curHisto].GetAlpha(); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs index a6faddc04..070e70574 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncProba.cs @@ -29,7 +29,7 @@ internal class Vp8EncProba this.Coeffs[i] = new Vp8BandProbas[WebpConstants.NumBands]; for (int j = 0; j < this.Coeffs[i].Length; j++) { - this.Coeffs[i][j] = new(); + this.Coeffs[i][j] = new Vp8BandProbas(); } } @@ -39,7 +39,7 @@ internal class Vp8EncProba this.Stats[i] = new Vp8Stats[WebpConstants.NumBands]; for (int j = 0; j < this.Stats[i].Length; j++) { - this.Stats[i][j] = new(); + this.Stats[i][j] = new Vp8Stats(); } } @@ -49,7 +49,7 @@ internal class Vp8EncProba this.LevelCost[i] = new Vp8Costs[WebpConstants.NumBands]; for (int j = 0; j < this.LevelCost[i].Length; j++) { - this.LevelCost[i][j] = new(); + this.LevelCost[i][j] = new Vp8Costs(); } } @@ -59,7 +59,7 @@ internal class Vp8EncProba this.RemappedCosts[i] = new Vp8Costs[16]; for (int j = 0; j < this.RemappedCosts[i].Length; j++) { - this.RemappedCosts[i][j] = new(); + this.RemappedCosts[i][j] = new Vp8Costs(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index 608c5391b..e4ebe1473 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -172,19 +172,19 @@ internal class Vp8Encoder : IDisposable this.MbInfo = new Vp8MacroBlockInfo[this.Mbw * this.Mbh]; for (int i = 0; i < this.MbInfo.Length; i++) { - this.MbInfo[i] = new(); + this.MbInfo[i] = new Vp8MacroBlockInfo(); } this.SegmentInfos = new Vp8SegmentInfo[4]; for (int i = 0; i < 4; i++) { - this.SegmentInfos[i] = new(); + this.SegmentInfos[i] = new Vp8SegmentInfo(); } - this.FilterHeader = new(); + this.FilterHeader = new Vp8FilterHeader(); int predSize = (((4 * this.Mbw) + 1) * ((4 * this.Mbh) + 1)) + this.PredsWidth + 1; this.PredsWidth = (4 * this.Mbw) + 1; - this.Proba = new(); + this.Proba = new Vp8EncProba(); this.Preds = new byte[predSize + this.PredsWidth + this.Mbw]; // Initialize with default values, which the reference c implementation uses, @@ -424,14 +424,14 @@ internal class Vp8Encoder : IDisposable this.uvAlpha /= totalMb; // Analysis is done, proceed to actual encoding. - this.SegmentHeader = new(4); + this.SegmentHeader = new Vp8EncSegmentHeader(4); this.AssignSegments(alphas); this.SetLoopParams(this.quality); // Initialize the bitwriter. int averageBytesPerMacroBlock = AverageBytesPerMb[this.BaseQuant >> 4]; int expectedSize = this.Mbw * this.Mbh * averageBytesPerMacroBlock; - this.bitWriter = new(expectedSize, this); + this.bitWriter = new Vp8BitWriter(expectedSize, this); // Stats-collection loop. this.StatLoop(width, height, yStride, uvStride); diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs index de03f3c93..0da6dfcad 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Proba.cs @@ -23,7 +23,7 @@ internal class Vp8Proba { for (int j = 0; j < WebpConstants.NumBands; j++) { - this.Bands[i, j] = new(); + this.Bands[i, j] = new Vp8BandProbas(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs index bd335f298..dda921a7c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Stats.cs @@ -13,7 +13,7 @@ internal class Vp8Stats this.Stats = new Vp8StatsArray[WebpConstants.NumCtx]; for (int i = 0; i < WebpConstants.NumCtx; i++) { - this.Stats[i] = new(); + this.Stats[i] = new Vp8StatsArray(); } } diff --git a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs index bd87b385c..f14df853c 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/WebpLossyDecoder.cs @@ -150,7 +150,7 @@ internal sealed class WebpLossyDecoder { int offset = yMulWidth + x; Bgr24 bgr = pixelsBgr[offset]; - decodedPixelRow[x] = TPixel.FromBgra32(new(bgr.R, bgr.G, bgr.B, alphaSpan[offset])); + decodedPixelRow[x] = TPixel.FromBgra32(new Bgra32(bgr.R, bgr.G, bgr.B, alphaSpan[offset])); } } } @@ -1173,13 +1173,13 @@ internal sealed class WebpLossyDecoder pSize = sizeLeft; } - dec.Vp8BitReaders[p] = new(this.bitReader.Data, (uint)pSize, partStart); + dec.Vp8BitReaders[p] = new Vp8BitReader(this.bitReader.Data, (uint)pSize, partStart); partStart += pSize; sizeLeft -= pSize; sz = sz[3..]; } - dec.Vp8BitReaders[lastPart] = new(this.bitReader.Data, (uint)sizeLeft, partStart); + dec.Vp8BitReaders[lastPart] = new Vp8BitReader(this.bitReader.Data, (uint)sizeLeft, partStart); } private void ParseDequantizationIndices(Vp8Decoder decoder) diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index d19efec3b..173d9436d 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -93,7 +93,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame? previousFrame = null; WebpFrameData? prevFrameData = null; - this.metadata = new(); + this.metadata = new ImageMetadata(); this.webpMetadata = this.metadata.GetWebpMetadata(); this.webpMetadata.RepeatCount = features.AnimationLoopCount; @@ -204,7 +204,7 @@ internal class WebpAnimationDecoder : IDisposable ImageFrame currentFrame; if (previousFrame is null) { - image = new(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); + image = new Image(this.configuration, (int)width, (int)height, backgroundColor, this.metadata); currentFrame = image.Frames.RootFrame; SetFrameMetadata(currentFrame.Metadata, frameData); diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index a4e88e227..8df159dbf 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -118,7 +118,7 @@ internal static class WebpChunkParsingUtils Vp8BitReader bitReader = new(stream, remaining, memoryAllocator, partitionLength) { Remaining = remaining }; - return new() + return new WebpImageInfo { Width = width, Height = height, @@ -176,7 +176,7 @@ internal static class WebpChunkParsingUtils WebpThrowHelper.ThrowNotSupportedException($"Unexpected version number {version} found in VP8L header"); } - return new() + return new WebpImageInfo { Width = width, Height = height, @@ -239,7 +239,7 @@ internal static class WebpChunkParsingUtils uint height = ReadUInt24LittleEndian(stream, buffer) + 1; // Read all the chunks in the order they occur. - return new() + return new WebpImageInfo { Width = width, Height = height, @@ -358,7 +358,7 @@ internal static class WebpChunkParsingUtils if (metadata.ExifProfile != null) { - metadata.ExifProfile = new(exifData); + metadata.ExifProfile = new ExifProfile(exifData); } break; @@ -372,7 +372,7 @@ internal static class WebpChunkParsingUtils if (metadata.XmpProfile != null) { - metadata.XmpProfile = new(xmpData); + metadata.XmpProfile = new XmpProfile(xmpData); } break; diff --git a/src/ImageSharp/Formats/Webp/WebpDecoder.cs b/src/ImageSharp/Formats/Webp/WebpDecoder.cs index 41c5d60f7..48d725b26 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoder.cs @@ -25,7 +25,7 @@ public sealed class WebpDecoder : SpecializedImageDecoder Guard.NotNull(options, nameof(options)); Guard.NotNull(stream, nameof(stream)); - using WebpDecoderCore decoder = new(new() { GeneralOptions = options }); + using WebpDecoderCore decoder = new(new WebpDecoderOptions { GeneralOptions = options }); return decoder.Identify(options.Configuration, stream, cancellationToken); } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index dfd80c838..51379a32a 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -93,7 +93,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } - image = new(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); + image = new Image(this.configuration, (int)this.webImageInfo.Width, (int)this.webImageInfo.Height, metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.webImageInfo.IsLossless) { @@ -136,8 +136,8 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable ImageMetadata metadata = new(); using (this.webImageInfo = this.ReadVp8Info(stream, metadata, true)) { - return new( - new((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), + return new ImageInfo( + new Size((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), metadata); } } @@ -229,7 +229,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable default: WebpThrowHelper.ThrowImageFormatException("Unrecognized VP8 header"); return - new(); // this return will never be reached, because throw helper will throw an exception. + new WebpImageInfo(); // this return will never be reached, because throw helper will throw an exception. } } @@ -389,7 +389,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable return; } - metadata.XmpProfile = new(xmpData); + metadata.XmpProfile = new XmpProfile(xmpData); } } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs index 8840805b1..6fb15acbb 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderOptions.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Formats.Webp; public sealed class WebpDecoderOptions : ISpecializedDecoderOptions { /// - public DecoderOptions GeneralOptions { get; init; } = new DecoderOptions(); + public DecoderOptions GeneralOptions { get; init; } = new(); /// /// Gets the flag to decide how to handle the background color Animation Chunk. diff --git a/src/ImageSharp/Formats/Webp/WebpFormat.cs b/src/ImageSharp/Formats/Webp/WebpFormat.cs index 1764182c5..9853ce7d7 100644 --- a/src/ImageSharp/Formats/Webp/WebpFormat.cs +++ b/src/ImageSharp/Formats/Webp/WebpFormat.cs @@ -15,7 +15,7 @@ public sealed class WebpFormat : IImageFormat /// /// Gets the shared instance. /// - public static WebpFormat Instance { get; } = new WebpFormat(); + public static WebpFormat Instance { get; } = new(); /// public string Name => "WEBP"; @@ -30,8 +30,8 @@ public sealed class WebpFormat : IImageFormat public IEnumerable FileExtensions => WebpConstants.FileExtensions; /// - public WebpMetadata CreateDefaultFormatMetadata() => new WebpMetadata(); + public WebpMetadata CreateDefaultFormatMetadata() => new(); /// - public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new WebpFrameMetadata(); + public WebpFrameMetadata CreateDefaultFormatFrameMetadata() => new(); } diff --git a/src/ImageSharp/Formats/Webp/WebpMetadata.cs b/src/ImageSharp/Formats/Webp/WebpMetadata.cs index 817addac5..1cdaeadb4 100644 --- a/src/ImageSharp/Formats/Webp/WebpMetadata.cs +++ b/src/ImageSharp/Formats/Webp/WebpMetadata.cs @@ -88,7 +88,7 @@ public class WebpMetadata : IFormatMetadata break; } - return new() + return new WebpMetadata { BitsPerPixel = bitsPerPixel, ColorType = color, @@ -126,7 +126,7 @@ public class WebpMetadata : IFormatMetadata break; } - return new(bpp) + return new PixelTypeInfo(bpp) { AlphaRepresentation = alpha, ColorType = colorType, diff --git a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs index aa0590619..9412062cc 100644 --- a/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs +++ b/src/ImageSharp/GraphicOptionsDefaultsExtensions.cs @@ -87,7 +87,7 @@ public static class GraphicOptionsDefaultsExtensions return go; } - GraphicsOptions configOptions = new GraphicsOptions(); + GraphicsOptions configOptions = new(); // capture the fallback so the same instance will always be returned in case its mutated configuration.Properties[typeof(GraphicsOptions)] = configOptions; diff --git a/src/ImageSharp/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs index 4ac8585c3..dc3d17902 100644 --- a/src/ImageSharp/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -84,5 +84,5 @@ public class GraphicsOptions : IDeepCloneable public PixelAlphaCompositionMode AlphaCompositionMode { get; set; } = PixelAlphaCompositionMode.SrcOver; /// - public GraphicsOptions DeepClone() => new GraphicsOptions(this); + public GraphicsOptions DeepClone() => new(this); } diff --git a/src/ImageSharp/IO/ChunkedMemoryStream.cs b/src/ImageSharp/IO/ChunkedMemoryStream.cs index a5a401144..d62a64c23 100644 --- a/src/ImageSharp/IO/ChunkedMemoryStream.cs +++ b/src/ImageSharp/IO/ChunkedMemoryStream.cs @@ -27,7 +27,7 @@ internal sealed class ChunkedMemoryStream : Stream /// /// The memory allocator. public ChunkedMemoryStream(MemoryAllocator allocator) - => this.memoryChunkBuffer = new(allocator); + => this.memoryChunkBuffer = new MemoryChunkBuffer(allocator); /// public override bool CanRead => !this.isDisposed; diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 7e61e5095..d2ee0f906 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -36,7 +36,7 @@ public abstract partial class Image width, height, configuration.PreferContiguousImageBuffers); - return new(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); + return new Image(configuration, uninitializedMemoryBuffer.FastMemoryGroup, width, height, metadata); } /// diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs index ab2718f6c..03bec8bc6 100644 --- a/src/ImageSharp/Image.WrapMemory.cs +++ b/src/ImageSharp/Image.WrapMemory.cs @@ -53,7 +53,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemory.Length >= (long)width * height, nameof(pixelMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemory); - return new(configuration, memorySource, width, height, metadata); + return new Image(configuration, memorySource, width, height, metadata); } /// @@ -87,7 +87,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemory, width, height, new()); + => WrapMemory(configuration, pixelMemory, width, height, new ImageMetadata()); /// /// @@ -148,7 +148,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new(configuration, memorySource, width, height, metadata); + return new Image(configuration, memorySource, width, height, metadata); } /// @@ -171,7 +171,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pixelMemoryOwner, width, height, new()); + => WrapMemory(configuration, pixelMemoryOwner, width, height, new ImageMetadata()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -235,7 +235,7 @@ public abstract partial class Image Guard.IsTrue(memoryManager.Memory.Length >= (long)width * height, nameof(byteMemory), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new(configuration, memorySource, width, height, metadata); + return new Image(configuration, memorySource, width, height, metadata); } /// @@ -269,7 +269,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemory, width, height, new()); + => WrapMemory(configuration, byteMemory, width, height, new ImageMetadata()); /// /// @@ -333,7 +333,7 @@ public abstract partial class Image Guard.IsTrue(pixelMemoryOwner.Memory.Length >= (long)width * height, nameof(pixelMemoryOwner), "The length of the input memory is less than the specified image size"); MemoryGroup memorySource = MemoryGroup.Wrap(pixelMemoryOwner); - return new(configuration, memorySource, width, height, metadata); + return new Image(configuration, memorySource, width, height, metadata); } /// @@ -356,7 +356,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, byteMemoryOwner, width, height, new()); + => WrapMemory(configuration, byteMemoryOwner, width, height, new ImageMetadata()); /// /// Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, @@ -429,7 +429,7 @@ public abstract partial class Image Guard.MustBeGreaterThanOrEqualTo(bufferSizeInBytes / sizeof(TPixel), memoryManager.Memory.Span.Length, nameof(bufferSizeInBytes)); MemoryGroup memorySource = MemoryGroup.Wrap(memoryManager.Memory); - return new(configuration, memorySource, width, height, metadata); + return new Image(configuration, memorySource, width, height, metadata); } /// @@ -470,7 +470,7 @@ public abstract partial class Image int width, int height) where TPixel : unmanaged, IPixel - => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new()); + => WrapMemory(configuration, pointer, bufferSizeInBytes, width, height, new ImageMetadata()); /// /// diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index 693b58db6..07b40a41a 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -47,7 +47,7 @@ public abstract partial class Image : IDisposable, IConfigurationProvider ImageMetadata metadata, int width, int height) - : this(configuration, pixelType, metadata, new(width, height)) + : this(configuration, pixelType, metadata, new Size(width, height)) { } diff --git a/src/ImageSharp/ImageFrame.LoadPixelData.cs b/src/ImageSharp/ImageFrame.LoadPixelData.cs index 90fe16bad..003a0349a 100644 --- a/src/ImageSharp/ImageFrame.LoadPixelData.cs +++ b/src/ImageSharp/ImageFrame.LoadPixelData.cs @@ -40,7 +40,7 @@ public partial class ImageFrame int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); - ImageFrame image = new ImageFrame(configuration, width, height); + ImageFrame image = new(configuration, width, height); data = data[..count]; data.CopyTo(image.PixelBuffer.FastMemoryGroup); diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs index 686292bc7..3d4b63fad 100644 --- a/src/ImageSharp/ImageFrame.cs +++ b/src/ImageSharp/ImageFrame.cs @@ -25,7 +25,7 @@ public abstract partial class ImageFrame : IConfigurationProvider, IDisposable protected ImageFrame(Configuration configuration, int width, int height, ImageFrameMetadata metadata) { this.Configuration = configuration; - this.Size = new(width, height); + this.Size = new Size(width, height); this.Metadata = metadata; } diff --git a/src/ImageSharp/ImageFrameCollection{TPixel}.cs b/src/ImageSharp/ImageFrameCollection{TPixel}.cs index da76aa4ab..ad7d71974 100644 --- a/src/ImageSharp/ImageFrameCollection{TPixel}.cs +++ b/src/ImageSharp/ImageFrameCollection{TPixel}.cs @@ -23,7 +23,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new(parent.Configuration, width, height, backgroundColor)); + this.frames.Add(new ImageFrame(parent.Configuration, width, height, backgroundColor)); } internal ImageFrameCollection(Image parent, int width, int height, MemoryGroup memorySource) @@ -31,7 +31,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.parent = parent ?? throw new ArgumentNullException(nameof(parent)); // Frames are already cloned within the caller - this.frames.Add(new(parent.Configuration, width, height, memorySource)); + this.frames.Add(new ImageFrame(parent.Configuration, width, height, memorySource)); } internal ImageFrameCollection(Image parent, IEnumerable> frames) @@ -269,7 +269,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer this.frames.Remove(frame); - return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); + return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { frame }); } /// @@ -284,7 +284,7 @@ public sealed class ImageFrameCollection : ImageFrameCollection, IEnumer ImageFrame frame = this[index]; ImageFrame clonedFrame = frame.Clone(); - return new(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); + return new Image(this.parent.Configuration, this.parent.Metadata.DeepClone(), new[] { clonedFrame }); } /// diff --git a/src/ImageSharp/ImageFrame{TPixel}.cs b/src/ImageSharp/ImageFrame{TPixel}.cs index ce673ba40..de71e77ca 100644 --- a/src/ImageSharp/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/ImageFrame{TPixel}.cs @@ -81,7 +81,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The color to clear the image with. internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new()) + : this(configuration, width, height, backgroundColor, new ImageFrameMetadata()) { } @@ -114,7 +114,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource /// The height of the image in pixels. /// The memory source. internal ImageFrame(Configuration configuration, int width, int height, MemoryGroup memorySource) - : this(configuration, width, height, memorySource, new()) + : this(configuration, width, height, memorySource, new ImageFrameMetadata()) { } @@ -132,7 +132,7 @@ public sealed class ImageFrame : ImageFrame, IPixelSource Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - this.PixelBuffer = new(memorySource, width, height); + this.PixelBuffer = new Buffer2D(memorySource, width, height); } /// diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index 543d6ab43..dff8f577f 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -41,7 +41,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(Configuration configuration, int width, int height, TPixel backgroundColor) - : this(configuration, width, height, backgroundColor, new()) + : this(configuration, width, height, backgroundColor, new ImageMetadata()) { } @@ -53,7 +53,7 @@ public sealed class Image : Image /// The height of the image in pixels. /// The color to initialize the pixels with. public Image(int width, int height, TPixel backgroundColor) - : this(Configuration.Default, width, height, backgroundColor, new()) + : this(Configuration.Default, width, height, backgroundColor, new ImageMetadata()) { } @@ -77,8 +77,8 @@ public sealed class Image : Image /// The height of the image in pixels. /// The images metadata. internal Image(Configuration configuration, int width, int height, ImageMetadata? metadata) - : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new(this, width, height, default(TPixel)); + : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new ImageMetadata(), width, height) + => this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); /// /// Initializes a new instance of the class @@ -111,7 +111,7 @@ public sealed class Image : Image int height, ImageMetadata metadata) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, width, height) - => this.frames = new(this, width, height, memoryGroup); + => this.frames = new ImageFrameCollection(this, width, height, memoryGroup); /// /// Initializes a new instance of the class @@ -128,8 +128,8 @@ public sealed class Image : Image int height, TPixel backgroundColor, ImageMetadata? metadata) - : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new(), width, height) - => this.frames = new(this, width, height, backgroundColor); + : base(configuration, TPixel.GetPixelTypeInfo(), metadata ?? new ImageMetadata(), width, height) + => this.frames = new ImageFrameCollection(this, width, height, backgroundColor); /// /// Initializes a new instance of the class @@ -140,7 +140,7 @@ public sealed class Image : Image /// The frames that will be owned by this image instance. internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable> frames) : base(configuration, TPixel.GetPixelTypeInfo(), metadata, ValidateFramesAndGetSize(frames)) - => this.frames = new(this, frames); + => this.frames = new ImageFrameCollection(this, frames); /// protected override ImageFrameCollection NonGenericFrameCollection => this.Frames; @@ -344,7 +344,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].Clone(configuration); } - return new(configuration, this.Metadata.DeepClone(), clonedFrames); + return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); } /// @@ -363,7 +363,7 @@ public sealed class Image : Image clonedFrames[i] = this.frames[i].CloneAs(configuration); } - return new(configuration, this.Metadata.DeepClone(), clonedFrames); + return new Image(configuration, this.Metadata.DeepClone(), clonedFrames); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs index cbf64e6a1..a6ed797d6 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/ManagedBufferBase.cs @@ -27,7 +27,7 @@ internal abstract class ManagedBufferBase : MemoryManager void* ptr = Unsafe.Add((void*)this.pinHandle.AddrOfPinnedObject(), elementIndex); // We should only pass pinnable:this, when GCHandle lifetime is managed by the MemoryManager instance. - return new(ptr, pinnable: this); + return new MemoryHandle(ptr, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs index 364aa05af..02bdf0f48 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/SharedArrayPoolBuffer{T}.cs @@ -19,7 +19,7 @@ internal class SharedArrayPoolBuffer : ManagedBufferBase, IRefCounted { this.lengthInBytes = lengthInElements * Unsafe.SizeOf(); this.Array = ArrayPool.Shared.Rent(this.lengthInBytes); - this.lifetimeGuard = new(this.Array); + this.lifetimeGuard = new LifetimeGuard(this.Array); } public byte[]? Array { get; private set; } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs index a505548d2..e3b73204d 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.LifetimeGuards.cs @@ -11,7 +11,7 @@ internal partial class UniformUnmanagedMemoryPool bool clear) where T : struct { - UnmanagedBuffer buffer = new UnmanagedBuffer(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); + UnmanagedBuffer buffer = new(lengthInElements, new ReturnToPoolBufferLifetimeGuard(this, handle)); if (clear) { buffer.Clear(); diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs index d7212a41f..5e15e46e9 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -214,14 +214,14 @@ internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedEx { lock (AllPools) { - AllPools.Add(new(pool)); + AllPools.Add(new WeakReference(pool)); // Invoke the timer callback more frequently, than trimSettings.TrimPeriodMilliseconds. // We are checking in the callback if enough time passed since the last trimming. If not, we do nothing. int period = settings.TrimPeriodMilliseconds / 4; if (trimTimer == null) { - trimTimer = new(_ => TimerCallback(), null, period, period); + trimTimer = new Timer(_ => TimerCallback(), null, period, period); } else if (settings.TrimPeriodMilliseconds < minTrimPeriodMilliseconds) { diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs index 5e7f386fd..854b40e0c 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedBuffer{T}.cs @@ -35,7 +35,7 @@ internal sealed unsafe class UnmanagedBuffer : MemoryManager, IRefCounted { DebugGuard.NotDisposed(this.disposed == 1, this.GetType().Name); DebugGuard.NotDisposed(this.lifetimeGuard.IsDisposed, this.lifetimeGuard.GetType().Name); - return new(this.Pointer, this.lengthInElements); + return new Span(this.Pointer, this.lengthInElements); } /// @@ -48,7 +48,7 @@ internal sealed unsafe class UnmanagedBuffer : MemoryManager, IRefCounted this.lifetimeGuard.AddRef(); void* pbData = Unsafe.Add(this.Pointer, elementIndex); - return new(pbData, pinnable: this); + return new MemoryHandle(pbData, pinnable: this); } /// diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs index 0fc5d2dea..6b31cadf4 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs @@ -64,7 +64,7 @@ internal struct UnmanagedMemoryHandle : IEquatable public static UnmanagedMemoryHandle Allocate(int lengthInBytes) { IntPtr handle = AllocateHandle(lengthInBytes); - return new(handle, lengthInBytes); + return new UnmanagedMemoryHandle(handle, lengthInBytes); } private static IntPtr AllocateHandle(int lengthInBytes) @@ -84,7 +84,7 @@ internal struct UnmanagedMemoryHandle : IEquatable counter++; Interlocked.Increment(ref totalOomRetries); - Interlocked.CompareExchange(ref lowMemoryMonitor, new(), null); + Interlocked.CompareExchange(ref lowMemoryMonitor, new object(), null); Monitor.Enter(lowMemoryMonitor); Monitor.Wait(lowMemoryMonitor, millisecondsTimeout: 1); Monitor.Exit(lowMemoryMonitor); diff --git a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs index 203a5df69..10defe6cd 100644 --- a/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs +++ b/src/ImageSharp/Memory/Allocators/UniformUnmanagedMemoryPoolMemoryAllocator.cs @@ -67,8 +67,8 @@ internal sealed class UniformUnmanagedMemoryPoolMemoryAllocator : MemoryAllocato this.poolBufferSizeInBytes = poolBufferSizeInBytes; this.poolCapacity = (int)(maxPoolSizeInBytes / poolBufferSizeInBytes); this.trimSettings = trimSettings; - this.pool = new(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); - this.nonPoolAllocator = new(unmanagedBufferSizeInBytes); + this.pool = new UniformUnmanagedMemoryPool(this.poolBufferSizeInBytes, this.poolCapacity, this.trimSettings); + this.nonPoolAllocator = new UnmanagedMemoryAllocator(unmanagedBufferSizeInBytes); } // This delegate allows overriding the method returning the available system memory, diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs index b8ac5a584..f0fa1438d 100644 --- a/src/ImageSharp/Memory/Buffer2DExtensions.cs +++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs @@ -126,7 +126,7 @@ public static class Buffer2DExtensions internal static Buffer2DRegion GetRegion(this Buffer2D buffer, int x, int y, int width, int height) where T : unmanaged => - new(buffer, new(x, y, width, height)); + new(buffer, new Rectangle(x, y, width, height)); /// /// Return a to the whole area of 'buffer' diff --git a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs index c628bfd85..f4b257b58 100644 --- a/src/ImageSharp/Memory/Buffer2DRegion{T}.cs +++ b/src/ImageSharp/Memory/Buffer2DRegion{T}.cs @@ -124,8 +124,8 @@ public readonly struct Buffer2DRegion int x = this.Rectangle.X + rectangle.X; int y = this.Rectangle.Y + rectangle.Y; - rectangle = new(x, y, rectangle.Width, rectangle.Height); - return new(this.Buffer, rectangle); + rectangle = new Rectangle(x, y, rectangle.Width, rectangle.Height); + return new Buffer2DRegion(this.Buffer, rectangle); } /// diff --git a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs index 91525e5ad..bc7175141 100644 --- a/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs +++ b/src/ImageSharp/Memory/ByteMemoryOwner{T}.cs @@ -24,7 +24,7 @@ internal sealed class ByteMemoryOwner : IMemoryOwner public ByteMemoryOwner(IMemoryOwner memoryOwner) { this.memoryOwner = memoryOwner; - this.memoryManager = new(memoryOwner.Memory); + this.memoryManager = new ByteMemoryManager(memoryOwner.Memory); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs index d2e4d00fb..148b5f6bf 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupExtensions.cs @@ -77,7 +77,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(source, nameof(source)); Guard.MustBeGreaterThanOrEqualTo(target.Length, source.TotalLength, nameof(target)); - MemoryGroupCursor cur = new MemoryGroupCursor(source); + MemoryGroupCursor cur = new(source); long position = 0; while (position < source.TotalLength) { @@ -100,7 +100,7 @@ internal static class MemoryGroupExtensions Guard.NotNull(target, nameof(target)); Guard.MustBeGreaterThanOrEqualTo(target.TotalLength, source.Length, nameof(target)); - MemoryGroupCursor cur = new MemoryGroupCursor(target); + MemoryGroupCursor cur = new(target); while (!source.IsEmpty) { @@ -126,8 +126,8 @@ internal static class MemoryGroupExtensions } long position = 0; - MemoryGroupCursor srcCur = new MemoryGroupCursor(source); - MemoryGroupCursor trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { @@ -162,8 +162,8 @@ internal static class MemoryGroupExtensions } long position = 0; - MemoryGroupCursor srcCur = new MemoryGroupCursor(source); - MemoryGroupCursor trgCur = new MemoryGroupCursor(target); + MemoryGroupCursor srcCur = new(source); + MemoryGroupCursor trgCur = new(target); while (position < source.TotalLength) { diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs index a3f45c8cf..76371e674 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupView{T}.cs @@ -31,7 +31,7 @@ internal class MemoryGroupView : IMemoryGroup for (int i = 0; i < owner.Count; i++) { - this.memoryWrappers[i] = new(this, i); + this.memoryWrappers[i] = new MemoryOwnerWrapper(this, i); } } @@ -79,7 +79,7 @@ internal class MemoryGroupView : IMemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public MemoryGroupEnumerator GetEnumerator() { - return new(this); + return new MemoryGroupEnumerator(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs index 783ab53a5..950e2a019 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Consumed.cs @@ -18,7 +18,7 @@ internal abstract partial class MemoryGroup : base(bufferLength, totalLength) { this.source = source; - this.View = new(this); + this.View = new MemoryGroupView(this); } public override int Count @@ -33,7 +33,7 @@ internal abstract partial class MemoryGroup [MethodImpl(InliningOptions.ShortMethod)] public override MemoryGroupEnumerator GetEnumerator() { - return new(this); + return new MemoryGroupEnumerator(this); } /// diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs index 937a1a32b..af896ee0e 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.Owned.cs @@ -23,7 +23,7 @@ internal abstract partial class MemoryGroup { this.memoryOwners = memoryOwners; this.Swappable = swappable; - this.View = new(this); + this.View = new MemoryGroupView(this); this.memoryGroupSpanCache = MemoryGroupSpanCache.Create(memoryOwners); } @@ -124,7 +124,7 @@ internal abstract partial class MemoryGroup public override void RecreateViewAfterSwap() { this.View.Invalidate(); - this.View = new(this); + this.View = new MemoryGroupView(this); } /// @@ -212,7 +212,7 @@ internal abstract partial class MemoryGroup public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* pbData = Unsafe.Add(this.handle.Pointer, elementIndex); - return new(pbData); + return new MemoryHandle(pbData); } public override void Unpin() diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index 8e4c88104..d08bf248b 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs @@ -260,14 +260,14 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable case SpanCacheMode.SinglePointer: { void* start = Unsafe.Add(this.memoryGroupSpanCache.SinglePointer, y * width); - return new(start, width); + return new Span(start, width); } case SpanCacheMode.MultiPointer: { this.GetMultiBufferPosition(y, width, out int bufferIdx, out int bufferStart); void* start = Unsafe.Add(this.memoryGroupSpanCache.MultiPointer[bufferIdx], bufferStart); - return new(start, width); + return new Span(start, width); } default: diff --git a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs index 8178ca818..ff306e1e4 100644 --- a/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs +++ b/src/ImageSharp/Memory/MemoryAllocatorExtensions.cs @@ -41,7 +41,7 @@ public static class MemoryAllocatorExtensions memoryGroup = memoryAllocator.AllocateGroup(groupLength, width, options); } - return new(memoryGroup, width, height); + return new Buffer2D(memoryGroup, width, height); } /// @@ -109,7 +109,7 @@ public static class MemoryAllocatorExtensions groupLength, width * alignmentMultiplier, options); - return new(memoryGroup, width, height); + return new Buffer2D(memoryGroup, width, height); } /// diff --git a/src/ImageSharp/Memory/RowInterval.cs b/src/ImageSharp/Memory/RowInterval.cs index 90a88d735..f27dc7441 100644 --- a/src/ImageSharp/Memory/RowInterval.cs +++ b/src/ImageSharp/Memory/RowInterval.cs @@ -79,7 +79,7 @@ public readonly struct RowInterval : IEquatable /// public override string ToString() => $"RowInterval [{this.Min}->{this.Max}]"; - internal RowInterval Slice(int start) => new RowInterval(this.Min + start, this.Max); + internal RowInterval Slice(int start) => new(this.Min + start, this.Max); - internal RowInterval Slice(int start, int length) => new RowInterval(this.Min + start, this.Min + start + length); + internal RowInterval Slice(int start, int length) => new(this.Min + start, this.Min + start + length); } diff --git a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs index df845dd7a..7f3163af3 100644 --- a/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs +++ b/src/ImageSharp/Memory/UnmanagedMemoryManager{T}.cs @@ -42,13 +42,13 @@ internal sealed unsafe class UnmanagedMemoryManager : MemoryManager /// public override Span GetSpan() { - return new(this.pointer, this.length); + return new Span(this.pointer, this.length); } /// public override MemoryHandle Pin(int elementIndex = 0) { - return new(((T*)this.pointer) + elementIndex, pinnable: this); + return new MemoryHandle(((T*)this.pointer) + elementIndex, pinnable: this); } /// diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs index a58e22869..d2b88cbff 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs @@ -71,7 +71,7 @@ internal static class ExifEncodedStringHelpers { // Little-endian BOM string text = Encoding.Unicode.GetString(textBuffer[2..]); - encodedString = new(code, text); + encodedString = new EncodedString(code, text); return true; } @@ -79,14 +79,14 @@ internal static class ExifEncodedStringHelpers { // Big-endian BOM string text = Encoding.BigEndianUnicode.GetString(textBuffer[2..]); - encodedString = new(code, text); + encodedString = new EncodedString(code, text); return true; } } { string text = GetEncoding(code, order).GetString(textBuffer); - encodedString = new(code, text); + encodedString = new EncodedString(code, text); return true; } } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index f67395165..aa987bbe7 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -82,7 +82,7 @@ public sealed class ExifProfile : IDeepCloneable if (other.values != null) { - this.values = new(other.Values.Count); + this.values = new List(other.Values.Count); foreach (IExifValue value in other.Values) { diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs index c04a6f78e..4cd4b4aac 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifReader.cs @@ -669,7 +669,7 @@ internal abstract class BaseExifReader uint numerator = this.ConvertToUInt32(buffer[..4]); uint denominator = this.ConvertToUInt32(buffer.Slice(4, 4)); - return new(numerator, denominator, false); + return new Rational(numerator, denominator, false); } private sbyte ConvertToSignedByte(ReadOnlySpan buffer) => unchecked((sbyte)buffer[0]); @@ -696,7 +696,7 @@ internal abstract class BaseExifReader int numerator = this.ConvertToInt32(buffer[..4]); int denominator = this.ConvertToInt32(buffer.Slice(4, 4)); - return new(numerator, denominator, false); + return new SignedRational(numerator, denominator, false); } private short ConvertToSignedShort(ReadOnlySpan buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs index 9ee2cf2f4..ff74ecd19 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Byte.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the FaxProfile exif tag. /// - public static ExifTag FaxProfile { get; } = new ExifTag(ExifTagValue.FaxProfile); + public static ExifTag FaxProfile { get; } = new(ExifTagValue.FaxProfile); /// /// Gets the ModeNumber exif tag. /// - public static ExifTag ModeNumber { get; } = new ExifTag(ExifTagValue.ModeNumber); + public static ExifTag ModeNumber { get; } = new(ExifTagValue.ModeNumber); /// /// Gets the GPSAltitudeRef exif tag. /// - public static ExifTag GPSAltitudeRef { get; } = new ExifTag(ExifTagValue.GPSAltitudeRef); + public static ExifTag GPSAltitudeRef { get; } = new(ExifTagValue.GPSAltitudeRef); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs index 00a9056d3..64d8e1437 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ByteArray.cs @@ -9,40 +9,40 @@ public abstract partial class ExifTag /// /// Gets the ClipPath exif tag. /// - public static ExifTag ClipPath => new ExifTag(ExifTagValue.ClipPath); + public static ExifTag ClipPath => new(ExifTagValue.ClipPath); /// /// Gets the VersionYear exif tag. /// - public static ExifTag VersionYear => new ExifTag(ExifTagValue.VersionYear); + public static ExifTag VersionYear => new(ExifTagValue.VersionYear); /// /// Gets the XMP exif tag. /// - public static ExifTag XMP => new ExifTag(ExifTagValue.XMP); + public static ExifTag XMP => new(ExifTagValue.XMP); /// /// Gets the IPTC exif tag. /// - public static ExifTag IPTC => new ExifTag(ExifTagValue.IPTC); + public static ExifTag IPTC => new(ExifTagValue.IPTC); /// /// Gets the IccProfile exif tag. /// - public static ExifTag IccProfile => new ExifTag(ExifTagValue.IccProfile); + public static ExifTag IccProfile => new(ExifTagValue.IccProfile); /// /// Gets the CFAPattern2 exif tag. /// - public static ExifTag CFAPattern2 => new ExifTag(ExifTagValue.CFAPattern2); + public static ExifTag CFAPattern2 => new(ExifTagValue.CFAPattern2); /// /// Gets the TIFFEPStandardID exif tag. /// - public static ExifTag TIFFEPStandardID => new ExifTag(ExifTagValue.TIFFEPStandardID); + public static ExifTag TIFFEPStandardID => new(ExifTagValue.TIFFEPStandardID); /// /// Gets the GPSVersionID exif tag. /// - public static ExifTag GPSVersionID => new ExifTag(ExifTagValue.GPSVersionID); + public static ExifTag GPSVersionID => new(ExifTagValue.GPSVersionID); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs index 91d0c97b3..fded12261 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.DoubleArray.cs @@ -9,20 +9,20 @@ public abstract partial class ExifTag /// /// Gets the PixelScale exif tag. /// - public static ExifTag PixelScale { get; } = new ExifTag(ExifTagValue.PixelScale); + public static ExifTag PixelScale { get; } = new(ExifTagValue.PixelScale); /// /// Gets the IntergraphMatrix exif tag. /// - public static ExifTag IntergraphMatrix { get; } = new ExifTag(ExifTagValue.IntergraphMatrix); + public static ExifTag IntergraphMatrix { get; } = new(ExifTagValue.IntergraphMatrix); /// /// Gets the ModelTiePoint exif tag. /// - public static ExifTag ModelTiePoint { get; } = new ExifTag(ExifTagValue.ModelTiePoint); + public static ExifTag ModelTiePoint { get; } = new(ExifTagValue.ModelTiePoint); /// /// Gets the ModelTransform exif tag. /// - public static ExifTag ModelTransform { get; } = new ExifTag(ExifTagValue.ModelTransform); + public static ExifTag ModelTransform { get; } = new(ExifTagValue.ModelTransform); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs index 4b53ba636..4cac0d0ca 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.EncodedString.cs @@ -9,15 +9,15 @@ public abstract partial class ExifTag /// /// Gets the UserComment exif tag. /// - public static ExifTag UserComment { get; } = new ExifTag(ExifTagValue.UserComment); + public static ExifTag UserComment { get; } = new(ExifTagValue.UserComment); /// /// Gets the GPSProcessingMethod exif tag. /// - public static ExifTag GPSProcessingMethod { get; } = new ExifTag(ExifTagValue.GPSProcessingMethod); + public static ExifTag GPSProcessingMethod { get; } = new(ExifTagValue.GPSProcessingMethod); /// /// Gets the GPSAreaInformation exif tag. /// - public static ExifTag GPSAreaInformation { get; } = new ExifTag(ExifTagValue.GPSAreaInformation); + public static ExifTag GPSAreaInformation { get; } = new(ExifTagValue.GPSAreaInformation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs index f6c7c8ea7..5f9dfb4cd 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Long.cs @@ -9,105 +9,105 @@ public abstract partial class ExifTag /// /// Gets the SubfileType exif tag. /// - public static ExifTag SubfileType { get; } = new ExifTag(ExifTagValue.SubfileType); + public static ExifTag SubfileType { get; } = new(ExifTagValue.SubfileType); /// /// Gets the SubIFDOffset exif tag. /// - public static ExifTag SubIFDOffset { get; } = new ExifTag(ExifTagValue.SubIFDOffset); + public static ExifTag SubIFDOffset { get; } = new(ExifTagValue.SubIFDOffset); /// /// Gets the GPSIFDOffset exif tag. /// - public static ExifTag GPSIFDOffset { get; } = new ExifTag(ExifTagValue.GPSIFDOffset); + public static ExifTag GPSIFDOffset { get; } = new(ExifTagValue.GPSIFDOffset); /// /// Gets the T4Options exif tag. /// - public static ExifTag T4Options { get; } = new ExifTag(ExifTagValue.T4Options); + public static ExifTag T4Options { get; } = new(ExifTagValue.T4Options); /// /// Gets the T6Options exif tag. /// - public static ExifTag T6Options { get; } = new ExifTag(ExifTagValue.T6Options); + public static ExifTag T6Options { get; } = new(ExifTagValue.T6Options); /// /// Gets the XClipPathUnits exif tag. /// - public static ExifTag XClipPathUnits { get; } = new ExifTag(ExifTagValue.XClipPathUnits); + public static ExifTag XClipPathUnits { get; } = new(ExifTagValue.XClipPathUnits); /// /// Gets the YClipPathUnits exif tag. /// - public static ExifTag YClipPathUnits { get; } = new ExifTag(ExifTagValue.YClipPathUnits); + public static ExifTag YClipPathUnits { get; } = new(ExifTagValue.YClipPathUnits); /// /// Gets the ProfileType exif tag. /// - public static ExifTag ProfileType { get; } = new ExifTag(ExifTagValue.ProfileType); + public static ExifTag ProfileType { get; } = new(ExifTagValue.ProfileType); /// /// Gets the CodingMethods exif tag. /// - public static ExifTag CodingMethods { get; } = new ExifTag(ExifTagValue.CodingMethods); + public static ExifTag CodingMethods { get; } = new(ExifTagValue.CodingMethods); /// /// Gets the T82ptions exif tag. /// - public static ExifTag T82ptions { get; } = new ExifTag(ExifTagValue.T82ptions); + public static ExifTag T82ptions { get; } = new(ExifTagValue.T82ptions); /// /// Gets the JPEGInterchangeFormat exif tag. /// - public static ExifTag JPEGInterchangeFormat { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormat); + public static ExifTag JPEGInterchangeFormat { get; } = new(ExifTagValue.JPEGInterchangeFormat); /// /// Gets the JPEGInterchangeFormatLength exif tag. /// - public static ExifTag JPEGInterchangeFormatLength { get; } = new ExifTag(ExifTagValue.JPEGInterchangeFormatLength); + public static ExifTag JPEGInterchangeFormatLength { get; } = new(ExifTagValue.JPEGInterchangeFormatLength); /// /// Gets the MDFileTag exif tag. /// - public static ExifTag MDFileTag { get; } = new ExifTag(ExifTagValue.MDFileTag); + public static ExifTag MDFileTag { get; } = new(ExifTagValue.MDFileTag); /// /// Gets the StandardOutputSensitivity exif tag. /// - public static ExifTag StandardOutputSensitivity { get; } = new ExifTag(ExifTagValue.StandardOutputSensitivity); + public static ExifTag StandardOutputSensitivity { get; } = new(ExifTagValue.StandardOutputSensitivity); /// /// Gets the RecommendedExposureIndex exif tag. /// - public static ExifTag RecommendedExposureIndex { get; } = new ExifTag(ExifTagValue.RecommendedExposureIndex); + public static ExifTag RecommendedExposureIndex { get; } = new(ExifTagValue.RecommendedExposureIndex); /// /// Gets the ISOSpeed exif tag. /// - public static ExifTag ISOSpeed { get; } = new ExifTag(ExifTagValue.ISOSpeed); + public static ExifTag ISOSpeed { get; } = new(ExifTagValue.ISOSpeed); /// /// Gets the ISOSpeedLatitudeyyy exif tag. /// - public static ExifTag ISOSpeedLatitudeyyy { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudeyyy); + public static ExifTag ISOSpeedLatitudeyyy { get; } = new(ExifTagValue.ISOSpeedLatitudeyyy); /// /// Gets the ISOSpeedLatitudezzz exif tag. /// - public static ExifTag ISOSpeedLatitudezzz { get; } = new ExifTag(ExifTagValue.ISOSpeedLatitudezzz); + public static ExifTag ISOSpeedLatitudezzz { get; } = new(ExifTagValue.ISOSpeedLatitudezzz); /// /// Gets the FaxRecvParams exif tag. /// - public static ExifTag FaxRecvParams { get; } = new ExifTag(ExifTagValue.FaxRecvParams); + public static ExifTag FaxRecvParams { get; } = new(ExifTagValue.FaxRecvParams); /// /// Gets the FaxRecvTime exif tag. /// - public static ExifTag FaxRecvTime { get; } = new ExifTag(ExifTagValue.FaxRecvTime); + public static ExifTag FaxRecvTime { get; } = new(ExifTagValue.FaxRecvTime); /// /// Gets the ImageNumber exif tag. /// - public static ExifTag ImageNumber { get; } = new ExifTag(ExifTagValue.ImageNumber); + public static ExifTag ImageNumber { get; } = new(ExifTagValue.ImageNumber); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs index 4767ca852..e6821651a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.LongArray.cs @@ -9,55 +9,55 @@ public abstract partial class ExifTag /// /// Gets the FreeOffsets exif tag. /// - public static ExifTag FreeOffsets { get; } = new ExifTag(ExifTagValue.FreeOffsets); + public static ExifTag FreeOffsets { get; } = new(ExifTagValue.FreeOffsets); /// /// Gets the FreeByteCounts exif tag. /// - public static ExifTag FreeByteCounts { get; } = new ExifTag(ExifTagValue.FreeByteCounts); + public static ExifTag FreeByteCounts { get; } = new(ExifTagValue.FreeByteCounts); /// /// Gets the ColorResponseUnit exif tag. /// - public static ExifTag ColorResponseUnit { get; } = new ExifTag(ExifTagValue.ColorResponseUnit); + public static ExifTag ColorResponseUnit { get; } = new(ExifTagValue.ColorResponseUnit); /// /// Gets the SMinSampleValue exif tag. /// - public static ExifTag SMinSampleValue { get; } = new ExifTag(ExifTagValue.SMinSampleValue); + public static ExifTag SMinSampleValue { get; } = new(ExifTagValue.SMinSampleValue); /// /// Gets the SMaxSampleValue exif tag. /// - public static ExifTag SMaxSampleValue { get; } = new ExifTag(ExifTagValue.SMaxSampleValue); + public static ExifTag SMaxSampleValue { get; } = new(ExifTagValue.SMaxSampleValue); /// /// Gets the JPEGQTables exif tag. /// - public static ExifTag JPEGQTables { get; } = new ExifTag(ExifTagValue.JPEGQTables); + public static ExifTag JPEGQTables { get; } = new(ExifTagValue.JPEGQTables); /// /// Gets the JPEGDCTables exif tag. /// - public static ExifTag JPEGDCTables { get; } = new ExifTag(ExifTagValue.JPEGDCTables); + public static ExifTag JPEGDCTables { get; } = new(ExifTagValue.JPEGDCTables); /// /// Gets the JPEGACTables exif tag. /// - public static ExifTag JPEGACTables { get; } = new ExifTag(ExifTagValue.JPEGACTables); + public static ExifTag JPEGACTables { get; } = new(ExifTagValue.JPEGACTables); /// /// Gets the StripRowCounts exif tag. /// - public static ExifTag StripRowCounts { get; } = new ExifTag(ExifTagValue.StripRowCounts); + public static ExifTag StripRowCounts { get; } = new(ExifTagValue.StripRowCounts); /// /// Gets the IntergraphRegisters exif tag. /// - public static ExifTag IntergraphRegisters { get; } = new ExifTag(ExifTagValue.IntergraphRegisters); + public static ExifTag IntergraphRegisters { get; } = new(ExifTagValue.IntergraphRegisters); /// /// Gets the offset to child IFDs exif tag. /// - public static ExifTag SubIFDs { get; } = new ExifTag(ExifTagValue.SubIFDs); + public static ExifTag SubIFDs { get; } = new(ExifTagValue.SubIFDs); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs index 2018e4cea..e023beeb7 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Number.cs @@ -9,45 +9,45 @@ public abstract partial class ExifTag /// /// Gets the ImageWidth exif tag. /// - public static ExifTag ImageWidth { get; } = new ExifTag(ExifTagValue.ImageWidth); + public static ExifTag ImageWidth { get; } = new(ExifTagValue.ImageWidth); /// /// Gets the ImageLength exif tag. /// - public static ExifTag ImageLength { get; } = new ExifTag(ExifTagValue.ImageLength); + public static ExifTag ImageLength { get; } = new(ExifTagValue.ImageLength); /// /// Gets the RowsPerStrip exif tag. /// - public static ExifTag RowsPerStrip { get; } = new ExifTag(ExifTagValue.RowsPerStrip); + public static ExifTag RowsPerStrip { get; } = new(ExifTagValue.RowsPerStrip); /// /// Gets the TileWidth exif tag. /// - public static ExifTag TileWidth { get; } = new ExifTag(ExifTagValue.TileWidth); + public static ExifTag TileWidth { get; } = new(ExifTagValue.TileWidth); /// /// Gets the TileLength exif tag. /// - public static ExifTag TileLength { get; } = new ExifTag(ExifTagValue.TileLength); + public static ExifTag TileLength { get; } = new(ExifTagValue.TileLength); /// /// Gets the BadFaxLines exif tag. /// - public static ExifTag BadFaxLines { get; } = new ExifTag(ExifTagValue.BadFaxLines); + public static ExifTag BadFaxLines { get; } = new(ExifTagValue.BadFaxLines); /// /// Gets the ConsecutiveBadFaxLines exif tag. /// - public static ExifTag ConsecutiveBadFaxLines { get; } = new ExifTag(ExifTagValue.ConsecutiveBadFaxLines); + public static ExifTag ConsecutiveBadFaxLines { get; } = new(ExifTagValue.ConsecutiveBadFaxLines); /// /// Gets the PixelXDimension exif tag. /// - public static ExifTag PixelXDimension { get; } = new ExifTag(ExifTagValue.PixelXDimension); + public static ExifTag PixelXDimension { get; } = new(ExifTagValue.PixelXDimension); /// /// Gets the PixelYDimension exif tag. /// - public static ExifTag PixelYDimension { get; } = new ExifTag(ExifTagValue.PixelYDimension); + public static ExifTag PixelYDimension { get; } = new(ExifTagValue.PixelYDimension); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs index cd8968141..6a7438fc6 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.NumberArray.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the StripOffsets exif tag. /// - public static ExifTag StripOffsets { get; } = new ExifTag(ExifTagValue.StripOffsets); + public static ExifTag StripOffsets { get; } = new(ExifTagValue.StripOffsets); /// /// Gets the StripByteCounts exif tag. /// - public static ExifTag StripByteCounts { get; } = new ExifTag(ExifTagValue.StripByteCounts); + public static ExifTag StripByteCounts { get; } = new(ExifTagValue.StripByteCounts); /// /// Gets the TileByteCounts exif tag. /// - public static ExifTag TileByteCounts { get; } = new ExifTag(ExifTagValue.TileByteCounts); + public static ExifTag TileByteCounts { get; } = new(ExifTagValue.TileByteCounts); /// /// Gets the TileOffsets exif tag. /// - public static ExifTag TileOffsets { get; } = new ExifTag(ExifTagValue.TileOffsets); + public static ExifTag TileOffsets { get; } = new(ExifTagValue.TileOffsets); /// /// Gets the ImageLayer exif tag. /// - public static ExifTag ImageLayer { get; } = new ExifTag(ExifTagValue.ImageLayer); + public static ExifTag ImageLayer { get; } = new(ExifTagValue.ImageLayer); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs index e4fe13fe5..02526ac34 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Rational.cs @@ -9,165 +9,165 @@ public abstract partial class ExifTag /// /// Gets the XPosition exif tag. /// - public static ExifTag XPosition { get; } = new ExifTag(ExifTagValue.XPosition); + public static ExifTag XPosition { get; } = new(ExifTagValue.XPosition); /// /// Gets the YPosition exif tag. /// - public static ExifTag YPosition { get; } = new ExifTag(ExifTagValue.YPosition); + public static ExifTag YPosition { get; } = new(ExifTagValue.YPosition); /// /// Gets the XResolution exif tag. /// - public static ExifTag XResolution { get; } = new ExifTag(ExifTagValue.XResolution); + public static ExifTag XResolution { get; } = new(ExifTagValue.XResolution); /// /// Gets the YResolution exif tag. /// - public static ExifTag YResolution { get; } = new ExifTag(ExifTagValue.YResolution); + public static ExifTag YResolution { get; } = new(ExifTagValue.YResolution); /// /// Gets the BatteryLevel exif tag. /// - public static ExifTag BatteryLevel { get; } = new ExifTag(ExifTagValue.BatteryLevel); + public static ExifTag BatteryLevel { get; } = new(ExifTagValue.BatteryLevel); /// /// Gets the ExposureTime exif tag. /// - public static ExifTag ExposureTime { get; } = new ExifTag(ExifTagValue.ExposureTime); + public static ExifTag ExposureTime { get; } = new(ExifTagValue.ExposureTime); /// /// Gets the FNumber exif tag. /// - public static ExifTag FNumber { get; } = new ExifTag(ExifTagValue.FNumber); + public static ExifTag FNumber { get; } = new(ExifTagValue.FNumber); /// /// Gets the MDScalePixel exif tag. /// - public static ExifTag MDScalePixel { get; } = new ExifTag(ExifTagValue.MDScalePixel); + public static ExifTag MDScalePixel { get; } = new(ExifTagValue.MDScalePixel); /// /// Gets the CompressedBitsPerPixel exif tag. /// - public static ExifTag CompressedBitsPerPixel { get; } = new ExifTag(ExifTagValue.CompressedBitsPerPixel); + public static ExifTag CompressedBitsPerPixel { get; } = new(ExifTagValue.CompressedBitsPerPixel); /// /// Gets the ApertureValue exif tag. /// - public static ExifTag ApertureValue { get; } = new ExifTag(ExifTagValue.ApertureValue); + public static ExifTag ApertureValue { get; } = new(ExifTagValue.ApertureValue); /// /// Gets the MaxApertureValue exif tag. /// - public static ExifTag MaxApertureValue { get; } = new ExifTag(ExifTagValue.MaxApertureValue); + public static ExifTag MaxApertureValue { get; } = new(ExifTagValue.MaxApertureValue); /// /// Gets the SubjectDistance exif tag. /// - public static ExifTag SubjectDistance { get; } = new ExifTag(ExifTagValue.SubjectDistance); + public static ExifTag SubjectDistance { get; } = new(ExifTagValue.SubjectDistance); /// /// Gets the FocalLength exif tag. /// - public static ExifTag FocalLength { get; } = new ExifTag(ExifTagValue.FocalLength); + public static ExifTag FocalLength { get; } = new(ExifTagValue.FocalLength); /// /// Gets the FlashEnergy2 exif tag. /// - public static ExifTag FlashEnergy2 { get; } = new ExifTag(ExifTagValue.FlashEnergy2); + public static ExifTag FlashEnergy2 { get; } = new(ExifTagValue.FlashEnergy2); /// /// Gets the FocalPlaneXResolution2 exif tag. /// - public static ExifTag FocalPlaneXResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution2); + public static ExifTag FocalPlaneXResolution2 { get; } = new(ExifTagValue.FocalPlaneXResolution2); /// /// Gets the FocalPlaneYResolution2 exif tag. /// - public static ExifTag FocalPlaneYResolution2 { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution2); + public static ExifTag FocalPlaneYResolution2 { get; } = new(ExifTagValue.FocalPlaneYResolution2); /// /// Gets the ExposureIndex2 exif tag. /// - public static ExifTag ExposureIndex2 { get; } = new ExifTag(ExifTagValue.ExposureIndex2); + public static ExifTag ExposureIndex2 { get; } = new(ExifTagValue.ExposureIndex2); /// /// Gets the Humidity exif tag. /// - public static ExifTag Humidity { get; } = new ExifTag(ExifTagValue.Humidity); + public static ExifTag Humidity { get; } = new(ExifTagValue.Humidity); /// /// Gets the Pressure exif tag. /// - public static ExifTag Pressure { get; } = new ExifTag(ExifTagValue.Pressure); + public static ExifTag Pressure { get; } = new(ExifTagValue.Pressure); /// /// Gets the Acceleration exif tag. /// - public static ExifTag Acceleration { get; } = new ExifTag(ExifTagValue.Acceleration); + public static ExifTag Acceleration { get; } = new(ExifTagValue.Acceleration); /// /// Gets the FlashEnergy exif tag. /// - public static ExifTag FlashEnergy { get; } = new ExifTag(ExifTagValue.FlashEnergy); + public static ExifTag FlashEnergy { get; } = new(ExifTagValue.FlashEnergy); /// /// Gets the FocalPlaneXResolution exif tag. /// - public static ExifTag FocalPlaneXResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneXResolution); + public static ExifTag FocalPlaneXResolution { get; } = new(ExifTagValue.FocalPlaneXResolution); /// /// Gets the FocalPlaneYResolution exif tag. /// - public static ExifTag FocalPlaneYResolution { get; } = new ExifTag(ExifTagValue.FocalPlaneYResolution); + public static ExifTag FocalPlaneYResolution { get; } = new(ExifTagValue.FocalPlaneYResolution); /// /// Gets the ExposureIndex exif tag. /// - public static ExifTag ExposureIndex { get; } = new ExifTag(ExifTagValue.ExposureIndex); + public static ExifTag ExposureIndex { get; } = new(ExifTagValue.ExposureIndex); /// /// Gets the DigitalZoomRatio exif tag. /// - public static ExifTag DigitalZoomRatio { get; } = new ExifTag(ExifTagValue.DigitalZoomRatio); + public static ExifTag DigitalZoomRatio { get; } = new(ExifTagValue.DigitalZoomRatio); /// /// Gets the GPSAltitude exif tag. /// - public static ExifTag GPSAltitude { get; } = new ExifTag(ExifTagValue.GPSAltitude); + public static ExifTag GPSAltitude { get; } = new(ExifTagValue.GPSAltitude); /// /// Gets the GPSDOP exif tag. /// - public static ExifTag GPSDOP { get; } = new ExifTag(ExifTagValue.GPSDOP); + public static ExifTag GPSDOP { get; } = new(ExifTagValue.GPSDOP); /// /// Gets the GPSSpeed exif tag. /// - public static ExifTag GPSSpeed { get; } = new ExifTag(ExifTagValue.GPSSpeed); + public static ExifTag GPSSpeed { get; } = new(ExifTagValue.GPSSpeed); /// /// Gets the GPSTrack exif tag. /// - public static ExifTag GPSTrack { get; } = new ExifTag(ExifTagValue.GPSTrack); + public static ExifTag GPSTrack { get; } = new(ExifTagValue.GPSTrack); /// /// Gets the GPSImgDirection exif tag. /// - public static ExifTag GPSImgDirection { get; } = new ExifTag(ExifTagValue.GPSImgDirection); + public static ExifTag GPSImgDirection { get; } = new(ExifTagValue.GPSImgDirection); /// /// Gets the GPSDestBearing exif tag. /// - public static ExifTag GPSDestBearing { get; } = new ExifTag(ExifTagValue.GPSDestBearing); + public static ExifTag GPSDestBearing { get; } = new(ExifTagValue.GPSDestBearing); /// /// Gets the GPSDestDistance exif tag. /// - public static ExifTag GPSDestDistance { get; } = new ExifTag(ExifTagValue.GPSDestDistance); + public static ExifTag GPSDestDistance { get; } = new(ExifTagValue.GPSDestDistance); /// /// Gets the GPSHPositioningError exif tag. /// - public static ExifTag GPSHPositioningError { get; } = new ExifTag(ExifTagValue.GPSHPositioningError); + public static ExifTag GPSHPositioningError { get; } = new(ExifTagValue.GPSHPositioningError); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs index 8b764c3f7..4ba140441 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.RationalArray.cs @@ -9,50 +9,50 @@ public abstract partial class ExifTag /// /// Gets the WhitePoint exif tag. /// - public static ExifTag WhitePoint { get; } = new ExifTag(ExifTagValue.WhitePoint); + public static ExifTag WhitePoint { get; } = new(ExifTagValue.WhitePoint); /// /// Gets the PrimaryChromaticities exif tag. /// - public static ExifTag PrimaryChromaticities { get; } = new ExifTag(ExifTagValue.PrimaryChromaticities); + public static ExifTag PrimaryChromaticities { get; } = new(ExifTagValue.PrimaryChromaticities); /// /// Gets the YCbCrCoefficients exif tag. /// - public static ExifTag YCbCrCoefficients { get; } = new ExifTag(ExifTagValue.YCbCrCoefficients); + public static ExifTag YCbCrCoefficients { get; } = new(ExifTagValue.YCbCrCoefficients); /// /// Gets the ReferenceBlackWhite exif tag. /// - public static ExifTag ReferenceBlackWhite { get; } = new ExifTag(ExifTagValue.ReferenceBlackWhite); + public static ExifTag ReferenceBlackWhite { get; } = new(ExifTagValue.ReferenceBlackWhite); /// /// Gets the GPSLatitude exif tag. /// - public static ExifTag GPSLatitude { get; } = new ExifTag(ExifTagValue.GPSLatitude); + public static ExifTag GPSLatitude { get; } = new(ExifTagValue.GPSLatitude); /// /// Gets the GPSLongitude exif tag. /// - public static ExifTag GPSLongitude { get; } = new ExifTag(ExifTagValue.GPSLongitude); + public static ExifTag GPSLongitude { get; } = new(ExifTagValue.GPSLongitude); /// /// Gets the GPSTimestamp exif tag. /// - public static ExifTag GPSTimestamp { get; } = new ExifTag(ExifTagValue.GPSTimestamp); + public static ExifTag GPSTimestamp { get; } = new(ExifTagValue.GPSTimestamp); /// /// Gets the GPSDestLatitude exif tag. /// - public static ExifTag GPSDestLatitude { get; } = new ExifTag(ExifTagValue.GPSDestLatitude); + public static ExifTag GPSDestLatitude { get; } = new(ExifTagValue.GPSDestLatitude); /// /// Gets the GPSDestLongitude exif tag. /// - public static ExifTag GPSDestLongitude { get; } = new ExifTag(ExifTagValue.GPSDestLongitude); + public static ExifTag GPSDestLongitude { get; } = new(ExifTagValue.GPSDestLongitude); /// /// Gets the LensSpecification exif tag. /// - public static ExifTag LensSpecification { get; } = new ExifTag(ExifTagValue.LensSpecification); + public static ExifTag LensSpecification { get; } = new(ExifTagValue.LensSpecification); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs index aeeda58bb..52972811e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Short.cs @@ -9,235 +9,235 @@ public abstract partial class ExifTag /// /// Gets the OldSubfileType exif tag. /// - public static ExifTag OldSubfileType { get; } = new ExifTag(ExifTagValue.OldSubfileType); + public static ExifTag OldSubfileType { get; } = new(ExifTagValue.OldSubfileType); /// /// Gets the Compression exif tag. /// - public static ExifTag Compression { get; } = new ExifTag(ExifTagValue.Compression); + public static ExifTag Compression { get; } = new(ExifTagValue.Compression); /// /// Gets the PhotometricInterpretation exif tag. /// - public static ExifTag PhotometricInterpretation { get; } = new ExifTag(ExifTagValue.PhotometricInterpretation); + public static ExifTag PhotometricInterpretation { get; } = new(ExifTagValue.PhotometricInterpretation); /// /// Gets the Thresholding exif tag. /// - public static ExifTag Thresholding { get; } = new ExifTag(ExifTagValue.Thresholding); + public static ExifTag Thresholding { get; } = new(ExifTagValue.Thresholding); /// /// Gets the CellWidth exif tag. /// - public static ExifTag CellWidth { get; } = new ExifTag(ExifTagValue.CellWidth); + public static ExifTag CellWidth { get; } = new(ExifTagValue.CellWidth); /// /// Gets the CellLength exif tag. /// - public static ExifTag CellLength { get; } = new ExifTag(ExifTagValue.CellLength); + public static ExifTag CellLength { get; } = new(ExifTagValue.CellLength); /// /// Gets the FillOrder exif tag. /// - public static ExifTag FillOrder { get; } = new ExifTag(ExifTagValue.FillOrder); + public static ExifTag FillOrder { get; } = new(ExifTagValue.FillOrder); /// /// Gets the Orientation exif tag. /// - public static ExifTag Orientation { get; } = new ExifTag(ExifTagValue.Orientation); + public static ExifTag Orientation { get; } = new(ExifTagValue.Orientation); /// /// Gets the SamplesPerPixel exif tag. /// - public static ExifTag SamplesPerPixel { get; } = new ExifTag(ExifTagValue.SamplesPerPixel); + public static ExifTag SamplesPerPixel { get; } = new(ExifTagValue.SamplesPerPixel); /// /// Gets the PlanarConfiguration exif tag. /// - public static ExifTag PlanarConfiguration { get; } = new ExifTag(ExifTagValue.PlanarConfiguration); + public static ExifTag PlanarConfiguration { get; } = new(ExifTagValue.PlanarConfiguration); /// /// Gets the Predictor exif tag. /// - public static ExifTag Predictor { get; } = new ExifTag(ExifTagValue.Predictor); + public static ExifTag Predictor { get; } = new(ExifTagValue.Predictor); /// /// Gets the GrayResponseUnit exif tag. /// - public static ExifTag GrayResponseUnit { get; } = new ExifTag(ExifTagValue.GrayResponseUnit); + public static ExifTag GrayResponseUnit { get; } = new(ExifTagValue.GrayResponseUnit); /// /// Gets the ResolutionUnit exif tag. /// - public static ExifTag ResolutionUnit { get; } = new ExifTag(ExifTagValue.ResolutionUnit); + public static ExifTag ResolutionUnit { get; } = new(ExifTagValue.ResolutionUnit); /// /// Gets the CleanFaxData exif tag. /// - public static ExifTag CleanFaxData { get; } = new ExifTag(ExifTagValue.CleanFaxData); + public static ExifTag CleanFaxData { get; } = new(ExifTagValue.CleanFaxData); /// /// Gets the InkSet exif tag. /// - public static ExifTag InkSet { get; } = new ExifTag(ExifTagValue.InkSet); + public static ExifTag InkSet { get; } = new(ExifTagValue.InkSet); /// /// Gets the NumberOfInks exif tag. /// - public static ExifTag NumberOfInks { get; } = new ExifTag(ExifTagValue.NumberOfInks); + public static ExifTag NumberOfInks { get; } = new(ExifTagValue.NumberOfInks); /// /// Gets the DotRange exif tag. /// - public static ExifTag DotRange { get; } = new ExifTag(ExifTagValue.DotRange); + public static ExifTag DotRange { get; } = new(ExifTagValue.DotRange); /// /// Gets the Indexed exif tag. /// - public static ExifTag Indexed { get; } = new ExifTag(ExifTagValue.Indexed); + public static ExifTag Indexed { get; } = new(ExifTagValue.Indexed); /// /// Gets the OPIProxy exif tag. /// - public static ExifTag OPIProxy { get; } = new ExifTag(ExifTagValue.OPIProxy); + public static ExifTag OPIProxy { get; } = new(ExifTagValue.OPIProxy); /// /// Gets the JPEGProc exif tag. /// - public static ExifTag JPEGProc { get; } = new ExifTag(ExifTagValue.JPEGProc); + public static ExifTag JPEGProc { get; } = new(ExifTagValue.JPEGProc); /// /// Gets the JPEGRestartInterval exif tag. /// - public static ExifTag JPEGRestartInterval { get; } = new ExifTag(ExifTagValue.JPEGRestartInterval); + public static ExifTag JPEGRestartInterval { get; } = new(ExifTagValue.JPEGRestartInterval); /// /// Gets the YCbCrPositioning exif tag. /// - public static ExifTag YCbCrPositioning { get; } = new ExifTag(ExifTagValue.YCbCrPositioning); + public static ExifTag YCbCrPositioning { get; } = new(ExifTagValue.YCbCrPositioning); /// /// Gets the Rating exif tag. /// - public static ExifTag Rating { get; } = new ExifTag(ExifTagValue.Rating); + public static ExifTag Rating { get; } = new(ExifTagValue.Rating); /// /// Gets the RatingPercent exif tag. /// - public static ExifTag RatingPercent { get; } = new ExifTag(ExifTagValue.RatingPercent); + public static ExifTag RatingPercent { get; } = new(ExifTagValue.RatingPercent); /// /// Gets the ExposureProgram exif tag. /// - public static ExifTag ExposureProgram { get; } = new ExifTag(ExifTagValue.ExposureProgram); + public static ExifTag ExposureProgram { get; } = new(ExifTagValue.ExposureProgram); /// /// Gets the Interlace exif tag. /// - public static ExifTag Interlace { get; } = new ExifTag(ExifTagValue.Interlace); + public static ExifTag Interlace { get; } = new(ExifTagValue.Interlace); /// /// Gets the SelfTimerMode exif tag. /// - public static ExifTag SelfTimerMode { get; } = new ExifTag(ExifTagValue.SelfTimerMode); + public static ExifTag SelfTimerMode { get; } = new(ExifTagValue.SelfTimerMode); /// /// Gets the SensitivityType exif tag. /// - public static ExifTag SensitivityType { get; } = new ExifTag(ExifTagValue.SensitivityType); + public static ExifTag SensitivityType { get; } = new(ExifTagValue.SensitivityType); /// /// Gets the MeteringMode exif tag. /// - public static ExifTag MeteringMode { get; } = new ExifTag(ExifTagValue.MeteringMode); + public static ExifTag MeteringMode { get; } = new(ExifTagValue.MeteringMode); /// /// Gets the LightSource exif tag. /// - public static ExifTag LightSource { get; } = new ExifTag(ExifTagValue.LightSource); + public static ExifTag LightSource { get; } = new(ExifTagValue.LightSource); /// /// Gets the FocalPlaneResolutionUnit2 exif tag. /// - public static ExifTag FocalPlaneResolutionUnit2 { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit2); + public static ExifTag FocalPlaneResolutionUnit2 { get; } = new(ExifTagValue.FocalPlaneResolutionUnit2); /// /// Gets the SensingMethod2 exif tag. /// - public static ExifTag SensingMethod2 { get; } = new ExifTag(ExifTagValue.SensingMethod2); + public static ExifTag SensingMethod2 { get; } = new(ExifTagValue.SensingMethod2); /// /// Gets the Flash exif tag. /// - public static ExifTag Flash { get; } = new ExifTag(ExifTagValue.Flash); + public static ExifTag Flash { get; } = new(ExifTagValue.Flash); /// /// Gets the ColorSpace exif tag. /// - public static ExifTag ColorSpace { get; } = new ExifTag(ExifTagValue.ColorSpace); + public static ExifTag ColorSpace { get; } = new(ExifTagValue.ColorSpace); /// /// Gets the FocalPlaneResolutionUnit exif tag. /// - public static ExifTag FocalPlaneResolutionUnit { get; } = new ExifTag(ExifTagValue.FocalPlaneResolutionUnit); + public static ExifTag FocalPlaneResolutionUnit { get; } = new(ExifTagValue.FocalPlaneResolutionUnit); /// /// Gets the SensingMethod exif tag. /// - public static ExifTag SensingMethod { get; } = new ExifTag(ExifTagValue.SensingMethod); + public static ExifTag SensingMethod { get; } = new(ExifTagValue.SensingMethod); /// /// Gets the CustomRendered exif tag. /// - public static ExifTag CustomRendered { get; } = new ExifTag(ExifTagValue.CustomRendered); + public static ExifTag CustomRendered { get; } = new(ExifTagValue.CustomRendered); /// /// Gets the ExposureMode exif tag. /// - public static ExifTag ExposureMode { get; } = new ExifTag(ExifTagValue.ExposureMode); + public static ExifTag ExposureMode { get; } = new(ExifTagValue.ExposureMode); /// /// Gets the WhiteBalance exif tag. /// - public static ExifTag WhiteBalance { get; } = new ExifTag(ExifTagValue.WhiteBalance); + public static ExifTag WhiteBalance { get; } = new(ExifTagValue.WhiteBalance); /// /// Gets the FocalLengthIn35mmFilm exif tag. /// - public static ExifTag FocalLengthIn35mmFilm { get; } = new ExifTag(ExifTagValue.FocalLengthIn35mmFilm); + public static ExifTag FocalLengthIn35mmFilm { get; } = new(ExifTagValue.FocalLengthIn35mmFilm); /// /// Gets the SceneCaptureType exif tag. /// - public static ExifTag SceneCaptureType { get; } = new ExifTag(ExifTagValue.SceneCaptureType); + public static ExifTag SceneCaptureType { get; } = new(ExifTagValue.SceneCaptureType); /// /// Gets the GainControl exif tag. /// - public static ExifTag GainControl { get; } = new ExifTag(ExifTagValue.GainControl); + public static ExifTag GainControl { get; } = new(ExifTagValue.GainControl); /// /// Gets the Contrast exif tag. /// - public static ExifTag Contrast { get; } = new ExifTag(ExifTagValue.Contrast); + public static ExifTag Contrast { get; } = new(ExifTagValue.Contrast); /// /// Gets the Saturation exif tag. /// - public static ExifTag Saturation { get; } = new ExifTag(ExifTagValue.Saturation); + public static ExifTag Saturation { get; } = new(ExifTagValue.Saturation); /// /// Gets the Sharpness exif tag. /// - public static ExifTag Sharpness { get; } = new ExifTag(ExifTagValue.Sharpness); + public static ExifTag Sharpness { get; } = new(ExifTagValue.Sharpness); /// /// Gets the SubjectDistanceRange exif tag. /// - public static ExifTag SubjectDistanceRange { get; } = new ExifTag(ExifTagValue.SubjectDistanceRange); + public static ExifTag SubjectDistanceRange { get; } = new(ExifTagValue.SubjectDistanceRange); /// /// Gets the GPSDifferential exif tag. /// - public static ExifTag GPSDifferential { get; } = new ExifTag(ExifTagValue.GPSDifferential); + public static ExifTag GPSDifferential { get; } = new(ExifTagValue.GPSDifferential); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs index dc708c50f..55e65517f 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.ShortArray.cs @@ -9,100 +9,100 @@ public abstract partial class ExifTag /// /// Gets the BitsPerSample exif tag. /// - public static ExifTag BitsPerSample { get; } = new ExifTag(ExifTagValue.BitsPerSample); + public static ExifTag BitsPerSample { get; } = new(ExifTagValue.BitsPerSample); /// /// Gets the MinSampleValue exif tag. /// - public static ExifTag MinSampleValue { get; } = new ExifTag(ExifTagValue.MinSampleValue); + public static ExifTag MinSampleValue { get; } = new(ExifTagValue.MinSampleValue); /// /// Gets the MaxSampleValue exif tag. /// - public static ExifTag MaxSampleValue { get; } = new ExifTag(ExifTagValue.MaxSampleValue); + public static ExifTag MaxSampleValue { get; } = new(ExifTagValue.MaxSampleValue); /// /// Gets the GrayResponseCurve exif tag. /// - public static ExifTag GrayResponseCurve { get; } = new ExifTag(ExifTagValue.GrayResponseCurve); + public static ExifTag GrayResponseCurve { get; } = new(ExifTagValue.GrayResponseCurve); /// /// Gets the ColorMap exif tag. /// - public static ExifTag ColorMap { get; } = new ExifTag(ExifTagValue.ColorMap); + public static ExifTag ColorMap { get; } = new(ExifTagValue.ColorMap); /// /// Gets the ExtraSamples exif tag. /// - public static ExifTag ExtraSamples { get; } = new ExifTag(ExifTagValue.ExtraSamples); + public static ExifTag ExtraSamples { get; } = new(ExifTagValue.ExtraSamples); /// /// Gets the PageNumber exif tag. /// - public static ExifTag PageNumber { get; } = new ExifTag(ExifTagValue.PageNumber); + public static ExifTag PageNumber { get; } = new(ExifTagValue.PageNumber); /// /// Gets the TransferFunction exif tag. /// - public static ExifTag TransferFunction { get; } = new ExifTag(ExifTagValue.TransferFunction); + public static ExifTag TransferFunction { get; } = new(ExifTagValue.TransferFunction); /// /// Gets the HalftoneHints exif tag. /// - public static ExifTag HalftoneHints { get; } = new ExifTag(ExifTagValue.HalftoneHints); + public static ExifTag HalftoneHints { get; } = new(ExifTagValue.HalftoneHints); /// /// Gets the SampleFormat exif tag. /// - public static ExifTag SampleFormat { get; } = new ExifTag(ExifTagValue.SampleFormat); + public static ExifTag SampleFormat { get; } = new(ExifTagValue.SampleFormat); /// /// Gets the TransferRange exif tag. /// - public static ExifTag TransferRange { get; } = new ExifTag(ExifTagValue.TransferRange); + public static ExifTag TransferRange { get; } = new(ExifTagValue.TransferRange); /// /// Gets the DefaultImageColor exif tag. /// - public static ExifTag DefaultImageColor { get; } = new ExifTag(ExifTagValue.DefaultImageColor); + public static ExifTag DefaultImageColor { get; } = new(ExifTagValue.DefaultImageColor); /// /// Gets the JPEGLosslessPredictors exif tag. /// - public static ExifTag JPEGLosslessPredictors { get; } = new ExifTag(ExifTagValue.JPEGLosslessPredictors); + public static ExifTag JPEGLosslessPredictors { get; } = new(ExifTagValue.JPEGLosslessPredictors); /// /// Gets the JPEGPointTransforms exif tag. /// - public static ExifTag JPEGPointTransforms { get; } = new ExifTag(ExifTagValue.JPEGPointTransforms); + public static ExifTag JPEGPointTransforms { get; } = new(ExifTagValue.JPEGPointTransforms); /// /// Gets the YCbCrSubsampling exif tag. /// - public static ExifTag YCbCrSubsampling { get; } = new ExifTag(ExifTagValue.YCbCrSubsampling); + public static ExifTag YCbCrSubsampling { get; } = new(ExifTagValue.YCbCrSubsampling); /// /// Gets the CFARepeatPatternDim exif tag. /// - public static ExifTag CFARepeatPatternDim { get; } = new ExifTag(ExifTagValue.CFARepeatPatternDim); + public static ExifTag CFARepeatPatternDim { get; } = new(ExifTagValue.CFARepeatPatternDim); /// /// Gets the IntergraphPacketData exif tag. /// - public static ExifTag IntergraphPacketData { get; } = new ExifTag(ExifTagValue.IntergraphPacketData); + public static ExifTag IntergraphPacketData { get; } = new(ExifTagValue.IntergraphPacketData); /// /// Gets the ISOSpeedRatings exif tag. /// - public static ExifTag ISOSpeedRatings { get; } = new ExifTag(ExifTagValue.ISOSpeedRatings); + public static ExifTag ISOSpeedRatings { get; } = new(ExifTagValue.ISOSpeedRatings); /// /// Gets the SubjectArea exif tag. /// - public static ExifTag SubjectArea { get; } = new ExifTag(ExifTagValue.SubjectArea); + public static ExifTag SubjectArea { get; } = new(ExifTagValue.SubjectArea); /// /// Gets the SubjectLocation exif tag. /// - public static ExifTag SubjectLocation { get; } = new ExifTag(ExifTagValue.SubjectLocation); + public static ExifTag SubjectLocation { get; } = new(ExifTagValue.SubjectLocation); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs index d645b5176..8fbbba217 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRational.cs @@ -9,30 +9,30 @@ public abstract partial class ExifTag /// /// Gets the ShutterSpeedValue exif tag. /// - public static ExifTag ShutterSpeedValue { get; } = new ExifTag(ExifTagValue.ShutterSpeedValue); + public static ExifTag ShutterSpeedValue { get; } = new(ExifTagValue.ShutterSpeedValue); /// /// Gets the BrightnessValue exif tag. /// - public static ExifTag BrightnessValue { get; } = new ExifTag(ExifTagValue.BrightnessValue); + public static ExifTag BrightnessValue { get; } = new(ExifTagValue.BrightnessValue); /// /// Gets the ExposureBiasValue exif tag. /// - public static ExifTag ExposureBiasValue { get; } = new ExifTag(ExifTagValue.ExposureBiasValue); + public static ExifTag ExposureBiasValue { get; } = new(ExifTagValue.ExposureBiasValue); /// /// Gets the AmbientTemperature exif tag. /// - public static ExifTag AmbientTemperature { get; } = new ExifTag(ExifTagValue.AmbientTemperature); + public static ExifTag AmbientTemperature { get; } = new(ExifTagValue.AmbientTemperature); /// /// Gets the WaterDepth exif tag. /// - public static ExifTag WaterDepth { get; } = new ExifTag(ExifTagValue.WaterDepth); + public static ExifTag WaterDepth { get; } = new(ExifTagValue.WaterDepth); /// /// Gets the CameraElevationAngle exif tag. /// - public static ExifTag CameraElevationAngle { get; } = new ExifTag(ExifTagValue.CameraElevationAngle); + public static ExifTag CameraElevationAngle { get; } = new(ExifTagValue.CameraElevationAngle); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs index ef1e8afea..a27108f8a 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedRationalArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the Decode exif tag. /// - public static ExifTag Decode { get; } = new ExifTag(ExifTagValue.Decode); + public static ExifTag Decode { get; } = new(ExifTagValue.Decode); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs index d6a920514..086842698 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.SignedShortArray.cs @@ -9,5 +9,5 @@ public abstract partial class ExifTag /// /// Gets the TimeZoneOffset exif tag. /// - public static ExifTag TimeZoneOffset { get; } = new ExifTag(ExifTagValue.TimeZoneOffset); + public static ExifTag TimeZoneOffset { get; } = new(ExifTagValue.TimeZoneOffset); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs index 498dad3eb..688403a65 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.String.cs @@ -9,270 +9,270 @@ public abstract partial class ExifTag /// /// Gets the ImageDescription exif tag. /// - public static ExifTag ImageDescription { get; } = new ExifTag(ExifTagValue.ImageDescription); + public static ExifTag ImageDescription { get; } = new(ExifTagValue.ImageDescription); /// /// Gets the Make exif tag. /// - public static ExifTag Make { get; } = new ExifTag(ExifTagValue.Make); + public static ExifTag Make { get; } = new(ExifTagValue.Make); /// /// Gets the Model exif tag. /// - public static ExifTag Model { get; } = new ExifTag(ExifTagValue.Model); + public static ExifTag Model { get; } = new(ExifTagValue.Model); /// /// Gets the Software exif tag. /// - public static ExifTag Software { get; } = new ExifTag(ExifTagValue.Software); + public static ExifTag Software { get; } = new(ExifTagValue.Software); /// /// Gets the DateTime exif tag. /// - public static ExifTag DateTime { get; } = new ExifTag(ExifTagValue.DateTime); + public static ExifTag DateTime { get; } = new(ExifTagValue.DateTime); /// /// Gets the Artist exif tag. /// - public static ExifTag Artist { get; } = new ExifTag(ExifTagValue.Artist); + public static ExifTag Artist { get; } = new(ExifTagValue.Artist); /// /// Gets the HostComputer exif tag. /// - public static ExifTag HostComputer { get; } = new ExifTag(ExifTagValue.HostComputer); + public static ExifTag HostComputer { get; } = new(ExifTagValue.HostComputer); /// /// Gets the Copyright exif tag. /// - public static ExifTag Copyright { get; } = new ExifTag(ExifTagValue.Copyright); + public static ExifTag Copyright { get; } = new(ExifTagValue.Copyright); /// /// Gets the DocumentName exif tag. /// - public static ExifTag DocumentName { get; } = new ExifTag(ExifTagValue.DocumentName); + public static ExifTag DocumentName { get; } = new(ExifTagValue.DocumentName); /// /// Gets the PageName exif tag. /// - public static ExifTag PageName { get; } = new ExifTag(ExifTagValue.PageName); + public static ExifTag PageName { get; } = new(ExifTagValue.PageName); /// /// Gets the InkNames exif tag. /// - public static ExifTag InkNames { get; } = new ExifTag(ExifTagValue.InkNames); + public static ExifTag InkNames { get; } = new(ExifTagValue.InkNames); /// /// Gets the TargetPrinter exif tag. /// - public static ExifTag TargetPrinter { get; } = new ExifTag(ExifTagValue.TargetPrinter); + public static ExifTag TargetPrinter { get; } = new(ExifTagValue.TargetPrinter); /// /// Gets the ImageID exif tag. /// - public static ExifTag ImageID { get; } = new ExifTag(ExifTagValue.ImageID); + public static ExifTag ImageID { get; } = new(ExifTagValue.ImageID); /// /// Gets the MDLabName exif tag. /// - public static ExifTag MDLabName { get; } = new ExifTag(ExifTagValue.MDLabName); + public static ExifTag MDLabName { get; } = new(ExifTagValue.MDLabName); /// /// Gets the MDSampleInfo exif tag. /// - public static ExifTag MDSampleInfo { get; } = new ExifTag(ExifTagValue.MDSampleInfo); + public static ExifTag MDSampleInfo { get; } = new(ExifTagValue.MDSampleInfo); /// /// Gets the MDPrepDate exif tag. /// - public static ExifTag MDPrepDate { get; } = new ExifTag(ExifTagValue.MDPrepDate); + public static ExifTag MDPrepDate { get; } = new(ExifTagValue.MDPrepDate); /// /// Gets the MDPrepTime exif tag. /// - public static ExifTag MDPrepTime { get; } = new ExifTag(ExifTagValue.MDPrepTime); + public static ExifTag MDPrepTime { get; } = new(ExifTagValue.MDPrepTime); /// /// Gets the MDFileUnits exif tag. /// - public static ExifTag MDFileUnits { get; } = new ExifTag(ExifTagValue.MDFileUnits); + public static ExifTag MDFileUnits { get; } = new(ExifTagValue.MDFileUnits); /// /// Gets the SEMInfo exif tag. /// - public static ExifTag SEMInfo { get; } = new ExifTag(ExifTagValue.SEMInfo); + public static ExifTag SEMInfo { get; } = new(ExifTagValue.SEMInfo); /// /// Gets the SpectralSensitivity exif tag. /// - public static ExifTag SpectralSensitivity { get; } = new ExifTag(ExifTagValue.SpectralSensitivity); + public static ExifTag SpectralSensitivity { get; } = new(ExifTagValue.SpectralSensitivity); /// /// Gets the DateTimeOriginal exif tag. /// - public static ExifTag DateTimeOriginal { get; } = new ExifTag(ExifTagValue.DateTimeOriginal); + public static ExifTag DateTimeOriginal { get; } = new(ExifTagValue.DateTimeOriginal); /// /// Gets the DateTimeDigitized exif tag. /// - public static ExifTag DateTimeDigitized { get; } = new ExifTag(ExifTagValue.DateTimeDigitized); + public static ExifTag DateTimeDigitized { get; } = new(ExifTagValue.DateTimeDigitized); /// /// Gets the SubsecTime exif tag. /// - public static ExifTag SubsecTime { get; } = new ExifTag(ExifTagValue.SubsecTime); + public static ExifTag SubsecTime { get; } = new(ExifTagValue.SubsecTime); /// /// Gets the SubsecTimeOriginal exif tag. /// - public static ExifTag SubsecTimeOriginal { get; } = new ExifTag(ExifTagValue.SubsecTimeOriginal); + public static ExifTag SubsecTimeOriginal { get; } = new(ExifTagValue.SubsecTimeOriginal); /// /// Gets the SubsecTimeDigitized exif tag. /// - public static ExifTag SubsecTimeDigitized { get; } = new ExifTag(ExifTagValue.SubsecTimeDigitized); + public static ExifTag SubsecTimeDigitized { get; } = new(ExifTagValue.SubsecTimeDigitized); /// /// Gets the RelatedSoundFile exif tag. /// - public static ExifTag RelatedSoundFile { get; } = new ExifTag(ExifTagValue.RelatedSoundFile); + public static ExifTag RelatedSoundFile { get; } = new(ExifTagValue.RelatedSoundFile); /// /// Gets the FaxSubaddress exif tag. /// - public static ExifTag FaxSubaddress { get; } = new ExifTag(ExifTagValue.FaxSubaddress); + public static ExifTag FaxSubaddress { get; } = new(ExifTagValue.FaxSubaddress); /// /// Gets the OffsetTime exif tag. /// - public static ExifTag OffsetTime { get; } = new ExifTag(ExifTagValue.OffsetTime); + public static ExifTag OffsetTime { get; } = new(ExifTagValue.OffsetTime); /// /// Gets the OffsetTimeOriginal exif tag. /// - public static ExifTag OffsetTimeOriginal { get; } = new ExifTag(ExifTagValue.OffsetTimeOriginal); + public static ExifTag OffsetTimeOriginal { get; } = new(ExifTagValue.OffsetTimeOriginal); /// /// Gets the OffsetTimeDigitized exif tag. /// - public static ExifTag OffsetTimeDigitized { get; } = new ExifTag(ExifTagValue.OffsetTimeDigitized); + public static ExifTag OffsetTimeDigitized { get; } = new(ExifTagValue.OffsetTimeDigitized); /// /// Gets the SecurityClassification exif tag. /// - public static ExifTag SecurityClassification { get; } = new ExifTag(ExifTagValue.SecurityClassification); + public static ExifTag SecurityClassification { get; } = new(ExifTagValue.SecurityClassification); /// /// Gets the ImageHistory exif tag. /// - public static ExifTag ImageHistory { get; } = new ExifTag(ExifTagValue.ImageHistory); + public static ExifTag ImageHistory { get; } = new(ExifTagValue.ImageHistory); /// /// Gets the ImageUniqueID exif tag. /// - public static ExifTag ImageUniqueID { get; } = new ExifTag(ExifTagValue.ImageUniqueID); + public static ExifTag ImageUniqueID { get; } = new(ExifTagValue.ImageUniqueID); /// /// Gets the OwnerName exif tag. /// - public static ExifTag OwnerName { get; } = new ExifTag(ExifTagValue.OwnerName); + public static ExifTag OwnerName { get; } = new(ExifTagValue.OwnerName); /// /// Gets the SerialNumber exif tag. /// - public static ExifTag SerialNumber { get; } = new ExifTag(ExifTagValue.SerialNumber); + public static ExifTag SerialNumber { get; } = new(ExifTagValue.SerialNumber); /// /// Gets the LensMake exif tag. /// - public static ExifTag LensMake { get; } = new ExifTag(ExifTagValue.LensMake); + public static ExifTag LensMake { get; } = new(ExifTagValue.LensMake); /// /// Gets the LensModel exif tag. /// - public static ExifTag LensModel { get; } = new ExifTag(ExifTagValue.LensModel); + public static ExifTag LensModel { get; } = new(ExifTagValue.LensModel); /// /// Gets the LensSerialNumber exif tag. /// - public static ExifTag LensSerialNumber { get; } = new ExifTag(ExifTagValue.LensSerialNumber); + public static ExifTag LensSerialNumber { get; } = new(ExifTagValue.LensSerialNumber); /// /// Gets the GDALMetadata exif tag. /// - public static ExifTag GDALMetadata { get; } = new ExifTag(ExifTagValue.GDALMetadata); + public static ExifTag GDALMetadata { get; } = new(ExifTagValue.GDALMetadata); /// /// Gets the GDALNoData exif tag. /// - public static ExifTag GDALNoData { get; } = new ExifTag(ExifTagValue.GDALNoData); + public static ExifTag GDALNoData { get; } = new(ExifTagValue.GDALNoData); /// /// Gets the GPSLatitudeRef exif tag. /// - public static ExifTag GPSLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSLatitudeRef); + public static ExifTag GPSLatitudeRef { get; } = new(ExifTagValue.GPSLatitudeRef); /// /// Gets the GPSLongitudeRef exif tag. /// - public static ExifTag GPSLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSLongitudeRef); + public static ExifTag GPSLongitudeRef { get; } = new(ExifTagValue.GPSLongitudeRef); /// /// Gets the GPSSatellites exif tag. /// - public static ExifTag GPSSatellites { get; } = new ExifTag(ExifTagValue.GPSSatellites); + public static ExifTag GPSSatellites { get; } = new(ExifTagValue.GPSSatellites); /// /// Gets the GPSStatus exif tag. /// - public static ExifTag GPSStatus { get; } = new ExifTag(ExifTagValue.GPSStatus); + public static ExifTag GPSStatus { get; } = new(ExifTagValue.GPSStatus); /// /// Gets the GPSMeasureMode exif tag. /// - public static ExifTag GPSMeasureMode { get; } = new ExifTag(ExifTagValue.GPSMeasureMode); + public static ExifTag GPSMeasureMode { get; } = new(ExifTagValue.GPSMeasureMode); /// /// Gets the GPSSpeedRef exif tag. /// - public static ExifTag GPSSpeedRef { get; } = new ExifTag(ExifTagValue.GPSSpeedRef); + public static ExifTag GPSSpeedRef { get; } = new(ExifTagValue.GPSSpeedRef); /// /// Gets the GPSTrackRef exif tag. /// - public static ExifTag GPSTrackRef { get; } = new ExifTag(ExifTagValue.GPSTrackRef); + public static ExifTag GPSTrackRef { get; } = new(ExifTagValue.GPSTrackRef); /// /// Gets the GPSImgDirectionRef exif tag. /// - public static ExifTag GPSImgDirectionRef { get; } = new ExifTag(ExifTagValue.GPSImgDirectionRef); + public static ExifTag GPSImgDirectionRef { get; } = new(ExifTagValue.GPSImgDirectionRef); /// /// Gets the GPSMapDatum exif tag. /// - public static ExifTag GPSMapDatum { get; } = new ExifTag(ExifTagValue.GPSMapDatum); + public static ExifTag GPSMapDatum { get; } = new(ExifTagValue.GPSMapDatum); /// /// Gets the GPSDestLatitudeRef exif tag. /// - public static ExifTag GPSDestLatitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLatitudeRef); + public static ExifTag GPSDestLatitudeRef { get; } = new(ExifTagValue.GPSDestLatitudeRef); /// /// Gets the GPSDestLongitudeRef exif tag. /// - public static ExifTag GPSDestLongitudeRef { get; } = new ExifTag(ExifTagValue.GPSDestLongitudeRef); + public static ExifTag GPSDestLongitudeRef { get; } = new(ExifTagValue.GPSDestLongitudeRef); /// /// Gets the GPSDestBearingRef exif tag. /// - public static ExifTag GPSDestBearingRef { get; } = new ExifTag(ExifTagValue.GPSDestBearingRef); + public static ExifTag GPSDestBearingRef { get; } = new(ExifTagValue.GPSDestBearingRef); /// /// Gets the GPSDestDistanceRef exif tag. /// - public static ExifTag GPSDestDistanceRef { get; } = new ExifTag(ExifTagValue.GPSDestDistanceRef); + public static ExifTag GPSDestDistanceRef { get; } = new(ExifTagValue.GPSDestDistanceRef); /// /// Gets the GPSDateStamp exif tag. /// - public static ExifTag GPSDateStamp { get; } = new ExifTag(ExifTagValue.GPSDateStamp); + public static ExifTag GPSDateStamp { get; } = new(ExifTagValue.GPSDateStamp); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs index 65acc4bd7..e13b3b30e 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Ucs2String.cs @@ -9,25 +9,25 @@ public abstract partial class ExifTag /// /// Gets the title tag used by Windows (encoded in UCS2). /// - public static ExifTag XPTitle => new ExifTag(ExifTagValue.XPTitle); + public static ExifTag XPTitle => new(ExifTagValue.XPTitle); /// /// Gets the comment tag used by Windows (encoded in UCS2). /// - public static ExifTag XPComment => new ExifTag(ExifTagValue.XPComment); + public static ExifTag XPComment => new(ExifTagValue.XPComment); /// /// Gets the author tag used by Windows (encoded in UCS2). /// - public static ExifTag XPAuthor => new ExifTag(ExifTagValue.XPAuthor); + public static ExifTag XPAuthor => new(ExifTagValue.XPAuthor); /// /// Gets the keywords tag used by Windows (encoded in UCS2). /// - public static ExifTag XPKeywords => new ExifTag(ExifTagValue.XPKeywords); + public static ExifTag XPKeywords => new(ExifTagValue.XPKeywords); /// /// Gets the subject tag used by Windows (encoded in UCS2). /// - public static ExifTag XPSubject => new ExifTag(ExifTagValue.XPSubject); + public static ExifTag XPSubject => new(ExifTagValue.XPSubject); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs index 417673b4a..e822c2a11 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Tags/ExifTag.Undefined.cs @@ -9,70 +9,70 @@ public abstract partial class ExifTag /// /// Gets the JPEGTables exif tag. /// - public static ExifTag JPEGTables { get; } = new ExifTag(ExifTagValue.JPEGTables); + public static ExifTag JPEGTables { get; } = new(ExifTagValue.JPEGTables); /// /// Gets the OECF exif tag. /// - public static ExifTag OECF { get; } = new ExifTag(ExifTagValue.OECF); + public static ExifTag OECF { get; } = new(ExifTagValue.OECF); /// /// Gets the ExifVersion exif tag. /// - public static ExifTag ExifVersion { get; } = new ExifTag(ExifTagValue.ExifVersion); + public static ExifTag ExifVersion { get; } = new(ExifTagValue.ExifVersion); /// /// Gets the ComponentsConfiguration exif tag. /// - public static ExifTag ComponentsConfiguration { get; } = new ExifTag(ExifTagValue.ComponentsConfiguration); + public static ExifTag ComponentsConfiguration { get; } = new(ExifTagValue.ComponentsConfiguration); /// /// Gets the MakerNote exif tag. /// - public static ExifTag MakerNote { get; } = new ExifTag(ExifTagValue.MakerNote); + public static ExifTag MakerNote { get; } = new(ExifTagValue.MakerNote); /// /// Gets the FlashpixVersion exif tag. /// - public static ExifTag FlashpixVersion { get; } = new ExifTag(ExifTagValue.FlashpixVersion); + public static ExifTag FlashpixVersion { get; } = new(ExifTagValue.FlashpixVersion); /// /// Gets the SpatialFrequencyResponse exif tag. /// - public static ExifTag SpatialFrequencyResponse { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse); + public static ExifTag SpatialFrequencyResponse { get; } = new(ExifTagValue.SpatialFrequencyResponse); /// /// Gets the SpatialFrequencyResponse2 exif tag. /// - public static ExifTag SpatialFrequencyResponse2 { get; } = new ExifTag(ExifTagValue.SpatialFrequencyResponse2); + public static ExifTag SpatialFrequencyResponse2 { get; } = new(ExifTagValue.SpatialFrequencyResponse2); /// /// Gets the Noise exif tag. /// - public static ExifTag Noise { get; } = new ExifTag(ExifTagValue.Noise); + public static ExifTag Noise { get; } = new(ExifTagValue.Noise); /// /// Gets the CFAPattern exif tag. /// - public static ExifTag CFAPattern { get; } = new ExifTag(ExifTagValue.CFAPattern); + public static ExifTag CFAPattern { get; } = new(ExifTagValue.CFAPattern); /// /// Gets the DeviceSettingDescription exif tag. /// - public static ExifTag DeviceSettingDescription { get; } = new ExifTag(ExifTagValue.DeviceSettingDescription); + public static ExifTag DeviceSettingDescription { get; } = new(ExifTagValue.DeviceSettingDescription); /// /// Gets the ImageSourceData exif tag. /// - public static ExifTag ImageSourceData { get; } = new ExifTag(ExifTagValue.ImageSourceData); + public static ExifTag ImageSourceData { get; } = new(ExifTagValue.ImageSourceData); /// /// Gets the FileSource exif tag. /// - public static ExifTag FileSource { get; } = new ExifTag(ExifTagValue.FileSource); + public static ExifTag FileSource { get; } = new(ExifTagValue.FileSource); /// /// Gets the ImageDescription exif tag. /// - public static ExifTag SceneType { get; } = new ExifTag(ExifTagValue.SceneType); + public static ExifTag SceneType { get; } = new(ExifTagValue.SceneType); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs index a7b9d44ae..14b097f81 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifEncodedString.cs @@ -33,7 +33,7 @@ internal sealed class ExifEncodedString : ExifValue if (value is string stringValue) { - this.Value = new(stringValue); + this.Value = new EncodedString(stringValue); return true; } else if (value is byte[] buffer) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs index e5c27f60a..c25f0f5dc 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRational.cs @@ -39,7 +39,7 @@ internal sealed class ExifRational : ExifValue if (signed.Numerator >= uint.MinValue && signed.Denominator >= uint.MinValue) { - this.Value = new((uint)signed.Numerator, (uint)signed.Denominator); + this.Value = new Rational((uint)signed.Numerator, (uint)signed.Denominator); } return true; diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs index 4ae2850a1..e8b2006df 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifRationalArray.cs @@ -38,7 +38,7 @@ internal sealed class ExifRationalArray : ExifArrayValue { if (signed.Numerator >= 0 && signed.Denominator >= 0) { - this.Value = [new((uint)signed.Numerator, (uint)signed.Denominator)]; + this.Value = [new Rational((uint)signed.Numerator, (uint)signed.Denominator)]; } return true; @@ -60,7 +60,7 @@ internal sealed class ExifRationalArray : ExifArrayValue for (int i = 0; i < signed.Length; i++) { SignedRational s = signed[i]; - unsigned[i] = new((uint)s.Numerator, (uint)s.Denominator); + unsigned[i] = new Rational((uint)s.Numerator, (uint)s.Denominator); } this.Value = unsigned; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs index 3e061c9d8..8663ebccc 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Curves.cs @@ -30,7 +30,7 @@ internal sealed partial class IccDataReader segments[i] = this.ReadCurveSegment(); } - return new(breakPoints, segments); + return new IccOneDimensionalCurve(breakPoints, segments); } /// @@ -63,7 +63,7 @@ internal sealed partial class IccDataReader } } - return new(type, xyzValues, response); + return new IccResponseCurve(type, xyzValues, response); } /// @@ -106,11 +106,11 @@ internal sealed partial class IccDataReader switch (type) { - case 0: return new(gamma); - case 1: return new(gamma, a, b); - case 2: return new(gamma, a, b, c); - case 3: return new(gamma, a, b, c, d); - case 4: return new(gamma, a, b, c, d, e, f); + case 0: return new IccParametricCurve(gamma); + case 1: return new IccParametricCurve(gamma, a, b); + case 2: return new IccParametricCurve(gamma, a, b, c); + case 3: return new IccParametricCurve(gamma, a, b, c, d); + case 4: return new IccParametricCurve(gamma, a, b, c, d, e, f); default: throw new InvalidIccProfileException($"Invalid parametric curve type of {type}"); } } @@ -165,7 +165,7 @@ internal sealed partial class IccDataReader e = this.ReadSingle(); } - return new(type, gamma, a, b, c, d, e); + return new IccFormulaCurveElement(type, gamma, a, b, c, d, e); } /// @@ -181,7 +181,7 @@ internal sealed partial class IccDataReader entries[i] = this.ReadSingle(); } - return new(entries); + return new IccSampledCurveElement(entries); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs index ff65125c3..700e43f97 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Lut.cs @@ -27,7 +27,7 @@ internal sealed partial class IccDataReader values[i] = this.ReadUInt16(); } - return new(values); + return new IccLut(values); } /// @@ -92,7 +92,7 @@ internal sealed partial class IccDataReader } } - return new(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); + return new IccClut(values, gridPointCount, IccClutDataType.UInt8, outChannelCount); } /// @@ -126,7 +126,7 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChannelCount * 2); - return new(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); + return new IccClut(values, gridPointCount, IccClutDataType.UInt16, outChannelCount); } /// @@ -158,6 +158,6 @@ internal sealed partial class IccDataReader } this.currentIndex = start + (length * outChCount * 4); - return new(values, gridPointCount, IccClutDataType.Float, outChCount); + return new IccClut(values, gridPointCount, IccClutDataType.Float, outChCount); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs index bff5e31bc..98b269f0b 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.MultiProcessElement.cs @@ -55,7 +55,7 @@ internal sealed partial class IccDataReader this.AddPadding(); } - return new(curves); + return new IccCurveSetProcessElement(curves); } /// @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// The read public IccMatrixProcessElement ReadMatrixProcessElement(int inChannelCount, int outChannelCount) { - return new( + return new IccMatrixProcessElement( this.ReadMatrix(inChannelCount, outChannelCount, true), this.ReadMatrix(outChannelCount, true)); } @@ -79,6 +79,6 @@ internal sealed partial class IccDataReader /// The read public IccClutProcessElement ReadClutProcessElement(int inChannelCount, int outChannelCount) { - return new(this.ReadClut(inChannelCount, outChannelCount, true)); + return new IccClutProcessElement(this.ReadClut(inChannelCount, outChannelCount, true)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index ea969b7ec..58b759555 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -18,7 +18,7 @@ internal sealed partial class IccDataReader { try { - return new( + return new DateTime( year: this.ReadUInt16(), month: this.ReadUInt16(), day: this.ReadUInt16(), @@ -45,7 +45,7 @@ internal sealed partial class IccDataReader int minor = (version >> 20) & 0x0F; int bugfix = (version >> 16) & 0x0F; - return new(major, minor, bugfix); + return new IccVersion(major, minor, bugfix); } /// @@ -54,7 +54,7 @@ internal sealed partial class IccDataReader /// the XYZ number public Vector3 ReadXyzNumber() { - return new( + return new Vector3( x: this.ReadFix16(), y: this.ReadFix16(), z: this.ReadFix16()); @@ -66,7 +66,7 @@ internal sealed partial class IccDataReader /// the profile ID public IccProfileId ReadProfileId() { - return new( + return new IccProfileId( p1: this.ReadUInt32(), p2: this.ReadUInt32(), p3: this.ReadUInt32(), @@ -79,7 +79,7 @@ internal sealed partial class IccDataReader /// the position number public IccPositionNumber ReadPositionNumber() { - return new( + return new IccPositionNumber( offset: this.ReadUInt32(), size: this.ReadUInt32()); } @@ -90,7 +90,7 @@ internal sealed partial class IccDataReader /// the response number public IccResponseNumber ReadResponseNumber() { - return new( + return new IccResponseNumber( deviceCode: this.ReadUInt16(), measurementValue: this.ReadFix16()); } @@ -111,7 +111,7 @@ internal sealed partial class IccDataReader deviceCoord[i] = this.ReadUInt16(); } - return new(name, pcsCoord, deviceCoord); + return new IccNamedColor(name, pcsCoord, deviceCoord); } /// @@ -128,7 +128,7 @@ internal sealed partial class IccDataReader IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = ReadText(); IccMultiLocalizedUnicodeTagDataEntry modelInfo = ReadText(); - return new( + return new IccProfileDescription( manufacturer, model, attributes, @@ -158,7 +158,7 @@ internal sealed partial class IccDataReader /// the profile description public IccColorantTableEntry ReadColorantTableEntry() { - return new( + return new IccColorantTableEntry( name: this.ReadAsciiString(32), pcs1: this.ReadUInt16(), pcs2: this.ReadUInt16(), @@ -171,7 +171,7 @@ internal sealed partial class IccDataReader /// the screening channel public IccScreeningChannel ReadScreeningChannel() { - return new( + return new IccScreeningChannel( frequency: this.ReadFix16(), angle: this.ReadFix16(), spotShape: (IccScreeningSpotType)this.ReadInt32()); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 591e08c6f..88281452e 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -130,7 +130,7 @@ internal sealed partial class IccDataReader public IccUnknownTagDataEntry ReadUnknownTagDataEntry(uint size) { int count = (int)size - 8; // 8 is the tag header size - return new(this.ReadBytes(count)); + return new IccUnknownTagDataEntry(this.ReadBytes(count)); } /// @@ -146,7 +146,7 @@ internal sealed partial class IccDataReader { // The type is known and so are the values (they are constant) // channelCount should always be 3 but it doesn't really matter if it's not - return new(colorant); + return new IccChromaticityTagDataEntry(colorant); } else { @@ -157,7 +157,7 @@ internal sealed partial class IccDataReader values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; } - return new(values); + return new IccChromaticityTagDataEntry(values); } } @@ -169,7 +169,7 @@ internal sealed partial class IccDataReader { uint colorantCount = this.ReadUInt32(); byte[] number = this.ReadBytes((int)colorantCount); - return new(number); + return new IccColorantOrderTagDataEntry(number); } /// @@ -185,7 +185,7 @@ internal sealed partial class IccDataReader cdata[i] = this.ReadColorantTableEntry(); } - return new(cdata); + return new IccColorantTableTagDataEntry(cdata); } /// @@ -198,12 +198,12 @@ internal sealed partial class IccDataReader if (pointCount == 0) { - return new(); + return new IccCurveTagDataEntry(); } if (pointCount == 1) { - return new(this.ReadUFix8()); + return new IccCurveTagDataEntry(this.ReadUFix8()); } float[] cdata = new float[pointCount]; @@ -212,7 +212,7 @@ internal sealed partial class IccDataReader cdata[i] = this.ReadUInt16() / 65535f; } - return new(cdata); + return new IccCurveTagDataEntry(cdata); // TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768). } @@ -232,7 +232,7 @@ internal sealed partial class IccDataReader int length = (int)size - 12; byte[] cdata = this.ReadBytes(length); - return new(cdata, ascii); + return new IccDataTagDataEntry(cdata, ascii); } /// @@ -276,7 +276,7 @@ internal sealed partial class IccDataReader outValues[i] = this.ReadLut16(outTableCount); } - return new(matrix, inValues, clut, outValues); + return new IccLut16TagDataEntry(matrix, inValues, clut, outValues); } /// @@ -311,7 +311,7 @@ internal sealed partial class IccDataReader outValues[i] = this.ReadLut8(); } - return new(matrix, inValues, clut, outValues); + return new IccLut8TagDataEntry(matrix, inValues, clut, outValues); } /// @@ -370,7 +370,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new IccLutAToBTagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -429,7 +429,7 @@ internal sealed partial class IccDataReader matrix3x1 = this.ReadMatrix(3, false); } - return new(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); + return new IccLutBToATagDataEntry(bCurve, matrix3x3, matrix3x1, mCurve, clut, aCurve); } /// @@ -472,10 +472,10 @@ internal sealed partial class IccDataReader for (int i = 0; i < recordCount; i++) { this.currentIndex = (int)(start + offset[i]); - text[i] = new(culture[i], this.ReadUnicodeString((int)length[i])); + text[i] = new IccLocalizedString(culture[i], this.ReadUnicodeString((int)length[i])); } - return new(text); + return new IccMultiLocalizedUnicodeTagDataEntry(text); CultureInfo ReadCulture(string language, string country) { @@ -487,7 +487,7 @@ internal sealed partial class IccDataReader { try { - return new(language); + return new CultureInfo(language); } catch (CultureNotFoundException) { @@ -498,7 +498,7 @@ internal sealed partial class IccDataReader { try { - return new($"{language}-{country}"); + return new CultureInfo($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -533,7 +533,7 @@ internal sealed partial class IccDataReader elements[i] = this.ReadMultiProcessElement(); } - return new(elements); + return new IccMultiProcessElementsTagDataEntry(elements); } /// @@ -554,7 +554,7 @@ internal sealed partial class IccDataReader colors[i] = this.ReadNamedColor(coordCount); } - return new(vendorFlag, prefix, suffix, colors); + return new IccNamedColor2TagDataEntry(vendorFlag, prefix, suffix, colors); } /// @@ -576,7 +576,7 @@ internal sealed partial class IccDataReader description[i] = this.ReadProfileDescription(); } - return new(description); + return new IccProfileSequenceDescTagDataEntry(description); } /// @@ -600,10 +600,10 @@ internal sealed partial class IccDataReader IccProfileId id = this.ReadProfileId(); this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode); IccMultiLocalizedUnicodeTagDataEntry description = this.ReadMultiLocalizedUnicodeTagDataEntry(); - entries[i] = new(id, description.Texts); + entries[i] = new IccProfileSequenceIdentifier(id, description.Texts); } - return new(entries); + return new IccProfileSequenceIdentifierTagDataEntry(entries); } /// @@ -629,7 +629,7 @@ internal sealed partial class IccDataReader curves[i] = this.ReadResponseCurve(channelCount); } - return new(curves); + return new IccResponseCurveSet16TagDataEntry(curves); } /// @@ -646,7 +646,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadFix16() / 256f; } - return new(arrayData); + return new IccFix16ArrayTagDataEntry(arrayData); } /// @@ -676,7 +676,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUFix16(); } - return new(arrayData); + return new IccUFix16ArrayTagDataEntry(arrayData); } /// @@ -693,7 +693,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt16(); } - return new(arrayData); + return new IccUInt16ArrayTagDataEntry(arrayData); } /// @@ -710,7 +710,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt32(); } - return new(arrayData); + return new IccUInt32ArrayTagDataEntry(arrayData); } /// @@ -727,7 +727,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadUInt64(); } - return new(arrayData); + return new IccUInt64ArrayTagDataEntry(arrayData); } /// @@ -740,7 +740,7 @@ internal sealed partial class IccDataReader int count = (int)size - 8; // 8 is the tag header size byte[] adata = this.ReadBytes(count); - return new(adata); + return new IccUInt8ArrayTagDataEntry(adata); } /// @@ -766,7 +766,7 @@ internal sealed partial class IccDataReader arrayData[i] = this.ReadXyzNumber(); } - return new(arrayData); + return new IccXyzTagDataEntry(arrayData); } /// @@ -801,7 +801,7 @@ internal sealed partial class IccDataReader this.AddIndex(1); // Null terminator } - return new( + return new IccTextDescriptionTagDataEntry( asciiValue, unicodeValue, scriptcodeValue, @@ -830,7 +830,7 @@ internal sealed partial class IccDataReader uint crd3Count = this.ReadUInt32(); string crd3Name = this.ReadAsciiString((int)crd3Count); - return new(productName, crd0Name, crd1Name, crd2Name, crd3Name); + return new IccCrdInfoTagDataEntry(productName, crd0Name, crd1Name, crd2Name, crd3Name); } /// @@ -847,7 +847,7 @@ internal sealed partial class IccDataReader channels[i] = this.ReadScreeningChannel(); } - return new(flags, channels); + return new IccScreeningTagDataEntry(flags, channels); } /// @@ -876,6 +876,6 @@ internal sealed partial class IccDataReader int descriptionLength = (int)(size - 8 - dataSize); // 8 is the tag header size string description = this.ReadAsciiString(descriptionLength); - return new(ucrCurve, bgCurve, description); + return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs index 8ad81415d..db199b438 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.NonPrimitives.cs @@ -111,9 +111,9 @@ internal sealed partial class IccDataWriter + this.WriteInt64((long)value.DeviceAttributes) + this.WriteUInt32((uint)value.TechnologyInformation) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceManufacturerInfo)) + + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceManufacturerInfo)) + this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode) - + this.WriteMultiLocalizedUnicodeTagDataEntry(new(value.DeviceModelInfo)); + + this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceModelInfo)); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs index 1233beda7..6019a0bff 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs @@ -20,7 +20,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)this.dataStream.Position; int count = this.WriteTagDataEntry(data); this.WritePadding(); - table = new(data.TagSignature, offset, (uint)count); + table = new IccTagTableEntry(data.TagSignature, offset, (uint)count); return count; } @@ -546,7 +546,7 @@ internal sealed partial class IccDataWriter uint offset = (uint)(this.dataStream.Position - start); int size = this.WriteMultiProcessElement(value.Data[i]); count += this.WritePadding(); - posTable[i] = new(offset, (uint)size); + posTable[i] = new IccPositionNumber(offset, (uint)size); count += size; } @@ -634,7 +634,7 @@ internal sealed partial class IccDataWriter int size = this.WriteProfileId(sequenceIdentifier.Id); size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description)); size += this.WritePadding(); - table[i] = new(offset, (uint)size); + table[i] = new IccPositionNumber(offset, (uint)size); count += size; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs index 941d3bb65..ce5332544 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.cs @@ -23,7 +23,7 @@ internal sealed partial class IccDataWriter : IDisposable /// public IccDataWriter() { - this.dataStream = new(); + this.dataStream = new MemoryStream(); } /// diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index b33c98432..392ccb306 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -186,7 +186,7 @@ public sealed class IccProfile : IDeepCloneable if (this.data is null) { - this.header = new(); + this.header = new IccProfileHeader(); return; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index da3566514..074712d30 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -22,7 +22,7 @@ internal sealed class IccReader IccProfileHeader header = ReadHeader(reader); IccTagDataEntry[] tagData = ReadTagData(reader); - return new(header, tagData); + return new IccProfile(header, tagData); } /// @@ -57,7 +57,7 @@ internal sealed class IccReader { reader.SetIndex(0); - return new() + return new IccProfileHeader { Size = reader.ReadUInt32(), CmmType = reader.ReadAsciiString(4), @@ -128,7 +128,7 @@ internal sealed class IccReader // Exclude entries that have nonsense values and could cause exceptions further on if (tagOffset < reader.DataLength && tagSize < reader.DataLength - 128) { - table.Add(new((IccProfileTag)tagSignature, tagOffset, tagSize)); + table.Add(new IccTagTableEntry((IccProfileTag)tagSignature, tagOffset, tagSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs index 8e0b4ae6d..5e73e2dd0 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs @@ -77,7 +77,7 @@ internal sealed class IccWriter writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry); foreach (IccTagDataEntry item in group) { - table.Add(new(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); + table.Add(new IccTagTableEntry(item.TagSignature, tableEntry.Offset, tableEntry.DataSize)); } } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs index b8c29ae09..9ddd0ce13 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs @@ -147,7 +147,7 @@ internal sealed class IccLut16TagDataEntry : IccTagDataEntry, IEquatable= 0x41 && p4 <= 0x5A) { string culture = new(new[] { (char)p1, (char)p2, '-', (char)p3, (char)p4 }); - return new(culture); + return new CultureInfo(culture); } return null; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 8d13d3862..85c23d174 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -185,7 +185,7 @@ public sealed class IptcProfile : IDeepCloneable } } - this.values.Add(new(tag, encoding, value, strict)); + this.values.Add(new IptcValue(tag, encoding, value, strict)); } /// @@ -322,7 +322,7 @@ public sealed class IptcProfile : IDeepCloneable { byte[] iptcData = new byte[byteCount]; Buffer.BlockCopy(this.Data, offset, iptcData, 0, (int)byteCount); - this.values.Add(new(tag, iptcData, false)); + this.values.Add(new IptcValue(tag, iptcData, false)); } offset += (int)byteCount; diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index f0b1b717a..7c5662e1f 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -124,7 +124,7 @@ public sealed class IptcValue : IDeepCloneable public int Length => this.data.Length; /// - public IptcValue DeepClone() => new IptcValue(this); + public IptcValue DeepClone() => new(this); /// /// Determines whether the specified object is equal to the current . diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs index 63630dd55..ca358be31 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs @@ -179,7 +179,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(backdrop.Y, source.Y); float cb = OverlayValueFunction(backdrop.Z, source.Z); - return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); } /// @@ -208,7 +208,7 @@ internal static partial class PorterDuffFunctions float cg = OverlayValueFunction(source.Y, backdrop.Y); float cb = OverlayValueFunction(source.Z, backdrop.Z); - return Vector4.Min(Vector4.One, new(cr, cg, cb, 0)); + return Vector4.Min(Vector4.One, new Vector4(cr, cg, cb, 0)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs index 00be93b22..1444b344b 100644 --- a/src/ImageSharp/PixelFormats/PixelComponentInfo.cs +++ b/src/ImageSharp/PixelFormats/PixelComponentInfo.cs @@ -81,7 +81,7 @@ public readonly struct PixelComponentInfo sum += p; } - return new(count, bitsPerPixel - sum, precisionData1, precisionData2); + return new PixelComponentInfo(count, bitsPerPixel - sum, precisionData1, precisionData2); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs index 453a39228..1190d307a 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs @@ -231,7 +231,7 @@ public partial struct Abgr32 : IPixel, IPackedVector public static Abgr32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Abgr32(rgb, rgb, rgb); } /// @@ -243,7 +243,7 @@ public partial struct Abgr32 : IPixel, IPackedVector public static Abgr32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Abgr32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -320,6 +320,6 @@ public partial struct Abgr32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Abgr32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs index f8608ecc5..b74f5db71 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs @@ -224,7 +224,7 @@ public partial struct Argb32 : IPixel, IPackedVector public static Argb32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Argb32(rgb, rgb, rgb); } /// @@ -236,7 +236,7 @@ public partial struct Argb32 : IPixel, IPackedVector public static Argb32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Argb32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -296,6 +296,6 @@ public partial struct Argb32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Argb32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index a860edc56..944cdf7bf 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs @@ -110,7 +110,7 @@ public partial struct Bgr24 : IPixel source = Numerics.Clamp(source, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(source.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8)); + return new Bgr24(result.GetElement(0), result.GetElement(4), result.GetElement(8)); } /// @@ -142,7 +142,7 @@ public partial struct Bgr24 : IPixel public static Bgr24 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Bgr24(rgb, rgb, rgb); } /// @@ -154,7 +154,7 @@ public partial struct Bgr24 : IPixel public static Bgr24 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb); + return new Bgr24(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs index e81b3e66f..87055bf22 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs @@ -28,7 +28,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVectorThe y-component /// The z-component public Bgr565(float x, float y, float z) - : this(new(x, y, z)) + : this(new Vector3(x, y, z)) { } @@ -84,7 +84,7 @@ public partial struct Bgr565(Vector3 vector) : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y, source.Z)) }; + public static Bgr565 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector3(source.X, source.Y, source.Z)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs index 0fe7e4cc2..903d9dc8c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs @@ -173,7 +173,7 @@ public partial struct Bgra32 : IPixel, IPackedVector public static Bgra32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Bgra32(rgb, rgb, rgb); } /// @@ -185,7 +185,7 @@ public partial struct Bgra32 : IPixel, IPackedVector public static Bgra32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Bgra32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -242,6 +242,6 @@ public partial struct Bgra32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Bgra32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs index d6ffa4723..55971210c 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs @@ -22,7 +22,7 @@ public partial struct Bgra4444 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra4444(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs index 45f013fb1..4c94dea5f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs @@ -23,7 +23,7 @@ public partial struct Bgra5551 : IPixel, IPackedVector /// The z-component /// The w-component public Bgra5551(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs index b4479fd50..680a7ee0b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs @@ -25,7 +25,7 @@ public partial struct Byte4 : IPixel, IPackedVector /// The z-component /// The w-component public Byte4(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs index 3ef711d6a..00deadb12 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfSingle.cs @@ -55,7 +55,7 @@ public partial struct HalfSingle : IPixel, IPackedVector { float single = this.ToSingle() + 1F; single /= 2F; - return new(single, 0, 0, 1F); + return new Vector4(single, 0, 0, 1F); } /// @@ -79,7 +79,7 @@ public partial struct HalfSingle : IPixel, IPackedVector float scaled = source.X; scaled *= 2F; scaled--; - return new() { PackedValue = HalfTypeHelper.Pack(scaled) }; + return new HalfSingle { PackedValue = HalfTypeHelper.Pack(scaled) }; } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs index 861a8480a..03d4dee89 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector2.cs @@ -63,7 +63,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2F; - return new(scaled, 0F, 1F); + return new Vector4(scaled, 0F, 1F); } /// @@ -71,7 +71,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector public readonly Vector4 ToVector4() { Vector2 vector = this.ToVector2(); - return new(vector.X, vector.Y, 0F, 1F); + return new Vector4(vector.X, vector.Y, 0F, 1F); } /// @@ -90,7 +90,7 @@ public partial struct HalfVector2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 2F; scaled -= Vector2.One; - return new() { PackedValue = Pack(scaled.X, scaled.Y) }; + return new HalfVector2 { PackedValue = Pack(scaled.X, scaled.Y) }; } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs index 254e9290d..d0b57d788 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/HalfVector4.cs @@ -22,7 +22,7 @@ public partial struct HalfVector4 : IPixel, IPackedVector /// The z-component. /// The w-component. public HalfVector4(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index faad37ab5..c5893f770 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -52,7 +52,7 @@ public partial struct L16 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = ColorNumerics.From16BitTo8Bit(this.PackedValue); - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// @@ -64,7 +64,7 @@ public partial struct L16 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float scaled = this.PackedValue / Max; - return new(scaled, scaled, scaled, 1f); + return new Vector4(scaled, scaled, scaled, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index 1ef5951fe..008eed459 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -54,7 +54,7 @@ public partial struct L8 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = this.PackedValue; - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// @@ -66,7 +66,7 @@ public partial struct L8 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.PackedValue / 255f; - return new(rgb, rgb, rgb, 1f); + return new Vector4(rgb, rgb, rgb, 1f); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index b1149dc3e..6c3fa7829 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -93,7 +93,7 @@ public partial struct La16 : IPixel, IPackedVector { const float max = 255f; float rgb = this.L / max; - return new(rgb, rgb, rgb, this.A / max); + return new Vector4(rgb, rgb, rgb, this.A / max); } /// @@ -188,6 +188,6 @@ public partial struct La16 : IPixel, IPackedVector byte l = ColorNumerics.Get8BitBT709Luminance(result.GetElement(0), result.GetElement(4), result.GetElement(8)); byte a = result.GetElement(12); - return new(l, a); + return new La16(l, a); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index ec2c38e3e..c99f6fe60 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -78,7 +78,7 @@ public partial struct La32 : IPixel, IPackedVector public readonly Rgba32 ToRgba32() { byte rgb = ColorNumerics.From16BitTo8Bit(this.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(this.A)); + return new Rgba32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(this.A)); } /// @@ -90,7 +90,7 @@ public partial struct La32 : IPixel, IPackedVector public readonly Vector4 ToVector4() { float rgb = this.L / Max; - return new(rgb, rgb, rgb, this.A / Max); + return new Vector4(rgb, rgb, rgb, this.A / Max); } /// @@ -117,7 +117,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -126,7 +126,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -143,7 +143,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -160,7 +160,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.From8BitTo16Bit(source.L); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -176,7 +176,7 @@ public partial struct La32 : IPixel, IPackedVector public static La32 FromRgb48(Rgb48 source) { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); - return new(l, ushort.MaxValue); + return new La32(l, ushort.MaxValue); } /// @@ -185,7 +185,7 @@ public partial struct La32 : IPixel, IPackedVector { ushort l = ColorNumerics.Get16BitBT709Luminance(source.R, source.G, source.B); ushort a = ColorNumerics.From8BitTo16Bit(source.A); - return new(l, a); + return new La32(l, a); } /// @@ -210,6 +210,6 @@ public partial struct La32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One) * Max; ushort l = ColorNumerics.Get16BitBT709Luminance(vector.X, vector.Y, vector.Z); ushort a = (ushort)MathF.Round(vector.W); - return new(l, a); + return new La32(l, a); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs index c4b6bf818..da2ab2440 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte2.cs @@ -24,7 +24,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVectorThe x-component. /// The y-component. public NormalizedByte2(float x, float y) - : this(new(x, y)) + : this(new Vector2(x, y)) { } @@ -70,7 +70,7 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector @@ -93,12 +93,12 @@ public partial struct NormalizedByte2 : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; + public static NormalizedByte2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs index 380465f4e..1fb386725 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedByte4.cs @@ -27,7 +27,7 @@ public partial struct NormalizedByte4 : IPixel, IPackedVectorThe z-component. /// The w-component. public NormalizedByte4(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs index edd2271ec..0942c3a76 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort2.cs @@ -26,7 +26,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector /// The x-component. /// The y-component. public NormalizedShort2(float x, float y) - : this(new(x, y)) + : this(new Vector2(x, y)) { } @@ -72,7 +72,7 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += Vector2.One; scaled /= 2f; - return new(scaled, 0f, 1f); + return new Vector4(scaled, 0f, 1f); } /// @@ -95,12 +95,12 @@ public partial struct NormalizedShort2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 2f; scaled -= Vector2.One; - return new() { PackedValue = Pack(scaled) }; + return new NormalizedShort2 { PackedValue = Pack(scaled) }; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; + public static NormalizedShort2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs index 2c30a0a56..2b33fec27 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/NormalizedShort4.cs @@ -28,7 +28,7 @@ public partial struct NormalizedShort4 : IPixel, IPackedVector /// The z-component. /// The w-component. public NormalizedShort4(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs index 89b2a65b2..e7c97269e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rg32.cs @@ -22,7 +22,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// The x-component /// The y-component public Rg32(float x, float y) - : this(new(x, y)) + : this(new Vector2(x, y)) { } @@ -90,7 +90,7 @@ public partial struct Rg32 : IPixel, IPackedVector /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; + public static Rg32 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index 8eaabe02e..190407296 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -62,7 +62,7 @@ public partial struct Rgb24 : IPixel /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Rgb24(Rgb color) - => FromScaledVector4(new(color.ToScaledVector3(), 1F)); + => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. @@ -121,7 +121,7 @@ public partial struct Rgb24 : IPixel source = Numerics.Clamp(source, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(source.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8)); + return new Rgb24(result.GetElement(0), result.GetElement(4), result.GetElement(8)); } /// @@ -153,7 +153,7 @@ public partial struct Rgb24 : IPixel public static Rgb24 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgb24(rgb, rgb, rgb); } /// @@ -165,7 +165,7 @@ public partial struct Rgb24 : IPixel public static Rgb24 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb); + return new Rgb24(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index e822d2abc..ed6f57abb 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs @@ -100,7 +100,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One) * Max; - return new((ushort)MathF.Round(source.X), (ushort)MathF.Round(source.Y), (ushort)MathF.Round(source.Z)); + return new Rgb48((ushort)MathF.Round(source.X), (ushort)MathF.Round(source.Y), (ushort)MathF.Round(source.Z)); } /// @@ -132,7 +132,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromL8(L8 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgb48(rgb, rgb, rgb); } /// @@ -144,7 +144,7 @@ public partial struct Rgb48 : IPixel public static Rgb48 FromLa16(La16 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.L); - return new(rgb, rgb, rgb); + return new Rgb48(rgb, rgb, rgb); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs index a022476fd..cdee22964 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba1010102.cs @@ -25,7 +25,7 @@ public partial struct Rgba1010102 : IPixel, IPackedVector /// The z-component /// The w-component public Rgba1010102(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index f618b9a2f..8980700c9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -187,7 +187,7 @@ public partial struct Rgba32 : IPixel, IPackedVector /// The instance of to convert. /// An instance of . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new(color.ToScaledVector3(), 1F)); + public static implicit operator Rgba32(Rgb color) => FromScaledVector4(new Vector4(color.ToScaledVector3(), 1F)); /// /// Compares two objects for equality. @@ -328,7 +328,7 @@ public partial struct Rgba32 : IPixel, IPackedVector public static Rgba32 FromL16(L16 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.PackedValue); - return new(rgb, rgb, rgb); + return new Rgba32(rgb, rgb, rgb); } /// @@ -340,7 +340,7 @@ public partial struct Rgba32 : IPixel, IPackedVector public static Rgba32 FromLa32(La32 source) { byte rgb = ColorNumerics.From16BitTo8Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); + return new Rgba32(rgb, rgb, rgb, ColorNumerics.From16BitTo8Bit(source.A)); } /// @@ -407,7 +407,7 @@ public partial struct Rgba32 : IPixel, IPackedVector vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new Rgba32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } /// @@ -444,6 +444,6 @@ public partial struct Rgba32 : IPixel, IPackedVector char g = hex[1]; char r = hex[0]; - return new(new[] { r, r, g, g, b, b, a, a }); + return new string(new[] { r, r, g, g, b, b, a, a }); } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs index 27c4752e1..c73daaf86 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs @@ -245,7 +245,7 @@ public partial struct Rgba64 : IPixel, IPackedVector public static Rgba64 FromL8(L8 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.PackedValue); - return new(rgb, rgb, rgb, ushort.MaxValue); + return new Rgba64(rgb, rgb, rgb, ushort.MaxValue); } /// @@ -257,7 +257,7 @@ public partial struct Rgba64 : IPixel, IPackedVector public static Rgba64 FromLa16(La16 source) { ushort rgb = ColorNumerics.From8BitTo16Bit(source.L); - return new(rgb, rgb, rgb, ColorNumerics.From8BitTo16Bit(source.A)); + return new Rgba64(rgb, rgb, rgb, ColorNumerics.From8BitTo16Bit(source.A)); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs index a27cffad8..3f9cab32f 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/RgbaVector.cs @@ -115,7 +115,7 @@ public partial struct RgbaVector : IPixel public static RgbaVector FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One); - return new(source.X, source.Y, source.Z, source.W); + return new RgbaVector(source.X, source.Y, source.Z, source.W); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs index c76f87047..39c853a5e 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short2.cs @@ -29,7 +29,7 @@ public partial struct Short2 : IPixel, IPackedVector /// The x-component. /// The y-component. public Short2(float x, float y) - : this(new(x, y)) + : this(new Vector2(x, y)) { } @@ -75,7 +75,7 @@ public partial struct Short2 : IPixel, IPackedVector Vector2 scaled = this.ToVector2(); scaled += new Vector2(32767f); scaled /= 65534F; - return new(scaled, 0f, 1f); + return new Vector4(scaled, 0f, 1f); } /// @@ -98,12 +98,12 @@ public partial struct Short2 : IPixel, IPackedVector { Vector2 scaled = new Vector2(source.X, source.Y) * 65534F; scaled -= new Vector2(32767F); - return new() { PackedValue = Pack(scaled) }; + return new Short2 { PackedValue = Pack(scaled) }; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new(source.X, source.Y)) }; + public static Short2 FromVector4(Vector4 source) => new() { PackedValue = Pack(new Vector2(source.X, source.Y)) }; /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs index c657263c0..b6cece2be 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Short4.cs @@ -31,7 +31,7 @@ public partial struct Short4 : IPixel, IPackedVector /// The z-component. /// The w-component. public Short4(float x, float y, float z, float w) - : this(new(x, y, z, w)) + : this(new Vector4(x, y, z, w)) { } diff --git a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs index 7eb95569d..559fcdde0 100644 --- a/src/ImageSharp/Primitives/ColorMatrix.Impl.cs +++ b/src/ImageSharp/Primitives/ColorMatrix.Impl.cs @@ -181,11 +181,11 @@ public partial struct ColorMatrix float m41, float m42, float m43, float m44, float m51, float m52, float m53, float m54) { - this.X = new(m11, m12, m13, m14); - this.Y = new(m21, m22, m23, m24); - this.Z = new(m31, m32, m33, m34); - this.W = new(m41, m42, m43, m44); - this.V = new(m51, m52, m53, m54); + this.X = new Vector4(m11, m12, m13, m14); + this.Y = new Vector4(m21, m22, m23, m24); + this.Z = new Vector4(m31, m32, m33, m34); + this.W = new Vector4(m41, m42, m43, m44); + this.V = new Vector4(m51, m52, m53, m54); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Primitives/Complex64.cs b/src/ImageSharp/Primitives/Complex64.cs index 2a16df969..061e2bd80 100644 --- a/src/ImageSharp/Primitives/Complex64.cs +++ b/src/ImageSharp/Primitives/Complex64.cs @@ -53,7 +53,7 @@ internal readonly struct Complex64 : IEquatable [MethodImpl(InliningOptions.ShortMethod)] public static ComplexVector4 operator *(Complex64 value, Vector4 vector) { - return new() { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; + return new ComplexVector4 { Real = vector * value.Real, Imaginary = vector * value.Imaginary }; } /// @@ -67,7 +67,7 @@ internal readonly struct Complex64 : IEquatable { Vector4 real = (value.Real * vector.Real) - (value.Imaginary * vector.Imaginary); Vector4 imaginary = (value.Real * vector.Imaginary) + (value.Imaginary * vector.Real); - return new() { Real = real, Imaginary = imaginary }; + return new ComplexVector4 { Real = real, Imaginary = imaginary }; } /// diff --git a/src/ImageSharp/Primitives/DenseMatrix{T}.cs b/src/ImageSharp/Primitives/DenseMatrix{T}.cs index b39f306cb..692507096 100644 --- a/src/ImageSharp/Primitives/DenseMatrix{T}.cs +++ b/src/ImageSharp/Primitives/DenseMatrix{T}.cs @@ -36,7 +36,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new(columns, rows); + this.Size = new Size(columns, rows); this.Count = columns * rows; this.Data = new T[this.Columns * this.Rows]; } @@ -56,7 +56,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new(columns, rows); + this.Size = new Size(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; @@ -84,7 +84,7 @@ public readonly struct DenseMatrix : IEquatable> this.Rows = rows; this.Columns = columns; - this.Size = new(columns, rows); + this.Size = new Size(columns, rows); this.Count = this.Columns * this.Rows; this.Data = new T[this.Columns * this.Rows]; diff --git a/src/ImageSharp/Primitives/LongRational.cs b/src/ImageSharp/Primitives/LongRational.cs index 0b3380ca9..69139ac9c 100644 --- a/src/ImageSharp/Primitives/LongRational.cs +++ b/src/ImageSharp/Primitives/LongRational.cs @@ -133,22 +133,22 @@ internal readonly struct LongRational : IEquatable { if (value == 0.0) { - return new(0, 1); + return new LongRational(0, 1); } if (double.IsNaN(value)) { - return new(0, 0); + return new LongRational(0, 0); } if (double.IsPositiveInfinity(value)) { - return new(1, 0); + return new LongRational(1, 0); } if (double.IsNegativeInfinity(value)) { - return new(-1, 0); + return new LongRational(-1, 0); } long numerator = 1; @@ -208,14 +208,14 @@ internal readonly struct LongRational : IEquatable if (this.Numerator == this.Denominator) { - return new(1, 1); + return new LongRational(1, 1); } long gcd = GreatestCommonDivisor(Math.Abs(this.Numerator), Math.Abs(this.Denominator)); if (gcd > 1) { - return new(this.Numerator / gcd, this.Denominator / gcd); + return new LongRational(this.Numerator / gcd, this.Denominator / gcd); } return this; diff --git a/src/ImageSharp/Primitives/Number.cs b/src/ImageSharp/Primitives/Number.cs index fae67bbea..a996a94f4 100644 --- a/src/ImageSharp/Primitives/Number.cs +++ b/src/ImageSharp/Primitives/Number.cs @@ -47,19 +47,19 @@ public struct Number : IEquatable, IComparable /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(int value) => new Number(value); + public static implicit operator Number(int value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(uint value) => new Number(value); + public static implicit operator Number(uint value) => new(value); /// /// Converts the specified to an instance of this type. /// /// The value. - public static implicit operator Number(ushort value) => new Number((uint)value); + public static implicit operator Number(ushort value) => new((uint)value); /// /// Converts the specified to a . diff --git a/src/ImageSharp/Primitives/Point.cs b/src/ImageSharp/Primitives/Point.cs index 5eae087ed..8ace7ffac 100644 --- a/src/ImageSharp/Primitives/Point.cs +++ b/src/ImageSharp/Primitives/Point.cs @@ -232,7 +232,7 @@ public struct Point : IEquatable /// The transformation matrix used. /// The transformed . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new(point.X, point.Y), matrix)); + public static Point Transform(Point point, Matrix3x2 matrix) => Round(Vector2.Transform(new Vector2(point.X, point.Y), matrix)); /// /// Deconstructs this point into two integers. diff --git a/src/ImageSharp/Primitives/Rectangle.cs b/src/ImageSharp/Primitives/Rectangle.cs index a3cb89cf0..e2ae5071e 100644 --- a/src/ImageSharp/Primitives/Rectangle.cs +++ b/src/ImageSharp/Primitives/Rectangle.cs @@ -214,7 +214,7 @@ public struct Rectangle : IEquatable if (x2 >= x1 && y2 >= y1) { - return new(x1, y1, x2 - x1, y2 - y1); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -245,7 +245,7 @@ public struct Rectangle : IEquatable { unchecked { - return new( + return new Rectangle( (int)MathF.Ceiling(rectangle.X), (int)MathF.Ceiling(rectangle.Y), (int)MathF.Ceiling(rectangle.Width), @@ -261,9 +261,9 @@ public struct Rectangle : IEquatable /// A transformed rectangle. public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix) { - PointF bottomRight = Point.Transform(new(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = Point.Transform(rectangle.Location, matrix); - return new(topLeft, new(bottomRight - topLeft)); + return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); } /// @@ -276,7 +276,7 @@ public struct Rectangle : IEquatable { unchecked { - return new( + return new Rectangle( (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, @@ -294,7 +294,7 @@ public struct Rectangle : IEquatable { unchecked { - return new( + return new Rectangle( (int)MathF.Round(rectangle.X), (int)MathF.Round(rectangle.Y), (int)MathF.Round(rectangle.Width), @@ -316,7 +316,7 @@ public struct Rectangle : IEquatable int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Bottom, b.Bottom); - return new(x1, y1, x2 - x1, y2 - y1); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/RectangleF.cs b/src/ImageSharp/Primitives/RectangleF.cs index 9a7a97a13..68add77d0 100644 --- a/src/ImageSharp/Primitives/RectangleF.cs +++ b/src/ImageSharp/Primitives/RectangleF.cs @@ -207,7 +207,7 @@ public struct RectangleF : IEquatable if (x2 >= x1 && y2 >= y1) { - return new(x1, y1, x2 - x1, y2 - y1); + return new RectangleF(x1, y1, x2 - x1, y2 - y1); } return Empty; @@ -236,9 +236,9 @@ public struct RectangleF : IEquatable /// A transformed . public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix) { - PointF bottomRight = PointF.Transform(new(rectangle.Right, rectangle.Bottom), matrix); + PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix); PointF topLeft = PointF.Transform(rectangle.Location, matrix); - return new(topLeft, new(bottomRight - topLeft)); + return new RectangleF(topLeft, new SizeF(bottomRight - topLeft)); } /// @@ -255,7 +255,7 @@ public struct RectangleF : IEquatable float y1 = MathF.Min(a.Y, b.Y); float y2 = MathF.Max(a.Bottom, b.Bottom); - return new(x1, y1, x2 - x1, y2 - y1); + return new RectangleF(x1, y1, x2 - x1, y2 - y1); } /// diff --git a/src/ImageSharp/Primitives/SignedRational.cs b/src/ImageSharp/Primitives/SignedRational.cs index 2b62b4c3e..0f8e6518a 100644 --- a/src/ImageSharp/Primitives/SignedRational.cs +++ b/src/ImageSharp/Primitives/SignedRational.cs @@ -117,7 +117,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value) { - return new(value, false); + return new SignedRational(value, false); } /// @@ -130,7 +130,7 @@ public readonly struct SignedRational : IEquatable /// public static SignedRational FromDouble(double value, bool bestPrecision) { - return new(value, bestPrecision); + return new SignedRational(value, bestPrecision); } /// diff --git a/src/ImageSharp/Primitives/Size.cs b/src/ImageSharp/Primitives/Size.cs index 5ceab493f..0e65a8138 100644 --- a/src/ImageSharp/Primitives/Size.cs +++ b/src/ImageSharp/Primitives/Size.cs @@ -237,9 +237,9 @@ public struct Size : IEquatable /// A transformed size. public static SizeF Transform(Size size, Matrix3x2 matrix) { - Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); - return new(v.X, v.Y); + return new SizeF(v.X, v.Y); } /// diff --git a/src/ImageSharp/Primitives/SizeF.cs b/src/ImageSharp/Primitives/SizeF.cs index 88c3b8319..81c749875 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -191,9 +191,9 @@ public struct SizeF : IEquatable /// A transformed size. public static SizeF Transform(SizeF size, Matrix3x2 matrix) { - Vector2 v = Vector2.Transform(new(size.Width, size.Height), matrix); + Vector2 v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix); - return new(v.X, v.Y); + return new SizeF(v.X, v.Y); } /// diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index 9a76269b3..f572dd658 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -68,7 +68,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfWidth public static ValueSize PercentageOfWidth(float percentage) { - return new(percentage, ValueSizeType.PercentageOfWidth); + return new ValueSize(percentage, ValueSizeType.PercentageOfWidth); } /// @@ -78,7 +78,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type PercentageOfHeight public static ValueSize PercentageOfHeight(float percentage) { - return new(percentage, ValueSizeType.PercentageOfHeight); + return new ValueSize(percentage, ValueSizeType.PercentageOfHeight); } /// @@ -88,7 +88,7 @@ internal readonly struct ValueSize : IEquatable /// a Values size with type Absolute. public static ValueSize Absolute(float value) { - return new(value, ValueSizeType.Absolute); + return new ValueSize(value, ValueSizeType.Absolute); } /// diff --git a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs index 6af61338d..d7f4ba359 100644 --- a/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Normalization/HistogramEqualizationExtensions.cs @@ -16,7 +16,7 @@ public static class HistogramEqualizationExtensions /// The current image processing context. /// The . public static IImageProcessingContext HistogramEqualization(this IImageProcessingContext source) => - HistogramEqualization(source, new()); + HistogramEqualization(source, new HistogramEqualizationOptions()); /// /// Equalizes the histogram of an image to increases the contrast. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs index 256bac64e..3025806d4 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/CropExtensions.cs @@ -19,7 +19,7 @@ public static class CropExtensions /// The target image height. /// The . public static IImageProcessingContext Crop(this IImageProcessingContext source, int width, int height) => - Crop(source, new(0, 0, width, height)); + Crop(source, new Rectangle(0, 0, width, height)); /// /// Crops an image to the given rectangle. diff --git a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs index cca3e4241..96b30d4f8 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/PadExtensions.cs @@ -33,7 +33,7 @@ public static class PadExtensions ResizeOptions options = new() { // Prevent downsizing. - Size = new(Math.Max(width, size.Width), Math.Max(height, size.Height)), + Size = new Size(Math.Max(width, size.Width), Math.Max(height, size.Height)), Mode = ResizeMode.BoxPad, Sampler = KnownResamplers.NearestNeighbor, PadColor = color diff --git a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs index 3ac9553d4..4a09639f8 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/ResizeExtensions.cs @@ -77,7 +77,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, Size size, IResampler sampler, bool compand) - => Resize(source, size.Width, size.Height, sampler, new(0, 0, size.Width, size.Height), compand); + => Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand); /// /// Resizes an image to the given width and height with the given sampler. @@ -90,7 +90,7 @@ public static class ResizeExtensions /// The . /// Passing zero for one of height or width will automatically preserve the aspect ratio of the original image or the nearest possible ratio. public static IImageProcessingContext Resize(this IImageProcessingContext source, int width, int height, IResampler sampler, bool compand) - => Resize(source, width, height, sampler, new(0, 0, width, height), compand); + => Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand); /// /// Resizes an image to the given width and height with the given sampler and @@ -120,7 +120,7 @@ public static class ResizeExtensions { ResizeOptions options = new() { - Size = new(width, height), + Size = new Size(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, @@ -153,7 +153,7 @@ public static class ResizeExtensions { ResizeOptions options = new() { - Size = new(width, height), + Size = new Size(width, height), Mode = ResizeMode.Manual, Sampler = sampler, TargetRectangle = targetRectangle, diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index dedde797b..60f90b10f 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -34,7 +34,7 @@ public static class TransformExtensions this IImageProcessingContext source, AffineTransformBuilder builder, IResampler sampler) => - source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs an affine transform of an image using the specified sampling algorithm. @@ -96,7 +96,7 @@ public static class TransformExtensions this IImageProcessingContext source, ProjectiveTransformBuilder builder, IResampler sampler) => - source.Transform(new(Point.Empty, source.GetCurrentSize()), builder, sampler); + source.Transform(new Rectangle(Point.Empty, source.GetCurrentSize()), builder, sampler); /// /// Performs a projective transform of an image using the specified sampling algorithm. diff --git a/src/ImageSharp/Processing/KnownFilterMatrices.cs b/src/ImageSharp/Processing/KnownFilterMatrices.cs index 0b40fa945..fd512557d 100644 --- a/src/ImageSharp/Processing/KnownFilterMatrices.cs +++ b/src/ImageSharp/Processing/KnownFilterMatrices.cs @@ -221,7 +221,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new() + return new ColorMatrix { M11 = amount, M22 = amount, @@ -246,7 +246,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float contrast = (-.5F * amount) + .5F; - return new() + return new ColorMatrix { M11 = amount, M22 = amount, @@ -338,7 +338,7 @@ public static class KnownFilterMatrices // The matrix is set up to preserve the luminance of the image. // See http://graficaobscura.com/matrix/index.html // Number are taken from https://msdn.microsoft.com/en-us/library/jj192162(v=vs.85).aspx - return new() + return new ColorMatrix { M11 = .213F + (cosRadian * .787F) - (sinRadian * .213F), M21 = .715F - (cosRadian * .715F) - (sinRadian * .715F), @@ -367,7 +367,7 @@ public static class KnownFilterMatrices // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc float invert = 1F - (2F * amount); - return new() + return new ColorMatrix { M11 = invert, M22 = invert, @@ -389,7 +389,7 @@ public static class KnownFilterMatrices Guard.MustBeBetweenOrEqualTo(amount, 0, 1, nameof(amount)); // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new() + return new ColorMatrix { M11 = 1F, M22 = 1F, @@ -443,7 +443,7 @@ public static class KnownFilterMatrices Guard.MustBeGreaterThanOrEqualTo(amount, 0, nameof(amount)); amount--; - return new() + return new ColorMatrix { M11 = 1F, M22 = 1F, @@ -467,7 +467,7 @@ public static class KnownFilterMatrices amount = 1F - amount; // See https://cs.chromium.org/chromium/src/cc/paint/render_surface_filters.cc - return new() + return new ColorMatrix { M11 = .393F + (.607F * amount), M21 = .769F - (.769F * amount), diff --git a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs index 2e675cdd4..bc34f759a 100644 --- a/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/CloningImageProcessor{TPixel}.cs @@ -158,7 +158,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor[] destinationFrames = new ImageFrame[source.Frames.Count]; for (int i = 0; i < destinationFrames.Length; i++) { - destinationFrames[i] = new( + destinationFrames[i] = new ImageFrame( this.Configuration, destinationSize.Width, destinationSize.Height, @@ -166,7 +166,7 @@ public abstract class CloningImageProcessor : ICloningImageProcessor(this.Configuration, source.Metadata.DeepClone(), destinationFrames); } private void CheckFrameCount(Image a, Image b) diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs index 96daca47a..727e8e96a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor{TPixel}.cs @@ -68,7 +68,7 @@ internal class BoxBlurProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using Convolution2PassProcessor processor = new Convolution2PassProcessor(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); + using Convolution2PassProcessor processor = new(this.Configuration, this.Kernel, false, this.Source, this.SourceRectangle, this.BorderWrapModeX, this.BorderWrapModeY); processor.Apply(source); } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs index 08e8425bb..bccf19174 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DRowOperation{TPixel}.cs @@ -75,7 +75,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - Convolution2DState state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. @@ -141,7 +141,7 @@ internal readonly struct Convolution2DRowOperation : IRowOperation targetYBuffer = span.Slice(boundsWidth, boundsWidth); Span targetXBuffer = span.Slice(boundsWidth * 2, boundsWidth); - Convolution2DState state = new Convolution2DState(in this.kernelMatrixY, in this.kernelMatrixX, this.map); + Convolution2DState state = new(in this.kernelMatrixY, in this.kernelMatrixX, this.map); ref int sampleRowBase = ref state.GetSampleRow((uint)(y - this.bounds.Y)); // Clear the target buffers for each row run. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs index b3dae6baa..6f5388e22 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DState.cs @@ -22,8 +22,8 @@ internal readonly ref struct Convolution2DState KernelSamplingMap map) { // We check the kernels are the same size upstream. - this.KernelY = new(kernelY); - this.KernelX = new(kernelX); + this.KernelY = new ReadOnlyKernel(kernelY); + this.KernelX = new ReadOnlyKernel(kernelX); this.kernelHeight = (uint)kernelY.Rows; this.kernelWidth = (uint)kernelY.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs index 20e95d058..6663c4502 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionState.cs @@ -20,7 +20,7 @@ internal readonly ref struct ConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new(kernel); + this.Kernel = new ReadOnlyKernel(kernel); this.kernelHeight = (uint)kernel.Rows; this.kernelWidth = (uint)kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs index fbf576c23..502c34402 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs @@ -55,7 +55,7 @@ internal class EdgeDetector2DProcessor : ImageProcessor /// protected override void OnFrameApply(ImageFrame source) { - using Convolution2DProcessor processor = new Convolution2DProcessor( + using Convolution2DProcessor processor = new( this.Configuration, in this.kernelX, in this.kernelY, diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs index cd9f4d7ab..b51ed1819 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/Implementation/LaplacianKernelFactory.cs @@ -19,7 +19,7 @@ internal static class LaplacianKernelFactory Guard.MustBeGreaterThanOrEqualTo(length, 3u, nameof(length)); Guard.IsFalse(length % 2 == 0, nameof(length), "The kernel length must be an odd number."); - DenseMatrix kernel = new DenseMatrix((int)length); + DenseMatrix kernel = new((int)length); kernel.Fill(-1); int mid = (int)(length / 2); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs index 5b2c903ba..137334c29 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianConvolutionState.cs @@ -21,7 +21,7 @@ internal readonly ref struct MedianConvolutionState in DenseMatrix kernel, KernelSamplingMap map) { - this.Kernel = new(kernel); + this.Kernel = new Kernel(kernel); this.kernelHeight = kernel.Rows; this.kernelWidth = kernel.Columns; this.rowOffsetMap = map.GetRowOffsetSpan(); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index 64fd40f15..ca2cabab5 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -153,7 +153,7 @@ internal readonly struct MedianRowOperation : IRowOperation // Taking the W value from the source pixels, where the middle index in the kernelSpan is by definition the resulting pixel. // This will preserve the alpha value. - return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); + return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], kernelSpan[halfLength].W); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -176,6 +176,6 @@ internal readonly struct MedianRowOperation : IRowOperation zChannel.Sort(); wChannel.Sort(); - return new(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); + return new Vector4(xChannel[halfLength], yChannel[halfLength], zChannel[halfLength], wChannel[halfLength]); } } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index 6832e2498..ae4483f2e 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -99,7 +99,7 @@ internal static class BokehBlurKernelDataProvider NormalizeKernels(kernels, kernelParameters); // Store them in the cache for future use - info = new(kernelParameters, kernels); + info = new BokehBlurKernelData(kernelParameters, kernels); Cache.TryAdd(parameters, info); } @@ -167,7 +167,7 @@ internal static class BokehBlurKernelDataProvider value *= value; // Fill in the complex kernel values - Unsafe.Add(ref baseRef, (uint)i) = new( + Unsafe.Add(ref baseRef, (uint)i) = new Complex64( MathF.Exp(-a * value) * MathF.Cos(b * value), MathF.Exp(-a * value) * MathF.Sin(b * value)); } diff --git a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs index d58f9020c..57d8ef59a 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/ErrorDither.KnownTypes.cs @@ -65,7 +65,7 @@ public readonly partial struct ErrorDither { 0, 1 / divisor, 0, 0 } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateBurks() @@ -79,7 +79,7 @@ public readonly partial struct ErrorDither { 2 / divisor, 4 / divisor, 8 / divisor, 4 / divisor, 2 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateFloydSteinberg() @@ -93,7 +93,7 @@ public readonly partial struct ErrorDither { 3 / divisor, 5 / divisor, 1 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateJarvisJudiceNinke() @@ -108,7 +108,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 3 / divisor, 5 / divisor, 3 / divisor, 1 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateSierra2() @@ -122,7 +122,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 3 / divisor, 2 / divisor, 1 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateSierra3() @@ -137,7 +137,7 @@ public readonly partial struct ErrorDither { 0, 2 / divisor, 3 / divisor, 2 / divisor, 0 } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateSierraLite() @@ -151,7 +151,7 @@ public readonly partial struct ErrorDither { 1 / divisor, 1 / divisor, 0 } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateStevensonArce() @@ -167,7 +167,7 @@ public readonly partial struct ErrorDither { 5 / divisor, 0, 12 / divisor, 0, 12 / divisor, 0, 5 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } private static ErrorDither CreateStucki() @@ -182,6 +182,6 @@ public readonly partial struct ErrorDither { 1 / divisor, 2 / divisor, 4 / divisor, 2 / divisor, 1 / divisor } }; - return new(matrix, offset); + return new ErrorDither(matrix, offset); } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index d4dd10b73..b0622cac5 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -32,7 +32,7 @@ public readonly partial struct OrderedDither : IDither, IEquatable thresholdMatrix = new DenseMatrix((int)length); + DenseMatrix thresholdMatrix = new((int)length); float m2 = length * length; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs index 9fa331d7b..ec82f01d7 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDitherFactory.cs @@ -29,7 +29,7 @@ internal static class OrderedDitherFactory while (length > bayerLength); // Create our Bayer matrix that matches the given exponent and dimensions - DenseMatrix matrix = new DenseMatrix((int)length); + DenseMatrix matrix = new((int)length); uint i = 0; for (int y = 0; y < length; y++) { diff --git a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs index 2f4a0a9f0..0d4680e21 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/PaletteDitherProcessor{TPixel}.cs @@ -37,7 +37,7 @@ internal sealed class PaletteDitherProcessor : ImageProcessor this.paletteOwner = this.Configuration.MemoryAllocator.Allocate(sourcePalette.Length); Color.ToPixel(sourcePalette, this.paletteOwner.Memory.Span); - this.ditherProcessor = new( + this.ditherProcessor = new DitherProcessor( this.Configuration, this.paletteOwner.Memory, definition.DitherScale); diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index d5499d586..d2a99ce92 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -112,7 +112,7 @@ internal class DrawImageProcessor : ImageProcessor } // Sanitize the dimensions so that we don't try and sample outside the image. - Rectangle backgroundRectangle = Rectangle.Intersect(new(left, top, width, height), this.SourceRectangle); + Rectangle backgroundRectangle = Rectangle.Intersect(new Rectangle(left, top, width, height), this.SourceRectangle); Configuration configuration = this.Configuration; DrawImageProcessor.RowOperation operation = @@ -127,7 +127,7 @@ internal class DrawImageProcessor : ImageProcessor ParallelRowIterator.IterateRows( configuration, - new(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), + new Rectangle(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs index 5e491c1ee..f811bae0f 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor{TPixel}.cs @@ -174,7 +174,7 @@ internal class OilPaintingProcessor : ImageProcessor float green = greenBinSpan[maxIndex] / maxIntensity; float alpha = sourceRowVector4Span[x].W; - targetRowVector4Span[x] = new(red, green, blue, alpha); + targetRowVector4Span[x] = new Vector4(red, green, blue, alpha); } } diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs index f1014c0df..06cfa49b3 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor.cs @@ -37,7 +37,7 @@ internal sealed class PixelRowDelegateProcessor : IImageProcessor public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixel : unmanaged, IPixel => new PixelRowDelegateProcessor( - new(this.PixelRowOperation), + new PixelRowDelegate(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs index a3aba4cfc..d38ffc801 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelRowDelegateProcessor{TPixel,TDelegate}.cs @@ -96,7 +96,7 @@ internal sealed class PixelRowDelegateProcessor : ImageProces PixelOperations.Instance.ToVector4(this.configuration, rowSpan, span, this.modifiers); // Run the user defined pixel shader to the current row of pixels - Unsafe.AsRef(in this.rowProcessor).Invoke(span, new(this.startX, y)); + Unsafe.AsRef(in this.rowProcessor).Invoke(span, new Point(this.startX, y)); PixelOperations.Instance.FromVector4Destructive(this.configuration, span, rowSpan, this.modifiers); } diff --git a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs index a54a7bfd2..6786eb5f5 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PositionAwarePixelRowDelegateProcessor.cs @@ -38,7 +38,7 @@ internal sealed class PositionAwarePixelRowDelegateProcessor : IImageProcessor where TPixel : unmanaged, IPixel { return new PixelRowDelegateProcessor( - new(this.PixelRowOperation), + new PixelRowDelegate(this.PixelRowOperation), configuration, this.Modifiers, source, diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs index e91124958..3d54836c5 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationProcessor{TPixel}.cs @@ -81,7 +81,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz RowIntervalOperation operation = new(cdfData, tileYStartPositions, tileWidth, tileHeight, tileCount, halfTileWidth, luminanceLevels, source.PixelBuffer); ParallelRowIterator.IterateRowIntervals( this.Configuration, - new(0, 0, sourceWidth, tileYStartPositions.Count), + new Rectangle(0, 0, sourceWidth, tileYStartPositions.Count), in operation); // Fix left column @@ -145,7 +145,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = cdfData.RemapGreyValue(cdfX, cdfY, GetLuminance(pixel, luminanceLevels)); - pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } } } @@ -191,7 +191,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX, cdfY + 1, tileY, tileHeight, luminanceLevels); - pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); } tileY++; @@ -243,7 +243,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz { ref TPixel pixel = ref rowSpan[dx]; float luminanceEqualized = InterpolateBetweenTwoTiles(pixel, cdfData, cdfX, cdfY, cdfX + 1, cdfY, tileX, tileWidth, luminanceLevels); - pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } } @@ -432,7 +432,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz this.tileHeight, this.luminanceLevels); - pixel = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); + pixel = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, pixel.ToVector4().W)); tileX++; } @@ -515,7 +515,7 @@ internal class AdaptiveHistogramEqualizationProcessor : HistogramEqualiz ParallelRowIterator.IterateRowIntervals( this.configuration, - new(0, 0, this.sourceWidth, this.tileYStartPositions.Count), + new Rectangle(0, 0, this.sourceWidth, this.tileYStartPositions.Count), in operation); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index 93144653e..8ca4a86a2 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -383,7 +383,7 @@ internal class AdaptiveHistogramEqualizationSlidingWindowProcessor : His // Map the current pixel to the new equalized value. int luminance = GetLuminance(this.source[x, y], this.processor.LuminanceLevels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / numberOfPixelsMinusCdfMin; - this.targetPixels[x, y] = TPixel.FromVector4(new(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W)); + this.targetPixels[x, y] = TPixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, this.source[x, y].ToVector4().W)); // Remove top most row from the histogram, mirroring rows which exceeds the borders. if (this.useFastPath) diff --git a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs index f104ee34a..e830cc55f 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AutoLevelProcessor{TPixel}.cs @@ -150,7 +150,7 @@ internal class AutoLevelProcessor : HistogramEqualizationProcessor.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); @@ -214,7 +214,7 @@ internal class AutoLevelProcessor : HistogramEqualizationProcessor.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index b159847bb..3ab8f7431 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class GlobalHistogramEqualizationProcessor : HistogramEqualizat Vector4 vector = Unsafe.Add(ref vectorRef, (uint)x); int luminance = ColorNumerics.GetBT709Luminance(ref vector, levels); float luminanceEqualized = Unsafe.Add(ref cdfBase, (uint)luminance) / noOfPixelsMinusCdfMin; - Unsafe.Add(ref vectorRef, (uint)x) = new(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); + Unsafe.Add(ref vectorRef, (uint)x) = new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W); } PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorBuffer, pixelRow); diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs index 317fa7e60..d73e7bea1 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor{TPixel}.cs @@ -105,7 +105,7 @@ internal class GlowProcessor : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (1 - (.95F * (distance / this.maxDistance))), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs index b24ed7ed5..b08cd898e 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor{TPixel}.cs @@ -113,7 +113,7 @@ internal class VignetteProcessor : ImageProcessor for (int i = 0; i < this.bounds.Width; i++) { - float distance = Vector2.Distance(this.center, new(i + this.bounds.X, y)); + float distance = Vector2.Distance(this.center, new Vector2(i + this.bounds.X, y)); span[i] = Numerics.Clamp(this.blendPercent * (.9F * (distance / this.maxDistance)), 0, 1F); } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs index 9a46a9883..0a1032bf0 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer.cs @@ -16,7 +16,7 @@ public class OctreeQuantizer : IQuantizer /// using the default . /// public OctreeQuantizer() - : this(new()) + : this(new QuantizerOptions()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index 25d3e7416..07596b68a 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -44,7 +44,7 @@ public struct OctreeQuantizer : IQuantizer this.maxColors = this.Options.MaxColors; this.bitDepth = Numerics.Clamp(ColorNumerics.GetBitsNeededForColorDepth(this.maxColors), 1, 8); - this.octree = new(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); + this.octree = new Octree(configuration, this.bitDepth, this.maxColors, this.Options.TransparencyThreshold); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.pixelMap = default; this.palette = default; @@ -547,14 +547,14 @@ public struct OctreeQuantizer : IQuantizer Vector4 vector = Vector4.Clamp( (sum + offset) / this.PixelCount, Vector4.Zero, - new(255)); + new Vector4(255)); if (vector.W < octree.transparencyThreshold255) { vector = Vector4.Zero; } - palette[paletteIndex] = TPixel.FromRgba32(new((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); + palette[paletteIndex] = TPixel.FromRgba32(new Rgba32((byte)vector.X, (byte)vector.Y, (byte)vector.Z, (byte)vector.W)); this.PaletteIndex = paletteIndex++; } diff --git a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs index 91d086fc6..a49691515 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/PaletteQuantizer.cs @@ -19,7 +19,7 @@ public class PaletteQuantizer : IQuantizer /// /// The color palette. public PaletteQuantizer(ReadOnlyMemory palette) - : this(palette, new()) + : this(palette, new QuantizerOptions()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs index b1dace40b..fa1763367 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WebSafePaletteQuantizer.cs @@ -12,7 +12,7 @@ public sealed class WebSafePaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WebSafePaletteQuantizer() - : this(new()) + : this(new QuantizerOptions()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs index 02c217c36..cd7b80e81 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WernerPaletteQuantizer.cs @@ -13,7 +13,7 @@ public sealed class WernerPaletteQuantizer : PaletteQuantizer /// Initializes a new instance of the class. /// public WernerPaletteQuantizer() - : this(new()) + : this(new QuantizerOptions()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs index cda78c7d1..86d798d96 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer.cs @@ -15,7 +15,7 @@ public class WuQuantizer : IQuantizer /// using the default . /// public WuQuantizer() - : this(new()) + : this(new QuantizerOptions()) { } diff --git a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs index cb7020486..03d6ac0da 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/WuQuantizer{TPixel}.cs @@ -513,7 +513,7 @@ internal struct WuQuantizer : IQuantizer continue; } - vector = new(half.R, half.G, half.B, half.A); + vector = new Vector4(half.R, half.G, half.B, half.A); temp += Vector4.Dot(vector, vector) / half.Weight; if (temp > max) diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs index 5465b502b..37e61b7d7 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor{TPixel}.cs @@ -29,7 +29,7 @@ internal class CropProcessor : TransformProcessor => this.cropRectangle = definition.CropRectangle; /// - protected override Size GetDestinationSize() => new Size(this.cropRectangle.Width, this.cropRectangle.Height); + protected override Size GetDestinationSize() => new(this.cropRectangle.Width, this.cropRectangle.Height); /// protected override void OnFrameApply(ImageFrame source, ImageFrame destination) @@ -50,7 +50,7 @@ internal class CropProcessor : TransformProcessor ParallelExecutionSettings parallelSettings = ParallelExecutionSettings.FromConfiguration(this.Configuration).MultiplyMinimumPixelsPerTask(4); - RowOperation operation = new RowOperation(bounds, source.PixelBuffer, destination.PixelBuffer); + RowOperation operation = new(bounds, source.PixelBuffer, destination.PixelBuffer); ParallelRowIterator.IterateRows( bounds, diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index 6115ded03..b3919e584 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -132,7 +132,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < destinationRowSpan.Length; x++) { - Vector2 point = Vector2.Transform(new(x, y), this.matrix); + Vector2 point = Vector2.Transform(new Vector2(x, y), this.matrix); int px = (int)MathF.Round(point.X); int py = (int)MathF.Round(point.Y); @@ -204,7 +204,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR for (int x = 0; x < span.Length; x++) { - Vector2 point = Vector2.Transform(new(x, y), matrix); + Vector2 point = Vector2.Transform(new Vector2(x, y), matrix); float pY = point.Y; float pX = point.X; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs index e9e2849ae..d90f948b6 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeHelper.cs @@ -72,7 +72,7 @@ internal static class ResizeHelper // case ResizeMode.Stretch: default: - return (new(Sanitize(width), Sanitize(height)), new(0, 0, Sanitize(width), Sanitize(height))); + return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(0, 0, Sanitize(width), Sanitize(height))); } } @@ -143,7 +143,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } // Switch to pad mode to downscale and calculate from there. @@ -253,7 +253,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMaxRectangle( @@ -282,7 +282,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateMinRectangle( @@ -298,7 +298,7 @@ internal static class ResizeHelper // Don't upscale if (width > sourceWidth || height > sourceHeight) { - return (new(sourceWidth, sourceHeight), new(0, 0, sourceWidth, sourceHeight)); + return (new Size(sourceWidth, sourceHeight), new Rectangle(0, 0, sourceWidth, sourceHeight)); } // Find the shortest distance to go. @@ -330,7 +330,7 @@ internal static class ResizeHelper } // Replace the size to match the rectangle. - return (new(Sanitize(targetWidth), Sanitize(targetHeight)), new(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(targetWidth), Sanitize(targetHeight)), new Rectangle(0, 0, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculatePadRectangle( @@ -398,7 +398,7 @@ internal static class ResizeHelper } // Target image width and height can be different to the rectangle width and height. - return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } private static (Size Size, Rectangle Rectangle) CalculateManualRectangle( @@ -419,7 +419,7 @@ internal static class ResizeHelper int targetHeight = targetRectangle.Height > 0 ? targetRectangle.Height : height; // Target image width and height can be different to the rectangle width and height. - return (new(Sanitize(width), Sanitize(height)), new(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); + return (new Size(Sanitize(width), Sanitize(height)), new Rectangle(targetX, targetY, Sanitize(targetWidth), Sanitize(targetHeight))); } [DoesNotReturn] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index fb4d31988..c1907bb52 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -255,7 +255,7 @@ internal partial class ResizeKernelMap : IDisposable ref float rowReference = ref MemoryMarshal.GetReference(rowSpan); float* rowPtr = (float*)Unsafe.AsPointer(ref rowReference); - return new(left, rowPtr, length); + return new ResizeKernel(left, rowPtr, length); } [Conditional("DEBUG")] diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs index a2bd29116..a047015d9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs @@ -158,7 +158,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling float widthFactor = sourceRectangle.Width / (float)destinationRectangle.Width; float heightFactor = sourceRectangle.Height / (float)destinationRectangle.Height; - NNRowOperation operation = new NNRowOperation( + NNRowOperation operation = new( sourceRectangle, destinationRectangle, interest, @@ -208,7 +208,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling // To reintroduce parallel processing, we would launch multiple workers // for different row intervals of the image. - using ResizeWorker worker = new ResizeWorker( + using ResizeWorker worker = new( configuration, sourceRegion, conversionModifiers, @@ -218,7 +218,7 @@ internal class ResizeProcessor : TransformProcessor, IResampling destinationRectangle.Location); worker.Initialize(); - RowInterval workingInterval = new RowInterval(interest.Top, interest.Bottom); + RowInterval workingInterval = new(interest.Top, interest.Bottom); worker.FillDestinationPixels(workingInterval, destination.PixelBuffer); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 3da3fcb6a..cce27a401 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -89,7 +89,7 @@ internal sealed class ResizeWorker : IDisposable this.tempRowBuffer = configuration.MemoryAllocator.Allocate(this.sourceRectangle.Width); this.tempColumnBuffer = configuration.MemoryAllocator.Allocate(targetWorkingRect.Width); - this.currentWindow = new(0, this.workerHeight); + this.currentWindow = new RowInterval(0, this.workerHeight); } public void Dispose() @@ -158,7 +158,7 @@ internal sealed class ResizeWorker : IDisposable 0, this.windowBandHeight); - this.currentWindow = new(minY, maxY); + this.currentWindow = new RowInterval(minY, maxY); // Calculate the remainder: this.CalculateFirstPassValues(this.currentWindow.Slice(this.windowBandHeight)); diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index 1813be2fd..06a2dd292 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -407,10 +407,10 @@ internal static class TransformUtils float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) // Apply the offset relative to the scale - SizeF offsetSize = usePixelSpace ? new(scaleX, scaleY) : SizeF.Empty; + SizeF offsetSize = usePixelSpace ? new SizeF(scaleX, scaleY) : SizeF.Empty; // Subtract the offset size to translate to the appropriate space (pixel or coordinate). - if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the correct space. return Size.Ceiling(ConstrainSize(bounds) + offsetSize); @@ -455,11 +455,11 @@ internal static class TransformUtils { float scaleX = 1F / new Vector2(matrix.M11, matrix.M21).Length(); // sqrt(M11^2 + M21^2) float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) - offsetSize = new(scaleX, scaleY); + offsetSize = new SizeF(scaleX, scaleY); } // Subtract the offset size to translate to the pixel space. - if (TryGetTransformedRectangle(new(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) { // Add the offset size back to translate the transformed bounds to the coordinate space. return Size.Ceiling((constrain ? ConstrainSize(bounds) : bounds.Size) + offsetSize); @@ -485,10 +485,10 @@ internal static class TransformUtils return false; } - Vector2 tl = Vector2.Transform(new(rectangle.Left, rectangle.Top), matrix); - Vector2 tr = Vector2.Transform(new(rectangle.Right, rectangle.Top), matrix); - Vector2 bl = Vector2.Transform(new(rectangle.Left, rectangle.Bottom), matrix); - Vector2 br = Vector2.Transform(new(rectangle.Right, rectangle.Bottom), matrix); + Vector2 tl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Top), matrix); + Vector2 tr = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Top), matrix); + Vector2 bl = Vector2.Transform(new Vector2(rectangle.Left, rectangle.Bottom), matrix); + Vector2 br = Vector2.Transform(new Vector2(rectangle.Right, rectangle.Bottom), matrix); bounds = GetBoundingRectangle(tl, tr, bl, br); return true; @@ -540,7 +540,7 @@ internal static class TransformUtils width = rectangle.Width; } - return new(width, height); + return new Size(width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index 321196582..82b897ea5 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -69,7 +69,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -87,7 +87,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder PrependRotationRadians(float radians, Vector2 origin) - => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); + => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); /// /// Appends a centered rotation matrix using the given rotation in degrees. @@ -103,7 +103,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -121,7 +121,7 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder AppendRotationRadians(float radians, Vector2 origin) - => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new(origin, 0))); + => this.AppendMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); /// /// Prepends a scale matrix from the given uniform scale. @@ -187,7 +187,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -207,7 +207,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.PrependMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.PrependMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Appends a centered skew matrix from the give angles in degrees. @@ -225,7 +225,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -245,7 +245,7 @@ public class ProjectiveTransformBuilder /// The skew origin point. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY, Vector2 origin) - => this.AppendMatrix(new(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); + => this.AppendMatrix(new Matrix4x4(Matrix3x2.CreateSkew(radiansX, radiansY, origin))); /// /// Prepends a translation matrix from the given vector. @@ -261,7 +261,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder PrependTranslation(Vector2 position) - => this.PrependMatrix(Matrix4x4.CreateTranslation(new(position, 0))); + => this.PrependMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); /// /// Appends a translation matrix from the given vector. @@ -277,7 +277,7 @@ public class ProjectiveTransformBuilder /// The translation position. /// The . public ProjectiveTransformBuilder AppendTranslation(Vector2 position) - => this.AppendMatrix(Matrix4x4.CreateTranslation(new(position, 0))); + => this.AppendMatrix(Matrix4x4.CreateTranslation(new Vector3(position, 0))); /// /// Prepends a quad distortion matrix using the specified corner points. @@ -289,7 +289,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder PrependQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Prepend(size => TransformUtils.CreateQuadDistortionMatrix( - new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Appends a quad distortion matrix using the specified corner points. @@ -301,7 +301,7 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder AppendQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Append(size => TransformUtils.CreateQuadDistortionMatrix( - new(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); /// /// Prepends a raw matrix. @@ -359,7 +359,7 @@ public class ProjectiveTransformBuilder Guard.MustBeGreaterThan(sourceRectangle.Height, 0, nameof(sourceRectangle)); // Translate the origin matrix to cater for source rectangle offsets. - Matrix4x4 matrix = Matrix4x4.CreateTranslation(new(-sourceRectangle.Location, 0)); + Matrix4x4 matrix = Matrix4x4.CreateTranslation(new Vector3(-sourceRectangle.Location, 0)); Size size = sourceRectangle.Size; diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs index e263e3c62..92d5bcdbf 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromRgba32Bytes.cs @@ -49,7 +49,7 @@ public abstract class FromRgba32Bytes for (int i = 0; i < this.Count; i++) { int i4 = i * 4; - d[i] = TPixel.FromRgba32(new(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); + d[i] = TPixel.FromRgba32(new Rgba32(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3])); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs index 53b76201c..eec926a23 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/DecodeBmp.cs @@ -37,6 +37,6 @@ public class DecodeBmp { using MemoryStream memoryStream = new(this.bmpBytes); using Image image = Image.Load(memoryStream); - return new(image.Width, image.Height); + return new Size(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs index 84428d2fc..3238e8dac 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeEncodeGif.cs @@ -23,7 +23,7 @@ public abstract class DecodeEncodeGif private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); [GlobalSetup] - public void Setup() => this.outputStream = new(); + public void Setup() => this.outputStream = new MemoryStream(); [GlobalCleanup] public void Cleanup() => this.outputStream.Close(); @@ -54,6 +54,6 @@ public class DecodeEncodeGif_CoarsePaletteEncoder : DecodeEncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs index 044a50d04..117cdd25b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/DecodeGif.cs @@ -36,6 +36,6 @@ public class DecodeGif { using MemoryStream memoryStream = new(this.gifBytes); using Image image = Image.Load(memoryStream); - return new(image.Width, image.Height); + return new Size(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs index 60c14ff25..b8f8f7851 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGif.cs @@ -38,7 +38,7 @@ public abstract class EncodeGif this.bmpDrawing = SDImage.FromStream(this.bmpStream); this.bmpStream.Position = 0; - this.magickImage = new(this.bmpStream); + this.magickImage = new MagickImageCollection(this.bmpStream); } } @@ -83,6 +83,6 @@ public class EncodeGif_CoarsePaletteEncoder : EncodeGif { protected override GifEncoder Encoder => new() { - Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) + Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4, ColorMatchingMode = ColorMatchingMode.Coarse }) }; } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs index 7a0542981..303272837 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs @@ -24,7 +24,7 @@ public class EncodeGifMultiple : MultiImageBenchmarkBase.WithImagesPreloaded // Try to get as close to System.Drawing's output as possible GifEncoder options = new() { - Quantizer = new WebSafePaletteQuantizer(new() { Dither = KnownDitherings.Bayer4x4 }) + Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = KnownDitherings.Bayer4x4 }) }; img.Save(ms, options); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs index 29a3ae5de..4ea0a92f1 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_CopyTo2x2.cs @@ -185,15 +185,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - Vector2 xLeft = new Vector2(sLeft.X); - Vector2 yLeft = new Vector2(sLeft.Y); - Vector2 zLeft = new Vector2(sLeft.Z); - Vector2 wLeft = new Vector2(sLeft.W); + Vector2 xLeft = new(sLeft.X); + Vector2 yLeft = new(sLeft.Y); + Vector2 zLeft = new(sLeft.Z); + Vector2 wLeft = new(sLeft.W); - Vector2 xRight = new Vector2(sRight.X); - Vector2 yRight = new Vector2(sRight.Y); - Vector2 zRight = new Vector2(sRight.Z); - Vector2 wRight = new Vector2(sRight.W); + Vector2 xRight = new(sRight.X); + Vector2 yRight = new(sRight.Y); + Vector2 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); dTopLeft = xLeft; Unsafe.Add(ref dTopLeft, 1) = yLeft; @@ -245,15 +245,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); ref Vector2 dBottomRight = ref Unsafe.Add(ref dBottomLeft, 4); - Vector4 xLeft = new Vector4(sLeft.X); - Vector4 yLeft = new Vector4(sLeft.Y); - Vector4 zLeft = new Vector4(sLeft.Z); - Vector4 wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - Vector4 xRight = new Vector4(sRight.X); - Vector4 yRight = new Vector4(sRight.Y); - Vector4 zRight = new Vector4(sRight.Z); - Vector4 wRight = new Vector4(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector4 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -303,15 +303,15 @@ public class Block8x8F_CopyTo2x2 ref Vector2 dTopLeft = ref Unsafe.Add(ref destBase, (uint)(2 * row * destStride)); ref Vector2 dBottomLeft = ref Unsafe.Add(ref dTopLeft, (uint)destStride); - Vector4 xLeft = new Vector4(sLeft.X); - Vector4 yLeft = new Vector4(sLeft.Y); - Vector4 zLeft = new Vector4(sLeft.Z); - Vector4 wLeft = new Vector4(sLeft.W); + Vector4 xLeft = new(sLeft.X); + Vector4 yLeft = new(sLeft.Y); + Vector4 zLeft = new(sLeft.Z); + Vector4 wLeft = new(sLeft.W); - Vector4 xRight = new Vector4(sRight.X); - Vector4 yRight = new Vector4(sRight.Y); - Vector4 zRight = new Vector4(sRight.Z); - Vector2 wRight = new Vector2(sRight.W); + Vector4 xRight = new(sRight.X); + Vector4 yRight = new(sRight.Y); + Vector4 zRight = new(sRight.Z); + Vector2 wRight = new(sRight.W); Unsafe.As(ref dTopLeft) = xLeft; Unsafe.As(ref Unsafe.Add(ref dTopLeft, 1)) = yLeft; @@ -362,25 +362,25 @@ public class Block8x8F_CopyTo2x2 ref Vector4 dTopLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)offset)); ref Vector4 dBottomLeft = ref Unsafe.As(ref Unsafe.Add(ref destBase, (uint)(offset + destStride))); - Vector4 xyLeft = new Vector4(sLeft.X) + Vector4 xyLeft = new(sLeft.X) { Z = sLeft.Y, W = sLeft.Y }; - Vector4 zwLeft = new Vector4(sLeft.Z) + Vector4 zwLeft = new(sLeft.Z) { Z = sLeft.W, W = sLeft.W }; - Vector4 xyRight = new Vector4(sRight.X) + Vector4 xyRight = new(sRight.X) { Z = sRight.Y, W = sRight.Y }; - Vector4 zwRight = new Vector4(sRight.Z) + Vector4 zwRight = new(sRight.Z) { Z = sRight.W, W = sRight.W diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs index ea8a1c47b..45c6f63b9 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/BlockOperations/Block8x8F_DivideRound.cs @@ -19,8 +19,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg.BlockOperations; public unsafe class Block8x8F_DivideRound { private const int ExecutionCount = 5; // Added this to reduce the effect of copying the blocks - private static readonly Vector4 MinusOne = new Vector4(-1); - private static readonly Vector4 Half = new Vector4(0.5f); + private static readonly Vector4 MinusOne = new(-1); + private static readonly Vector4 Half = new(0.5f); private Block8x8F inputDividend; private Block8x8F inputDivisor; diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs index 959522d81..436aa9bcd 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/ColorConversion/ColorConversionBenchmark.cs @@ -38,7 +38,7 @@ public abstract class ColorConversionBenchmark float minVal = 0f, float maxVal = 255f) { - Random rnd = new Random(42); + Random rnd = new(42); Buffer2D[] buffers = new Buffer2D[componentCount]; for (int i = 0; i < componentCount; i++) { diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs index 6e089d443..dbd255722 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg.cs @@ -19,7 +19,7 @@ public class DecodeJpeg { this.decoder = JpegDecoder.Instance; byte[] bytes = File.ReadAllBytes(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, imageSubpath)); - this.preloadedImageStream = new(bytes); + this.preloadedImageStream = new MemoryStream(bytes); } private void GenericBenchmark() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs index 91ee82136..e7b66576d 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpegParseStreamOnly.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.IO; @@ -38,7 +39,7 @@ public class DecodeJpegParseStreamOnly { using MemoryStream memoryStream = new(this.jpegBytes); using BufferedReadStream bufferedStream = new(Configuration.Default, memoryStream); - JpegDecoderOptions options = new() { GeneralOptions = new() { SkipMetadata = true } }; + JpegDecoderOptions options = new() { GeneralOptions = new DecoderOptions { SkipMetadata = true } }; using JpegDecoderCore decoder = new(options); NoopSpectralConverter spectralConverter = new(); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs index 78beda5ef..9a4ee3967 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/DecodeJpeg_ImageSpecific.cs @@ -49,8 +49,8 @@ public class DecodeJpeg_ImageSpecific public Size ImageSharp() { using MemoryStream memoryStream = new(this.jpegBytes); - using Image image = Image.Load(new() { SkipMetadata = true }, memoryStream); - return new(image.Width, image.Height); + using Image image = Image.Load(new DecoderOptions { SkipMetadata = true }, memoryStream); + return new Size(image.Width, image.Height); } /* diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs index b865bb85d..c7cecd1a5 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs @@ -38,9 +38,9 @@ public class EncodeJpegComparison using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.imageImageSharp = Image.Load(imageBinaryStream); - this.encoderImageSharp = new() { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; + this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 }; - this.destinationStream = new(); + this.destinationStream = new MemoryStream(); } [GlobalCleanup(Target = nameof(BenchmarkImageSharp))] @@ -67,7 +67,7 @@ public class EncodeJpegComparison this.imageSkiaSharp = SKBitmap.Decode(imageBinaryStream); - this.destinationStream = new(); + this.destinationStream = new MemoryStream(); } [GlobalCleanup(Target = nameof(BenchmarkSkiaSharp))] diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs index 2e1cae973..858917995 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs @@ -44,13 +44,13 @@ public class EncodeJpegFeatures { using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); this.bmpCore = Image.Load(imageBinaryStream); - this.encoder = new() + this.encoder = new JpegEncoder { Quality = this.Quality, ColorType = this.TargetColorSpace, Interleaved = true, }; - this.destinationStream = new(); + this.destinationStream = new MemoryStream(); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs index 64d06ac17..0adc52441 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/MultiImageBenchmarkBase.cs @@ -155,7 +155,7 @@ public abstract class MultiImageBenchmarkBase this.FileNamesToImageSharpImages[fn] = Image.Load(ms1); } - this.FileNamesToSystemDrawingImages[fn] = new(new MemoryStream(bytes)); + this.FileNamesToSystemDrawingImages[fn] = new Bitmap(new MemoryStream(bytes)); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs index 4c60de663..125b42680 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Png/EncodeIndexedPng.cs @@ -52,7 +52,7 @@ public class EncodeIndexedPng public void PngCoreOctreeNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new OctreeQuantizer(new() { Dither = null }) }; + PngEncoder options = new() { Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -68,7 +68,7 @@ public class EncodeIndexedPng public void PngCorePaletteNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new() { Dither = null }) }; + PngEncoder options = new() { Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null }) }; this.bmpCore.SaveAsPng(memoryStream, options); } @@ -84,7 +84,7 @@ public class EncodeIndexedPng public void PngCoreWuNoDither() { using MemoryStream memoryStream = new(); - PngEncoder options = new() { Quantizer = new WuQuantizer(new() { Dither = null }), ColorType = PngColorType.Palette }; + PngEncoder options = new() { Quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }), ColorType = PngColorType.Palette }; this.bmpCore.SaveAsPng(memoryStream, options); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs index c9ab74eda..169a44d91 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tga/EncodeTga.cs @@ -26,7 +26,7 @@ public class EncodeTga if (this.tga == null) { this.tga = Image.Load(this.TestImageFullPath); - this.tgaMagick = new(this.TestImageFullPath); + this.tgaMagick = new MagickImage(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs index 44c04caef..6fa6a15ed 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Tiff/EncodeTiff.cs @@ -62,7 +62,7 @@ public class EncodeTiff ImageCodecInfo codec = FindCodecForType("image/tiff"); using EncoderParameters parameters = new(1) { - Param = { [0] = new(Encoder.Compression, (long)Cast(this.Compression)) } + Param = { [0] = new EncoderParameter(Encoder.Compression, (long)Cast(this.Compression)) } }; using MemoryStream memoryStream = new(); diff --git a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs index 9c134c0e1..3b9058498 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Webp/EncodeWebp.cs @@ -30,7 +30,7 @@ public class EncodeWebp if (this.webp == null) { this.webp = Image.Load(this.TestImageFullPath); - this.webpMagick = new(this.TestImageFullPath); + this.webpMagick = new MagickImage(this.TestImageFullPath); } } diff --git a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs index 38715e6ca..5166c89a9 100644 --- a/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs +++ b/tests/ImageSharp.Benchmarks/Color/ColorEquality.cs @@ -15,5 +15,5 @@ public class ColorEquality [Benchmark(Description = "ImageSharp Color Equals")] public bool ColorEqual() - => new Rgba32(128, 128, 128, 128).Equals(new(128, 128, 128, 128)); + => new Rgba32(128, 128, 128, 128).Equals(new Rgba32(128, 128, 128, 128)); } diff --git a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs index dcc46df37..b847e3ac5 100644 --- a/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs +++ b/tests/ImageSharp.Benchmarks/Color/RgbWorkingSpaceAdapt.cs @@ -13,7 +13,7 @@ public class RgbWorkingSpaceAdapt private static readonly RGBColor RGBColor = new(0.206162, 0.260277, 0.746717); - private static readonly ColorProfileConverter ColorProfileConverter = new(new() { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); + private static readonly ColorProfileConverter ColorProfileConverter = new(new ColorConversionOptions { SourceRgbWorkingSpace = KnownRgbWorkingSpaces.WideGamutRgb, TargetRgbWorkingSpace = KnownRgbWorkingSpaces.SRgb }); private static readonly IColorConverter ColourfulConverter = new ConverterBuilder().FromRGB(RGBWorkingSpaces.WideGamutRGB).ToRGB(RGBWorkingSpaces.sRGB).Build(); diff --git a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs index 37db166ae..093397ad5 100644 --- a/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs +++ b/tests/ImageSharp.Benchmarks/Color/YcbCrToRgb.cs @@ -22,7 +22,7 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (0.34414F * ccb) - (0.71414F * ccr), 0, 255); byte b = (byte)Numerics.Clamp(y + (1.772F * ccb), 0, 255); - return new(r, g, b); + return new Vector3(r, g, b); } [Benchmark(Description = "Scaled Integer Conversion")] @@ -45,6 +45,6 @@ public class YcbCrToRgb byte g = (byte)Numerics.Clamp(y - (g0 >> 10) - (g1 >> 10), 0, 255); byte b = (byte)Numerics.Clamp(y + (b0 >> 10), 0, 255); - return new(r, g, b); + return new Vector3(r, g, b); } } diff --git a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs index 30023feca..64a8092c6 100644 --- a/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs +++ b/tests/ImageSharp.Benchmarks/General/Adler32Benchmark.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Benchmarks.General; public class Adler32Benchmark { private byte[] data; - private readonly SharpAdler32 adler = new SharpAdler32(); + private readonly SharpAdler32 adler = new(); [Params(1024, 2048, 4096)] public int Count { get; set; } diff --git a/tests/ImageSharp.Benchmarks/General/Array2D.cs b/tests/ImageSharp.Benchmarks/General/Array2D.cs index 2d244607b..f0a36ee1d 100644 --- a/tests/ImageSharp.Benchmarks/General/Array2D.cs +++ b/tests/ImageSharp.Benchmarks/General/Array2D.cs @@ -44,7 +44,7 @@ public class Array2D this.jaggedData[i] = new float[this.Count]; } - this.matrix = new(this.array2D); + this.matrix = new DenseMatrix(this.array2D); this.Min = (this.Count / 2) - 10; this.Min = Math.Max(0, this.Min); diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs index 458927a35..b61ba27ff 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampSpan.cs @@ -12,7 +12,7 @@ public class ClampSpan public void Setup() { - Random r = new Random(); + Random r = new(); for (int i = 0; i < A.Length; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs index 5d93d2083..186f88bb7 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs @@ -42,13 +42,13 @@ public class ClampVector4 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorClamp(float x, float min, float max) { - return Vector4.Clamp(new(x), new(min), new(max)); + return Vector4.Clamp(new Vector4(x), new Vector4(min), new Vector4(max)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector4 ClampUsingVectorMinMax(float x, float min, float max) { - return Vector4.Min(new(max), Vector4.Max(new(min), new(x))); + return Vector4.Min(new Vector4(max), Vector4.Max(new Vector4(min), new Vector4(x))); } // RESULTS diff --git a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs index 85daa5bd2..031f9ecf2 100644 --- a/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs +++ b/tests/ImageSharp.Benchmarks/General/CopyBuffers.cs @@ -36,11 +36,11 @@ public class CopyBuffers public void Setup() { this.sourceArray = new byte[this.Count]; - this.sourceMemory = new(this.sourceArray); + this.sourceMemory = new Memory(this.sourceArray); this.sourceHandle = this.sourceMemory.Pin(); this.destArray = new byte[this.Count]; - this.destMemory = new(this.destArray); + this.destMemory = new Memory(this.destArray); this.destHandle = this.destMemory.Pin(); } diff --git a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs index f9b32d22a..d32e1fdd0 100644 --- a/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs +++ b/tests/ImageSharp.Benchmarks/General/IO/BufferedStreams.cs @@ -31,28 +31,28 @@ public class BufferedStreams [GlobalSetup] public void CreateStreams() { - this.stream1 = new(this.buffer); - this.stream2 = new(this.buffer); - this.stream3 = new(this.buffer); - this.stream4 = new(this.buffer); - this.stream5 = new(this.buffer); - this.stream6 = new(this.buffer); - this.stream6 = new(this.buffer); - - this.chunkedMemoryStream1 = new(Configuration.Default.MemoryAllocator); + this.stream1 = new MemoryStream(this.buffer); + this.stream2 = new MemoryStream(this.buffer); + this.stream3 = new MemoryStream(this.buffer); + this.stream4 = new MemoryStream(this.buffer); + this.stream5 = new MemoryStream(this.buffer); + this.stream6 = new MemoryStream(this.buffer); + this.stream6 = new MemoryStream(this.buffer); + + this.chunkedMemoryStream1 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream1.Write(this.buffer); this.chunkedMemoryStream1.Position = 0; - this.chunkedMemoryStream2 = new(Configuration.Default.MemoryAllocator); + this.chunkedMemoryStream2 = new ChunkedMemoryStream(Configuration.Default.MemoryAllocator); this.chunkedMemoryStream2.Write(this.buffer); this.chunkedMemoryStream2.Position = 0; - this.bufferedStream1 = new(Configuration.Default, this.stream3); - this.bufferedStream2 = new(Configuration.Default, this.stream4); - this.bufferedStream3 = new(Configuration.Default, this.chunkedMemoryStream1); - this.bufferedStream4 = new(Configuration.Default, this.chunkedMemoryStream2); - this.bufferedStreamWrap1 = new(this.stream5); - this.bufferedStreamWrap2 = new(this.stream6); + this.bufferedStream1 = new BufferedReadStream(Configuration.Default, this.stream3); + this.bufferedStream2 = new BufferedReadStream(Configuration.Default, this.stream4); + this.bufferedStream3 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream1); + this.bufferedStream4 = new BufferedReadStream(Configuration.Default, this.chunkedMemoryStream2); + this.bufferedStreamWrap1 = new BufferedReadStreamWrapper(this.stream5); + this.bufferedStreamWrap2 = new BufferedReadStreamWrapper(this.stream6); } [GlobalCleanup] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs index 33fe56fc6..c864e26c6 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromRgba32.cs @@ -96,9 +96,9 @@ public abstract class PixelConversion_ConvertFromRgba32 [GlobalSetup] public void Setup() { - this.CompatibleMemLayoutRunner = new(this.Count); - this.PermutedRunnerRgbaToArgb = new(this.Count); - this.RunnerRgbaToRgbaVector = new(this.Count); + this.CompatibleMemLayoutRunner = new ConversionRunner(this.Count); + this.PermutedRunnerRgbaToArgb = new ConversionRunner(this.Count); + this.RunnerRgbaToRgbaVector = new ConversionRunner(this.Count); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs index c0dd6b93d..57f79ba1f 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertFromVector4.cs @@ -65,8 +65,8 @@ public class PixelConversion_ConvertFromVector4 [GlobalSetup] public void Setup() { - this.nonVectorRunner = new(this.Count); - this.vectorRunner = new(this.Count); + this.nonVectorRunner = new ConversionRunner(this.Count); + this.vectorRunner = new ConversionRunner(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs index 4a36e9cf1..1a03a0c04 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32.cs @@ -69,8 +69,8 @@ public class PixelConversion_ConvertToRgba32 [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new(this.Count); - this.permutedRunner = new(this.Count); + this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); + this.permutedRunner = new ConversionRunner(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs index ad2e71626..69a71734a 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation.cs @@ -76,8 +76,8 @@ public class PixelConversion_ConvertToRgba32_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.compatibleMemoryLayoutRunner = new(this.Count); - this.permutedRunner = new(this.Count); + this.compatibleMemoryLayoutRunner = new ConversionRunner(this.Count); + this.permutedRunner = new ConversionRunner(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs index ee0fbb499..9b498b0f2 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4.cs @@ -59,7 +59,7 @@ public class PixelConversion_ConvertToVector4 [GlobalSetup] public void Setup() { - this.runner = new(this.Count); + this.runner = new ConversionRunner(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs index d9723b0e3..50c3d0d13 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_ConvertToVector4_AsPartOfCompositeOperation.cs @@ -73,7 +73,7 @@ public class PixelConversion_ConvertToVector4_AsPartOfCompositeOperation [GlobalSetup] public void Setup() { - this.runner = new(this.Count); + this.runner = new ConversionRunner(this.Count); } [Benchmark(Baseline = true)] diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs index 21808b5ef..232d8b3e2 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/PixelConversion_Rgba32_To_Bgra32.cs @@ -252,8 +252,8 @@ public class PixelConversion_Rgba32_To_Bgra32 private static void BitopsSimdImpl(ref Octet s, ref Octet d) { Vector sVec = Unsafe.As, Vector>(ref s); - Vector aMask = new Vector(0xFF00FF00); - Vector bMask = new Vector(0x00FF00FF); + Vector aMask = new(0xFF00FF00); + Vector bMask = new(0x00FF00FF); Vector aa = sVec & aMask; Vector bb = sVec & bMask; diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs index 21bef5a15..8698f8223 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestArgb.cs @@ -103,6 +103,6 @@ public struct TestArgb : ITestPixel vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new TestArgb(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs index 1499fb7d3..751cd68b4 100644 --- a/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs +++ b/tests/ImageSharp.Benchmarks/General/PixelConversion/TestRgba.cs @@ -79,6 +79,6 @@ public struct TestRgba : ITestPixel vector = Numerics.Clamp(vector, Vector4.Zero, MaxBytes); Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); - return new(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); + return new TestRgba(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } } diff --git a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs index c7df2467b..5919137bf 100644 --- a/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs +++ b/tests/ImageSharp.Benchmarks/General/Vector4Constants.cs @@ -24,8 +24,8 @@ public class Vector4Constants [GlobalSetup] public void Setup() { - this.random = new(42); - this.parameter = new( + this.random = new Random(42); + this.parameter = new Vector4( this.GetRandomFloat(), this.GetRandomFloat(), this.GetRandomFloat(), @@ -51,8 +51,8 @@ public class Vector4Constants Vector4 x = (p * new Vector4(1.2f) / new Vector4(2.3f)) + (p * new Vector4(4.5f) / new Vector4(6.7f)); Vector4 y = (p / new Vector4(1.2f) * new Vector4(2.3f)) + (p / new Vector4(4.5f) * new Vector4(6.7f)); - Vector4 z = Vector4.Min(p, new(1.2f)); - Vector4 w = Vector4.Max(p, new(2.3f)); + Vector4 z = Vector4.Min(p, new Vector4(1.2f)); + Vector4 w = Vector4.Max(p, new Vector4(2.3f)); return x + y + z + w; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs index 69babfb92..2f9b02b59 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -43,11 +43,11 @@ public class BitwiseOrUInt32 [Benchmark] public void Simd() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = Vector.BitwiseOr(a, v); a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs index 2c30cd103..fd243638b 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs @@ -43,11 +43,11 @@ public class DivFloat [Benchmark] public void Simd() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs index 6bdbccace..0d2923b61 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs @@ -44,11 +44,11 @@ public class DivUInt32 [Benchmark] public void Simd() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a / v; a.CopyTo(this.result, i); diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs index 5277897bb..61ff9466e 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Divide.cs @@ -57,7 +57,7 @@ public class DivInt16 : SIMDBenchmarkBase.Divide { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs index 8d5d66c4b..801b0e161 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -43,11 +43,11 @@ public class MulFloat [Benchmark] public void SimdMultiplyByVector() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } @@ -60,7 +60,7 @@ public class MulFloat for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs index d8079423f..db64486ad 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -43,11 +43,11 @@ public class MulUInt32 [Benchmark] public void Simd() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); a = a * v; a.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs index 7e890cb92..d9542bc3f 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Multiply.cs @@ -40,7 +40,7 @@ public class MulInt16 : SIMDBenchmarkBase.Multiply { protected override short GetTestValue() => 42; - protected override Vector GetTestVector() => new Vector(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); + protected override Vector GetTestVector() => new(new short[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }); [Benchmark(Baseline = true)] public void Standard() diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs index 8129222c3..f99b141b4 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/Premultiply.cs @@ -12,14 +12,14 @@ public class Premultiply [Benchmark(Baseline = true)] public Vector4 PremultiplyByVal() { - Vector4 input = new Vector4(.5F); + Vector4 input = new(.5F); return Vector4Utils.Premultiply(input); } [Benchmark] public Vector4 PremultiplyByRef() { - Vector4 input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRef(ref input); return input; } @@ -27,7 +27,7 @@ public class Premultiply [Benchmark] public Vector4 PremultiplyRefWithPropertyAssign() { - Vector4 input = new Vector4(.5F); + Vector4 input = new(.5F); Vector4Utils.PremultiplyRefWithPropertyAssign(ref input); return input; } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs index d7204d96d..557d8ff38 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -53,7 +53,7 @@ public class ReinterpretUInt32AsFloat { for (int i = 0; i < this.input.Length; i += Vector.Count) { - Vector a = new Vector(this.input, i); + Vector a = new(this.input, i); Vector b = Vector.AsVectorSingle(a); b.CopyTo(this.result, i); } diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs index 54e9622a3..4048bc210 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/UInt32ToSingle.cs @@ -27,10 +27,10 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; - Vector bVec = new Vector(256.0f / 255.0f); - Vector magicFloat = new Vector(32768.0f); - Vector magicInt = new Vector(1191182336); // reinterpreted value of 32768.0f - Vector mask = new Vector(255); + Vector bVec = new(256.0f / 255.0f); + Vector magicFloat = new(32768.0f); + Vector magicInt = new(1191182336); // reinterpreted value of 32768.0f + Vector mask = new(255); for (nuint i = 0; i < n; i++) { @@ -55,7 +55,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - Vector scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -74,7 +74,7 @@ public class UInt32ToSingle ref Vector bf = ref Unsafe.As>(ref this.data[0]); ref Vector bu = ref Unsafe.As, Vector>(ref bf); - Vector scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { @@ -91,7 +91,7 @@ public class UInt32ToSingle nuint n = Count / (uint)Vector.Count; ref Vector bf = ref Unsafe.As>(ref this.data[0]); - Vector scale = new Vector(1f / 255f); + Vector scale = new(1f / 255f); for (nuint i = 0; i < n; i++) { diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs index e8b6626cd..9c7fd5b6c 100644 --- a/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/VectorFetching.cs @@ -47,11 +47,11 @@ public class VectorFetching [Benchmark] public void FetchWithVectorConstructor() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); for (int i = 0; i < this.data.Length; i += Vector.Count) { - Vector a = new Vector(this.data, i); + Vector a = new(this.data, i); a = a * v; a.CopyTo(this.data, i); } @@ -60,7 +60,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCast() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -79,7 +79,7 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastNoTempVector() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); ref Vector start = ref Unsafe.As>(ref this.data[0]); nuint n = (uint)this.InputSize / (uint)Vector.Count; @@ -94,9 +94,9 @@ public class VectorFetching [Benchmark] public void FetchWithUnsafeCastFromReference() { - Vector v = new Vector(this.testValue); + Vector v = new(this.testValue); - Span span = new Span(this.data); + Span span = new(this.data); ref Vector start = ref Unsafe.As>(ref MemoryMarshal.GetReference(span)); diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs index 65ca779ca..5d137a615 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs @@ -18,7 +18,7 @@ public class LoadResizeSaveStressBenchmarks [GlobalSetup] public void Setup() { - this.runner = new() + this.runner = new LoadResizeSaveStressRunner { ImageCount = Environment.ProcessorCount, Filter = Filter diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index 1a2d0360e..75bc5289c 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -117,7 +117,7 @@ public class LoadResizeSaveStressRunner public void ForEachImageParallel(Action action) => Parallel.ForEach( this.Images, - new() { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, + new ParallelOptions { MaxDegreeOfParallelism = this.MaxDegreeOfParallelism }, action); public Task ForEachImageParallelAsync(Func action) @@ -148,7 +148,7 @@ public class LoadResizeSaveStressRunner private void LogImageProcessed(int width, int height) { - this.LastProcessedImageSize = new(width, height); + this.LastProcessedImageSize = new ImageSharpSize(width, height); double pixels = width * (double)height; this.TotalProcessedMegapixels += pixels / 1_000_000.0; } @@ -322,7 +322,7 @@ public class LoadResizeSaveStressRunner (int width, int height) = this.ScaledSize(info.Width, info.Height, this.ThumbnailSize); SKSizeI supportedScale = codec.GetScaledDimensions((float)width / info.Width); - using SKBitmap original = SKBitmap.Decode(codec, new(supportedScale.Width, supportedScale.Height)); + using SKBitmap original = SKBitmap.Decode(codec, new SKImageInfo(supportedScale.Width, supportedScale.Height)); using SKBitmap resized = original.Resize(new SKImageInfo(width, height), SKFilterQuality.High); if (resized == null) { diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index 9f75f9dc2..a308c0c46 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -73,7 +73,7 @@ public class PorterDuffBulkVsPixel BulkVectorConvert(span, span, span, amounts.GetSpan()); } - return new(image.Width, image.Height); + return new Size(image.Width, image.Height); } [Benchmark(Description = "ImageSharp BulkPixelConvert")] @@ -89,6 +89,6 @@ public class PorterDuffBulkVsPixel BulkPixelConvert(span, span, span, amounts.GetSpan()); } - return new(image.Width, image.Height); + return new Size(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Crop.cs b/tests/ImageSharp.Benchmarks/Processing/Crop.cs index d526c6ba4..e14366bfd 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Crop.cs @@ -24,7 +24,7 @@ public class Crop graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality; - graphics.DrawImage(source, new(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); + graphics.DrawImage(source, new SDRectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel); return destination.Size; } @@ -34,6 +34,6 @@ public class Crop { using Image image = new(800, 800); image.Mutate(x => x.Crop(100, 100)); - return new(image.Width, image.Height); + return new Size(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs index 8be48260a..93ac9fc0e 100644 --- a/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs +++ b/tests/ImageSharp.Benchmarks/Processing/HistogramEqualization.cs @@ -33,7 +33,7 @@ public class HistogramEqualization [Benchmark(Description = "Global Histogram Equalization")] public void GlobalHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new() + new HistogramEqualizationOptions { LuminanceLevels = 256, Method = HistogramEqualizationMethod.Global @@ -42,7 +42,7 @@ public class HistogramEqualization [Benchmark(Description = "AdaptiveHistogramEqualization (Tile interpolation)")] public void AdaptiveHistogramEqualization() => this.image.Mutate(img => img.HistogramEqualization( - new() + new HistogramEqualizationOptions { LuminanceLevels = 256, Method = HistogramEqualizationMethod.AdaptiveTileInterpolation diff --git a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs index e3e413fe4..707748499 100644 --- a/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs +++ b/tests/ImageSharp.Benchmarks/Processing/OilPaint.cs @@ -13,7 +13,7 @@ public class OilPaint [Benchmark] public void DoOilPaint() { - using Image image = new Image(1920, 1200, new(127, 191, 255)); + using Image image = new(1920, 1200, new RgbaVector(127, 191, 255)); image.Mutate(ctx => ctx.OilPaint()); } } diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 949b14afa..356027221 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Resize.cs @@ -218,9 +218,9 @@ public class Resize_Bicubic_Compare_Rgba32_Rgb24 [GlobalSetup] public void Setup() { - this.rgb24 = new(); + this.rgb24 = new Resize_Bicubic_Rgb24(); this.rgb24.Setup(); - this.rgba32 = new(); + this.rgba32 = new Resize_Bicubic_Rgba32(); this.rgba32.Setup(); } diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs index 79128cfee..6850756df 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/LoadResizeSaveParallelMemoryStress.cs @@ -17,7 +17,7 @@ internal class LoadResizeSaveParallelMemoryStress { private LoadResizeSaveParallelMemoryStress() { - this.Benchmarks = new() + this.Benchmarks = new LoadResizeSaveStressRunner { Filter = JpegKind.Baseline, }; @@ -295,7 +295,7 @@ internal class LoadResizeSaveParallelMemoryStress (int)B(this.MaxContiguousPoolBufferMegaBytes), B(this.MaxPoolSizeMegaBytes), (int)B(this.MaxCapacityOfNonPoolBuffersMegaBytes), - new() + new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = this.TrimTimeSeconds.Value * 1000 }); diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index 43e17f5c9..3e4f77f9e 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -64,13 +64,13 @@ public class Program private static void RunResizeProfilingTest() { - ResizeProfilingBenchmarks test = new ResizeProfilingBenchmarks(new ConsoleOutput()); + ResizeProfilingBenchmarks test = new(new ConsoleOutput()); test.ResizeBicubic(4000, 4000); } private static void RunToVector4ProfilingTest() { - PixelOperationsTests.Rgba32_OperationsTests tests = new PixelOperationsTests.Rgba32_OperationsTests(new ConsoleOutput()); + PixelOperationsTests.Rgba32_OperationsTests tests = new(new ConsoleOutput()); tests.Benchmark_ToVector4(); } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs index 6c3377d10..2e2f0d07d 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.CastTo.cs @@ -108,10 +108,10 @@ public partial class ColorTests Color color = Color.FromScaledVector(Vector4.One); // Assert: - Assert.Equal(new(1, 1, 1, 1), color.ToPixel()); - Assert.Equal(new(65535, 65535, 65535, 65535), color.ToPixel()); - Assert.Equal(new(255, 255, 255, 255), color.ToPixel()); - Assert.Equal(new(255), color.ToPixel()); + Assert.Equal(new RgbaVector(1, 1, 1, 1), color.ToPixel()); + Assert.Equal(new Rgba64(65535, 65535, 65535, 65535), color.ToPixel()); + Assert.Equal(new Rgba32(255, 255, 255, 255), color.ToPixel()); + Assert.Equal(new L8(255), color.ToPixel()); } [Fact] diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index 8b636ee39..d430df5b4 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -108,29 +108,29 @@ public partial class ColorTests [Fact] public void ShortHex() { - Assert.Equal(new(255, 255, 255), Color.ParseHex("#fff").ToPixel()); - Assert.Equal(new(255, 255, 255), Color.ParseHex("fff").ToPixel()); - Assert.Equal(new(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); + Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("#fff").ToPixel()); + Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("fff").ToPixel()); + Assert.Equal(new Rgba32(0, 0, 0, 255), Color.ParseHex("000f").ToPixel()); } [Fact] public void TryShortHex() { Assert.True(Color.TryParseHex("#fff", out Color actual)); - Assert.Equal(new(255, 255, 255), actual.ToPixel()); + Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("fff", out actual)); - Assert.Equal(new(255, 255, 255), actual.ToPixel()); + Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); Assert.True(Color.TryParseHex("000f", out actual)); - Assert.Equal(new(0, 0, 0, 255), actual.ToPixel()); + Assert.Equal(new Rgba32(0, 0, 0, 255), actual.ToPixel()); } [Fact] public void LeadingPoundIsOptional() { - Assert.Equal(new(0, 128, 128), Color.ParseHex("#008080").ToPixel()); - Assert.Equal(new(0, 128, 128), Color.ParseHex("008080").ToPixel()); + Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("#008080").ToPixel()); + Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("008080").ToPixel()); } [Fact] diff --git a/tests/ImageSharp.Tests/Color/ReferencePalette.cs b/tests/ImageSharp.Tests/Color/ReferencePalette.cs index 8e2696109..2db2aae19 100644 --- a/tests/ImageSharp.Tests/Color/ReferencePalette.cs +++ b/tests/ImageSharp.Tests/Color/ReferencePalette.cs @@ -273,7 +273,7 @@ internal static class ReferencePalette }; public static readonly Dictionary ColorNames = - new Dictionary(StringComparer.OrdinalIgnoreCase) + new(StringComparer.OrdinalIgnoreCase) { { nameof(Color.AliceBlue), Color.AliceBlue }, { nameof(Color.AntiqueWhite), Color.AntiqueWhite }, diff --git a/tests/ImageSharp.Tests/Color/RgbaDouble.cs b/tests/ImageSharp.Tests/Color/RgbaDouble.cs index 9a751e879..76fdf365c 100644 --- a/tests/ImageSharp.Tests/Color/RgbaDouble.cs +++ b/tests/ImageSharp.Tests/Color/RgbaDouble.cs @@ -115,7 +115,7 @@ public struct RgbaDouble : IPixel public static RgbaDouble FromVector4(Vector4 source) { source = Numerics.Clamp(source, Vector4.Zero, Vector4.One); - return new(source.X, source.Y, source.Z, source.W); + return new RgbaDouble(source.X, source.Y, source.Z, source.W); } /// diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs index 93e64aa9b..69fabc750 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLabTests.cs @@ -35,8 +35,8 @@ public class CieLabTests Assert.True(new CieLab(1, 0, 1) != default); Assert.False(new CieLab(1, 0, 1) == default); Assert.Equal(default, default(CieLab)); - Assert.Equal(new(1, 0, 1), new CieLab(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieLab(Vector3.One)); + Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); + Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(new CieLab(1, 0, 1) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs index e2bf8655e..484db3e8c 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchTests.cs @@ -33,8 +33,8 @@ public class CieLchTests Assert.True(default == default(CieLch)); Assert.False(default != default(CieLch)); Assert.Equal(default, default(CieLch)); - Assert.Equal(new(1, 0, 1), new CieLch(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieLch(Vector3.One)); + Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); + Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs index cc8f9789a..3fe550a5b 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLchuvTests.cs @@ -34,8 +34,8 @@ public class CieLchuvTests Assert.True(default == default(CieLchuv)); Assert.False(default != default(CieLchuv)); Assert.Equal(default, default(CieLchuv)); - Assert.Equal(new(1, 0, 1), new CieLchuv(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieLchuv(Vector3.One)); + Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); + Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs index 7d715349f..173491081 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieLuvTests.cs @@ -34,8 +34,8 @@ public class CieLuvTests Assert.True(default == default(CieLuv)); Assert.False(default != default(CieLuv)); Assert.Equal(default, default(CieLuv)); - Assert.Equal(new(1, 0, 1), new CieLuv(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieLuv(Vector3.One)); + Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); + Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs index 5875b78c1..8bc71f1e1 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyChromaticityCoordinatesTests.cs @@ -32,8 +32,8 @@ public class CieXyChromaticityCoordinatesTests Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.Equal(default, default(CieXyChromaticityCoordinates)); - Assert.Equal(new(1, 0), new CieXyChromaticityCoordinates(1, 0)); - Assert.Equal(new(1, 1), new CieXyChromaticityCoordinates(1, 1)); + Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); + Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); Assert.False(x.Equals(y)); Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs index 6290546a8..80904c5df 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyyTests.cs @@ -34,8 +34,8 @@ public class CieXyyTests Assert.True(default == default(CieXyy)); Assert.False(default != default(CieXyy)); Assert.Equal(default, default(CieXyy)); - Assert.Equal(new(1, 0, 1), new CieXyy(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieXyy(Vector3.One)); + Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); + Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs index e7e4261c6..683b3b661 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CieXyzTests.cs @@ -34,8 +34,8 @@ public class CieXyzTests Assert.True(default == default(CieXyz)); Assert.False(default != default(CieXyz)); Assert.Equal(default, default(CieXyz)); - Assert.Equal(new(1, 0, 1), new CieXyz(1, 0, 1)); - Assert.Equal(new(Vector3.One), new CieXyz(Vector3.One)); + Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); + Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs index a732c68c5..22b7a7f70 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CmykTests.cs @@ -36,8 +36,8 @@ public class CmykTests Assert.True(default == default(Cmyk)); Assert.False(default != default(Cmyk)); Assert.Equal(default, default(Cmyk)); - Assert.Equal(new(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); - Assert.Equal(new(Vector4.One), new Cmyk(Vector4.One)); + Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); + Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs index 24b221155..1bdefa109 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/CompandingTests.cs @@ -102,7 +102,7 @@ public class CompandingTests private static void CompandingIsCorrectImpl(Vector4 e, Vector4 c, float expanded, Vector4 compressed) { // W (alpha) is already the linear representation of the color. - Assert.Equal(new(expanded, expanded, expanded, e.W), e, Comparer); + Assert.Equal(new Vector4(expanded, expanded, expanded, e.W), e, Comparer); Assert.Equal(compressed, c, Comparer); } } diff --git a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs index 6d9af0eee..6697cbfde 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HslTests.cs @@ -34,8 +34,8 @@ public class HslTests Assert.True(default == default(Hsl)); Assert.False(default != default(Hsl)); Assert.Equal(default, default(Hsl)); - Assert.Equal(new(1, 0, 1), new Hsl(1, 0, 1)); - Assert.Equal(new(Vector3.One), new Hsl(Vector3.One)); + Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); + Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs index 36a8d599b..dd71fcd3f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HsvTests.cs @@ -34,8 +34,8 @@ public class HsvTests Assert.True(default == default(Hsv)); Assert.False(default != default(Hsv)); Assert.Equal(default, default(Hsv)); - Assert.Equal(new(1, 0, 1), new Hsv(1, 0, 1)); - Assert.Equal(new(Vector3.One), new Hsv(Vector3.One)); + Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); + Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs index f136aa288..af06b3c91 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/HunterLabTests.cs @@ -35,8 +35,8 @@ public class HunterLabTests Assert.True(new HunterLab(1, 0, 1) != default); Assert.False(new HunterLab(1, 0, 1) == default); Assert.Equal(default, default(HunterLab)); - Assert.Equal(new(1, 0, 1), new HunterLab(1, 0, 1)); - Assert.Equal(new(Vector3.One), new HunterLab(Vector3.One)); + Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); + Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs index cd6fe33cc..6c56dc682 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs @@ -152,7 +152,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) private static Vector4 GetActualTargetValues(float[] input, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new() + ColorProfileConverter converter = new(new ColorConversionOptions { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -163,20 +163,20 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) return sourceDataSpace switch { IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new(new(input))).ToScaledVector4(), + => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), IccColorSpaceType.Cmyk when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new(new(input))).ToScaledVector4(), + => converter.Convert(new Cmyk(new Vector4(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Cmyk - => converter.Convert(new(new(input))).ToScaledVector4(), + => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), IccColorSpaceType.Rgb when targetDataSpace == IccColorSpaceType.Rgb - => converter.Convert(new(new(input))).ToScaledVector4(), + => converter.Convert(new Rgb(new Vector3(input))).ToScaledVector4(), _ => throw new NotSupportedException($"Unsupported ICC profile data color space conversion: {sourceDataSpace} -> {targetDataSpace}") }; } private static List GetBulkActualTargetValues(List inputs, string sourceProfile, string targetProfile) { - ColorProfileConverter converter = new(new() + ColorProfileConverter converter = new(new ColorConversionOptions { SourceIccProfile = TestIccProfiles.GetProfile(sourceProfile), TargetIccProfile = TestIccProfiles.GetProfile(targetProfile) @@ -189,7 +189,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) { case IccColorSpaceType.Cmyk: { - Span inputSpan = inputs.Select(x => new Cmyk(new(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Cmyk(new Vector4(x))).ToArray(); switch (targetDataSpace) { @@ -214,7 +214,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) case IccColorSpaceType.Rgb: { - Span inputSpan = inputs.Select(x => new Rgb(new(x))).ToArray(); + Span inputSpan = inputs.Select(x => new Rgb(new Vector3(x))).ToArray(); switch (targetDataSpace) { diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs index c5f950784..eec27fcd7 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/TestIccProfiles.cs @@ -3,6 +3,7 @@ using System.Collections.Concurrent; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using Wacton.Unicolour; using Wacton.Unicolour.Icc; namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc; @@ -58,12 +59,12 @@ internal static class TestIccProfiles public const string StandardRgbV2 = "sRGB2014.icc"; public static IccProfile GetProfile(string file) - => ProfileCache.GetOrAdd(file, f => new(File.ReadAllBytes(GetFullPath(f)))); + => ProfileCache.GetOrAdd(file, f => new IccProfile(File.ReadAllBytes(GetFullPath(f)))); public static Wacton.Unicolour.Configuration GetUnicolourConfiguration(string file) => UnicolourConfigurationCache.GetOrAdd( file, - f => new(iccConfig: new(GetFullPath(f), Intent.Unspecified, f))); + f => new Wacton.Unicolour.Configuration(iccConfig: new IccConfiguration(GetFullPath(f), Intent.Unspecified, f))); public static bool HasUnicolourConfiguration(string file) => UnicolourConfigurationCache.ContainsKey(file); diff --git a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs index c409bfd69..395b547fd 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/LmsTests.cs @@ -35,8 +35,8 @@ public class LmsTests Assert.True(new Lms(1, 0, 1) != default); Assert.False(new Lms(1, 0, 1) == default); Assert.Equal(default, default(Lms)); - Assert.Equal(new(1, 0, 1), new Lms(1, 0, 1)); - Assert.Equal(new(Vector3.One), new Lms(Vector3.One)); + Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); + Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs index 5ee4dac11..707b3e2a7 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/RgbTests.cs @@ -35,8 +35,8 @@ public class RgbTests Assert.True(default == default(Rgb)); Assert.False(default != default(Rgb)); Assert.Equal(default, default(Rgb)); - Assert.Equal(new(1, 0, 1), new Rgb(1, 0, 1)); - Assert.Equal(new(Vector3.One), new Rgb(Vector3.One)); + Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); + Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs index 1a52d8a7f..f61124d8f 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/StringRepresentationTests.cs @@ -50,7 +50,7 @@ public class StringRepresentationTests { new HunterLab(Random), "HunterLab(42.4, 94.5, 83.4)" }, { new Lms(Random), "Lms(42.4, 94.5, 83.4)" }, { new Rgb(Random), "Rgb(42.4, 94.5, 83.4)" }, - { Rgb.Clamp(new(Random)), "Rgb(1, 1, 1)" }, + { Rgb.Clamp(new Rgb(Random)), "Rgb(1, 1, 1)" }, { new Hsl(Random), "Hsl(42.4, 1, 1)" }, // clamping to 1 is expected { new Hsv(Random), "Hsv(42.4, 1, 1)" }, // clamping to 1 is expected { new Y(Random.X), "Y(1)" }, diff --git a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs index 7bd7c5167..64558a3f8 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YCbCrTests.cs @@ -34,8 +34,8 @@ public class YCbCrTests Assert.True(default == default(YCbCr)); Assert.False(default != default(YCbCr)); Assert.Equal(default, default(YCbCr)); - Assert.Equal(new(1, 0, 1), new YCbCr(1, 0, 1)); - Assert.Equal(new(Vector3.One), new YCbCr(Vector3.One)); + Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); + Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs index e92448418..7e5e48b69 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YTests.cs @@ -28,9 +28,9 @@ public class YTests Assert.True(default == default(Y)); Assert.False(default != default(Y)); Assert.Equal(default, default(Y)); - Assert.Equal(new(1), new Y(1)); + Assert.Equal(new Y(1), new Y(1)); - Assert.Equal(new(.5F), new Y(.5F)); + Assert.Equal(new Y(.5F), new Y(.5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); Assert.False(x.GetHashCode().Equals(y.GetHashCode())); diff --git a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs index ada125f59..bfe0bdb17 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/YccKTests.cs @@ -34,8 +34,8 @@ public class YccKTests Assert.True(default == default(YccK)); Assert.False(default != default(YccK)); Assert.Equal(default, default(YccK)); - Assert.Equal(new(1, 1, 1, 1), new YccK(1, 1, 1, 1)); - Assert.Equal(new(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); + Assert.Equal(new YccK(1, 1, 1, 1), new YccK(1, 1, 1, 1)); + Assert.Equal(new YccK(.5F, .5F, .5F, .5F), new YccK(.5F, .5F, .5F, .5F)); Assert.False(x.Equals(y)); Assert.False(x.Equals((object)y)); diff --git a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs index db2da6a69..8421c1fd7 100644 --- a/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/EncoderExtensionsTests.cs @@ -20,7 +20,7 @@ public class EncoderExtensionsTests [Fact] public void GetString_Buffer_ReturnsString() { - ReadOnlySpan buffer = new ReadOnlySpan(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); + ReadOnlySpan buffer = new(new byte[] { 73, 109, 97, 103, 101, 83, 104, 97, 114, 112 }); string result = Encoding.UTF8.GetString(buffer); diff --git a/tests/ImageSharp.Tests/Common/NumericsTests.cs b/tests/ImageSharp.Tests/Common/NumericsTests.cs index 69f8f9c2c..ebee57060 100644 --- a/tests/ImageSharp.Tests/Common/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Common/NumericsTests.cs @@ -28,7 +28,7 @@ public class NumericsTests [InlineData(1, 100)] public void DivideCeil_RandomValues(int seed, int count) { - Random rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < count; i++) { uint value = (uint)rng.Next(); diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index e4d9a04b4..36b301264 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -51,7 +51,7 @@ public partial class SimdUtilsTests data[i] = data[i - 4] + 100f; } - return new(data); + return new Vector(data); } private static Vector CreateRandomTestVector(int seed, float min, float max) @@ -66,7 +66,7 @@ public partial class SimdUtilsTests data[i] = v; } - return new(data); + return new Vector(data); } [Fact] @@ -287,7 +287,7 @@ public partial class SimdUtilsTests TPixel[] expected = new TPixel[count]; for (int i = 0; i < count; i++) { - expected[i] = TPixel.FromRgb24(new(r[i], g[i], b[i])); + expected[i] = TPixel.FromRgb24(new Rgb24(r[i], g[i], b[i])); } TPixel[] actual = new TPixel[count + 3]; // padding for Rgb24 AVX2 diff --git a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs index 3df5e8f30..5ea7afaf8 100644 --- a/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Common/StreamExtensionsTests.cs @@ -10,7 +10,7 @@ public class StreamExtensionsTests [InlineData(-1)] public void Skip_CountZeroOrLower_PositionNotChanged(int count) { - using (MemoryStream memStream = new MemoryStream(5)) + using (MemoryStream memStream = new(5)) { memStream.Position = 4; memStream.Skip(count); @@ -22,7 +22,7 @@ public class StreamExtensionsTests [Fact] public void Skip_SeekableStream_SeekIsCalled() { - using (SeekableStream seekableStream = new SeekableStream(4)) + using (SeekableStream seekableStream = new(4)) { seekableStream.Skip(4); @@ -34,7 +34,7 @@ public class StreamExtensionsTests [Fact] public void Skip_NonSeekableStream_BytesAreRead() { - using (NonSeekableStream nonSeekableStream = new NonSeekableStream()) + using (NonSeekableStream nonSeekableStream = new()) { nonSeekableStream.Skip(5); @@ -49,7 +49,7 @@ public class StreamExtensionsTests [Fact] public void Skip_EofStream_NoExceptionIsThrown() { - using (EofStream eofStream = new EofStream(7)) + using (EofStream eofStream = new(7)) { eofStream.Skip(7); @@ -79,7 +79,7 @@ public class StreamExtensionsTests { public override bool CanSeek => false; - public List Counts = new List(); + public List Counts = new(); public NonSeekableStream() : base(4) diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index b90579a02..3c6c759f8 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -27,7 +27,7 @@ public class ConfigurationTests // The shallow copy of configuration should behave exactly like the default configuration, // so by using the copy, we test both the default and the copy. this.DefaultConfiguration = Configuration.CreateDefaultInstance().Clone(); - this.ConfigurationEmpty = new(); + this.ConfigurationEmpty = new Configuration(); } [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 2e2c30784..1d0fdf62d 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -77,11 +77,11 @@ public class DrawImageTests PngEncoder encoder; if (provider.PixelType == PixelTypes.Rgba64) { - encoder = new() { BitDepth = PngBitDepth.Bit16 }; + encoder = new PngEncoder { BitDepth = PngBitDepth.Bit16 }; } else { - encoder = new(); + encoder = new PngEncoder(); } image.DebugSave(provider, testInfo, encoder: encoder); @@ -195,9 +195,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new(0, 255, 255)); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new(64, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new Point(64, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -216,9 +216,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new(0, 255, 255)); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(320, 128, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(320, 128, 32, 32), 1F)); background.DebugSave( provider, @@ -237,9 +237,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new(0, 255, 255)); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new(10, 10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new Point(10, 10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -258,9 +258,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new(0, 255, 255)); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new Point(-10, -10), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, @@ -279,9 +279,9 @@ public class DrawImageTests where TPixel : unmanaged, IPixel { using Image foreground = provider.GetImage(); - using Image background = new(100, 100, new(0, 255, 255)); + using Image background = new(100, 100, new Rgba32(0, 255, 255)); - background.Mutate(c => c.DrawImage(foreground, new(80, 80), new Rectangle(32, 32, 32, 32), 1F)); + background.Mutate(c => c.DrawImage(foreground, new Point(80, 80), new Rectangle(32, 32, 32, 32), 1F)); background.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 09ef49a61..5ebcc8bb9 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -332,7 +332,7 @@ public class BmpEncoderTests public void Encode_PreservesColorProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image input = provider.GetImage(BmpDecoder.Instance, new()); + using Image input = provider.GetImage(BmpDecoder.Instance, new BmpDecoderOptions()); ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs index 8b4857645..00a19466a 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpFileHeaderTests.cs @@ -11,7 +11,7 @@ public class BmpFileHeaderTests [Fact] public void TestWrite() { - BmpFileHeader header = new BmpFileHeader(1, 2, 3, 4); + BmpFileHeader header = new(1, 2, 3, 4); byte[] buffer = new byte[14]; diff --git a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs index 988e8935a..14b017bee 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(file, new()); + image.SaveAsBmp(file, new BmpEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsBmp(memoryStream, new()); + image.SaveAsBmp(memoryStream, new BmpEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 9bf5a13c4..48253bee7 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -90,7 +90,7 @@ public class GifDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 }, + TargetSize = new Size { Width = 150, Height = 150 }, MaxFrames = 1 }; @@ -257,7 +257,7 @@ public class GifDecoderTests public void Issue405_BadApplicationExtensionBlockLength(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -269,7 +269,7 @@ public class GifDecoderTests public void Issue1668_InvalidColorIndex(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -318,7 +318,7 @@ public class GifDecoderTests public void Issue1962(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); @@ -330,7 +330,7 @@ public class GifDecoderTests public void Issue2012EmptyXmp(TestImageProvider provider) where TPixel : unmanaged, IPixel { - using Image image = provider.GetImage(GifDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(GifDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); image.DebugSave(provider); image.CompareFirstFrameToReferenceOutput(ImageComparer.Exact, provider); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 740cb9ac7..370106ca3 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -56,7 +56,7 @@ public class GifEncoderTests { // Use the palette quantizer without dithering to ensure results // are consistent - Quantizer = new WebSafePaletteQuantizer(new() { Dither = null, TransparencyThreshold = 0 }) + Quantizer = new WebSafePaletteQuantizer(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }) }; // Always save as we need to compare the encoded output. @@ -115,16 +115,16 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = FrameColorTableMode.Global, - Quantizer = new OctreeQuantizer(new() { Dither = null }) + Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }) }; // Always save as we need to compare the encoded output. provider.Utility.SaveTestOutputFile(image, "gif", encoder, "global"); - encoder = new() + encoder = new GifEncoder { ColorTableMode = FrameColorTableMode.Local, - Quantizer = new OctreeQuantizer(new() { Dither = null }), + Quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }), }; provider.Utility.SaveTestOutputFile(image, "gif", encoder, "local"); @@ -191,7 +191,7 @@ public class GifEncoderTests GifEncoder encoder = new() { ColorTableMode = colorMode, - Quantizer = new OctreeQuantizer(new() { MaxColors = maxColors }) + Quantizer = new OctreeQuantizer(new QuantizerOptions { MaxColors = maxColors }) }; image.Save(outStream, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs index 625b043d4..dd3879703 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs @@ -86,7 +86,7 @@ public class GifMetadataTests using Image image = testFile.CreateRgba32Image(GifDecoder.Instance); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new('c', 349), metadata.Comments[0]); + Assert.Equal(new string('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } @@ -104,7 +104,7 @@ public class GifMetadataTests using Image image = decoder.Decode(DecoderOptions.Default, memoryStream); GifMetadata metadata = image.Metadata.GetGifMetadata(); Assert.Equal(2, metadata.Comments.Count); - Assert.Equal(new('c', 349), metadata.Comments[0]); + Assert.Equal(new string('c', 349), metadata.Comments[0]); Assert.Equal("ImageSharp", metadata.Comments[1]); } diff --git a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs index d23efdd79..97fdb38e7 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(file, new()); + image.SaveAsGif(file, new GifEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsGif(memoryStream, new()); + image.SaveAsGif(memoryStream, new GifEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs index e076ccab6..85ff51b18 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Ico; using SixLabors.ImageSharp.Formats.Icon; @@ -277,7 +278,7 @@ public class IcoDecoderTests [WithFile(MultiSizeF, PixelTypes.Rgba32)] public void MultiSize_CanDecodeSingleFrame(TestImageProvider provider) { - using Image image = provider.GetImage(IcoDecoder.Instance, new() { MaxFrames = 1 }); + using Image image = provider.GetImage(IcoDecoder.Instance, new DecoderOptions { MaxFrames = 1 }); Assert.Single(image.Frames); } @@ -293,7 +294,7 @@ public class IcoDecoderTests TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new() { MaxFrames = 1 }, stream); + ImageInfo imageInfo = Image.Identify(new DecoderOptions { MaxFrames = 1 }, stream); Assert.Single(imageInfo.FrameMetadataCollection); } diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index f7743e149..324bd4783 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -24,7 +24,7 @@ public class ImageFormatManagerTests public ImageFormatManagerTests() { this.DefaultFormatsManager = Configuration.CreateDefaultInstance().ImageFormatsManager; - this.FormatsManagerEmpty = new(); + this.FormatsManagerEmpty = new ImageFormatManager(); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs index ae6f0331d..fb1e062f2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs @@ -157,7 +157,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - Random rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -188,7 +188,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - Random rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { @@ -223,7 +223,7 @@ public class Block8x8Tests : JpegFixture static void RunTest(string seedSerialized) { int seed = FeatureTestRunner.Deserialize(seedSerialized); - Random rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs index 625932e2a..36b792fa1 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs @@ -69,7 +69,7 @@ public class HuffmanScanEncoderTests { int maxNumber = 1 << 16; - Random rng = new Random(seed); + Random rng = new(seed); for (int i = 0; i < 1000; i++) { uint number = (uint)rng.Next(0, maxNumber); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs index 0d8bf3a74..b1f799732 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(file, new()); + image.SaveAsJpeg(file, new JpegEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsJpeg(memoryStream, new()); + image.SaveAsJpeg(memoryStream, new JpegEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index ba60139c5..d58ff9823 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -620,10 +620,10 @@ public class JpegColorConverterTests // no need to dispose when buffer is not array owner Memory memory = new(values); MemoryGroup source = MemoryGroup.Wrap(memory); - buffers[i] = new(source, values.Length, 1); + buffers[i] = new Buffer2D(source, values.Length, 1); } - return new(buffers, 0); + return new JpegColorConverterBase.ComponentValues(buffers, 0); } private static float[] CreateRandomValues(int length, Random rnd) @@ -783,8 +783,8 @@ public class JpegColorConverterTests g /= MaxColorChannelValue; b /= MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -804,9 +804,9 @@ public class JpegColorConverterTests r /= MaxColorChannelValue; g /= MaxColorChannelValue; b /= MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -817,9 +817,9 @@ public class JpegColorConverterTests float r = values.Component0[i] / MaxColorChannelValue; float g = values.Component1[i] / MaxColorChannelValue; float b = values.Component2[i] / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -828,9 +828,9 @@ public class JpegColorConverterTests private static void ValidateGrayScale(in JpegColorConverterBase.ComponentValues values, in JpegColorConverterBase.ComponentValues result, int i) { float y = values.Component0[i] / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(y, y, y)); + Rgb expected = Rgb.Clamp(new Rgb(y, y, y)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component0[i], result.Component0[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component0[i], result.Component0[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); @@ -846,9 +846,9 @@ public class JpegColorConverterTests float r = c * k / MaxColorChannelValue; float g = m * k / MaxColorChannelValue; float b = y * k / MaxColorChannelValue; - Rgb expected = Rgb.Clamp(new(r, g, b)); + Rgb expected = Rgb.Clamp(new Rgb(r, g, b)); - Rgb actual = Rgb.Clamp(new(result.Component0[i], result.Component1[i], result.Component2[i])); + Rgb actual = Rgb.Clamp(new Rgb(result.Component0[i], result.Component1[i], result.Component2[i])); bool equal = ColorSpaceComparer.Equals(expected, actual); Assert.True(equal, $"Colors {expected} and {actual} are not equal at index {i}"); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs index d2c7bcd5c..11c7dc86d 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs @@ -400,10 +400,10 @@ public partial class JpegDecoderTests exif.SetValue(ExifTag.XPSubject, "This is a subject"); // exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "ビッ")); - exif.SetValue(ExifTag.UserComment, new(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); + exif.SetValue(ExifTag.UserComment, new EncodedString(EncodedString.CharacterCode.JIS, "eng comment text (JIS)")); - exif.SetValue(ExifTag.GPSProcessingMethod, new(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); - exif.SetValue(ExifTag.GPSAreaInformation, new(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); + exif.SetValue(ExifTag.GPSProcessingMethod, new EncodedString(EncodedString.CharacterCode.ASCII, "GPS processing method (ASCII)")); + exif.SetValue(ExifTag.GPSAreaInformation, new EncodedString(EncodedString.CharacterCode.Unicode, "GPS area info (Unicode)")); image.Metadata.ExifProfile = exif; @@ -461,7 +461,7 @@ public partial class JpegDecoderTests // We want to test the encoder to ensure the determined values can be encoded but not by encoding // the full size image as it would be too slow. // We will crop the image to a smaller size and then encode it. - image.Mutate(x => x.Crop(new(0, 0, 100, 100))); + image.Mutate(x => x.Crop(new Rectangle(0, 0, 100, 100))); using MemoryStream ms = new(); image.Save(ms, new JpegEncoder()); @@ -495,13 +495,13 @@ public partial class JpegDecoderTests Assert.Equal("Carers; seniors; caregiver; senior care; retirement home; hands; old; elderly; elderly caregiver; elder care; elderly care; geriatric care; nursing home; age; old age care; outpatient; needy; health care; home nurse; home care; sick; retirement; medical; mobile; the elderly; nursing department; nursing treatment; nursing; care services; nursing services; nursing care; nursing allowance; nursing homes; home nursing; care category; nursing class; care; nursing shortage; nursing patient care staff\0", exifProfile.GetValue(ExifTag.XPKeywords).Value); Assert.Equal( - new(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), + new EncodedString(EncodedString.CharacterCode.ASCII, "StockSubmitter|Miscellaneous||Miscellaneous$|00|0000330000000110000000000000000|22$@NA_1005010.460@145$$@Miscellaneous.Miscellaneous$$@$@26$$@$@$@$@205$@$@$@$@$@$@$@$@$@43$@$@$@$$@Miscellaneous.Miscellaneous$$@90$$@22$@$@$@$@$@$@$|||"), exifProfile.GetValue(ExifTag.UserComment).Value); // the profile contains 4 duplicated UserComment Assert.Equal(1, exifProfile.Values.Count(t => t.Tag == ExifTag.UserComment)); - image.Mutate(x => x.Crop(new(0, 0, 100, 100))); + image.Mutate(x => x.Crop(new Rectangle(0, 0, 100, 100))); image.Save(ms, new JpegEncoder()); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 6df354276..8126a37fe 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -116,7 +116,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); FormattableString details = $"{options.TargetSize.Value.Width}_{options.TargetSize.Value.Height}"; @@ -136,7 +136,7 @@ public partial class JpegDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 }, + TargetSize = new Size { Width = 150, Height = 150 }, Sampler = KnownResamplers.Bicubic }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -156,7 +156,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_IDCT_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -180,7 +180,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_Scale_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -204,7 +204,7 @@ public partial class JpegDecoderTests public void JpegDecoder_Decode_Specialized_Combined_Resize(TestImageProvider provider) where TPixel : unmanaged, IPixel { - DecoderOptions options = new() { TargetSize = new() { Width = 150, Height = 150 } }; + DecoderOptions options = new() { TargetSize = new Size { Width = 150, Height = 150 } }; JpegDecoderOptions specializedOptions = new() { GeneralOptions = options, @@ -372,7 +372,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -387,7 +387,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); @@ -407,7 +407,7 @@ public partial class JpegDecoderTests { JpegDecoderOptions options = new() { - GeneralOptions = new() { ColorProfileHandling = ColorProfileHandling.Convert } + GeneralOptions = new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert } }; using Image image = provider.GetImage(JpegDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs index ebc5a77a9..99322687c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs @@ -57,7 +57,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.ExifProfile = new(); + input.Metadata.ExifProfile = new ExifProfile(); input.Metadata.ExifProfile.SetValue(ExifTag.Software, "unit_test"); // act @@ -78,7 +78,7 @@ public partial class JpegEncoderTests { // arrange using Image input = new(1, 1); - input.Metadata.IccProfile = new(IccTestDataProfiles.ProfileRandomArray); + input.Metadata.IccProfile = new IccProfile(IccTestDataProfiles.ProfileRandomArray); // act using MemoryStream memStream = new(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs index 1f8bdd67a..62362ec80 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegFileMarkerTests.cs @@ -14,7 +14,7 @@ public class JpegFileMarkerTests { const byte app1 = JpegConstants.Markers.APP1; const int position = 5; - JpegFileMarker marker = new JpegFileMarker(app1, position); + JpegFileMarker marker = new(app1, position); Assert.Equal(app1, marker.Marker); Assert.Equal(position, marker.Position); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs index df0595d7b..37be0f8f5 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs @@ -12,7 +12,7 @@ public class JpegMetadataTests [Fact] public void CloneIsDeep() { - JpegMetadata meta = new JpegMetadata { ColorType = JpegColorType.Luminance }; + JpegMetadata meta = new() { ColorType = JpegColorType.Luminance }; JpegMetadata clone = (JpegMetadata)meta.DeepClone(); clone.ColorType = JpegColorType.YCbCrRatio420; @@ -23,7 +23,7 @@ public class JpegMetadataTests [Fact] public void Quality_DefaultQuality() { - JpegMetadata meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.Equal(meta.Quality, ImageSharp.Formats.Jpeg.Components.Quantization.DefaultQualityFactor); } @@ -33,7 +33,7 @@ public class JpegMetadataTests { int quality = 50; - JpegMetadata meta = new JpegMetadata { LuminanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -43,7 +43,7 @@ public class JpegMetadataTests { int quality = 50; - JpegMetadata meta = new JpegMetadata { LuminanceQuality = quality, ChrominanceQuality = quality }; + JpegMetadata meta = new() { LuminanceQuality = quality, ChrominanceQuality = quality }; Assert.Equal(meta.Quality, quality); } @@ -54,7 +54,7 @@ public class JpegMetadataTests int qualityLuma = 50; int qualityChroma = 30; - JpegMetadata meta = new JpegMetadata { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; + JpegMetadata meta = new() { LuminanceQuality = qualityLuma, ChrominanceQuality = qualityChroma }; Assert.Equal(meta.Quality, qualityLuma); } @@ -62,7 +62,7 @@ public class JpegMetadataTests [Fact] public void Comment_EmptyComment() { - JpegMetadata meta = new JpegMetadata(); + JpegMetadata meta = new(); Assert.True(Array.Empty().SequenceEqual(meta.Comments)); } @@ -71,9 +71,9 @@ public class JpegMetadataTests public void Comment_OnlyComment() { string comment = "test comment"; - Collection expectedCollection = new Collection { comment }; + Collection expectedCollection = new() { comment }; - JpegMetadata meta = new JpegMetadata(); + JpegMetadata meta = new(); meta.Comments.Add(JpegComData.FromString(comment)); Assert.Equal(1, meta.Comments.Count); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs index e9821db4c..b6a59fa93 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs @@ -47,7 +47,7 @@ public class ParseStreamTests Assert.Equal(expectedSizeInBlocks, decoder.Frame.McuSize); - Size uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); IJpegComponent c0 = decoder.Components[0]; VerifyJpeg.VerifyComponent(c0, expectedSizeInBlocks, uniform1, uniform1); } @@ -62,7 +62,7 @@ public class ParseStreamTests [InlineData(TestImages.Jpeg.Baseline.Cmyk)] public void PrintComponentData(string imageFile) { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); using (JpegDecoderCore decoder = JpegFixture.ParseJpegStream(imageFile)) { @@ -110,7 +110,7 @@ public class ParseStreamTests IJpegComponent c1 = decoder.Components[1]; IJpegComponent c2 = decoder.Components[2]; - Size uniform1 = new Size(1, 1); + Size uniform1 = new(1, 1); Size expectedLumaSizeInBlocks = decoder.Frame.McuSize.MultiplyBy(fLuma); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index e069296d1..60de0a204 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -101,7 +101,7 @@ public class SpectralJpegTests int componentCount = imageSharpData.ComponentCount; if (libJpegData.ComponentCount != componentCount) { - throw new("libJpegData.ComponentCount != componentCount"); + throw new Exception("libJpegData.ComponentCount != componentCount"); } double averageDifference = 0; @@ -202,10 +202,10 @@ public class SpectralJpegTests for (int i = 0; i < spectralComponents.Length; i++) { JpegComponent component = this.frame.Components[i]; - spectralComponents[i] = new(component.WidthInBlocks, component.HeightInBlocks, component.Index); + spectralComponents[i] = new LibJpegTools.ComponentData(component.WidthInBlocks, component.HeightInBlocks, component.Index); } - this.spectralData = new(spectralComponents); + this.spectralData = new LibJpegTools.SpectralData(spectralComponents); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index 186f72341..d55a25453 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -48,7 +48,7 @@ public class SpectralToPixelConversionTests provider.Utility.TestName = JpegDecoderTests.DecodeBaselineJpegOutputName; // Comparison - using Image image = new(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new()); + using Image image = new(Configuration.Default, converter.GetPixelBuffer(null, CancellationToken.None), new ImageMetadata()); using Image referenceImage = provider.GetReferenceOutputImage(appendPixelTypeToFileName: false); ImageSimilarityReport report = ImageComparer.Exact.CompareImagesOrFrames(referenceImage, image); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs index 511150c52..33e95c5aa 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs @@ -72,7 +72,7 @@ public class JpegFixture : MeasureFixture // ReSharper disable once InconsistentNaming public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42) { - Random rnd = new Random(seed); + Random rnd = new(seed); int[] result = new int[64]; for (int i = 0; i < 8; i++) { @@ -87,7 +87,7 @@ public class JpegFixture : MeasureFixture public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42, int xBorder = 8, int yBorder = 8) { - Random rnd = new Random(seed); + Random rnd = new(seed); float[] result = new float[64]; for (int y = 0; y < yBorder; y++) { @@ -112,7 +112,7 @@ public class JpegFixture : MeasureFixture internal void Print8x8Data(Span data) { - StringBuilder bld = new StringBuilder(); + StringBuilder bld = new(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) @@ -135,7 +135,7 @@ public class JpegFixture : MeasureFixture count = data.Length; } - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); for (int i = 0; i < count; i++) { sb.Append($"{data[i],3} "); @@ -158,7 +158,7 @@ public class JpegFixture : MeasureFixture internal void CompareBlocks(Span a, Span b, float tolerance) { - ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); double totalDifference = 0.0; bool failed = false; @@ -192,7 +192,7 @@ public class JpegFixture : MeasureFixture internal static bool CompareBlocks(Span a, Span b, float tolerance, out float diff) { - ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance); + ApproximateFloatComparer comparer = new(tolerance); bool failed = false; diff = 0; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs index b08202df5..888459112 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs @@ -18,12 +18,12 @@ internal static partial class LibJpegTools BigInteger totalDiff = 0; if (actual.WidthInBlocks < expected.WidthInBlocks) { - throw new("actual.WidthInBlocks < expected.WidthInBlocks"); + throw new Exception("actual.WidthInBlocks < expected.WidthInBlocks"); } if (actual.HeightInBlocks < expected.HeightInBlocks) { - throw new("actual.HeightInBlocks < expected.HeightInBlocks"); + throw new Exception("actual.HeightInBlocks < expected.HeightInBlocks"); } int w = expected.WidthInBlocks; @@ -127,7 +127,7 @@ internal static partial class LibJpegTools } } - return new(result); + return new SpectralData(result); } } finally diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs index acb3d27e3..7c7f47f94 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs @@ -219,8 +219,8 @@ internal static partial class ReferenceImplementations y[6] = c3 * r[6] - c2 * r[2]; */ - w0 = new(1.175876f); - w1 = new(0.785695f); + w0 = new Vector4(1.175876f); + w1 = new Vector4(0.785695f); c3 = (w0 * t4) + (w1 * t7); c0 = (w0 * t7) - (w1 * t4); /* @@ -228,8 +228,8 @@ internal static partial class ReferenceImplementations c0 = t7 * r[3] - t4 * r[5]; */ - w0 = new(1.387040f); - w1 = new(0.275899f); + w0 = new Vector4(1.387040f); + w1 = new Vector4(0.275899f); c2 = (w0 * t5) + (w1 * t6); c1 = (w0 * t6) - (w1 * t5); /* @@ -300,7 +300,7 @@ internal static partial class ReferenceImplementations #pragma warning restore SA1300 // Element should begin with upper-case letter { src = src.Slice(offset); - return new(src[0], src[1], src[2], src[3]); + return new Vector4(src[0], src[1], src[2], src[3]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs index d7b0b64b2..7a31e35d0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs @@ -11,7 +11,7 @@ internal static class VerifyJpeg { internal static void VerifySize(IJpegComponent component, int expectedBlocksX, int expectedBlocksY) { - Assert.Equal(new(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); + Assert.Equal(new Size(expectedBlocksX, expectedBlocksY), component.SizeInBlocks); } internal static void VerifyComponent( diff --git a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs index 1b71f49d5..5cbdd3dab 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(file, new()); + image.SaveAsPbm(file, new PbmEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPbm(memoryStream, new()); + image.SaveAsPbm(memoryStream, new PbmEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs index 2da801532..476538ccd 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmDecoderTests.cs @@ -108,7 +108,7 @@ public class PbmDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PbmDecoder.Instance, options); @@ -130,7 +130,7 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(bytes); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new(100, 100), eofHitCounter.Image.Size); + Assert.Equal(new Size(100, 100), eofHitCounter.Image.Size); } [Fact] @@ -139,6 +139,6 @@ public class PbmDecoderTests using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(RgbBinaryPrematureEof); Assert.True(eofHitCounter.EofHitCount <= 2); - Assert.Equal(new(29, 30), eofHitCounter.Image.Size); + Assert.Equal(new Size(29, 30), eofHitCounter.Image.Size); } } diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs index 0501ed2b2..0fea65f6e 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmEncoderTests.cs @@ -38,12 +38,12 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_PreserveColorType(string imagePath, PbmColorType pbmColorType) { - PbmEncoder options = new PbmEncoder(); + PbmEncoder options = new(); TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); memStream.Position = 0; @@ -60,7 +60,7 @@ public class PbmEncoderTests [MemberData(nameof(PbmColorTypeFiles))] public void PbmEncoder_WithPlainEncoding_PreserveBitsPerPixel(string imagePath, PbmColorType pbmColorType) { - PbmEncoder options = new PbmEncoder() + PbmEncoder options = new() { Encoding = PbmEncoding.Plain }; @@ -68,7 +68,7 @@ public class PbmEncoderTests TestFile testFile = TestFile.Create(imagePath); using (Image input = testFile.CreateRgba32Image()) { - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { input.Save(memStream, options); @@ -132,9 +132,9 @@ public class PbmEncoderTests { using (Image image = provider.GetImage()) { - PbmEncoder encoder = new PbmEncoder { ColorType = colorType, Encoding = encoding }; + PbmEncoder encoder = new() { ColorType = colorType, Encoding = encoding }; - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); memStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs index f7c6dc171..6524b3506 100644 --- a/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs +++ b/tests/ImageSharp.Tests/Formats/Pbm/PbmRoundTripTests.cs @@ -22,7 +22,7 @@ public class PbmRoundTripTests { // Arrange TestFile testFile = TestFile.Create(imagePath); - using MemoryStream stream = new MemoryStream(testFile.Bytes, false); + using MemoryStream stream = new(testFile.Bytes, false); // Act using Image originalImage = Image.Load(stream); @@ -43,7 +43,7 @@ public class PbmRoundTripTests { // Arrange TestFile testFile = TestFile.Create(imagePath); - using MemoryStream stream = new MemoryStream(testFile.Bytes, false); + using MemoryStream stream = new(testFile.Bytes, false); // Act using Image originalImage = Image.Load(stream); @@ -57,7 +57,7 @@ public class PbmRoundTripTests private Image RoundTrip(Image originalImage) where TPixel : unmanaged, IPixel { - using MemoryStream decodedStream = new MemoryStream(); + using MemoryStream decodedStream = new(); originalImage.SaveAsPbm(decodedStream); decodedStream.Seek(0, SeekOrigin.Begin); Image encodedImage = Image.Load(decodedStream); diff --git a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs index 6e03042fa..53f9a0278 100644 --- a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs @@ -30,7 +30,7 @@ public class Adler32Tests { // arrange byte[] data = GetBuffer(length); - SharpAdler32 adler = new SharpAdler32(); + SharpAdler32 adler = new(); adler.Update(data); long expected = adler.Value; diff --git a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs index 145cc1d68..a03e1a7aa 100644 --- a/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Png/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(file, new()); + image.SaveAsPng(file, new PngEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsPng(memoryStream, new()); + image.SaveAsPng(memoryStream, new PngEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index 71523d5b6..829cc64ff 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -64,7 +64,7 @@ public partial class PngDecoderTests { string chunkName = GetChunkTypeName(chunkType); - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { WriteHeaderChunk(memStream); WriteChunk(memStream, chunkName); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 26da6f521..1a74fe5b2 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -140,7 +140,7 @@ public partial class PngDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PngDecoder.Instance, options); @@ -178,7 +178,7 @@ public partial class PngDecoderTests DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(PngDecoder.Instance, options); @@ -389,7 +389,7 @@ public partial class PngDecoderTests TestFile testFile = TestFile.Create(imagePath); using MemoryStream stream = new(testFile.Bytes, false); - ImageInfo imageInfo = Image.Identify(new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); + ImageInfo imageInfo = Image.Identify(new DecoderOptions { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream); Assert.NotNull(imageInfo); Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel); @@ -674,12 +674,12 @@ public partial class PngDecoderTests public void Binary_PrematureEof() { PngDecoder decoder = PngDecoder.Instance; - PngDecoderOptions options = new() { GeneralOptions = new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData } }; + PngDecoderOptions options = new() { GeneralOptions = new DecoderOptions { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData } }; using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(TestImages.Png.Bad.FlagOfGermany0000016446, decoder, options); // TODO: Try to reduce this to 1. Assert.True(eofHitCounter.EofHitCount <= 3); - Assert.Equal(new(200, 120), eofHitCounter.Image.Size); + Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 9ce1a9386..a930426b6 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -31,7 +31,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -45,7 +45,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -59,7 +59,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -73,7 +73,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Average, Size); + TestData data = new(PngFilterMethod.Average, Size); data.TestFilter(); } @@ -87,7 +87,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -101,7 +101,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -115,7 +115,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Paeth, Size); + TestData data = new(PngFilterMethod.Paeth, Size); data.TestFilter(); } @@ -129,7 +129,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -143,7 +143,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -157,7 +157,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Up, Size); + TestData data = new(PngFilterMethod.Up, Size); data.TestFilter(); } @@ -171,7 +171,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -185,7 +185,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -199,7 +199,7 @@ public class PngEncoderFilterTests : MeasureFixture { static void RunTest() { - TestData data = new TestData(PngFilterMethod.Sub, Size); + TestData data = new(PngFilterMethod.Sub, Size); data.TestFilter(); } @@ -227,7 +227,7 @@ public class PngEncoderFilterTests : MeasureFixture this.expectedResult = new byte[1 + (size * size * bpp)]; this.resultBuffer = new byte[1 + (size * size * bpp)]; - Random rng = new Random(12345678); + Random rng = new(12345678); byte[] tmp = new byte[6]; for (int i = 0; i < this.previousScanline.Length; i += bpp) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 56909b9dc..f1dcb357c 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -380,7 +380,7 @@ public partial class PngEncoderTests if (colorType is PngColorType.Grayscale or PngColorType.GrayscaleWithAlpha) { byte luminance = ColorNumerics.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); - expectedColor = new(luminance, luminance, luminance); + expectedColor = new Rgba32(luminance, luminance, luminance); } actual.ProcessPixelRows(accessor => @@ -680,7 +680,7 @@ public partial class PngEncoderTests PaletteQuantizer quantizer = new( palette.Select(Color.FromPixel).ToArray(), - new() { ColorMatchingMode = ColorMatchingMode.Hybrid }); + new QuantizerOptions { ColorMatchingMode = ColorMatchingMode.Hybrid }); using MemoryStream ms = new(); image.Save(ms, new PngEncoder @@ -720,7 +720,7 @@ public partial class PngEncoderTests FilterMethod = pngFilterMethod, CompressionLevel = compressionLevel, BitDepth = bitDepth, - Quantizer = new WuQuantizer(new() { MaxColors = paletteSize }), + Quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = paletteSize }), InterlaceMethod = interlaceMode, ChunkFilter = optimizeMethod, }; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs index 8fde21654..efc18c16a 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngFrameMetadataTests.cs @@ -14,7 +14,7 @@ public class PngFrameMetadataTests { PngFrameMetadata meta = new() { - FrameDelay = new(1, 0), + FrameDelay = new Rational(1, 0), DisposalMode = FrameDisposalMode.RestoreToBackground, BlendMode = FrameBlendMode.Over, }; @@ -25,7 +25,7 @@ public class PngFrameMetadataTests Assert.True(meta.DisposalMode.Equals(clone.DisposalMode)); Assert.True(meta.BlendMode.Equals(clone.BlendMode)); - clone.FrameDelay = new(2, 1); + clone.FrameDelay = new Rational(2, 1); clone.DisposalMode = FrameDisposalMode.RestoreToPrevious; clone.BlendMode = FrameBlendMode.Source; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 690299024..5cbc27611 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -111,10 +111,10 @@ public class PngMetadataTests using MemoryStream memoryStream = new(); // This will be a zTXt chunk. - PngTextData expectedText = new("large-text", new('c', 100), string.Empty, string.Empty); + PngTextData expectedText = new("large-text", new string('c', 100), string.Empty, string.Empty); // This will be a iTXt chunk. - PngTextData expectedTextNoneLatin = new("large-text-non-latin", new('Ф', 100), "language-tag", "translated-keyword"); + PngTextData expectedTextNoneLatin = new("large-text-non-latin", new string('Ф', 100), "language-tag", "translated-keyword"); PngMetadata inputMetadata = input.Metadata.GetFormatMetadata(PngFormat.Instance); inputMetadata.TextData.Add(expectedText); inputMetadata.TextData.Add(expectedTextNoneLatin); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs index f4c2f5897..4c46692f3 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngTextDataTests.cs @@ -65,7 +65,7 @@ public class PngTextDataTests Assert.Equal("unit", property.LanguageTag); Assert.Equal("test", property.TranslatedKeyword); - property = new("Foo", string.Empty, string.Empty, null); + property = new PngTextData("Foo", string.Empty, string.Empty, null); Assert.Equal("Foo", property.Keyword); Assert.Equal(string.Empty, property.Value); Assert.Equal(string.Empty, property.LanguageTag); diff --git a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs index 11e79512e..31ec27da0 100644 --- a/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Qoi/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(file, new()); + image.SaveAsQoi(file, new QoiEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsQoi(memoryStream, new()); + image.SaveAsQoi(memoryStream, new QoiEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs index 9648f93e5..9b6daee4c 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/ImageExtensionsTest.cs @@ -47,7 +47,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(file, new()); + image.SaveAsTga(file, new TgaEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -108,7 +108,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTga(memoryStream, new()); + image.SaveAsTga(memoryStream, new TgaEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs index dbd7885e5..03669908e 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs @@ -749,7 +749,7 @@ public class TgaDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(TgaDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs index 04e8f2940..d19f27807 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/BigTiffMetadataTests.cs @@ -131,7 +131,7 @@ public class BigTiffMetadataTests values.Add(newExifValue); } - input.Frames.RootFrame.Metadata.ExifProfile = new(values, Array.Empty()); + input.Frames.RootFrame.Metadata.ExifProfile = new ExifProfile(values, Array.Empty()); // act TiffEncoder encoder = new(); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs index ca39cd5be..cc2faeab7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/DeflateTiffCompressionTests.cs @@ -41,6 +41,6 @@ public class DeflateTiffCompressionTests } compressedStream.Seek(0, SeekOrigin.Begin); - return new(Configuration.Default, compressedStream); + return new BufferedReadStream(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs index 01aaca9f5..25c9633c1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/LzwTiffCompressionTests.cs @@ -54,6 +54,6 @@ public class LzwTiffCompressionTests compressedStream.Seek(0, SeekOrigin.Begin); - return new(Configuration.Default, compressedStream); + return new BufferedReadStream(Configuration.Default, compressedStream); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs index 0a2726c21..b911d1b17 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/NoneTiffCompressionTests.cs @@ -14,11 +14,11 @@ public class NoneTiffCompressionTests [InlineData(new byte[] { 10, 15, 20, 25, 30, 35, 40, 45 }, 5, new byte[] { 10, 15, 20, 25, 30 })] public void Decompress_ReadsData(byte[] inputData, uint byteCount, byte[] expectedResult) { - using MemoryStream memoryStream = new MemoryStream(inputData); - using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using NoneTiffCompression decompressor = new NoneTiffCompression(default, default, default); + using NoneTiffCompression decompressor = new(default, default, default); decompressor.Decompress(stream, 0, byteCount, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs index f5fbcb2e1..8f71cdda7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Compression/PackBitsTiffCompressionTests.cs @@ -22,11 +22,11 @@ public class PackBitsTiffCompressionTests [InlineData(new byte[] { 0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA }, new byte[] { 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA })] // Apple PackBits sample public void Decompress_ReadsData(byte[] inputData, byte[] expectedResult) { - using MemoryStream memoryStream = new MemoryStream(inputData); - using BufferedReadStream stream = new BufferedReadStream(Configuration.Default, memoryStream); + using MemoryStream memoryStream = new(inputData); + using BufferedReadStream stream = new(Configuration.Default, memoryStream); byte[] buffer = new byte[expectedResult.Length]; - using PackBitsTiffCompression decompressor = new PackBitsTiffCompression(MemoryAllocator.Create(), default, default); + using PackBitsTiffCompression decompressor = new(MemoryAllocator.Create(), default, default); decompressor.Decompress(stream, 0, (uint)inputData.Length, 1, buffer, default); Assert.Equal(expectedResult, buffer); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs index 69d70e5e7..bf9e73ea6 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(file, new()); + image.SaveAsTiff(file, new TiffEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTest using (Image image = new(10, 10)) { - image.SaveAsTiff(memoryStream, new()); + image.SaveAsTiff(memoryStream, new TiffEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index d2176f7e6..0fa7e01e8 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -154,7 +154,7 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode( expectedResult, - pixels => new BlackIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); + pixels => new BlackIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height)); [Theory] [MemberData(nameof(BilevelData))] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index fce40c4c4..13be77a29 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -83,7 +83,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, ushort[] colorMap, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode(expectedResult, pixels => { - new PaletteTiffColor(new(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); + new PaletteTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); }); private static uint[][] GeneratePalette(int count) @@ -124,7 +124,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase for (int x = 0; x < pixelLookup[y].Length; x++) { uint[] sourceColor = colorPalette[pixelLookup[y][x]]; - result[y][x] = new(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); + result[y][x] = new Rgba32(sourceColor[0] / 65535F, sourceColor[1] / 65535F, sourceColor[2] / 65535F); } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs index ef57b288c..7040e167d 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PhotometricInterpretationTestBase.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public abstract class PhotometricInterpretationTestBase { - public static Rgba32 DefaultColor = new Rgba32(42, 96, 18, 128); + public static Rgba32 DefaultColor = new(42, 96, 18, 128); public static Rgba32[][] Offset(Rgba32[][] input, int xOffset, int yOffset, int width, int height) { @@ -45,7 +45,7 @@ public abstract class PhotometricInterpretationTestBase int resultWidth = expectedResult[0].Length; int resultHeight = expectedResult.Length; - using (Image image = new Image(resultWidth, resultHeight)) + using (Image image = new(resultWidth, resultHeight)) { image.Mutate(x => x.BackgroundColor(Color.FromPixel(DefaultColor))); Buffer2D pixels = image.GetRootFramePixelBuffer(); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index 6e0d5b2be..2ca9df3d0 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -12,19 +12,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4R = { @@ -112,19 +112,19 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4R = { @@ -175,19 +175,19 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4R = { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs index aeb135773..80a04a7d1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs @@ -10,19 +10,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff.PhotometricInterpretation; [Trait("Format", "Tiff")] public class RgbTiffColorTests : PhotometricInterpretationTestBase { - private static readonly Rgba32 Rgb4_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb4_444 = new Rgba32(68, 68, 68, 255); - private static readonly Rgba32 Rgb4_888 = new Rgba32(136, 136, 136, 255); - private static readonly Rgba32 Rgb4_CCC = new Rgba32(204, 204, 204, 255); - private static readonly Rgba32 Rgb4_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb4_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb4_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb4_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb4_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb4_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb4_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb4_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb4_48C = new Rgba32(68, 136, 204, 255); + private static readonly Rgba32 Rgb4_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb4_444 = new(68, 68, 68, 255); + private static readonly Rgba32 Rgb4_888 = new(136, 136, 136, 255); + private static readonly Rgba32 Rgb4_CCC = new(204, 204, 204, 255); + private static readonly Rgba32 Rgb4_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb4_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb4_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb4_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb4_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb4_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb4_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb4_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4 = { @@ -74,19 +74,19 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb8_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb8_444 = new Rgba32(64, 64, 64, 255); - private static readonly Rgba32 Rgb8_888 = new Rgba32(128, 128, 128, 255); - private static readonly Rgba32 Rgb8_CCC = new Rgba32(192, 192, 192, 255); - private static readonly Rgba32 Rgb8_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb8_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb8_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb8_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb8_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb8_400 = new Rgba32(64, 0, 0, 255); - private static readonly Rgba32 Rgb8_800 = new Rgba32(128, 0, 0, 255); - private static readonly Rgba32 Rgb8_C00 = new Rgba32(192, 0, 0, 255); - private static readonly Rgba32 Rgb8_48C = new Rgba32(64, 128, 192, 255); + private static readonly Rgba32 Rgb8_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb8_444 = new(64, 64, 64, 255); + private static readonly Rgba32 Rgb8_888 = new(128, 128, 128, 255); + private static readonly Rgba32 Rgb8_CCC = new(192, 192, 192, 255); + private static readonly Rgba32 Rgb8_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb8_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb8_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb8_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb8_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb8_400 = new(64, 0, 0, 255); + private static readonly Rgba32 Rgb8_800 = new(128, 0, 0, 255); + private static readonly Rgba32 Rgb8_C00 = new(192, 0, 0, 255); + private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4 = { @@ -116,19 +116,19 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase } } - private static readonly Rgba32 Rgb484_000 = new Rgba32(0, 0, 0, 255); - private static readonly Rgba32 Rgb484_444 = new Rgba32(68, 64, 68, 255); - private static readonly Rgba32 Rgb484_888 = new Rgba32(136, 128, 136, 255); - private static readonly Rgba32 Rgb484_CCC = new Rgba32(204, 192, 204, 255); - private static readonly Rgba32 Rgb484_FFF = new Rgba32(255, 255, 255, 255); - private static readonly Rgba32 Rgb484_F00 = new Rgba32(255, 0, 0, 255); - private static readonly Rgba32 Rgb484_0F0 = new Rgba32(0, 255, 0, 255); - private static readonly Rgba32 Rgb484_00F = new Rgba32(0, 0, 255, 255); - private static readonly Rgba32 Rgb484_F0F = new Rgba32(255, 0, 255, 255); - private static readonly Rgba32 Rgb484_400 = new Rgba32(68, 0, 0, 255); - private static readonly Rgba32 Rgb484_800 = new Rgba32(136, 0, 0, 255); - private static readonly Rgba32 Rgb484_C00 = new Rgba32(204, 0, 0, 255); - private static readonly Rgba32 Rgb484_48C = new Rgba32(68, 128, 204, 255); + private static readonly Rgba32 Rgb484_000 = new(0, 0, 0, 255); + private static readonly Rgba32 Rgb484_444 = new(68, 64, 68, 255); + private static readonly Rgba32 Rgb484_888 = new(136, 128, 136, 255); + private static readonly Rgba32 Rgb484_CCC = new(204, 192, 204, 255); + private static readonly Rgba32 Rgb484_FFF = new(255, 255, 255, 255); + private static readonly Rgba32 Rgb484_F00 = new(255, 0, 0, 255); + private static readonly Rgba32 Rgb484_0F0 = new(0, 255, 0, 255); + private static readonly Rgba32 Rgb484_00F = new(0, 0, 255, 255); + private static readonly Rgba32 Rgb484_F0F = new(255, 0, 255, 255); + private static readonly Rgba32 Rgb484_400 = new(68, 0, 0, 255); + private static readonly Rgba32 Rgb484_800 = new(136, 0, 0, 255); + private static readonly Rgba32 Rgb484_C00 = new(204, 0, 0, 255); + private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4 = { diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index a79cc0058..fa193c184 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -155,7 +155,7 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { AssertDecode(expectedResult, pixels => { - new WhiteIsZeroTiffColor(new(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); + new WhiteIsZeroTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0)).Decode(inputData, pixels, left, top, width, height); }); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index a16b26f9e..5dd1f7884 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -810,7 +810,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(TiffDecoder.Instance, options); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs index 70ba2e5df..158a0d473 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderBaseTester.cs @@ -26,9 +26,9 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { // arrange - TiffEncoder tiffEncoder = new TiffEncoder() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; + TiffEncoder tiffEncoder = new() { PhotometricInterpretation = photometricInterpretation, Compression = compression }; using Image input = provider.GetImage(); - using MemoryStream memStream = new MemoryStream(); + using MemoryStream memStream = new(); TiffFrameMetadata inputMeta = input.Frames.RootFrame.Metadata.GetTiffMetadata(); TiffCompression inputCompression = inputMeta.Compression; @@ -89,7 +89,7 @@ public abstract class TiffEncoderBaseTester where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - TiffEncoder encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = photometricInterpretation, BitsPerPixel = bitsPerPixel, diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs index a138d9ef8..9f6e74183 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderMultiframeTests.cs @@ -46,7 +46,7 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - TiffEncoder encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, @@ -69,22 +69,22 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester using Image image = provider.GetImage(); Assert.Equal(1, image.Frames.Count); - using Image image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using Image image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image1.Frames.RootFrame); image.Frames.AddFrame(image2.Frames.RootFrame); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit24; - TiffEncoder encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.Rgb, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Deflate }; - using (MemoryStream ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new()) { image.Save(ms, encoder); @@ -121,11 +121,11 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester { using Image image = provider.GetImage(); - using Image image0 = new Image(image.Width, image.Height, Color.Red.ToPixel()); + using Image image0 = new(image.Width, image.Height, Color.Red.ToPixel()); - using Image image1 = new Image(image.Width, image.Height, Color.Green.ToPixel()); + using Image image1 = new(image.Width, image.Height, Color.Green.ToPixel()); - using Image image2 = new Image(image.Width, image.Height, Color.Yellow.ToPixel()); + using Image image2 = new(image.Width, image.Height, Color.Yellow.ToPixel()); image.Frames.AddFrame(image0.Frames.RootFrame); image.Frames.AddFrame(image1.Frames.RootFrame); @@ -133,14 +133,14 @@ public class TiffEncoderMultiframeTests : TiffEncoderBaseTester image.Frames.RemoveFrame(0); TiffBitsPerPixel bitsPerPixel = TiffBitsPerPixel.Bit8; - TiffEncoder encoder = new TiffEncoder + TiffEncoder encoder = new() { PhotometricInterpretation = TiffPhotometricInterpretation.PaletteColor, BitsPerPixel = bitsPerPixel, Compression = TiffCompression.Lzw }; - using (MemoryStream ms = new System.IO.MemoryStream()) + using (MemoryStream ms = new()) { image.Save(ms, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index b00b8d7ac..4317c2714 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -334,7 +334,7 @@ public class TiffEncoderTests : TiffEncoderBaseTester foreach (ImageFrame frame in image.Frames) { TiffFrameMetadata metadata = frame.Metadata.GetTiffMetadata(); - encodedDimensions.Add(new(metadata.EncodingWidth, metadata.EncodingHeight)); + encodedDimensions.Add(new Size(metadata.EncodingWidth, metadata.EncodingHeight)); } const int scale = 2; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs index 3bcbd26e5..939baeeb6 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffWriterTests.cs @@ -11,8 +11,8 @@ public class TiffWriterTests [Fact] public void IsLittleEndian_IsTrueOnWindows() { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); Assert.True(TiffStreamWriter.IsLittleEndian); } @@ -22,8 +22,8 @@ public class TiffWriterTests [InlineData(new byte[] { 1, 2, 3, 4, 5 }, 5)] public void Position_EqualsTheStreamPosition(byte[] data, long expectedResult) { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(data); Assert.Equal(writer.Position, expectedResult); } @@ -31,8 +31,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByte() { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(42); Assert.Equal(new byte[] { 42 }, stream.ToArray()); @@ -41,8 +41,8 @@ public class TiffWriterTests [Fact] public void Write_WritesByteArray() { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(new byte[] { 2, 4, 6, 8 }); Assert.Equal(new byte[] { 2, 4, 6, 8 }, stream.ToArray()); @@ -51,8 +51,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt16() { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(1234, stackalloc byte[2]); Assert.Equal(new byte[] { 0xD2, 0x04 }, stream.ToArray()); @@ -61,8 +61,8 @@ public class TiffWriterTests [Fact] public void Write_WritesUInt32() { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.Write(12345678U, stackalloc byte[4]); Assert.Equal(new byte[] { 0x4E, 0x61, 0xBC, 0x00 }, stream.ToArray()); @@ -78,8 +78,8 @@ public class TiffWriterTests public void WritePadded_WritesByteArray(byte[] bytes, byte[] expectedResult) { - using MemoryStream stream = new MemoryStream(); - using TiffStreamWriter writer = new TiffStreamWriter(stream); + using MemoryStream stream = new(); + using TiffStreamWriter writer = new(stream); writer.WritePadded(bytes); Assert.Equal(expectedResult, stream.ToArray()); @@ -88,10 +88,10 @@ public class TiffWriterTests [Fact] public void WriteMarker_WritesToPlacedPosition() { - using MemoryStream stream = new MemoryStream(); + using MemoryStream stream = new(); Span buffer = stackalloc byte[4]; - using (TiffStreamWriter writer = new TiffStreamWriter(stream)) + using (TiffStreamWriter writer = new(stream)) { writer.Write(0x11111111, buffer); long marker = writer.PlaceMarker(buffer); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs index 510d67103..ea13fd712 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ImageExtensionsTests.cs @@ -48,7 +48,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(file, new()); + image.SaveAsWebp(file, new WebpEncoder()); } IImageFormat format = Image.DetectFormat(file); @@ -109,7 +109,7 @@ public class ImageExtensionsTests using (Image image = new(10, 10)) { - image.SaveAsWebp(memoryStream, new()); + image.SaveAsWebp(memoryStream, new WebpEncoder()); } memoryStream.Position = 0; diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 321aff2bd..09aa94c75 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -89,7 +89,7 @@ public class LosslessUtilsTests 392450, 196861, 16712192, 16711680, 130564, 16451071 }; - Vp8LMultipliers m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, @@ -121,7 +121,7 @@ public class LosslessUtilsTests 16711680, 65027, 16712962 }; - Vp8LMultipliers m = new Vp8LMultipliers() + Vp8LMultipliers m = new() { GreenToBlue = 240, GreenToRed = 232, diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index a15441756..b4279b045 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -150,7 +150,7 @@ public class PredictorEncoderTests where TPixel : unmanaged, IPixel { Rgba32 rgba = color.ToRgba32(); - return new(rgba.R, rgba.G, rgba.B, rgba.A); + return new Bgra32(rgba.R, rgba.G, rgba.B, rgba.A); } private static string TestImageFullPath(string path) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs index 79c7ff26b..990c58385 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8HistogramTests.cs @@ -13,7 +13,7 @@ public class Vp8HistogramTests { get { - List result = new List(); + List result = new(); result.Add(new object[] { new byte[] @@ -69,7 +69,7 @@ public class Vp8HistogramTests private static void RunCollectHistogramTest() { // arrange - Vp8Histogram histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); byte[] reference = { @@ -172,7 +172,7 @@ public class Vp8HistogramTests public void GetAlpha_WithEmptyHistogram_Works() { // arrange - Vp8Histogram histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); // act int alpha = histogram.GetAlpha(); @@ -186,7 +186,7 @@ public class Vp8HistogramTests public void GetAlpha_Works(byte[] reference, byte[] pred) { // arrange - Vp8Histogram histogram = new Vp8Histogram(); + Vp8Histogram histogram = new(); histogram.CollectHistogram(reference, pred, 0, 1); // act @@ -201,9 +201,9 @@ public class Vp8HistogramTests public void Merge_Works(byte[] reference, byte[] pred) { // arrange - Vp8Histogram histogram1 = new Vp8Histogram(); + Vp8Histogram histogram1 = new(); histogram1.CollectHistogram(reference, pred, 0, 1); - Vp8Histogram histogram2 = new Vp8Histogram(); + Vp8Histogram histogram2 = new(); histogram1.Merge(histogram2); // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs index a014e8991..ded637967 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ModeScoreTests.cs @@ -11,7 +11,7 @@ public class Vp8ModeScoreTests [Fact] public void InitScore_Works() { - Vp8ModeScore score = new Vp8ModeScore(); + Vp8ModeScore score = new(); score.InitScore(); Assert.Equal(0, score.D); Assert.Equal(0, score.SD); @@ -25,7 +25,7 @@ public class Vp8ModeScoreTests public void CopyScore_Works() { // arrange - Vp8ModeScore score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -36,7 +36,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - Vp8ModeScore score2 = new Vp8ModeScore(); + Vp8ModeScore score2 = new(); score2.InitScore(); // act @@ -55,7 +55,7 @@ public class Vp8ModeScoreTests public void AddScore_Works() { // arrange - Vp8ModeScore score1 = new Vp8ModeScore + Vp8ModeScore score1 = new() { Score = 123, Nz = 1, @@ -66,7 +66,7 @@ public class Vp8ModeScoreTests R = 6, SD = 7 }; - Vp8ModeScore score2 = new Vp8ModeScore + Vp8ModeScore score2 = new() { Score = 123, Nz = 1, diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index dcb54dc19..4982929c2 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -80,7 +80,7 @@ public class Vp8ResidualTests Vp8BandProbas[] bandProbas = new Vp8BandProbas[8]; for (int i = 0; i < bandProbas.Length; i++) { - bandProbas[i] = new(); + bandProbas[i] = new Vp8BandProbas(); for (int j = 0; j < bandProbas[i].Probabilities.Length; j++) { for (int k = 0; k < 11; k++) @@ -95,7 +95,7 @@ public class Vp8ResidualTests residual.Costs = new Vp8Costs[16]; for (int i = 0; i < residual.Costs.Length; i++) { - residual.Costs[i] = new(); + residual.Costs[i] = new Vp8Costs(); Vp8CostArray[] costsArray = residual.Costs[i].Costs; for (int j = 0; j < costsArray.Length; j++) { @@ -109,7 +109,7 @@ public class Vp8ResidualTests residual.Stats = new Vp8Stats[8]; for (int i = 0; i < residual.Stats.Length; i++) { - residual.Stats[i] = new(); + residual.Stats[i] = new Vp8Stats(); for (int j = 0; j < residual.Stats[i].Stats.Length; j++) { for (int k = 0; k < residual.Stats[i].Stats[j].Stats.Length; k++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index f8c7770e6..111544f7f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -349,7 +349,7 @@ public class WebpDecoderTests WebpDecoderOptions options = new() { BackgroundColorHandling = BackgroundColorHandling.Ignore, - GeneralOptions = new() + GeneralOptions = new DecoderOptions { MaxFrames = 1 } @@ -388,7 +388,7 @@ public class WebpDecoderTests { DecoderOptions options = new() { - TargetSize = new() { Width = 150, Height = 150 } + TargetSize = new Size { Width = 150, Height = 150 } }; using Image image = provider.GetImage(WebpDecoder.Instance, options); @@ -460,7 +460,7 @@ public class WebpDecoderTests // Web using Image image = provider.GetImage( WebpDecoder.Instance, - new() { BackgroundColorHandling = BackgroundColorHandling.Ignore }); + new WebpDecoderOptions { BackgroundColorHandling = BackgroundColorHandling.Ignore }); // We can't use the reference decoder here. // It creates frames of different size without blending the frames. diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs index 55a6e8ba0..f9836ffb1 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs @@ -139,14 +139,14 @@ public class WebpEncoderTests }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "octree"); - gifEncoder = new() + gifEncoder = new GifEncoder { Quantizer = new WuQuantizer(options) }; provider.Utility.SaveTestOutputFile(image, "gif", gifEncoder, "wu"); // Now clone and quantize the image using the same quantizers without alpha thresholding and save as webp. - options = new() + options = new QuantizerOptions { TransparencyThreshold = 0 }; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs index fefe27790..020b42f37 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpMetaDataTests.cs @@ -103,9 +103,9 @@ public class WebpMetaDataTests public void Encode_WritesExifWithPadding(WebpFileFormatType fileFormatType) { // arrange - using Image input = new Image(25, 25); - using MemoryStream memoryStream = new MemoryStream(); - ExifProfile expectedExif = new ExifProfile(); + using Image input = new(25, 25); + using MemoryStream memoryStream = new(); + ExifProfile expectedExif = new(); string expectedSoftware = "ImageSharp"; expectedExif.SetValue(ExifTag.Software, expectedSoftware); input.Metadata.ExifProfile = expectedExif; @@ -129,7 +129,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using MemoryStream memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -150,7 +150,7 @@ public class WebpMetaDataTests { // arrange using Image input = provider.GetImage(WebpDecoder.Instance); - using MemoryStream memoryStream = new MemoryStream(); + using MemoryStream memoryStream = new(); ExifProfile expectedExif = input.Metadata.ExifProfile; // act @@ -174,7 +174,7 @@ public class WebpMetaDataTests ImageSharp.Metadata.Profiles.Icc.IccProfile expectedProfile = input.Metadata.IccProfile; byte[] expectedProfileBytes = expectedProfile.ToByteArray(); - using MemoryStream memStream = new MemoryStream(); + using MemoryStream memStream = new(); input.Save(memStream, new WebpEncoder() { FileFormat = fileFormat diff --git a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs index e894f7b86..682f5373d 100644 --- a/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicOptionsDefaultsExtensionsTests.cs @@ -12,9 +12,9 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnProcessingContext() { - GraphicsOptions option = new GraphicsOptions(); - Configuration config = new Configuration(); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + GraphicsOptions option = new(); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); @@ -26,12 +26,12 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnProcessingContext_AlwaysNewInstance() { - GraphicsOptions option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - Configuration config = new Configuration(); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions(option); context.SetGraphicsOptions(o => @@ -48,8 +48,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void SetDefaultOptionsOnConfiguration() { - GraphicsOptions option = new GraphicsOptions(); - Configuration config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); @@ -59,11 +59,11 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void UpdateDefaultOptionsOnConfiguration_AlwaysNewInstance() { - GraphicsOptions option = new GraphicsOptions() + GraphicsOptions option = new() { BlendPercentage = 0.9f }; - Configuration config = new Configuration(); + Configuration config = new(); config.SetGraphicsOptions(option); config.SetGraphicsOptions(o => @@ -80,7 +80,7 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_SettingNullThenReturnsNewInstance() { - Configuration config = new Configuration(); + Configuration config = new(); GraphicsOptions options = config.GetGraphicsOptions(); Assert.NotNull(options); @@ -96,7 +96,7 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_IgnoreIncorectlyTypesDictionEntry() { - Configuration config = new Configuration(); + Configuration config = new(); config.Properties[typeof(GraphicsOptions)] = "wronge type"; GraphicsOptions options = config.GetGraphicsOptions(); @@ -107,7 +107,7 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsInstance() { - Configuration config = new Configuration(); + Configuration config = new(); Assert.DoesNotContain(typeof(GraphicsOptions), config.Properties.Keys); GraphicsOptions options = config.GetGraphicsOptions(); @@ -117,7 +117,7 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromConfiguration_AlwaysReturnsSameValue() { - Configuration config = new Configuration(); + Configuration config = new(); GraphicsOptions options = config.GetGraphicsOptions(); GraphicsOptions options2 = config.GetGraphicsOptions(); @@ -127,8 +127,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstance() { - Configuration config = new Configuration(); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.NotNull(ctxOptions); @@ -137,8 +137,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromProcessingContext_AlwaysReturnsInstanceEvenIfSetToNull() { - Configuration config = new Configuration(); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.SetGraphicsOptions((GraphicsOptions)null); GraphicsOptions ctxOptions = context.GetGraphicsOptions(); @@ -148,10 +148,10 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromProcessingContext_FallbackToConfigsInstance() { - GraphicsOptions option = new GraphicsOptions(); - Configuration config = new Configuration(); + GraphicsOptions option = new(); + Configuration config = new(); config.SetGraphicsOptions(option); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); GraphicsOptions ctxOptions = context.GetGraphicsOptions(); Assert.Equal(option, ctxOptions); @@ -160,8 +160,8 @@ public class GraphicOptionsDefaultsExtensionsTests [Fact] public void GetDefaultOptionsFromProcessingContext_IgnoreIncorectlyTypesDictionEntry() { - Configuration config = new Configuration(); - FakeImageOperationsProvider.FakeImageOperations context = new FakeImageOperationsProvider.FakeImageOperations(config, null, true); + Configuration config = new(); + FakeImageOperationsProvider.FakeImageOperations context = new(config, null, true); context.Properties[typeof(GraphicsOptions)] = "wronge type"; GraphicsOptions options = context.GetGraphicsOptions(); Assert.NotNull(options); diff --git a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs index 351254e40..0ccb80d3f 100644 --- a/tests/ImageSharp.Tests/GraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/GraphicsOptionsTests.cs @@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Tests; public class GraphicsOptionsTests { - private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new GraphicsOptionsComparer(); - private readonly GraphicsOptions newGraphicsOptions = new GraphicsOptions(); + private static readonly GraphicsOptionsComparer GraphicsOptionsComparer = new(); + private readonly GraphicsOptions newGraphicsOptions = new(); private readonly GraphicsOptions cloneGraphicsOptions = new GraphicsOptions().DeepClone(); [Fact] @@ -57,7 +57,7 @@ public class GraphicsOptionsTests [Fact] public void NonDefaultClone() { - GraphicsOptions expected = new GraphicsOptions + GraphicsOptions expected = new() { AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop, Antialias = false, @@ -74,7 +74,7 @@ public class GraphicsOptionsTests [Fact] public void CloneIsDeep() { - GraphicsOptions expected = new GraphicsOptions(); + GraphicsOptions expected = new(); GraphicsOptions actual = expected.DeepClone(); actual.AlphaCompositionMode = PixelAlphaCompositionMode.DestAtop; diff --git a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs index 1e6ab7bc9..1bf137f34 100644 --- a/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ColorNumericsTests.cs @@ -15,7 +15,7 @@ public class ColorNumericsTests public void GetBT709Luminance_WithVector4(float x, float y, float z, int luminanceLevels, int expected) { // arrange - Vector4 vector = new Vector4(x, y, z, 0.0f); + Vector4 vector = new(x, y, z, 0.0f); // act int actual = ColorNumerics.GetBT709Luminance(ref vector, luminanceLevels); diff --git a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs index c40fffd55..1106144c4 100644 --- a/tests/ImageSharp.Tests/Helpers/NumericsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/NumericsTests.cs @@ -9,7 +9,7 @@ public class NumericsTests { private delegate void SpanAction(Span span, TArg arg, TArg1 arg1); - private readonly ApproximateFloatComparer approximateFloatComparer = new ApproximateFloatComparer(1e-6f); + private readonly ApproximateFloatComparer approximateFloatComparer = new(1e-6f); [Theory] [InlineData(0)] @@ -162,7 +162,7 @@ public class NumericsTests [InlineData(63)] public void PremultiplyVectorSpan(int length) { - Random rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -182,7 +182,7 @@ public class NumericsTests [InlineData(63)] public void UnPremultiplyVectorSpan(int length) { - Random rnd = new Random(42); + Random rnd = new(42); Vector4[] source = rnd.GenerateRandomVectorArray(length, 0, 1); Vector4[] expected = source.Select(v => { @@ -280,7 +280,7 @@ public class NumericsTests { Span actual = new T[length]; - Random r = new Random(); + Random r = new(); for (int i = 0; i < length; i++) { actual[i] = (T)Convert.ChangeType(r.Next(byte.MinValue, byte.MaxValue), typeof(T)); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs index eadae9124..983c3cc2b 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelExecutionSettingsTests.cs @@ -28,7 +28,7 @@ public class ParallelExecutionSettingsTests } else { - ParallelExecutionSettings parallelSettings = new ParallelExecutionSettings( + ParallelExecutionSettings parallelSettings = new( maxDegreeOfParallelism, Configuration.Default.MemoryAllocator); Assert.Equal(maxDegreeOfParallelism, parallelSettings.MaxDegreeOfParallelism); diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs index e5e6b18f8..4b06f877f 100644 --- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs @@ -328,7 +328,7 @@ public class ParallelRowIteratorTests { for (int x = rect.Left; x < rect.Right; x++) { - buffer[x, y] = new(x, y); + buffer[x, y] = new Point(x, y); } } diff --git a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs index cc367df30..215cd58bc 100644 --- a/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs +++ b/tests/ImageSharp.Tests/Helpers/RowIntervalTests.cs @@ -10,7 +10,7 @@ public class RowIntervalTests [Fact] public void Slice1() { - RowInterval rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(5); Assert.Equal(15, sliced.Min); @@ -20,7 +20,7 @@ public class RowIntervalTests [Fact] public void Slice2() { - RowInterval rowInterval = new RowInterval(10, 20); + RowInterval rowInterval = new(10, 20); RowInterval sliced = rowInterval.Slice(3, 5); Assert.Equal(13, sliced.Min); @@ -30,8 +30,8 @@ public class RowIntervalTests [Fact] public void Equality_WhenTrue() { - RowInterval a = new RowInterval(42, 123); - RowInterval b = new RowInterval(42, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 123); Assert.True(a.Equals(b)); Assert.True(a.Equals((object)b)); @@ -42,9 +42,9 @@ public class RowIntervalTests [Fact] public void Equality_WhenFalse() { - RowInterval a = new RowInterval(42, 123); - RowInterval b = new RowInterval(42, 125); - RowInterval c = new RowInterval(40, 123); + RowInterval a = new(42, 123); + RowInterval b = new(42, 125); + RowInterval c = new(40, 123); Assert.False(a.Equals(b)); Assert.False(c.Equals(a)); diff --git a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs index 64f79840c..0cacbdc87 100644 --- a/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs +++ b/tests/ImageSharp.Tests/Helpers/TolerantMathTests.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers; public class TolerantMathTests { - private readonly TolerantMath tolerantMath = new TolerantMath(0.1); + private readonly TolerantMath tolerantMath = new(0.1); [Theory] [InlineData(0)] diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 560d77e21..390170cfe 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -269,7 +269,7 @@ public class ChunkedMemoryStreamTests { ChunkedMemoryStream memoryStream; const string bufferSize = nameof(bufferSize); - using (memoryStream = new(this.allocator)) + using (memoryStream = new ChunkedMemoryStream(this.allocator)) { const string destination = nameof(destination); Assert.Throws(destination, () => memoryStream.CopyTo(destination: null)); @@ -293,7 +293,7 @@ public class ChunkedMemoryStreamTests Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); // Then for the destination being disposed. - memoryStream = new(this.allocator); + memoryStream = new ChunkedMemoryStream(this.allocator); Assert.Throws(() => memoryStream.CopyTo(disposedStream, 1)); memoryStream.Dispose(); } diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 409fd46b9..0680c9a82 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -10,7 +10,7 @@ public class ImageCloneTests [Fact] public void CloneAs_WhenDisposed_Throws() { - Image image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.CloneAs()); @@ -19,7 +19,7 @@ public class ImageCloneTests [Fact] public void Clone_WhenDisposed_Throws() { - Image image = new Image(5, 5); + Image image = new(5, 5); image.Dispose(); Assert.Throws(() => image.Clone()); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs index c3ed16dcd..887a67dd3 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Globalization; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Tests; @@ -14,10 +15,10 @@ public abstract partial class ImageFrameCollectionTests : IDisposable public ImageFrameCollectionTests() { // Needed to get English exception messages, which are checked in several tests. - System.Threading.Thread.CurrentThread.CurrentUICulture = new("en-US"); + System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); - this.Image = new(10, 10); - this.Collection = new(this.Image, 10, 10, default(Rgba32)); + this.Image = new Image(10, 10); + this.Collection = new ImageFrameCollection(this.Image, 10, 10, default(Rgba32)); } public void Dispose() diff --git a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs index f3070311d..f8146363c 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameTests.cs @@ -16,7 +16,7 @@ public class ImageFrameTests private void LimitBufferCapacity(int bufferCapacityInBytes) { - TestMemoryAllocator allocator = new TestMemoryAllocator(); + TestMemoryAllocator allocator = new(); allocator.BufferCapacityInBytes = bufferCapacityInBytes; this.configuration.MemoryAllocator = allocator; } @@ -31,7 +31,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; Rgba32 val = frame[3, 4]; Assert.Equal(default(Rgba32), val); @@ -40,7 +40,7 @@ public class ImageFrameTests Assert.Equal(Color.Red.ToPixel(), val); } - public static TheoryData OutOfRangeData = new TheoryData() + public static TheoryData OutOfRangeData = new() { { false, -1 }, { false, 10 }, @@ -57,7 +57,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => _ = frame[x, 3]); Assert.Equal("x", ex.ParamName); @@ -72,7 +72,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[x, 3] = default); Assert.Equal("x", ex.ParamName); @@ -87,7 +87,7 @@ public class ImageFrameTests this.LimitBufferCapacity(100); } - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); ImageFrame frame = image.Frames.RootFrame; ArgumentOutOfRangeException ex = Assert.Throws(() => frame[3, y] = default); Assert.Equal("y", ex.ParamName); @@ -105,7 +105,7 @@ public class ImageFrameTests this.LimitBufferCapacity(20); } - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); if (disco) { Assert.True(image.GetPixelMemoryGroup().Count > 1); @@ -131,7 +131,7 @@ public class ImageFrameTests [InlineData(true)] public void CopyPixelDataTo_DestinationTooShort_Throws(bool byteSpan) { - using Image image = new Image(this.configuration, 10, 10); + using Image image = new(this.configuration, 10, 10); Assert.ThrowsAny(() => { @@ -173,7 +173,7 @@ public class ImageFrameTests [Fact] public void NullReference_Throws() { - using Image img = new Image(1, 1); + using Image img = new(1, 1); ImageFrame frame = img.Frames.RootFrame; Assert.Throws(() => frame.ProcessPixelRows(null)); diff --git a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs index e9bdd5128..e7d3b548b 100644 --- a/tests/ImageSharp.Tests/Image/ImageRotationTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageRotationTests.cs @@ -12,14 +12,14 @@ public class ImageRotationTests public void RotateImageByMinus90Degrees() { (Size original, Size rotated) = Rotate(-90); - Assert.Equal(new(original.Height, original.Width), rotated); + Assert.Equal(new Size(original.Height, original.Width), rotated); } [Fact] public void RotateImageBy90Degrees() { (Size original, Size rotated) = Rotate(90); - Assert.Equal(new(original.Height, original.Width), rotated); + Assert.Equal(new Size(original.Height, original.Width), rotated); } [Fact] @@ -33,7 +33,7 @@ public class ImageRotationTests public void RotateImageBy270Degrees() { (Size original, Size rotated) = Rotate(270); - Assert.Equal(new(original.Height, original.Width), rotated); + Assert.Equal(new Size(original.Height, original.Width), rotated); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index c92383ca8..e2f3c6337 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -23,22 +23,22 @@ public class ImageSaveTests : IDisposable public ImageSaveTests() { - this.localImageFormat = new(); + this.localImageFormat = new Mock(); this.localImageFormat.Setup(x => x.FileExtensions).Returns(new[] { "png" }); this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormat.Object); - this.encoder = new(); + this.encoder = new Mock(); - this.encoderNotInFormat = new(); + this.encoderNotInFormat = new Mock(); - this.fileSystem = new(); + this.fileSystem = new Mock(); Configuration config = new() { FileSystem = this.fileSystem.Object }; config.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); config.ImageFormatsManager.SetEncoder(this.localImageFormat.Object, this.encoder.Object); - this.image = new(config, 1, 1); + this.image = new Image(config, 1, 1); } [Fact] diff --git a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs index f9a68c8bf..a1966e2bb 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs @@ -114,7 +114,7 @@ public partial class ImageTests { DecoderOptions options = new() { - Configuration = new() + Configuration = new Configuration() }; Assert.Throws(() => Image.DetectFormat(options, this.DataStream)); @@ -145,7 +145,7 @@ public partial class ImageTests { DecoderOptions options = new() { - Configuration = new() + Configuration = new Configuration() }; return Assert.ThrowsAsync(async () => await Image.DetectFormatAsync(options, new AsyncStreamWrapper(this.DataStream, () => false))); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs index 88e2b86ed..f3b1a01c9 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.EncodeCancellation.cs @@ -15,7 +15,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsBmpAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsBmpAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -23,7 +23,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsCurAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsCurAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -31,7 +31,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -41,7 +41,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsGifAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsGifAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -49,7 +49,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsIcoAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsIcoAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -57,7 +57,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsJpegAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsJpegAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -65,7 +65,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPbmAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsPbmAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -73,7 +73,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -83,7 +83,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsPngAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsPngAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -91,7 +91,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsQoiAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsQoiAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -99,7 +99,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTgaAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsTgaAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -107,7 +107,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsTiffAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsTiffAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -115,7 +115,7 @@ public partial class ImageTests { using Image image = new(10, 10); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); } [Fact] @@ -125,7 +125,7 @@ public partial class ImageTests image.Frames.CreateFrame(); await Assert.ThrowsAsync( - async () => await image.SaveAsWebpAsync(Stream.Null, new(canceled: true))); + async () => await image.SaveAsWebpAsync(Stream.Null, new CancellationToken(canceled: true))); } } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 7f6651d90..6a196fd16 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -131,7 +131,7 @@ public partial class ImageTests [Fact] public void WhenNoMatchingFormatFound_Throws_UnknownImageFormatException() { - DecoderOptions options = new() { Configuration = new() }; + DecoderOptions options = new() { Configuration = new Configuration() }; Assert.Throws(() => Image.Identify(options, this.DataStream)); } @@ -279,7 +279,7 @@ public partial class ImageTests [Fact] public Task WhenNoMatchingFormatFoundAsync_Throws_UnknownImageFormatException() { - DecoderOptions options = new() { Configuration = new() }; + DecoderOptions options = new() { Configuration = new Configuration() }; AsyncStreamWrapper asyncStream = new(this.DataStream, () => false); return Assert.ThrowsAsync(async () => await Image.IdentifyAsync(options, asyncStream)); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs index ae48fde39..b0875a1e6 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs @@ -56,13 +56,13 @@ public partial class ImageTests protected ImageLoadTestBase() { // TODO: Remove all this mocking. It's too complicated and we can now use fakes. - this.localStreamReturnImageRgba32 = new(1, 1); - this.localStreamReturnImageAgnostic = new(1, 1); - this.LocalImageInfo = new(new(1, 1), new() { DecodedImageFormat = PngFormat.Instance }); + this.localStreamReturnImageRgba32 = new Image(1, 1); + this.localStreamReturnImageAgnostic = new Image(1, 1); + this.LocalImageInfo = new ImageInfo(new Size(1, 1), new ImageMetadata { DecodedImageFormat = PngFormat.Instance }); - this.localImageFormatMock = new(); + this.localImageFormatMock = new Mock(); - this.localDecoder = new(); + this.localDecoder = new Mock(); this.localDecoder.Setup(x => x.Identify(It.IsAny(), It.IsAny())) .Returns(this.LocalImageInfo); @@ -111,15 +111,15 @@ public partial class ImageTests this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object); - this.LocalConfiguration = new(); + this.LocalConfiguration = new Configuration(); this.LocalConfiguration.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector); this.LocalConfiguration.ImageFormatsManager.SetDecoder(this.localImageFormatMock.Object, this.localDecoder.Object); - this.TopLevelConfiguration = new(this.TestFormat); + this.TopLevelConfiguration = new Configuration(this.TestFormat); this.Marker = Guid.NewGuid().ToByteArray(); - this.dataStreamLazy = new(this.CreateStream); + this.dataStreamLazy = new Lazy(this.CreateStream); Stream StreamFactory() => this.DataStream; this.LocalFileSystemMock.Setup(x => x.OpenRead(this.MockFilePath)).Returns(StreamFactory); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs index 8c110d143..3e488be9a 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath_UseDefaultConfiguration.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private string Path { get; } = TestFile.GetInputFileFullPath(TestImages.Bmp.Bit8); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Path_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index 80a407a35..00ec985ac 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -14,7 +14,7 @@ public partial class ImageTests private static Span ByteSpan => new(ByteArray); - private static void VerifyDecodedImage(Image img) => Assert.Equal(new(127, 64), img.Size); + private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Bytes_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs index 9b9f968bb..a03157822 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs @@ -12,7 +12,7 @@ public partial class ImageTests { private static readonly byte[] Data = new byte[] { 0x01 }; - private MemoryStream Stream { get; } = new MemoryStream(Data); + private MemoryStream Stream { get; } = new(Data); [Fact] public void Image_Load_Throws_UnknownImageFormatException() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs index c16a50b43..7a5bd186b 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs @@ -21,12 +21,12 @@ public partial class ImageTests public Load_FromStream_UseDefaultConfiguration() { - this.BaseStream = new(Data); - this.Stream = new(this.BaseStream, () => this.AllowSynchronousIO); + this.BaseStream = new MemoryStream(Data); + this.Stream = new AsyncStreamWrapper(this.BaseStream, () => this.AllowSynchronousIO); } private static void VerifyDecodedImage(Image img) - => Assert.Equal(new(127, 64), img.Size); + => Assert.Equal(new Size(127, 64), img.Size); [Fact] public void Stream_Specific() diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs index d38ed749a..6322e65aa 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs @@ -64,13 +64,13 @@ public partial class ImageTests public override unsafe Span GetSpan() { void* ptr = (void*)this.bmpData.Scan0; - return new(ptr, this.length); + return new Span(ptr, this.length); } public override unsafe MemoryHandle Pin(int elementIndex = 0) { void* ptr = (void*)this.bmpData.Scan0; - return new(ptr, pinnable: this); + return new MemoryHandle(ptr, pinnable: this); } public override void Unpin() diff --git a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs index ffb89923a..8d1b54658 100644 --- a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs +++ b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs @@ -31,7 +31,7 @@ public class LargeImageIntegrationTests Configuration configuration = Configuration.Default.Clone(); configuration.PreferContiguousImageBuffers = true; - using Image image = new Image(configuration, 2048, 2048); + using Image image = new(configuration, 2048, 2048); Assert.True(image.DangerousTryGetSinglePixelMemory(out Memory mem)); Assert.Equal(2048 * 2048, mem.Length); } diff --git a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs index 1a6d563c8..27e42f84e 100644 --- a/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs +++ b/tests/ImageSharp.Tests/Image/ProcessPixelRowsTestBase.cs @@ -51,7 +51,7 @@ public abstract class ProcessPixelRowsTestBase Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new((ushort)(x * y)); + row[x] = new L16((ushort)(x * y)); } } }); @@ -78,7 +78,7 @@ public abstract class ProcessPixelRowsTestBase Span row = buffer.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new((ushort)(x * y)); + row[x] = new L16((ushort)(x * y)); } } @@ -116,7 +116,7 @@ public abstract class ProcessPixelRowsTestBase Span row = buffer2.DangerousGetRowSpan(y); for (int x = 0; x < 256; x++) { - row[x] = new((ushort)(x * y)); + row[x] = new L16((ushort)(x * y)); } } diff --git a/tests/ImageSharp.Tests/Issues/Issue594.cs b/tests/ImageSharp.Tests/Issues/Issue594.cs index 7f976a373..36308edae 100644 --- a/tests/ImageSharp.Tests/Issues/Issue594.cs +++ b/tests/ImageSharp.Tests/Issues/Issue594.cs @@ -40,7 +40,7 @@ public class Issue594 const float z = 0.5f; const float w = -0.7f; - pixel = new(x, y, z, w); + pixel = new NormalizedByte4(x, y, z, w); Assert.Equal(0xA740DA0D, pixel.PackedValue); NormalizedByte4 n = NormalizedByte4.FromRgba32(pixel.ToRgba32()); Assert.Equal(0xA740DA0D, n.PackedValue); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs index 6b9907ef5..c4cef5d93 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/BufferTestSuite.cs @@ -58,7 +58,7 @@ public abstract class BufferTestSuite } } - public static readonly TheoryData LengthValues = new TheoryData { 0, 1, 7, 1023, 1024 }; + public static readonly TheoryData LengthValues = new() { 0, 1, 7, 1023, 1024 }; [Theory] [MemberData(nameof(LengthValues))] diff --git a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs index ac03863fd..8eb364828 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/RefCountedLifetimeGuardTests.cs @@ -14,7 +14,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void Dispose_ResultsInSingleRelease(int disposeCount) { - MockLifetimeGuard guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); Assert.Equal(0, guard.ReleaseInvocationCount); for (int i = 0; i < disposeCount; i++) @@ -45,7 +45,7 @@ public class RefCountedLifetimeGuardTests [InlineData(3)] public void AddRef_PreventsReleaseOnDispose(int addRefCount) { - MockLifetimeGuard guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); for (int i = 0; i < addRefCount; i++) { @@ -80,7 +80,7 @@ public class RefCountedLifetimeGuardTests [Fact] public void AddRefReleaseRefMisuse_DoesntLeadToMultipleReleases() { - MockLifetimeGuard guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); guard.Dispose(); guard.AddRef(); guard.ReleaseRef(); @@ -92,7 +92,7 @@ public class RefCountedLifetimeGuardTests public void UnmanagedBufferLifetimeGuard_Handle_IsReturnedByRef() { UnmanagedMemoryHandle h = UnmanagedMemoryHandle.Allocate(10); - using UnmanagedBufferLifetimeGuard.FreeHandle guard = new UnmanagedBufferLifetimeGuard.FreeHandle(h); + using UnmanagedBufferLifetimeGuard.FreeHandle guard = new(h); Assert.True(guard.Handle.IsValid); guard.Handle.Free(); Assert.False(guard.Handle.IsValid); @@ -101,7 +101,7 @@ public class RefCountedLifetimeGuardTests [MethodImpl(MethodImplOptions.NoInlining)] private static void LeakGuard(bool addRef) { - MockLifetimeGuard guard = new MockLifetimeGuard(); + MockLifetimeGuard guard = new(); if (addRef) { guard.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs index 51552be7d..72b90c238 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SharedArrayPoolBufferTests.cs @@ -16,7 +16,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - using (SharedArrayPoolBuffer buffer = new SharedArrayPoolBuffer(900)) + using (SharedArrayPoolBuffer buffer = new(900)) { Assert.Equal(900, buffer.GetSpan().Length); buffer.GetSpan().Fill(42); @@ -36,7 +36,7 @@ public class SharedArrayPoolBufferTests static void RunTest() { - SharedArrayPoolBuffer buffer = new SharedArrayPoolBuffer(900); + SharedArrayPoolBuffer buffer = new(900); Span span = buffer.GetSpan(); buffer.AddRef(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs index 665f34a34..0e791c5d9 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/SimpleGcMemoryAllocatorTests.cs @@ -17,7 +17,7 @@ public class SimpleGcMemoryAllocatorTests } } - protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new SimpleGcMemoryAllocator(); + protected SimpleGcMemoryAllocator MemoryAllocator { get; } = new(); public static TheoryData InvalidLengths { get; set; } = new() { diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index c5820c27f..f518b2272 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -24,8 +24,8 @@ public partial class UniformUnmanagedMemoryPoolTests RemoteExecutor.Invoke(RunTest).Dispose(); static void RunTest() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 5_000 }; - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, 256, trimSettings); + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 5_000 }; + UniformUnmanagedMemoryPool pool = new(128, 256, trimSettings); UnmanagedMemoryHandle[] a = pool.Rent(64); UnmanagedMemoryHandle[] b = pool.Rent(64); @@ -77,11 +77,11 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 6_000 }; - UniformUnmanagedMemoryPool pool1 = new UniformUnmanagedMemoryPool(128, 256, trimSettings1); + UniformUnmanagedMemoryPool.TrimSettings trimSettings1 = new() { TrimPeriodMilliseconds = 6_000 }; + UniformUnmanagedMemoryPool pool1 = new(128, 256, trimSettings1); Thread.Sleep(8_000); // Let some callbacks fire already - UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 3_000 }; - UniformUnmanagedMemoryPool pool2 = new UniformUnmanagedMemoryPool(128, 256, trimSettings2); + UniformUnmanagedMemoryPool.TrimSettings trimSettings2 = new() { TrimPeriodMilliseconds = 3_000 }; + UniformUnmanagedMemoryPool pool2 = new(128, 256, trimSettings2); pool1.Return(pool1.Rent(64)); pool2.Return(pool2.Rent(64)); @@ -104,7 +104,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance() { - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { TrimPeriodMilliseconds = 4_000 }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { TrimPeriodMilliseconds = 4_000 }; _ = new UniformUnmanagedMemoryPool(128, 256, trimSettings); } } @@ -129,13 +129,13 @@ public partial class UniformUnmanagedMemoryPoolTests Assert.False(Environment.Is64BitProcess); const int oneMb = 1 << 20; - UniformUnmanagedMemoryPool.TrimSettings trimSettings = new UniformUnmanagedMemoryPool.TrimSettings { HighPressureThresholdRate = 0.2f }; + UniformUnmanagedMemoryPool.TrimSettings trimSettings = new() { HighPressureThresholdRate = 0.2f }; GCMemoryInfo memInfo = GC.GetGCMemoryInfo(); int highLoadThreshold = (int)(memInfo.HighMemoryLoadThresholdBytes / oneMb); highLoadThreshold = (int)(trimSettings.HighPressureThresholdRate * highLoadThreshold); - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(oneMb, 16, trimSettings); + UniformUnmanagedMemoryPool pool = new(oneMb, 16, trimSettings); pool.Return(pool.Rent(16)); Assert.Equal(16, UnmanagedMemoryHandle.TotalOutstandingHandles); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs index c0c7f5c22..ec79d91c3 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs @@ -55,7 +55,7 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(7, 4)] public void Constructor_InitializesProperties(int arrayLength, int capacity) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(arrayLength, capacity); + UniformUnmanagedMemoryPool pool = new(arrayLength, capacity); Assert.Equal(arrayLength, pool.BufferLength); Assert.Equal(capacity, pool.Capacity); } @@ -65,8 +65,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(8, 10)] public void Rent_SingleBuffer_ReturnsCorrectBuffer(int length, int capacity) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(length, capacity); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, capacity); + using CleanupUtil cleanup = new(pool); for (int i = 0; i < capacity; i++) { @@ -83,7 +83,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); @@ -105,7 +105,7 @@ public partial class UniformUnmanagedMemoryPoolTests Assert.True(span.SequenceEqual(expected)); } - private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new Span(h.Pointer, length); + private static unsafe Span GetSpan(UnmanagedMemoryHandle h, int length) => new(h.Pointer, length); [Theory] [InlineData(1, 1)] @@ -114,8 +114,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(5, 10)] public void Rent_MultiBuffer_ReturnsCorrectBuffers(int length, int bufferCount) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(length, 10); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(length, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] handles = pool.Rent(bufferCount); cleanup.Register(handles); @@ -131,8 +131,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_MultipleTimesWithoutReturn_ReturnsDifferentHandles() { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, 10); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, 10); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] a = pool.Rent(2); cleanup.Register(a); UnmanagedMemoryHandle b = pool.Rent(); @@ -149,10 +149,10 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(12, 4, 12)] public void RentReturnRent_SameBuffers(int totalCount, int rentUnit, int capacity) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); - using CleanupUtil cleanup = new CleanupUtil(pool); - HashSet allHandles = new HashSet(); - List handleUnits = new List(); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); + HashSet allHandles = new(); + List handleUnits = new(); UnmanagedMemoryHandle[] handles; for (int i = 0; i < totalCount; i += rentUnit) @@ -197,8 +197,8 @@ public partial class UniformUnmanagedMemoryPoolTests [Fact] public void Rent_SingleBuffer_OverCapacity_ReturnsInvalidBuffer() { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(7, 1000); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(7, 1000); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(1000); Assert.NotNull(initial); cleanup.Register(initial); @@ -212,8 +212,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(4, 7, 10)] public void Rent_MultiBuffer_OverCapacity_ReturnsNull(int initialRent, int attempt, int capacity) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] initial = pool.Rent(initialRent); Assert.NotNull(initial); cleanup.Register(initial); @@ -228,8 +228,8 @@ public partial class UniformUnmanagedMemoryPoolTests [InlineData(3, 3, 7)] public void Rent_MultiBuff_BelowCapacity_Succeeds(int initialRent, int attempt, int capacity) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(128, capacity); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(128, capacity); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle[] b0 = pool.Rent(initialRent); Assert.NotNull(b0); cleanup.Register(b0); @@ -250,8 +250,8 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest(string multipleInner) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); - using CleanupUtil cleanup = new CleanupUtil(pool); + UniformUnmanagedMemoryPool pool = new(16, 16); + using CleanupUtil cleanup = new(pool); UnmanagedMemoryHandle b0 = pool.Rent(); IntPtr h0 = b0.Handle; UnmanagedMemoryHandle b1 = pool.Rent(); @@ -290,7 +290,7 @@ public partial class UniformUnmanagedMemoryPoolTests static void RunTest() { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 16); + UniformUnmanagedMemoryPool pool = new(16, 16); UnmanagedMemoryHandle a = pool.Rent(); UnmanagedMemoryHandle[] b = pool.Rent(2); pool.Return(a); @@ -306,13 +306,13 @@ public partial class UniformUnmanagedMemoryPoolTests public void RentReturn_IsThreadSafe() { int count = Environment.ProcessorCount * 200; - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(8, count); - using CleanupUtil cleanup = new CleanupUtil(pool); - Random rnd = new Random(0); + UniformUnmanagedMemoryPool pool = new(8, count); + using CleanupUtil cleanup = new(pool); + Random rnd = new(0); Parallel.For(0, Environment.ProcessorCount, (int i) => { - List allHandles = new List(); + List allHandles = new(); int pauseAt = rnd.Next(100); for (int j = 0; j < 100; j++) { @@ -359,7 +359,7 @@ public partial class UniformUnmanagedMemoryPoolTests [MethodImpl(MethodImplOptions.NoInlining)] static void LeakPoolInstance(bool withGuardedBuffers) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(16, 128); + UniformUnmanagedMemoryPool pool = new(16, 128); if (withGuardedBuffers) { UnmanagedMemoryHandle h = pool.Rent(); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index e0f129a65..f62e99a8b 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -165,7 +165,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { - MemoryAllocator allocator = MemoryAllocator.Create(new() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { MaximumPoolSizeMegabytes = 8 }); @@ -422,7 +422,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void Allocate_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = 4 }); @@ -434,7 +434,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [Fact] public void AllocateGroup_OverLimit_ThrowsInvalidMemoryOperationException() { - MemoryAllocator allocator = MemoryAllocator.Create(new() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = 4 }); @@ -450,7 +450,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests static void RunTest() { const long threeGB = 3L * (1 << 30); - MemoryAllocator allocator = MemoryAllocator.Create(new() + MemoryAllocator allocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = (int)(threeGB / 1024) }); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs index 1e4795bc8..3b33eae5e 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedBufferTests.cs @@ -76,7 +76,7 @@ public class UnmanagedBufferTests static List> FillList(int countInner) { - List> l = new List>(); + List> l = new(); for (int i = 0; i < countInner; i++) { UnmanagedBuffer h = UnmanagedBuffer.Allocate(42); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs index ef3af71f4..59b793e01 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UnmanagedMemoryHandleTests.cs @@ -47,7 +47,7 @@ public class UnmanagedMemoryHandleTests static void RunTest(string countStr) { int countInner = int.Parse(countStr); - List l = new List(); + List l = new(); for (int i = 0; i < countInner; i++) { Assert.Equal(i, UnmanagedMemoryHandle.TotalOutstandingHandles); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs index 578ffc480..e17c8c46f 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.SwapOrCopyContent.cs @@ -29,8 +29,8 @@ public partial class Buffer2DTests Assert.Equal(bb, a.FastMemoryGroup.Single()); Assert.Equal(aa, b.FastMemoryGroup.Single()); - Assert.Equal(new(3, 7), a.Size()); - Assert.Equal(new(10, 5), b.Size()); + Assert.Equal(new Size(3, 7), a.Size()); + Assert.Equal(new Size(10, 5), b.Size()); Assert.Equal(666, b[1, 3]); Assert.Equal(444, a[1, 3]); diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs index a5c2eea2d..6dfdd294c 100644 --- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs +++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs @@ -72,7 +72,7 @@ public partial class Buffer2DTests using Buffer2D buffer = useSizeOverload ? this.MemoryAllocator.Allocate2D( - new(200, 200), + new Size(200, 200), preferContiguosImageBuffers: true) : this.MemoryAllocator.Allocate2D( 200, @@ -169,7 +169,7 @@ public partial class Buffer2DTests } // Re-seed - rnd = new(42); + rnd = new Random(42); for (int y = 0; y < buffer.Height; y++) { Span span = buffer.GetSafeRowMemory(y).Span; @@ -341,9 +341,9 @@ public partial class Buffer2DTests public static TheoryData InvalidLengths { get; set; } = new() { - { new(-1, -1) }, - { new(32768, 32769) }, - { new(32769, 32768) } + { new Size(-1, -1) }, + { new Size(32768, 32769) }, + { new Size(32769, 32768) } }; [Theory] @@ -354,7 +354,7 @@ public partial class Buffer2DTests [Theory] [MemberData(nameof(InvalidLengths))] public void Allocate_IncorrectAmount_ThrowsCorrect_InvalidMemoryOperationException_Size(Size size) - => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new(size))); + => Assert.Throws(() => this.MemoryAllocator.Allocate2D(new Size(size))); [Theory] [MemberData(nameof(InvalidLengths))] diff --git a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs index cb89f6cf6..be7edbacc 100644 --- a/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs +++ b/tests/ImageSharp.Tests/Memory/BufferAreaTests.cs @@ -7,14 +7,14 @@ namespace SixLabors.ImageSharp.Tests.Memory; public class BufferAreaTests { - private readonly TestMemoryAllocator memoryAllocator = new TestMemoryAllocator(); + private readonly TestMemoryAllocator memoryAllocator = new(); [Fact] public void Construct() { using Buffer2D buffer = this.memoryAllocator.Allocate2D(10, 20); - Rectangle rectangle = new Rectangle(3, 2, 5, 6); - Buffer2DRegion area = new Buffer2DRegion(buffer, rectangle); + Rectangle rectangle = new(3, 2, 5, 6); + Buffer2DRegion area = new(buffer, rectangle); Assert.Equal(buffer, area.Buffer); Assert.Equal(rectangle, area.Rectangle); @@ -43,7 +43,7 @@ public class BufferAreaTests { this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - Rectangle r = new Rectangle(rx, ry, 5, 6); + Rectangle r = new(rx, ry, 5, 6); Buffer2DRegion region = buffer.GetRegion(r); @@ -62,7 +62,7 @@ public class BufferAreaTests this.memoryAllocator.BufferCapacityInBytes = sizeof(int) * bufferCapacity; using Buffer2D buffer = this.CreateTestBuffer(20, 30); - Rectangle r = new Rectangle(rx, ry, w, h); + Rectangle r = new(rx, ry, w, h); Buffer2DRegion region = buffer.GetRegion(r); @@ -87,7 +87,7 @@ public class BufferAreaTests Buffer2DRegion area1 = area0.GetSubRegion(4, 4, 5, 5); - Rectangle expectedRect = new Rectangle(10, 12, 5, 5); + Rectangle expectedRect = new(10, 12, 5, 5); Assert.Equal(buffer, area1.Buffer); Assert.Equal(expectedRect, area1.Rectangle); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs index ea98357cb..878084674 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndex.cs @@ -27,7 +27,7 @@ public struct MemoryGroupIndex : IEquatable public static MemoryGroupIndex operator +(MemoryGroupIndex idx, int val) { int nextElementIndex = idx.ElementIndex + val; - return new( + return new MemoryGroupIndex( idx.BufferLength, idx.BufferIndex + (nextElementIndex / idx.BufferLength), nextElementIndex % idx.BufferLength); @@ -105,14 +105,14 @@ internal static class MemoryGroupIndexExtensions public static MemoryGroupIndex MinIndex(this IMemoryGroup group) where T : struct { - return new(group.BufferLength, 0, 0); + return new MemoryGroupIndex(group.BufferLength, 0, 0); } public static MemoryGroupIndex MaxIndex(this IMemoryGroup group) where T : struct { return group.Count == 0 - ? new(group.BufferLength, 0, 0) + ? new MemoryGroupIndex(group.BufferLength, 0, 0) : new MemoryGroupIndex(group.BufferLength, group.Count - 1, group[group.Count - 1].Length); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs index 9c7915e22..4e67df53b 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupIndexTests.cs @@ -47,7 +47,7 @@ public class MemoryGroupIndexTests { MemoryGroupIndex a = new(10, 3, 3); a += 1; - Assert.Equal(new(10, 3, 4), a); + Assert.Equal(new MemoryGroupIndex(10, 3, 4), a); } [Fact] @@ -58,7 +58,7 @@ public class MemoryGroupIndexTests a += 8; b += 1; - Assert.Equal(new(10, 6, 1), a); - Assert.Equal(new(10, 6, 0), b); + Assert.Equal(new MemoryGroupIndex(10, 6, 1), a); + Assert.Equal(new MemoryGroupIndex(10, 6, 0), b); } } diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs index ac242e846..678a089a8 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.Allocate.cs @@ -83,7 +83,7 @@ public partial class MemoryGroupTests return; } - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(bufferCapacity, expectedNumberOfBuffers); + UniformUnmanagedMemoryPool pool = new(bufferCapacity, expectedNumberOfBuffers); // Act: Assert.True(MemoryGroup.TryAllocate(pool, totalLength, bufferAlignment, AllocationOptions.None, out MemoryGroup g)); @@ -98,7 +98,7 @@ public partial class MemoryGroupTests [InlineData(AllocationOptions.Clean)] public unsafe void Allocate_FromPool_AllocationOptionsAreApplied(AllocationOptions options) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(10, 5); + UniformUnmanagedMemoryPool pool = new(10, 5); UnmanagedMemoryHandle[] buffers = pool.Rent(5); foreach (UnmanagedMemoryHandle b in buffers) { @@ -128,7 +128,7 @@ public partial class MemoryGroupTests int requestBytes, bool shouldSucceed) { - UniformUnmanagedMemoryPool pool = new UniformUnmanagedMemoryPool(bufferCapacityBytes, poolCapacity); + UniformUnmanagedMemoryPool pool = new(bufferCapacityBytes, poolCapacity); int alignmentElements = alignmentBytes / Unsafe.SizeOf(); int requestElements = requestBytes / Unsafe.SizeOf(); diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs index 044c8f584..fe1867f20 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTests.cs @@ -28,7 +28,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase #pragma warning disable SA1509 private static readonly TheoryData CopyAndTransformData = - new TheoryData() + new() { { 20, 10, 20, 10 }, { 20, 5, 20, 4 }, @@ -102,8 +102,8 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase int[] data0 = { 1, 2, 3, 4 }; int[] data1 = { 5, 6, 7, 8 }; int[] data2 = { 9, 10 }; - using TestMemoryManager mgr0 = new TestMemoryManager(data0); - using TestMemoryManager mgr1 = new TestMemoryManager(data1); + using TestMemoryManager mgr0 = new(data0); + using TestMemoryManager mgr1 = new(data1); using MemoryGroup group = MemoryGroup.Wrap(mgr0.Memory, mgr1.Memory, data2); @@ -124,7 +124,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase } } - public static TheoryData GetBoundedSlice_SuccessData = new TheoryData() + public static TheoryData GetBoundedSlice_SuccessData = new() { { 300, 100, 110, 80 }, { 300, 100, 100, 100 }, @@ -153,7 +153,7 @@ public partial class MemoryGroupTests : MemoryGroupTestsBase } } - public static TheoryData GetBoundedSlice_ErrorData = new TheoryData() + public static TheoryData GetBoundedSlice_ErrorData = new() { { 300, 100, -1, 91 }, { 300, 100, 110, 91 }, diff --git a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs index 56e2e95fe..0eaebbfef 100644 --- a/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs +++ b/tests/ImageSharp.Tests/Memory/DiscontiguousBuffers/MemoryGroupTestsBase.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Memory.DiscontiguousBuffers; public abstract class MemoryGroupTestsBase { - internal readonly TestMemoryAllocator MemoryAllocator = new TestMemoryAllocator(); + internal readonly TestMemoryAllocator MemoryAllocator = new(); /// /// Create a group, either uninitialized or filled with incrementing numbers starting with 1. diff --git a/tests/ImageSharp.Tests/Memory/TestStructs.cs b/tests/ImageSharp.Tests/Memory/TestStructs.cs index 0fd823ee5..bb6a07ec9 100644 --- a/tests/ImageSharp.Tests/Memory/TestStructs.cs +++ b/tests/ImageSharp.Tests/Memory/TestStructs.cs @@ -22,7 +22,7 @@ public static class TestStructs Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new(i + 1, i + 1); + result[i] = new Foo(i + 1, i + 1); } return result; @@ -73,7 +73,7 @@ public static class TestStructs AlignedFoo[] result = new AlignedFoo[size]; for (int i = 0; i < size; i++) { - result[i] = new(i + 1, i + 1); + result[i] = new AlignedFoo(i + 1, i + 1); } return result; diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index a19b82e64..395dfd455 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -38,7 +38,7 @@ public static class MemoryAllocatorValidator public static TestMemoryDiagnostics MonitorAllocations() { - TestMemoryDiagnostics diag = new TestMemoryDiagnostics(); + TestMemoryDiagnostics diag = new(); LocalInstance.Value = diag; return diag; } diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index 2a78b74be..6d35517ac 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -48,7 +48,7 @@ public class ImageFrameMetadataTests XmpProfile xmpProfile = new(Array.Empty()); IccProfile iccProfile = new() { - Header = new() + Header = new IccProfileHeader { CmmType = "Unittest" } diff --git a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs index 78290db63..ae02c3d57 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageMetadataTests.cs @@ -36,7 +36,7 @@ public class ImageMetadataTests { ImageMetadata metaData = new() { - ExifProfile = new(), + ExifProfile = new ExifProfile(), HorizontalResolution = 4, VerticalResolution = 2 }; @@ -86,8 +86,8 @@ public class ImageMetadataTests public void SyncProfiles() { ExifProfile exifProfile = new(); - exifProfile.SetValue(ExifTag.XResolution, new(200)); - exifProfile.SetValue(ExifTag.YResolution, new(300)); + exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); + exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); using Image image = new(1, 1); image.Metadata.ExifProfile = exifProfile; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs index ab4d8a0d1..ff8b034c5 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/CICP/CicpProfileTests.cs @@ -25,10 +25,10 @@ public class CicpProfileTests public void WritingPng_PreservesCicpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); CicpProfile original = CreateCicpProfile(); image.Metadata.CicpProfile = original; - PngEncoder encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -49,7 +49,7 @@ public class CicpProfileTests private static CicpProfile CreateCicpProfile() { - CicpProfile profile = new CicpProfile() + CicpProfile profile = new() { ColorPrimaries = CicpColorPrimaries.ItuRBt2020_2, TransferCharacteristics = CicpTransferCharacteristics.SmpteSt2084, @@ -70,7 +70,7 @@ public class CicpProfileTests private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs index 1f8b80b40..6c499f40c 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -63,7 +63,7 @@ public class ExifProfileTests Assert.Null(image.Metadata.ExifProfile); const string expected = "Dirk Lemstra"; - image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile = new ExifProfile(); image.Metadata.ExifProfile.SetValue(ExifTag.Copyright, expected); image = WriteAndRead(image, imageFormat); @@ -125,7 +125,7 @@ public class ExifProfileTests ExifProfile profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new(exposureTime)); + profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime)); Image image = new(1, 1); image.Metadata.ExifProfile = profile; @@ -142,7 +142,7 @@ public class ExifProfileTests memStream.Position = 0; profile = GetExifProfile(); - profile.SetValue(ExifTag.ExposureTime, new(exposureTime, true)); + profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime, true)); image.Metadata.ExifProfile = profile; image = WriteAndRead(image, imageFormat); @@ -164,26 +164,26 @@ public class ExifProfileTests public void ReadWriteInfinity(TestImageWriteFormat imageFormat) { Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image(); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.PositiveInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity)); image = WriteAndReadJpeg(image); IExifValue value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new(double.PositiveInfinity), value.Value); + Assert.Equal(new SignedRational(double.PositiveInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); value = image.Metadata.ExifProfile.GetValue(ExifTag.ExposureBiasValue); Assert.NotNull(value); - Assert.Equal(new(double.NegativeInfinity), value.Value); + Assert.Equal(new SignedRational(double.NegativeInfinity), value.Value); - image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new(double.NegativeInfinity)); + image.Metadata.ExifProfile.SetValue(ExifTag.FlashEnergy, new Rational(double.NegativeInfinity)); image = WriteAndRead(image, imageFormat); IExifValue value2 = image.Metadata.ExifProfile.GetValue(ExifTag.FlashEnergy); Assert.NotNull(value2); - Assert.Equal(new(double.PositiveInfinity), value2.Value); + Assert.Equal(new Rational(double.PositiveInfinity), value2.Value); image.Dispose(); } @@ -209,20 +209,20 @@ public class ExifProfileTests Assert.True(software.TrySetValue(15)); Assert.False(software.TrySetValue(15F)); - image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new(75.55)); + image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55)); IExifValue shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new(7555, 100), shutterSpeed.Value); + Assert.Equal(new SignedRational(7555, 100), shutterSpeed.Value); Assert.False(shutterSpeed.TrySetValue(75)); - image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new(150.0)); + image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0)); // We also need to change this value because this overrides XResolution when the image is written. image.Metadata.HorizontalResolution = 150.0; IExifValue xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new(150, 1), xResolution.Value); + Assert.Equal(new Rational(150, 1), xResolution.Value); Assert.False(xResolution.TrySetValue("ImageSharp")); @@ -251,10 +251,10 @@ public class ExifProfileTests Assert.Equal("15", software.Value); shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue); - Assert.Equal(new(75.55), shutterSpeed.Value); + Assert.Equal(new SignedRational(75.55), shutterSpeed.Value); xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution); - Assert.Equal(new(150.0), xResolution.Value); + Assert.Equal(new Rational(150.0), xResolution.Value); referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite, false); Assert.Null(referenceBlackWhite); @@ -309,8 +309,8 @@ public class ExifProfileTests public void Syncs() { ExifProfile exifProfile = new(); - exifProfile.SetValue(ExifTag.XResolution, new(200)); - exifProfile.SetValue(ExifTag.YResolution, new(300)); + exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); + exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); ImageMetadata metaData = new() { @@ -568,7 +568,7 @@ public class ExifProfileTests private static Image WriteAndReadWebp(Image image, WebpFileFormatType fileFormat) { using MemoryStream memStream = new(); - image.SaveAsWebp(memStream, new() { FileFormat = fileFormat }); + image.SaveAsWebp(memStream, new WebpEncoder { FileFormat = fileFormat }); image.Dispose(); memStream.Position = 0; @@ -593,7 +593,7 @@ public class ExifProfileTests Assert.Equal("Windows Photo Editor 10.0.10011.16384", software.Value); IExifValue xResolution = profile.GetValue(ExifTag.XResolution); - Assert.Equal(new(300.0), xResolution.Value); + Assert.Equal(new Rational(300.0), xResolution.Value); IExifValue xDimension = profile.GetValue(ExifTag.PixelXDimension); Assert.Equal(2338U, xDimension.Value); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs index dcdc5f0f3..983ff4493 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifReaderTests.cs @@ -11,7 +11,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsEmpty_ReturnsEmptyCollection() { - ExifReader reader = new ExifReader(Array.Empty()); + ExifReader reader = new(Array.Empty()); IList result = reader.ReadValues(); @@ -21,7 +21,7 @@ public class ExifReaderTests [Fact] public void Read_DataIsMinimal_ReturnsEmptyCollection() { - ExifReader reader = new ExifReader(new byte[] { 69, 120, 105, 102, 0, 0 }); + ExifReader reader = new(new byte[] { 69, 120, 105, 102, 0, 0 }); IList result = reader.ReadValues(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs index 4ba259f39..3f13afa6f 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifTagDescriptionAttributeTests.cs @@ -12,7 +12,7 @@ public class ExifTagDescriptionAttributeTests [Fact] public void TestExifTag() { - ExifProfile exifProfile = new ExifProfile(); + ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1); IExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index bf6018c65..cb006ba29 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -9,14 +9,14 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Exif.Values; [Trait("Profile", "Exif")] public class ExifValuesTests { - public static TheoryData ByteTags => new TheoryData + public static TheoryData ByteTags => new() { { ExifTag.FaxProfile }, { ExifTag.ModeNumber }, { ExifTag.GPSAltitudeRef } }; - public static TheoryData ByteArrayTags => new TheoryData + public static TheoryData ByteArrayTags => new() { { ExifTag.ClipPath }, { ExifTag.VersionYear }, @@ -26,7 +26,7 @@ public class ExifValuesTests { ExifTag.GPSVersionID }, }; - public static TheoryData DoubleArrayTags => new TheoryData + public static TheoryData DoubleArrayTags => new() { { ExifTag.PixelScale }, { ExifTag.IntergraphMatrix }, @@ -34,7 +34,7 @@ public class ExifValuesTests { ExifTag.ModelTransform } }; - public static TheoryData LongTags => new TheoryData + public static TheoryData LongTags => new() { { ExifTag.SubfileType }, { ExifTag.SubIFDOffset }, @@ -59,7 +59,7 @@ public class ExifValuesTests { ExifTag.ImageNumber }, }; - public static TheoryData LongArrayTags => new TheoryData + public static TheoryData LongArrayTags => new() { { ExifTag.FreeOffsets }, { ExifTag.FreeByteCounts }, @@ -73,7 +73,7 @@ public class ExifValuesTests { ExifTag.IntergraphRegisters } }; - public static TheoryData NumberTags => new TheoryData + public static TheoryData NumberTags => new() { { ExifTag.ImageWidth }, { ExifTag.ImageLength }, @@ -85,7 +85,7 @@ public class ExifValuesTests { ExifTag.PixelYDimension } }; - public static TheoryData NumberArrayTags => new TheoryData + public static TheoryData NumberArrayTags => new() { { ExifTag.StripOffsets }, { ExifTag.StripByteCounts }, @@ -94,7 +94,7 @@ public class ExifValuesTests { ExifTag.ImageLayer } }; - public static TheoryData RationalTags => new TheoryData + public static TheoryData RationalTags => new() { { ExifTag.XPosition }, { ExifTag.YPosition }, @@ -131,7 +131,7 @@ public class ExifValuesTests { ExifTag.GPSHPositioningError }, }; - public static TheoryData RationalArrayTags => new TheoryData + public static TheoryData RationalArrayTags => new() { { ExifTag.WhitePoint }, { ExifTag.PrimaryChromaticities }, @@ -145,7 +145,7 @@ public class ExifValuesTests { ExifTag.LensSpecification } }; - public static TheoryData ShortTags => new TheoryData + public static TheoryData ShortTags => new() { { ExifTag.OldSubfileType }, { ExifTag.Compression }, @@ -196,7 +196,7 @@ public class ExifValuesTests { ExifTag.GPSDifferential } }; - public static TheoryData ShortArrayTags => new TheoryData + public static TheoryData ShortArrayTags => new() { { ExifTag.BitsPerSample }, { ExifTag.MinSampleValue }, @@ -220,7 +220,7 @@ public class ExifValuesTests { ExifTag.SubjectLocation } }; - public static TheoryData SignedRationalTags => new TheoryData + public static TheoryData SignedRationalTags => new() { { ExifTag.ShutterSpeedValue }, { ExifTag.BrightnessValue }, @@ -230,17 +230,17 @@ public class ExifValuesTests { ExifTag.CameraElevationAngle } }; - public static TheoryData SignedRationalArrayTags => new TheoryData + public static TheoryData SignedRationalArrayTags => new() { { ExifTag.Decode } }; - public static TheoryData SignedShortArrayTags => new TheoryData + public static TheoryData SignedShortArrayTags => new() { { ExifTag.TimeZoneOffset } }; - public static TheoryData StringTags => new TheoryData + public static TheoryData StringTags => new() { { ExifTag.ImageDescription }, { ExifTag.Make }, @@ -298,13 +298,13 @@ public class ExifValuesTests { ExifTag.GPSDateStamp }, }; - public static TheoryData UndefinedTags => new TheoryData + public static TheoryData UndefinedTags => new() { { ExifTag.FileSource }, { ExifTag.SceneType } }; - public static TheoryData UndefinedArrayTags => new TheoryData + public static TheoryData UndefinedArrayTags => new() { { ExifTag.JPEGTables }, { ExifTag.OECF }, @@ -320,14 +320,14 @@ public class ExifValuesTests { ExifTag.ImageSourceData }, }; - public static TheoryData EncodedStringTags => new TheoryData + public static TheoryData EncodedStringTags => new() { { ExifTag.UserComment }, { ExifTag.GPSProcessingMethod }, { ExifTag.GPSAreaInformation } }; - public static TheoryData Ucs2StringTags => new TheoryData + public static TheoryData Ucs2StringTags => new() { { ExifTag.XPTitle }, { ExifTag.XPComment }, @@ -481,7 +481,7 @@ public class ExifValuesTests [MemberData(nameof(RationalTags))] public void ExifRationalTests(ExifTag tag) { - Rational expected = new Rational(21, 42); + Rational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -540,7 +540,7 @@ public class ExifValuesTests [MemberData(nameof(SignedRationalTags))] public void ExifSignedRationalTests(ExifTag tag) { - SignedRational expected = new SignedRational(21, 42); + SignedRational expected = new(21, 42); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -633,7 +633,7 @@ public class ExifValuesTests Assert.Equal(ExifEncodedStringHelpers.CharacterCodeBytesLength, ExifEncodedStringHelpers.GetCodeBytes(charCode).Length); const string expectedText = "test string"; - EncodedString expected = new EncodedString(charCode, expectedText); + EncodedString expected = new(charCode, expectedText); ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(123)); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs index 9f089f482..86c6a5e9f 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderCurvesTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderCurvesTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs index 817832807..a686d4487 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderLutTests.cs @@ -77,6 +77,6 @@ public class IccDataReaderLutTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs index 030cf0df4..930665a07 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderMultiProcessElementTests.cs @@ -55,6 +55,6 @@ public class IccDataReaderMultiProcessElementTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs index f4f89d11d..ee0464bb2 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderNonPrimitivesTests.cs @@ -122,6 +122,6 @@ public class IccDataReaderNonPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs index 77e334a49..9c5be4c67 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderPrimitivesTests.cs @@ -82,6 +82,6 @@ public class IccDataReaderPrimitivesTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs index 735a6abf7..e0cfa6543 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataReader/IccDataReaderTagDataEntryTests.cs @@ -442,6 +442,6 @@ public class IccDataReaderTagDataEntryTests private static IccDataReader CreateReader(byte[] data) { - return new(data); + return new IccDataReader(data); } } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs index f6ac8517d..79578f1ad 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterCurvesTests.cs @@ -81,5 +81,5 @@ public class IccDataWriterCurvesTests Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() => new IccDataWriter(); + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs index 8f696e99d..27db7e4e6 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterLutTests.cs @@ -81,5 +81,5 @@ public class IccDataWriterLutTests Assert.Equal(expected, output); } - private static IccDataWriter CreateWriter() => new IccDataWriter(); + private static IccDataWriter CreateWriter() => new(); } diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs index 79a8fb263..27ce0ffa8 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccProfileTests.cs @@ -34,7 +34,7 @@ public class IccProfileTests [MemberData(nameof(IccTestDataProfiles.ProfileValidityTestData), MemberType = typeof(IccTestDataProfiles))] public void CheckIsValid_WithProfiles_ReturnsValidity(byte[] data, bool expected) { - IccProfile profile = new IccProfile(data); + IccProfile profile = new(data); bool result = profile.CheckIsValid(); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs index ffc4ed2eb..71c58c25d 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/IccWriterTests.cs @@ -12,7 +12,7 @@ public class IccWriterTests [Fact] public void WriteProfile_NoEntries() { - IccProfile profile = new IccProfile + IccProfile profile = new() { Header = IccTestDataProfiles.HeaderRandomWrite }; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs index e56f7f182..5af672c21 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/Various/IccProfileIdTests.cs @@ -19,7 +19,7 @@ public class IccProfileIdTests [Fact] public void SetIsTrueWhenNonDefaultValue() { - IccProfileId id = new IccProfileId(1, 2, 3, 4); + IccProfileId id = new(1, 2, 3, 4); Assert.True(id.IsSet); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index 36df7da0c..c64fcab58 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -78,7 +78,7 @@ public class IptcProfileTests { // arrange IptcProfile profile = new(); - DateTimeOffset datetime = new(new(1994, 3, 17)); + DateTimeOffset datetime = new(new DateTime(1994, 3, 17)); // act profile.SetDateTimeValue(tag, datetime); @@ -228,7 +228,7 @@ public class IptcProfileTests { // arrange using Image image = new(1, 1); - image.Metadata.IptcProfile = new(); + image.Metadata.IptcProfile = new IptcProfile(); const string expectedCaptionWriter = "unittest"; const string expectedCaption = "test"; image.Metadata.IptcProfile.SetValue(IptcTag.CaptionWriter, expectedCaptionWriter); @@ -380,7 +380,7 @@ public class IptcProfileTests private static void ContainsIptcValue(List values, IptcTag tag, string value) { Assert.True(values.Any(val => val.Tag == tag), $"Missing iptc tag {tag}"); - Assert.True(values.Contains(new(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); + Assert.True(values.Contains(new IptcValue(tag, System.Text.Encoding.UTF8.GetBytes(value), false)), $"expected iptc value '{value}' was not found for tag '{tag}'"); } private static Image WriteAndReadJpeg(Image image) diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index 1c253bbbe..e121d24f9 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -111,10 +111,10 @@ public class XmpProfileTests public void WritingGif_PreservesXmpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - GifEncoder encoder = new GifEncoder(); + GifEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -129,10 +129,10 @@ public class XmpProfileTests public void WritingJpeg_PreservesXmpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - JpegEncoder encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -150,7 +150,7 @@ public class XmpProfileTests TestImageProvider provider = TestImageProvider.File(TestImages.Jpeg.Baseline.ExtendedXmp); using Image image = await provider.GetImageAsync(JpegDecoder.Instance); XmpProfile original = image.Metadata.XmpProfile; - JpegEncoder encoder = new JpegEncoder(); + JpegEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -165,10 +165,10 @@ public class XmpProfileTests public void WritingPng_PreservesXmpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - PngEncoder encoder = new PngEncoder(); + PngEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -183,10 +183,10 @@ public class XmpProfileTests public void WritingTiff_PreservesXmpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Frames.RootFrame.Metadata.XmpProfile = original; - TiffEncoder encoder = new TiffEncoder(); + TiffEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -201,10 +201,10 @@ public class XmpProfileTests public void WritingWebp_PreservesXmpProfile() { // arrange - using Image image = new Image(1, 1); + using Image image = new(1, 1); XmpProfile original = CreateMinimalXmlProfile(); image.Metadata.XmpProfile = original; - WebpEncoder encoder = new WebpEncoder(); + WebpEncoder encoder = new(); // act using Image reloadedImage = WriteAndRead(image, encoder); @@ -228,13 +228,13 @@ public class XmpProfileTests { string content = $" "; byte[] data = Encoding.UTF8.GetBytes(content); - XmpProfile profile = new XmpProfile(data); + XmpProfile profile = new(data); return profile; } private static Image WriteAndRead(Image image, IImageEncoder encoder) { - using (MemoryStream memStream = new MemoryStream()) + using (MemoryStream memStream = new()) { image.Save(memStream, encoder); image.Dispose(); diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs index 9e7e3b7a0..f9cefaddd 100644 --- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs @@ -70,19 +70,19 @@ public class RationalTests Assert.Equal(7U, rational.Numerator); Assert.Equal(55U, rational.Denominator); - rational = new(755, 100); + rational = new Rational(755, 100); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new(755, 100, false); + rational = new Rational(755, 100, false); Assert.Equal(755U, rational.Numerator); Assert.Equal(100U, rational.Denominator); - rational = new(-7.55); + rational = new Rational(-7.55); Assert.Equal(151U, rational.Numerator); Assert.Equal(20U, rational.Denominator); - rational = new(7); + rational = new Rational(7); Assert.Equal(7U, rational.Numerator); Assert.Equal(1U, rational.Denominator); } @@ -101,7 +101,7 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new(2, 0); + rational = new Rational(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); } @@ -111,19 +111,19 @@ public class RationalTests Rational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new(double.PositiveInfinity); + rational = new Rational(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new(double.NegativeInfinity); + rational = new Rational(double.NegativeInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new(0, 1); + rational = new Rational(0, 1); Assert.Equal("0", rational.ToString()); - rational = new(2, 1); + rational = new Rational(2, 1); Assert.Equal("2", rational.ToString()); - rational = new(1, 2); + rational = new Rational(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs index 275ba4d5f..f194484c4 100644 --- a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs +++ b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs @@ -51,23 +51,23 @@ public class SignedRationalTests Assert.Equal(7, rational.Numerator); Assert.Equal(-55, rational.Denominator); - rational = new(-755, 100); + rational = new SignedRational(-755, 100); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new(-755, -100, false); + rational = new SignedRational(-755, -100, false); Assert.Equal(-755, rational.Numerator); Assert.Equal(-100, rational.Denominator); - rational = new(-151, -20); + rational = new SignedRational(-151, -20); Assert.Equal(-151, rational.Numerator); Assert.Equal(-20, rational.Denominator); - rational = new(-7.55); + rational = new SignedRational(-7.55); Assert.Equal(-151, rational.Numerator); Assert.Equal(20, rational.Denominator); - rational = new(7); + rational = new SignedRational(7); Assert.Equal(7, rational.Numerator); Assert.Equal(1, rational.Denominator); } @@ -86,10 +86,10 @@ public class SignedRationalTests SignedRational rational = new(0, 0); Assert.Equal(double.NaN, rational.ToDouble()); - rational = new(2, 0); + rational = new SignedRational(2, 0); Assert.Equal(double.PositiveInfinity, rational.ToDouble()); - rational = new(-2, 0); + rational = new SignedRational(-2, 0); Assert.Equal(double.NegativeInfinity, rational.ToDouble()); } @@ -99,19 +99,19 @@ public class SignedRationalTests SignedRational rational = new(0, 0); Assert.Equal("[ Indeterminate ]", rational.ToString()); - rational = new(double.PositiveInfinity); + rational = new SignedRational(double.PositiveInfinity); Assert.Equal("[ PositiveInfinity ]", rational.ToString()); - rational = new(double.NegativeInfinity); + rational = new SignedRational(double.NegativeInfinity); Assert.Equal("[ NegativeInfinity ]", rational.ToString()); - rational = new(0, 1); + rational = new SignedRational(0, 1); Assert.Equal("0", rational.ToString()); - rational = new(2, 1); + rational = new SignedRational(2, 1); Assert.Equal("2", rational.ToString()); - rational = new(1, 2); + rational = new SignedRational(1, 2); Assert.Equal("1/2", rational.ToString()); } } diff --git a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs index 4b348b88f..4b4e84b4b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/A8Tests.cs @@ -101,7 +101,7 @@ public class A8Tests const byte expected = byte.MaxValue; // act - A8 alpha = A8.FromBgra5551(new(0.0f, 0.0f, 0.0f, 1.0f)); + A8 alpha = A8.FromBgra5551(new Bgra5551(0.0f, 0.0f, 0.0f, 1.0f)); // assert Assert.Equal(expected, alpha.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs index 415650321..98fdce5db 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Abgr32Tests.cs @@ -96,7 +96,7 @@ public class Abgr32Tests [Fact] public void FromRgba32() { - Abgr32 abgr = Abgr32.FromRgba32(new(1, 2, 3, 4)); + Abgr32 abgr = Abgr32.FromRgba32(new Rgba32(1, 2, 3, 4)); Assert.Equal(1, abgr.R); Assert.Equal(2, abgr.G); @@ -136,7 +136,7 @@ public class Abgr32Tests const uint expected = uint.MaxValue; // act - Abgr32 abgr = Abgr32.FromBgra5551(new(1f, 1f, 1f, 1f)); + Abgr32 abgr = Abgr32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, abgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs index 8e05c5ca0..bcaf9265a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Argb32Tests.cs @@ -128,7 +128,7 @@ public class Argb32Tests const uint expected = uint.MaxValue; // act - Argb32 argb = Argb32.FromBgra5551(new(1f, 1f, 1f, 1f)); + Argb32 argb = Argb32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, argb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index a7e4a08f0..362e20bba 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -80,7 +80,7 @@ public class Bgr24Tests [Fact] public void FromRgba32() { - Bgr24 rgb = Bgr24.FromRgba32(new(1, 2, 3, 4)); + Bgr24 rgb = Bgr24.FromRgba32(new Rgba32(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -115,7 +115,7 @@ public class Bgr24Tests public void Bgr24_FromBgra5551() { // act - Bgr24 bgr = Bgr24.FromBgra5551(new(1f, 1f, 1f, 1f)); + Bgr24 bgr = Bgr24.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(255, bgr.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs index f74660731..3c4a10423 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr565Tests.cs @@ -17,8 +17,8 @@ public class Bgr565Tests public void AreEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new(0.0f)); - Bgr565 color3 = new(new(1.0f, 0.0f, 1.0f)); + Bgr565 color2 = new(new Vector3(0.0f)); + Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 1.0f)); Bgr565 color4 = new(1.0f, 0.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgr565Tests public void AreNotEqual() { Bgr565 color1 = new(0.0f, 0.0f, 0.0f); - Bgr565 color2 = new(new(1.0f)); - Bgr565 color3 = new(new(1.0f, 0.0f, 0.0f)); + Bgr565 color2 = new(new Vector3(1.0f)); + Bgr565 color3 = new(new Vector3(1.0f, 0.0f, 0.0f)); Bgr565 color4 = new(1.0f, 1.0f, 0.0f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr = Bgr565.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -115,8 +115,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromArgb32(new(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromArgb32(new Argb32(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -131,8 +131,8 @@ public class Bgr565Tests const ushort expected2 = ushort.MaxValue; // act - Bgr565 bgr1 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 1.0f)); - Bgr565 bgr2 = Bgr565.FromRgba32(new(1.0f, 1.0f, 1.0f, 0.0f)); + Bgr565 bgr1 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 1.0f)); + Bgr565 bgr2 = Bgr565.FromRgba32(new Rgba32(1.0f, 1.0f, 1.0f, 0.0f)); // assert Assert.Equal(expected1, bgr1.PackedValue); @@ -159,7 +159,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -172,7 +172,7 @@ public class Bgr565Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, bgr.PackedValue); @@ -185,7 +185,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -198,7 +198,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgr565 bgr = Bgr565.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -211,7 +211,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL8(new(byte.MaxValue)); + Bgr565 bgr = Bgr565.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); @@ -224,7 +224,7 @@ public class Bgr565Tests const ushort expected = ushort.MaxValue; // act - Bgr565 bgr = Bgr565.FromL16(new(ushort.MaxValue)); + Bgr565 bgr = Bgr565.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, bgr.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index d0150c808..277975896 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -96,7 +96,7 @@ public class Bgra32Tests [Fact] public void FromRgba32() { - Bgra32 bgra = Bgra32.FromRgba32(new(1, 2, 3, 4)); + Bgra32 bgra = Bgra32.FromRgba32(new Rgba32(1, 2, 3, 4)); Assert.Equal(1, bgra.R); Assert.Equal(2, bgra.G); @@ -136,7 +136,7 @@ public class Bgra32Tests const uint expected = uint.MaxValue; // act - Bgra32 bgra = Bgra32.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra32 bgra = Bgra32.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, bgra.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs index 166a06940..5d20b5cf1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra4444Tests.cs @@ -17,8 +17,8 @@ public class Bgra4444Tests public void AreEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new(0.0f)); - Bgra4444 color3 = new(new(1.0f, 0.0f, 1.0f, 1.0f)); + Bgra4444 color2 = new(new Vector4(0.0f)); + Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 1.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 0.0f, 1.0f, 1.0f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra4444Tests public void AreNotEqual() { Bgra4444 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra4444 color2 = new(new(1.0f)); - Bgra4444 color3 = new(new(1.0f, 0.0f, 0.0f, 1.0f)); + Bgra4444 color2 = new(new Vector4(1.0f)); + Bgra4444 color3 = new(new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); Bgra4444 color4 = new(1.0f, 1.0f, 0.0f, 1.0f); Assert.NotEqual(color1, color2); @@ -114,7 +114,7 @@ public class Bgra4444Tests const ushort expected = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Bgra4444 pixel = Bgra4444.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -127,7 +127,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromArgb32(new(255, 255, 255, 255)); + Bgra4444 pixel = Bgra4444.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -141,8 +141,8 @@ public class Bgra4444Tests const ushort expectedPackedValue2 = 0xFF0F; // act - Bgra4444 bgra1 = Bgra4444.FromRgba32(new(255, 255, 255, 255)); - Bgra4444 bgra2 = Bgra4444.FromRgba32(new(255, 0, 255, 255)); + Bgra4444 bgra1 = Bgra4444.FromRgba32(new Rgba32(255, 255, 255, 255)); + Bgra4444 bgra2 = Bgra4444.FromRgba32(new Rgba32(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -156,7 +156,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -169,7 +169,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -182,7 +182,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL16(new(ushort.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -195,7 +195,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromL8(new(byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -208,7 +208,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -221,7 +221,7 @@ public class Bgra4444Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra4444 pixel = Bgra4444.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra4444 pixel = Bgra4444.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs index a19f0e9a1..38f809e49 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra5551Tests.cs @@ -17,8 +17,8 @@ public class Bgra5551Tests public void AreEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new(0.0f)); - Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new Vector4(0.0f)); + Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 0.0f, 0.0f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Bgra5551Tests public void AreNotEqual() { Bgra5551 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Bgra5551 color2 = new(new(1f)); - Bgra5551 color3 = new(new(1f, 0.0f, 0.0f, 1f)); + Bgra5551 color2 = new(new Vector4(1f)); + Bgra5551 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); Bgra5551 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -134,8 +134,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromRgba32(new(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromRgba32(new(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromRgba32(new Rgba32(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromRgba32(new Rgba32(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -150,8 +150,8 @@ public class Bgra5551Tests const ushort expectedPackedValue2 = 0xFC1F; // act - Bgra5551 bgra1 = Bgra5551.FromBgra32(new(255, 255, 255, 255)); - Bgra5551 bgra2 = Bgra5551.FromBgra32(new(255, 0, 255, 255)); + Bgra5551 bgra1 = Bgra5551.FromBgra32(new Bgra32(255, 255, 255, 255)); + Bgra5551 bgra2 = Bgra5551.FromBgra32(new Bgra32(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, bgra1.PackedValue); @@ -165,7 +165,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromArgb32(new(255, 255, 255, 255)); + Bgra5551 pixel = Bgra5551.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -178,7 +178,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -191,7 +191,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -204,7 +204,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL16(new(ushort.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -217,7 +217,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromL8(new(byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -230,7 +230,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -243,7 +243,7 @@ public class Bgra5551Tests const ushort expectedPackedValue = ushort.MaxValue; // act - Bgra5551 pixel = Bgra5551.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Bgra5551 pixel = Bgra5551.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs index 51c7ec4db..e73d64640 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Byte4Tests.cs @@ -17,8 +17,8 @@ public class Byte4Tests public void AreEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new(0f)); - Byte4 color3 = new(new(1f, 0f, 1f, 1f)); + Byte4 color2 = new(new Vector4(0f)); + Byte4 color3 = new(new Vector4(1f, 0f, 1f, 1f)); Byte4 color4 = new(1f, 0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Byte4Tests public void AreNotEqual() { Byte4 color1 = new(0f, 0f, 0f, 0f); - Byte4 color2 = new(new(1f)); - Byte4 color3 = new(new(1f, 0f, 0f, 1f)); + Byte4 color2 = new(new Vector4(1f)); + Byte4 color3 = new(new Vector4(1f, 0f, 0f, 1f)); Byte4 color4 = new(1f, 1f, 0f, 1f); Assert.NotEqual(color1, color2); @@ -111,7 +111,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromArgb32(new(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -124,7 +124,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -137,7 +137,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL8(new(byte.MaxValue)); + Byte4 pixel = Byte4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -150,7 +150,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromL16(new(ushort.MaxValue)); + Byte4 pixel = Byte4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -163,7 +163,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Byte4 pixel = Byte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -176,7 +176,7 @@ public class Byte4Tests const uint expected = 0xFFFFFFFF; // act - Byte4 pixel = Byte4.FromBgra5551(new(1f, 1f, 1f, 1f)); + Byte4 pixel = Byte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.PackedValue); @@ -189,7 +189,7 @@ public class Byte4Tests const uint expectedPackedValue1 = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba32(new(255, 255, 255, 255)); + Byte4 pixel = Byte4.FromRgba32(new Rgba32(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue1, pixel.PackedValue); @@ -202,7 +202,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); @@ -215,7 +215,7 @@ public class Byte4Tests const uint expectedPackedValue = uint.MaxValue; // act - Byte4 pixel = Byte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Byte4 pixel = Byte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs index d723aac47..c5a89df1e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector2Tests.cs @@ -76,7 +76,7 @@ public class HalfVector2Tests public void HalfVector2_FromBgra5551() { // act - HalfVector2 pixel = HalfVector2.FromBgra5551(new(1f, 1f, 1f, 1f)); + HalfVector2 pixel = HalfVector2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Vector4 actual = pixel.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs index 571711800..16c78a23d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/HalfVector4Tests.cs @@ -73,7 +73,7 @@ public class HalfVector4Tests Vector4 expected = Vector4.One; // act - HalfVector4 pixel = HalfVector4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + HalfVector4 pixel = HalfVector4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 5631bbc7e..7f0a4217c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -115,7 +115,7 @@ public class L16Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - L16 pixel = L16.FromRgba32(new(rgb, rgb, rgb)); + L16 pixel = L16.FromRgba32(new Rgba32(rgb, rgb, rgb)); ushort actual = pixel.PackedValue; // Assert @@ -149,7 +149,7 @@ public class L16Tests const ushort expected = ushort.MaxValue; // act - L16 pixel = L16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + L16 pixel = L16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, pixel.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index b1c94c754..1ca865ef4 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -114,7 +114,7 @@ public class L8Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - L8 pixel = L8.FromRgba32(new(rgb, rgb, rgb)); + L8 pixel = L8.FromRgba32(new Rgba32(rgb, rgb, rgb)); byte actual = pixel.PackedValue; // Assert @@ -145,7 +145,7 @@ public class L8Tests const byte expected = byte.MaxValue; // act - L8 grey = L8.FromBgra5551(new(1f, 1f, 1f, 1f)); + L8 grey = L8.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, grey.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index d82afdff1..f6cbfc442 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -116,7 +116,7 @@ public class La16Tests byte expected = ColorNumerics.Get8BitBT709Luminance(rgb, rgb, rgb); // Act - La16 gray = La16.FromRgba32(new(rgb, rgb, rgb)); + La16 gray = La16.FromRgba32(new Rgba32(rgb, rgb, rgb)); byte actual = gray.L; // Assert @@ -148,7 +148,7 @@ public class La16Tests const byte expected = byte.MaxValue; // act - La16 grey = La16.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + La16 grey = La16.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, grey.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs index 571aa3fd0..fd5556d3b 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -119,7 +119,7 @@ public class La32Tests ushort expected = ColorNumerics.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act - La32 pixel = La32.FromRgba32(new(rgb, rgb, rgb)); + La32 pixel = La32.FromRgba32(new Rgba32(rgb, rgb, rgb)); ushort actual = pixel.L; // Assert @@ -154,7 +154,7 @@ public class La32Tests const ushort expected = ushort.MaxValue; // act - La32 pixel = La32.FromBgra5551(new(1f, 1f, 1f, 1f)); + La32 pixel = La32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.L); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs index c6a14518a..ffbddb139 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte2Tests.cs @@ -32,8 +32,8 @@ public class NormalizedByte2Tests [Fact] public void NormalizedByte2_ToVector4() { - Assert.Equal(new(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); - Assert.Equal(new(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); + Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedByte2(Vector2.One).ToVector4()); + Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedByte2(Vector2.Zero).ToVector4()); } [Fact] @@ -74,7 +74,7 @@ public class NormalizedByte2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new(1f, 1f, 1f, 1f)); + NormalizedByte2 pixel = NormalizedByte2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs index 40d81cad6..5a025f6c4 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedByte4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedByte4Tests public void AreEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new(0.0f)); - NormalizedByte4 color3 = new(new(1f, 0.0f, 1f, 1f)); + NormalizedByte4 color2 = new(new Vector4(0.0f)); + NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); NormalizedByte4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedByte4Tests public void AreNotEqual() { NormalizedByte4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedByte4 color2 = new(new(1f)); - NormalizedByte4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); + NormalizedByte4 color2 = new(new Vector4(1f)); + NormalizedByte4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); NormalizedByte4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -98,7 +98,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -111,7 +111,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -124,7 +124,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL8(new(byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -137,7 +137,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromL16(new(ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -150,7 +150,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -163,7 +163,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new(255, 255, 255, 255)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba32(new Rgba32(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -176,7 +176,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new(1f, 1f, 1f, 1f)); + NormalizedByte4 pixel = NormalizedByte4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, pixel.ToVector4()); @@ -189,7 +189,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -202,7 +202,7 @@ public class NormalizedByte4Tests Vector4 expected = Vector4.One; // act - NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedByte4 pixel = NormalizedByte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs index f153f6aea..be7b39052 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort2Tests.cs @@ -36,8 +36,8 @@ public class NormalizedShort2Tests [Fact] public void NormalizedShort2_ToVector4() { - Assert.Equal(new(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); - Assert.Equal(new(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); + Assert.Equal(new Vector4(1, 1, 0, 1), new NormalizedShort2(Vector2.One).ToVector4()); + Assert.Equal(new Vector4(0, 0, 0, 1), new NormalizedShort2(Vector2.Zero).ToVector4()); } [Fact] @@ -78,7 +78,7 @@ public class NormalizedShort2Tests Vector4 expected = new(1, 1, 0, 1); // act - NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new(1f, 1f, 1f, 1f)); + NormalizedShort2 normalizedShort2 = NormalizedShort2.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort2.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs index cf0c3e819..281ae7ee5 100644 --- a/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/NormalizedShort4Tests.cs @@ -17,8 +17,8 @@ public class NormalizedShort4Tests public void AreEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new(0.0f)); - NormalizedShort4 color3 = new(new(1f, 0.0f, 1f, 1f)); + NormalizedShort4 color2 = new(new Vector4(0.0f)); + NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); NormalizedShort4 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class NormalizedShort4Tests public void AreNotEqual() { NormalizedShort4 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - NormalizedShort4 color2 = new(new(1f)); - NormalizedShort4 color3 = new(new(1f, 0.0f, 0.0f, 1f)); + NormalizedShort4 color2 = new(new Vector4(1f)); + NormalizedShort4 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); NormalizedShort4 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -99,7 +99,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -112,7 +112,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -125,7 +125,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL8(new(byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -138,7 +138,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromL16(new(ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -151,7 +151,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -164,7 +164,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new(255, 255, 255, 255)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba32(new Rgba32(255, 255, 255, 255)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -177,7 +177,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -190,7 +190,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + NormalizedShort4 pixel = NormalizedShort4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expected, pixel.ToScaledVector4()); @@ -216,7 +216,7 @@ public class NormalizedShort4Tests Vector4 expected = Vector4.One; // act - NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new(1f, 1f, 1f, 1f)); + NormalizedShort4 normalizedShort4 = NormalizedShort4.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, normalizedShort4.ToVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs index 2e66115b0..924e94d92 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenderTests.cs @@ -44,14 +44,14 @@ public class PixelBlenderTests public static TheoryData ColorBlendingExpectedResults = new() { { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Normal, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new(0xFFEEE7FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new(0xFFC62D32) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new(0xFFDDCEFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new(0xFF701919) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new(0xFFE1E4FF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new(0xFFFFFDFF) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new(0xFF71CBE6) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new(0xFF631619) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Screen, new Rgba32(0xFFEEE7FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.HardLight, new Rgba32(0xFFC62D32) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Overlay, new Rgba32(0xFFDDCEFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Darken, new Rgba32(0xFF701919) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Lighten, new Rgba32(0xFFE1E4FF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Add, new Rgba32(0xFFFFFDFF) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Subtract, new Rgba32(0xFF71CBE6) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelColorBlendingMode.Multiply, new Rgba32(0xFF631619) }, }; [Theory] @@ -67,17 +67,17 @@ public class PixelBlenderTests public static TheoryData AlphaCompositionExpectedResults = new() { - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new(0) }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Clear, new Rgba32(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Xor, new Rgba32(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Dest, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestAtop, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestIn, Color.MistyRose.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOut, new Rgba32(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.DestOver, Color.MistyRose.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.Src, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcAtop, Color.MidnightBlue.ToPixel() }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcIn, Color.MidnightBlue.ToPixel() }, - { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new(0) }, + { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOut, new Rgba32(0) }, { Color.MistyRose.ToPixel(), Color.MidnightBlue.ToPixel(), 1, PixelAlphaCompositionMode.SrcOver, Color.MidnightBlue.ToPixel() }, }; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs index 908625e17..976a272eb 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests.cs @@ -16,8 +16,8 @@ public class PorterDuffFunctionsTests public static TheoryData NormalBlendFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) } }; [Theory] @@ -47,9 +47,9 @@ public class PorterDuffFunctionsTests public static TheoryData MultiplyFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1) }, - { new(0.9f, 0.9f, 0.9f, 0.9f), new(0.4f, 0.4f, 0.4f, 0.4f), .5f, new(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1) }, + { new TestVector4(0.9f, 0.9f, 0.9f, 0.9f), new TestVector4(0.4f, 0.4f, 0.4f, 0.4f), .5f, new TestVector4(0.7834783f, 0.7834783f, 0.7834783f, 0.92f) } }; [Theory] @@ -79,9 +79,9 @@ public class PorterDuffFunctionsTests public static TheoryData AddFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(0.24324325f, 0.24324325f, 0.24324325f, .37f) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(0.24324325f, 0.24324325f, 0.24324325f, .37f) } }; [Theory] @@ -111,9 +111,9 @@ public class PorterDuffFunctionsTests public static TheoryData SubtractFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(0, 0, 0, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2027027f, .2027027f, .2027027f, .37f) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(0, 0, 0, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2027027f, .2027027f, .2027027f, .37f) } }; [Theory] @@ -143,9 +143,9 @@ public class PorterDuffFunctionsTests public static TheoryData ScreenFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2383784f, .2383784f, .2383784f, .37f) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2383784f, .2383784f, .2383784f, .37f) } }; [Theory] @@ -175,9 +175,9 @@ public class PorterDuffFunctionsTests public static TheoryData DarkenFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(.6f, .6f, .6f, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2189189f, .2189189f, .2189189f, .37f) } + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(.6f, .6f, .6f, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2189189f, .2189189f, .2189189f, .37f) } }; [Theory] @@ -207,9 +207,9 @@ public class PorterDuffFunctionsTests public static TheoryData LightenFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.227027f, .227027f, .227027f, .37f) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.227027f, .227027f, .227027f, .37f) }, }; [Theory] @@ -239,9 +239,9 @@ public class PorterDuffFunctionsTests public static TheoryData OverlayFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(1, 1, 1, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(1, 1, 1, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] @@ -271,9 +271,9 @@ public class PorterDuffFunctionsTests public static TheoryData HardLightFunctionData { get; } = new() { - { new(1, 1, 1, 1), new(1, 1, 1, 1), 1, new(1, 1, 1, 1) }, - { new(1, 1, 1, 1), new(0, 0, 0, .8f), .5f, new(0.6f, 0.6f, 0.6f, 1f) }, - { new(0.2f, 0.2f, 0.2f, 0.3f), new(0.3f, 0.3f, 0.3f, 0.2f), .5f, new(.2124324f, .2124324f, .2124324f, .37f) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(1, 1, 1, 1), 1, new TestVector4(1, 1, 1, 1) }, + { new TestVector4(1, 1, 1, 1), new TestVector4(0, 0, 0, .8f), .5f, new TestVector4(0.6f, 0.6f, 0.6f, 1f) }, + { new TestVector4(0.2f, 0.2f, 0.2f, 0.3f), new TestVector4(0.3f, 0.3f, 0.3f, 0.2f), .5f, new TestVector4(.2124324f, .2124324f, .2124324f, .37f) }, }; [Theory] diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs index 4c15fda31..2c97cbde0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTestsTPixel.cs @@ -12,7 +12,7 @@ public class PorterDuffFunctionsTestsTPixel private static Span AsSpan(T value) where T : struct { - return new(new[] { value }); + return new Span(new[] { value }); } public static TheoryData NormalBlendFunctionData = new() diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs index 6d5013cde..32b62fc03 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs @@ -117,7 +117,7 @@ public abstract class PixelOperationsTests : MeasureFixture const byte alpha = byte.MinValue; const byte noAlpha = byte.MaxValue; - TPixel pixel = TPixel.FromRgba32(new(0, 0, 0, alpha)); + TPixel pixel = TPixel.FromRgba32(new Rgba32(0, 0, 0, alpha)); Rgba32 dest = pixel.ToRgba32(); @@ -480,7 +480,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromArgb32(new(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); + expected[i] = TPixel.FromArgb32(new Argb32(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0])); } TestOperation( @@ -524,7 +524,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromBgr24(new(source[i3 + 2], source[i3 + 1], source[i3])); + expected[i] = TPixel.FromBgr24(new Bgr24(source[i3 + 2], source[i3 + 1], source[i3])); } TestOperation( @@ -566,7 +566,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromBgra32(new(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); + expected[i] = TPixel.FromBgra32(new Bgra32(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3])); } TestOperation( @@ -609,7 +609,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromAbgr32(new(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); + expected[i] = TPixel.FromAbgr32(new Abgr32(source[i4 + 3], source[i4 + 2], source[i4 + 1], source[i4 + 0])); } TestOperation( @@ -863,7 +863,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i3 = i * 3; - expected[i] = TPixel.FromRgb24(new(source[i3 + 0], source[i3 + 1], source[i3 + 2])); + expected[i] = TPixel.FromRgb24(new Rgb24(source[i3 + 0], source[i3 + 1], source[i3 + 2])); } TestOperation( @@ -905,7 +905,7 @@ public abstract class PixelOperationsTests : MeasureFixture { int i4 = i * 4; - expected[i] = TPixel.FromRgba32(new(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); + expected[i] = TPixel.FromRgba32(new Rgba32(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3])); } TestOperation( diff --git a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs index c4e2fc7a2..b2790469a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rg32Tests.cs @@ -69,7 +69,7 @@ public class Rg32Tests const uint expected = 0xFFFFFFFF; // act - Rg32 rg32 = Rg32.FromBgra5551(new(1f, 1f, 1f, 1f)); + Rg32 rg32 = Rg32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rg32.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs index 22c977dcc..6364378c1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs @@ -68,7 +68,7 @@ public class Rgb24Tests [Fact] public void FromRgba32() { - Rgb24 rgb = Rgb24.FromRgba32(new(1, 2, 3, 4)); + Rgb24 rgb = Rgb24.FromRgba32(new Rgba32(1, 2, 3, 4)); Assert.Equal(1, rgb.R); Assert.Equal(2, rgb.G); @@ -117,7 +117,7 @@ public class Rgb24Tests public void Rgb24_FromBgra5551() { // act - Rgb24 rgb = Rgb24.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Rgb24 rgb = Rgb24.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(255, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs index cf8e2e7e9..764627ee3 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgb48Tests.cs @@ -65,7 +65,7 @@ public class Rgb48Tests const ushort expected = ushort.MaxValue; // act - Rgb48 rgb = Rgb48.FromBgra5551(new(1f, 1f, 1f, 1f)); + Rgb48 rgb = Rgb48.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs index c342d0aa3..79a1aefc9 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba1010102Tests.cs @@ -17,8 +17,8 @@ public class Rgba1010102Tests public void AreEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new(0.0f)); - Rgba1010102 color3 = new(new(1f, 0.0f, 1f, 1f)); + Rgba1010102 color2 = new(new Vector4(0.0f)); + Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 1f, 1f)); Rgba1010102 color4 = new(1f, 0.0f, 1f, 1f); Assert.Equal(color1, color2); @@ -32,8 +32,8 @@ public class Rgba1010102Tests public void AreNotEqual() { Rgba1010102 color1 = new(0.0f, 0.0f, 0.0f, 0.0f); - Rgba1010102 color2 = new(new(1f)); - Rgba1010102 color3 = new(new(1f, 0.0f, 0.0f, 1f)); + Rgba1010102 color2 = new(new Vector4(1f)); + Rgba1010102 color3 = new(new Vector4(1f, 0.0f, 0.0f, 1f)); Rgba1010102 color4 = new(1f, 1f, 0.0f, 1f); Assert.NotEqual(color1, color2); @@ -101,7 +101,7 @@ public class Rgba1010102Tests const uint expected = 0xFFFFFFFF; // act - Rgba1010102 rgba = Rgba1010102.FromBgra5551(new(1f, 1f, 1f, 1f)); + Rgba1010102 rgba = Rgba1010102.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgba.PackedValue); @@ -114,7 +114,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromArgb32(new(255, 255, 255, 255)); + Rgba1010102 rgba = Rgba1010102.FromArgb32(new Argb32(255, 255, 255, 255)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -128,8 +128,8 @@ public class Rgba1010102Tests const uint expectedPackedValue2 = 0xFFF003FF; // act - Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new(255, 255, 255, 255)); - Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new(255, 0, 255, 255)); + Rgba1010102 rgba1 = Rgba1010102.FromRgba32(new Rgba32(255, 255, 255, 255)); + Rgba1010102 rgba2 = Rgba1010102.FromRgba32(new Rgba32(255, 0, 255, 255)); // assert Assert.Equal(expectedPackedValue1, rgba1.PackedValue); @@ -143,7 +143,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromBgr24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -156,7 +156,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL8(new(byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -169,7 +169,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromL16(new(ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -182,7 +182,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb24(new(byte.MaxValue, byte.MaxValue, byte.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -195,7 +195,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgb48(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); @@ -208,7 +208,7 @@ public class Rgba1010102Tests const uint expectedPackedValue = uint.MaxValue; // act - Rgba1010102 rgba = Rgba1010102.FromRgba64(new(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); + Rgba1010102 rgba = Rgba1010102.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); // assert Assert.Equal(expectedPackedValue, rgba.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs index fafee5d3c..6d56185ec 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs @@ -286,7 +286,7 @@ public class Rgba32Tests const uint expected = 0xFFFFFFFF; // act - Rgba32 rgb = Rgba32.FromBgra5551(new(1f, 1f, 1f, 1f)); + Rgba32 rgb = Rgba32.FromBgra5551(new Bgra5551(1f, 1f, 1f, 1f)); // assert Assert.Equal(expected, rgb.PackedValue); diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs index e962b41fe..694d0ace1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba64Tests.cs @@ -106,7 +106,7 @@ public class Rgba64Tests const ushort expected = ushort.MaxValue; // act - Rgba64 rgba = Rgba64.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Rgba64 rgba = Rgba64.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgba.R); diff --git a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs index daafabaa3..5273482ef 100644 --- a/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/RgbaVectorTests.cs @@ -150,7 +150,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgb = RgbaVector.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + RgbaVector rgb = RgbaVector.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, rgb.ToScaledVector4()); @@ -163,7 +163,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL16(new(ushort.MaxValue)); + RgbaVector rgba = RgbaVector.FromL16(new L16(ushort.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); @@ -176,7 +176,7 @@ public class RgbaVectorTests Vector4 expected = Vector4.One; // act - RgbaVector rgba = RgbaVector.FromL8(new(byte.MaxValue)); + RgbaVector rgba = RgbaVector.FromL8(new L8(byte.MaxValue)); // assert Assert.Equal(expected, rgba.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs index a9942220c..f23da0c7a 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short2Tests.cs @@ -36,9 +36,9 @@ public class Short2Tests [Fact] public void Short2_ToVector4() { - Assert.Equal(new(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); - Assert.Equal(new(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); - Assert.Equal(new(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); + Assert.Equal(new Vector4(0x7FFF, 0x7FFF, 0, 1), new Short2(Vector2.One * 0x7FFF).ToVector4()); + Assert.Equal(new Vector4(0, 0, 0, 1), new Short2(Vector2.Zero).ToVector4()); + Assert.Equal(new Vector4(-0x8000, -0x8000, 0, 1), new Short2(Vector2.One * -0x8000).ToVector4()); } [Fact] @@ -140,7 +140,7 @@ public class Short2Tests public void Short2_FromBgra5551() { // act - Short2 short2 = Short2.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Short2 short2 = Short2.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Vector4 actual = short2.ToScaledVector4(); diff --git a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs index fd25f5086..819ff0e1e 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Short4Tests.cs @@ -190,7 +190,7 @@ public class Short4Tests Vector4 expected = Vector4.One; // act - Short4 short4 = Short4.FromBgra5551(new(1.0f, 1.0f, 1.0f, 1.0f)); + Short4 short4 = Short4.FromBgra5551(new Bgra5551(1.0f, 1.0f, 1.0f, 1.0f)); // assert Assert.Equal(expected, short4.ToScaledVector4()); diff --git a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs index e5162e23d..f83ebc53c 100644 --- a/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs +++ b/tests/ImageSharp.Tests/Primitives/DenseMatrixTests.cs @@ -43,7 +43,7 @@ public class DenseMatrixTests Assert.True(dense.Rows == FloydSteinbergMatrix.GetLength(0)); Assert.Equal(3, dense.Columns); Assert.Equal(2, dense.Rows); - Assert.Equal(new(3, 2), dense.Size); + Assert.Equal(new Size(3, 2), dense.Size); } [Fact] diff --git a/tests/ImageSharp.Tests/Primitives/PointFTests.cs b/tests/ImageSharp.Tests/Primitives/PointFTests.cs index 772d8bd2d..8b574daf0 100644 --- a/tests/ImageSharp.Tests/Primitives/PointFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointFTests.cs @@ -130,7 +130,7 @@ public class PointFTests Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, PointF.Empty); PointF pout = PointF.Transform(p, matrix); - Assert.Equal(new(30, 30), pout); + Assert.Equal(new PointF(30, 30), pout); } [Theory] diff --git a/tests/ImageSharp.Tests/Primitives/PointTests.cs b/tests/ImageSharp.Tests/Primitives/PointTests.cs index 8ade95eb1..3ad2a83b3 100644 --- a/tests/ImageSharp.Tests/Primitives/PointTests.cs +++ b/tests/ImageSharp.Tests/Primitives/PointTests.cs @@ -76,7 +76,7 @@ public class PointTests public void PointFConversionTest(int x, int y) { PointF p = new Point(x, y); - Assert.Equal(new(x, y), p); + Assert.Equal(new PointF(x, y), p); } [Theory] @@ -87,7 +87,7 @@ public class PointTests public void SizeConversionTest(int x, int y) { Size sz = (Size)new Point(x, y); - Assert.Equal(new(x, y), sz); + Assert.Equal(new Size(x, y), sz); } [Theory] @@ -102,8 +102,8 @@ public class PointTests unchecked { - addExpected = new(x + y, y + x); - subExpected = new(x - y, y - x); + addExpected = new Point(x + y, y + x); + subExpected = new Point(x - y, y - x); } Assert.Equal(addExpected, p + s); @@ -124,9 +124,9 @@ public class PointTests unchecked { - pCeiling = new((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); - pTruncate = new((int)x, (int)y); - pRound = new((int)MathF.Round(x), (int)MathF.Round(y)); + pCeiling = new Point((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); + pTruncate = new Point((int)x, (int)y); + pRound = new Point((int)MathF.Round(x), (int)MathF.Round(y)); } Assert.Equal(pCeiling, Point.Ceiling(pf)); @@ -161,7 +161,7 @@ public class PointTests Point pout = Point.Transform(p, matrix); - Assert.Equal(new(-3, 21), pout); + Assert.Equal(new Point(-3, 21), pout); } [Fact] @@ -171,7 +171,7 @@ public class PointTests Matrix3x2 matrix = Matrix3x2Extensions.CreateSkewDegrees(45, 45, Point.Empty); Point pout = Point.Transform(p, matrix); - Assert.Equal(new(30, 30), pout); + Assert.Equal(new Point(30, 30), pout); } [Theory] diff --git a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs index 0e8bf4f34..4122daaa5 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleFTests.cs @@ -23,10 +23,10 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void NonDefaultConstructorTest(float x, float y, float width, float height) { - RectangleF rect1 = new RectangleF(x, y, width, height); - PointF p = new PointF(x, y); - SizeF s = new SizeF(width, height); - RectangleF rect2 = new RectangleF(p, s); + RectangleF rect1 = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); + RectangleF rect2 = new(p, s); Assert.Equal(rect1, rect2); } @@ -38,7 +38,7 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void FromLTRBTest(float left, float top, float right, float bottom) { - RectangleF expected = new RectangleF(left, top, right - left, bottom - top); + RectangleF expected = new(left, top, right - left, bottom - top); RectangleF actual = RectangleF.FromLTRB(left, top, right, bottom); Assert.Equal(expected, actual); @@ -51,9 +51,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void DimensionsTest(float x, float y, float width, float height) { - RectangleF rect = new RectangleF(x, y, width, height); - PointF p = new PointF(x, y); - SizeF s = new SizeF(width, height); + RectangleF rect = new(x, y, width, height); + PointF p = new(x, y); + SizeF s = new(width, height); Assert.Equal(p, rect.Location); Assert.Equal(s, rect.Size); @@ -84,8 +84,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void LocationSetTest(float x, float y) { - PointF point = new PointF(x, y); - RectangleF rect = new RectangleF(10, 10, 10, 10) { Location = point }; + PointF point = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Location = point }; Assert.Equal(point, rect.Location); Assert.Equal(point.X, rect.X); Assert.Equal(point.Y, rect.Y); @@ -96,8 +96,8 @@ public class RectangleFTests [InlineData(float.MaxValue, float.MinValue)] public void SizeSetTest(float x, float y) { - SizeF size = new SizeF(x, y); - RectangleF rect = new RectangleF(10, 10, 10, 10) { Size = size }; + SizeF size = new(x, y); + RectangleF rect = new(10, 10, 10, 10) { Size = size }; Assert.Equal(size, rect.Size); Assert.Equal(size.Width, rect.Width); Assert.Equal(size.Height, rect.Height); @@ -109,8 +109,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void EqualityTest(float x, float y, float width, float height) { - RectangleF rect1 = new RectangleF(x, y, width, height); - RectangleF rect2 = new RectangleF(width, height, x, y); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(width, height, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -121,7 +121,7 @@ public class RectangleFTests [Fact] public void EqualityTestNotRectangleF() { - RectangleF rectangle = new RectangleF(0, 0, 0, 0); + RectangleF rectangle = new(0, 0, 0, 0); Assert.False(rectangle.Equals(null)); Assert.False(rectangle.Equals(0)); @@ -137,8 +137,8 @@ public class RectangleFTests [Fact] public void GetHashCodeTest() { - RectangleF rect1 = new RectangleF(10, 10, 10, 10); - RectangleF rect2 = new RectangleF(10, 10, 10, 10); + RectangleF rect1 = new(10, 10, 10, 10); + RectangleF rect2 = new(10, 10, 10, 10); Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(20, 10, 10, 10).GetHashCode()); Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 20, 10, 10).GetHashCode()); @@ -151,11 +151,11 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void ContainsTest(float x, float y, float width, float height) { - RectangleF rect = new RectangleF(x, y, width, height); + RectangleF rect = new(x, y, width, height); float x1 = (x + width) / 2; float y1 = (y + height) / 2; - PointF p = new PointF(x1, y1); - RectangleF r = new RectangleF(x1, y1, width / 2, height / 2); + PointF p = new(x1, y1); + RectangleF r = new(x1, y1, width / 2, height / 2); Assert.False(rect.Contains(x1, y1)); Assert.False(rect.Contains(p)); @@ -168,13 +168,13 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { - RectangleF rect = new RectangleF(x, y, width, height); - RectangleF inflatedRect = new RectangleF(x - width, y - height, width + (2 * width), height + (2 * height)); + RectangleF rect = new(x, y, width, height); + RectangleF inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); rect.Inflate(width, height); Assert.Equal(inflatedRect, rect); - SizeF s = new SizeF(x, y); + SizeF s = new(x, y); inflatedRect = RectangleF.Inflate(rect, x, y); rect.Inflate(s); @@ -186,8 +186,8 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { - RectangleF rect1 = new RectangleF(x, y, width, height); - RectangleF rect2 = new RectangleF(y, x, width, height); + RectangleF rect1 = new(x, y, width, height); + RectangleF rect2 = new(y, x, width, height); RectangleF expectedRect = RectangleF.Intersect(rect1, rect2); rect1.Intersect(rect2); Assert.Equal(expectedRect, rect1); @@ -197,9 +197,9 @@ public class RectangleFTests [Fact] public void IntersectIntersectingRectsTest() { - RectangleF rect1 = new RectangleF(0, 0, 5, 5); - RectangleF rect2 = new RectangleF(1, 1, 3, 3); - RectangleF expected = new RectangleF(1, 1, 3, 3); + RectangleF rect1 = new(0, 0, 5, 5); + RectangleF rect2 = new(1, 1, 3, 3); + RectangleF expected = new(1, 1, 3, 3); Assert.Equal(expected, RectangleF.Intersect(rect1, rect2)); } @@ -211,15 +211,15 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void UnionTest(float x, float y, float width, float height) { - RectangleF a = new RectangleF(x, y, width, height); - RectangleF b = new RectangleF(width, height, x, y); + RectangleF a = new(x, y, width, height); + RectangleF b = new(width, height, x, y); float x1 = Math.Min(a.X, b.X); float x2 = Math.Max(a.X + a.Width, b.X + b.Width); float y1 = Math.Min(a.Y, b.Y); float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - RectangleF expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); + RectangleF expectedRectangle = new(x1, y1, x2 - x1, y2 - y1); Assert.Equal(expectedRectangle, RectangleF.Union(a, b)); } @@ -231,9 +231,9 @@ public class RectangleFTests [InlineData(0, float.MinValue, float.MaxValue, 0)] public void OffsetTest(float x, float y, float width, float height) { - RectangleF r1 = new RectangleF(x, y, width, height); - RectangleF expectedRect = new RectangleF(x + width, y + height, width, height); - PointF p = new PointF(width, height); + RectangleF r1 = new(x, y, width, height); + RectangleF expectedRect = new(x + width, y + height, width, height); + PointF p = new(width, height); r1.Offset(p); Assert.Equal(expectedRect, r1); @@ -246,7 +246,7 @@ public class RectangleFTests [Fact] public void ToStringTest() { - RectangleF r = new RectangleF(5, 5.1F, 1.3F, 1); + RectangleF r = new(5, 5.1F, 1.3F, 1); Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } @@ -270,7 +270,7 @@ public class RectangleFTests [InlineData(0, 0, 0, 0)] public void DeconstructTest(float x, float y, float width, float height) { - RectangleF r = new RectangleF(x, y, width, height); + RectangleF r = new(x, y, width, height); (float dx, float dy, float dw, float dh) = r; diff --git a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs index 2a4d64147..2800852af 100644 --- a/tests/ImageSharp.Tests/Primitives/RectangleTests.cs +++ b/tests/ImageSharp.Tests/Primitives/RectangleTests.cs @@ -24,7 +24,7 @@ public class RectangleTests public void NonDefaultConstructorTest(int x, int y, int width, int height) { Rectangle rect1 = new(x, y, width, height); - Rectangle rect2 = new(new(x, y), new(width, height)); + Rectangle rect2 = new(new Point(x, y), new Size(width, height)); Assert.Equal(rect1, rect2); } @@ -69,8 +69,8 @@ public class RectangleTests public void DimensionsTest(int x, int y, int width, int height) { Rectangle rect = new(x, y, width, height); - Assert.Equal(new(x, y), rect.Location); - Assert.Equal(new(width, height), rect.Size); + Assert.Equal(new Point(x, y), rect.Location); + Assert.Equal(new Size(width, height), rect.Size); Assert.Equal(x, rect.X); Assert.Equal(y, rect.Y); @@ -171,15 +171,15 @@ public class RectangleTests unchecked { - rCeiling = new( + rCeiling = new Rectangle( (int)Math.Ceiling(x), (int)Math.Ceiling(y), (int)Math.Ceiling(width), (int)Math.Ceiling(height)); - rTruncate = new((int)x, (int)y, (int)width, (int)height); + rTruncate = new Rectangle((int)x, (int)y, (int)width, (int)height); - rRound = new( + rRound = new Rectangle( (int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(width), @@ -214,7 +214,7 @@ public class RectangleTests Rectangle inflatedRect, rect = new(x, y, width, height); unchecked { - inflatedRect = new(x - width, y - height, width + (2 * width), height + (2 * height)); + inflatedRect = new Rectangle(x - width, y - height, width + (2 * width), height + (2 * height)); } Assert.Equal(inflatedRect, Rectangle.Inflate(rect, width, height)); @@ -225,7 +225,7 @@ public class RectangleTests Size s = new(x, y); unchecked { - inflatedRect = new(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); + inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + (2 * x), rect.Height + (2 * y)); } rect.Inflate(s); diff --git a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs index 246f21b1e..2893a7c71 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeFTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeFTests.cs @@ -25,8 +25,8 @@ public class SizeFTests SizeF s2 = new(s1); Assert.Equal(s1, s2); - Assert.Equal(s1, new(p1)); - Assert.Equal(s2, new(p1)); + Assert.Equal(s1, new SizeF(p1)); + Assert.Equal(s2, new SizeF(p1)); Assert.Equal(width, s1.Width); Assert.Equal(height, s1.Height); @@ -136,7 +136,7 @@ public class SizeFTests PointF p1 = (PointF)s1; Size s2 = new(unchecked((int)width), unchecked((int)height)); - Assert.Equal(new(width, height), p1); + Assert.Equal(new PointF(width, height), p1); Assert.Equal(p1, (PointF)s1); Assert.Equal(s2, (Size)s1); } @@ -175,7 +175,7 @@ public class SizeFTests SizeF sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new(dimension * multiplier, dimension * multiplier); + mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -188,7 +188,7 @@ public class SizeFTests SizeF sz1 = new(width, height); SizeF mulExpected; - mulExpected = new(width * multiplier, height * multiplier); + mulExpected = new SizeF(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); diff --git a/tests/ImageSharp.Tests/Primitives/SizeTests.cs b/tests/ImageSharp.Tests/Primitives/SizeTests.cs index 6b366e183..63320796a 100644 --- a/tests/ImageSharp.Tests/Primitives/SizeTests.cs +++ b/tests/ImageSharp.Tests/Primitives/SizeTests.cs @@ -72,7 +72,7 @@ public class SizeTests public void PointFConversionTest(int width, int height) { SizeF sz = new Size(width, height); - Assert.Equal(new(width, height), sz); + Assert.Equal(new SizeF(width, height), sz); } [Theory] @@ -83,7 +83,7 @@ public class SizeTests public void SizeConversionTest(int width, int height) { Point sz = (Point)new Size(width, height); - Assert.Equal(new(width, height), sz); + Assert.Equal(new Point(width, height), sz); } [Theory] @@ -99,8 +99,8 @@ public class SizeTests unchecked { - addExpected = new(width + height, height + width); - subExpected = new(width - height, height - width); + addExpected = new Size(width + height, height + width); + subExpected = new Size(width - height, height - width); } Assert.Equal(addExpected, sz1 + sz2); @@ -121,9 +121,9 @@ public class SizeTests unchecked { - pCeiling = new((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); - pTruncate = new((int)width, (int)height); - pRound = new((int)MathF.Round(width), (int)MathF.Round(height)); + pCeiling = new Size((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); + pTruncate = new Size((int)width, (int)height); + pRound = new Size((int)MathF.Round(width), (int)MathF.Round(height)); } Assert.Equal(pCeiling, Size.Ceiling(szF)); @@ -211,7 +211,7 @@ public class SizeTests unchecked { - mulExpected = new(dimension * multiplier, dimension * multiplier); + mulExpected = new Size(dimension * multiplier, dimension * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -227,7 +227,7 @@ public class SizeTests unchecked { - mulExpected = new(width * multiplier, height * multiplier); + mulExpected = new Size(width * multiplier, height * multiplier); } Assert.Equal(mulExpected, sz1 * multiplier); @@ -261,7 +261,7 @@ public class SizeTests Size sz1 = new(dimension, dimension); SizeF mulExpected; - mulExpected = new(dimension * multiplier, dimension * multiplier); + mulExpected = new SizeF(dimension * multiplier, dimension * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -274,7 +274,7 @@ public class SizeTests Size sz1 = new(width, height); SizeF mulExpected; - mulExpected = new(width * multiplier, height * multiplier); + mulExpected = new SizeF(width * multiplier, height * multiplier); Assert.Equal(mulExpected, sz1 * multiplier); Assert.Equal(mulExpected, multiplier * sz1); @@ -308,7 +308,7 @@ public class SizeTests Size size = new(dimension, dimension); Size expected; - expected = new(dimension / divisor, dimension / divisor); + expected = new Size(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -320,7 +320,7 @@ public class SizeTests Size size = new(width, height); Size expected; - expected = new(width / divisor, height / divisor); + expected = new Size(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } @@ -344,7 +344,7 @@ public class SizeTests SizeF size = new(dimension, dimension); SizeF expected; - expected = new(dimension / divisor, dimension / divisor); + expected = new SizeF(dimension / divisor, dimension / divisor); Assert.Equal(expected, size / divisor); } @@ -355,7 +355,7 @@ public class SizeTests SizeF size = new(width, height); SizeF expected; - expected = new(width / divisor, height / divisor); + expected = new SizeF(width / divisor, height / divisor); Assert.Equal(expected, size / divisor); } diff --git a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs index 1b8388eba..5e5887c92 100644 --- a/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs +++ b/tests/ImageSharp.Tests/Processing/BaseImageOperationsExtensionTest.cs @@ -18,10 +18,10 @@ public abstract class BaseImageOperationsExtensionTest : IDisposable public BaseImageOperationsExtensionTest() { - this.options = new() { Antialias = false }; - this.source = new(91 + 324, 123 + 56); - this.rect = new(91, 123, 324, 56); // make this random? - this.internalOperations = new(this.source.Configuration, this.source, false); + this.options = new GraphicsOptions { Antialias = false }; + this.source = new Image(91 + 324, 123 + 56); + this.rect = new Rectangle(91, 123, 324, 56); // make this random? + this.internalOperations = new FakeImageOperationsProvider.FakeImageOperations(this.source.Configuration, this.source, false); this.internalOperations.SetGraphicsOptions(this.options); this.operations = this.internalOperations; } diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs index c7eb95953..32b8bf276 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs @@ -10,14 +10,14 @@ public class OrderedDitherFactoryTests { #pragma warning disable SA1025 // Code should not contain multiple whitespace in a row - private static readonly DenseMatrix Expected2x2Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected2x2Matrix = new( new uint[2, 2] { { 0, 2 }, { 3, 1 } }); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new uint[3, 3] { { 0, 5, 2 }, @@ -25,7 +25,7 @@ public class OrderedDitherFactoryTests { 3, 6, 1 } }); - private static readonly DenseMatrix Expected4x4Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected4x4Matrix = new( new uint[4, 4] { { 0, 8, 2, 10 }, @@ -34,7 +34,7 @@ public class OrderedDitherFactoryTests { 15, 7, 13, 5 } }); - private static readonly DenseMatrix Expected8x8Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected8x8Matrix = new( new uint[8, 8] { { 0, 32, 8, 40, 2, 34, 10, 42 }, diff --git a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs index 2cf1c744d..d90ccee41 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs @@ -11,8 +11,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { @@ -30,8 +30,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { @@ -49,8 +49,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { @@ -68,8 +68,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { @@ -87,8 +87,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9BounceBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(1, 1, 9, 9); + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { @@ -108,8 +108,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9MirrorBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(1, 1, 9, 9); + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { @@ -129,8 +129,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image9x9WrapBorder() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(1, 1, 9, 9); + Size kernelSize = new(5, 5); + Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { @@ -150,8 +150,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7RepeatBorderTile() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { @@ -169,8 +169,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7BounceBorderTile() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { @@ -188,8 +188,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7MirrorBorderTile() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { @@ -207,8 +207,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel5Image7x7WrapBorderTile() { - Size kernelSize = new Size(5, 5); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(5, 5); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { @@ -226,8 +226,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorder() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { @@ -245,8 +245,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7BounceBorder() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { @@ -264,8 +264,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7MirrorBorder() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { @@ -283,8 +283,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorder() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(0, 0, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { @@ -302,8 +302,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7RepeatBorderTile() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = { @@ -321,8 +321,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7BounceBorderTile() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = { @@ -340,8 +340,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7MirrorBorderTile() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = { @@ -359,8 +359,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x7WrapBorderTile() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(2, 2, 7, 7); + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = { @@ -378,8 +378,8 @@ public class KernelSamplingMapTest [Fact] public void KernalSamplingMap_Kernel3Image7x5WrapBorderTile() { - Size kernelSize = new Size(3, 3); - Rectangle bounds = new Rectangle(2, 2, 7, 5); + Size kernelSize = new(3, 3); + Rectangle bounds = new(2, 2, 7, 5); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] xExpected = { @@ -405,7 +405,7 @@ public class KernelSamplingMapTest private void AssertOffsets(Size kernelSize, Rectangle bounds, BorderWrappingMode xBorderMode, BorderWrappingMode yBorderMode, int[] xExpected, int[] yExpected) { // Arrange - KernelSamplingMap map = new KernelSamplingMap(Configuration.Default.MemoryAllocator); + KernelSamplingMap map = new(Configuration.Default.MemoryAllocator); // Act map.BuildSamplingOffsetMap(kernelSize.Height, kernelSize.Width, bounds, xBorderMode, yBorderMode); diff --git a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs index 800cb06ac..6c6fa6b2b 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/Processors/LaplacianKernelFactoryTests.cs @@ -7,9 +7,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Convolution.Processors; public class LaplacianKernelFactoryTests { - private static readonly ApproximateFloatComparer ApproximateComparer = new ApproximateFloatComparer(0.0001F); + private static readonly ApproximateFloatComparer ApproximateComparer = new(0.0001F); - private static readonly DenseMatrix Expected3x3Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected3x3Matrix = new( new float[,] { { -1, -1, -1 }, @@ -17,7 +17,7 @@ public class LaplacianKernelFactoryTests { -1, -1, -1 } }); - private static readonly DenseMatrix Expected5x5Matrix = new DenseMatrix( + private static readonly DenseMatrix Expected5x5Matrix = new( new float[,] { { -1, -1, -1, -1, -1 }, diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 8b2411bf2..703a64333 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -69,7 +69,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle) { - this.Applied.Add(new() + this.Applied.Add(new AppliedOperation { Rectangle = rectangle, NonGenericProcessor = processor @@ -79,7 +79,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public IImageProcessingContext ApplyProcessor(IImageProcessor processor) { - this.Applied.Add(new() + this.Applied.Add(new AppliedOperation { NonGenericProcessor = processor }); diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs index 9cfc3a3f0..135212400 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs @@ -35,24 +35,24 @@ public class BrightnessTest : BaseImageOperationsExtensionTest rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new(0, 0, 0), rgbImage[0, 0]); + Assert.Equal(new Rgb24(0, 0, 0), rgbImage[0, 0]); - rgbImage = new(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); + rgbImage = new Image(Configuration.Default, 100, 100, new Rgb24(10, 10, 10)); rgbImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new(20, 20, 20), rgbImage[0, 0]); + Assert.Equal(new Rgb24(20, 20, 20), rgbImage[0, 0]); Image halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-1)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new(-1), halfSingleImage[0, 0]); + Assert.Equal(new HalfSingle(-1), halfSingleImage[0, 0]); - halfSingleImage = new(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); + halfSingleImage = new Image(Configuration.Default, 100, 100, new HalfSingle(-0.5f)); halfSingleImage.Mutate(x => x.ApplyProcessor(new BrightnessProcessor(2))); - Assert.Equal(new(0), halfSingleImage[0, 0]); + Assert.Equal(new HalfSingle(0), halfSingleImage[0, 0]); } } diff --git a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs index d53dc74b9..09fbcdc70 100644 --- a/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageOperationTests.cs @@ -22,13 +22,13 @@ public class ImageOperationTests : IDisposable public ImageOperationTests() { - this.provider = new(); + this.provider = new FakeImageOperationsProvider(); Mock processorMock = new(); this.processorDefinition = processorMock.Object; - this.image = new( - new() + this.image = new Image( + new Configuration { ImageOperationsProvider = this.provider }, diff --git a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs index 06eb90005..e39d8075b 100644 --- a/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs +++ b/tests/ImageSharp.Tests/Processing/ImageProcessingContextTests.cs @@ -27,10 +27,10 @@ public class ImageProcessingContextTests : IDisposable public ImageProcessingContextTests() { - this.processorDefinition = new(); - this.cloningProcessorDefinition = new(); - this.regularProcessorImpl = new(); - this.cloningProcessorImpl = new(); + this.processorDefinition = new Mock(); + this.cloningProcessorDefinition = new Mock(); + this.regularProcessorImpl = new Mock>(); + this.cloningProcessorImpl = new Mock>(); } // bool throwException, bool useBounds diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index e37cd5db1..5c5fd20e4 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -39,7 +39,7 @@ public class HistogramEqualizationTests for (int x = 0; x < 8; x++) { byte luminance = pixels[(y * 8) + x]; - image[x, y] = new(luminance, luminance, luminance); + image[x, y] = new Rgba32(luminance, luminance, luminance); } } @@ -56,7 +56,7 @@ public class HistogramEqualizationTests }; // Act - image.Mutate(x => x.HistogramEqualization(new() + image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions { LuminanceLevels = luminanceLevels, Method = HistogramEqualizationMethod.Global diff --git a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs index 50c177cc0..2b609a9b2 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/MagickCompareTests.cs @@ -49,7 +49,7 @@ public class MagickCompareTests ?? throw new InvalidOperationException("CompareToMagick() works only with file providers!"); TestFile testFile = TestFile.Create(path); - return new(testFile.FullPath, FileMode.Open); + return new FileStream(testFile.FullPath, FileMode.Open); } private static Image ConvertImageFromMagick(MagickImage magickImage) diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index be9263334..c7881597a 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -45,7 +45,7 @@ public class GlowTest : BaseImageOperationsExtensionTest [Fact] public void Glow_Rect_GlowProcessorWithDefaultValues() { - Rectangle rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Glow(rect); GlowProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 14dcc7438..e222c566f 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -48,7 +48,7 @@ public class VignetteTest : BaseImageOperationsExtensionTest [Fact] public void Vignette_Rect_VignetteProcessorWithDefaultValues() { - Rectangle rect = new Rectangle(12, 123, 43, 65); + Rectangle rect = new(12, 123, 43, 65); this.operations.Vignette(rect); VignetteProcessor p = this.Verify(rect); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 18f62c171..64dd7a866 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -17,7 +17,7 @@ public class BinaryDitherTests TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; - public static readonly TheoryData OrderedDitherers = new TheoryData + public static readonly TheoryData OrderedDitherers = new() { { "Bayer8x8", KnownDitherings.Bayer8x8 }, { "Bayer4x4", KnownDitherings.Bayer4x4 }, @@ -25,7 +25,7 @@ public class BinaryDitherTests { "Bayer2x2", KnownDitherings.Bayer2x2 } }; - public static readonly TheoryData ErrorDiffusers = new TheoryData + public static readonly TheoryData ErrorDiffusers = new() { { "Atkinson", KnownDitherings.Atkinson }, { "Burks", KnownDitherings.Burks }, @@ -102,7 +102,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultDitherer, bounds)); image.DebugSave(provider); @@ -119,7 +119,7 @@ public class BinaryDitherTests using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.BinaryDither(DefaultErrorDiffuser, bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index a94c75975..9c63d0f7c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization; public class BinaryThresholdTest { public static readonly TheoryData BinaryThresholdValues - = new TheoryData - { + = new() + { .25F, .75F }; @@ -46,7 +46,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, bounds)); image.DebugSave(provider, value); @@ -76,7 +76,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.Saturation, bounds)); image.DebugSave(provider, value); @@ -114,7 +114,7 @@ public class BinaryThresholdTest using (Image source = provider.GetImage()) using (Image image = source.Clone()) { - Rectangle bounds = new Rectangle(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); + Rectangle bounds = new(image.Width / 8, image.Height / 8, 6 * image.Width / 8, 6 * image.Width / 8); image.Mutate(x => x.BinaryThreshold(value, BinaryThresholdMode.MaxChroma, bounds)); image.DebugSave(provider, value); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs index 13ddf85c1..455aa48ae 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs @@ -12,7 +12,7 @@ public abstract class Basic1ParameterConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); - public static readonly TheoryData Values = new TheoryData { 3, 5 }; + public static readonly TheoryData Values = new() { 3, 5 }; public static readonly string[] InputImages = { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index 9c1ffbbef..f045c981e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -108,9 +108,9 @@ public class BokehBlurTest public static readonly TheoryData BokehBlurValues = new() { - new() { Radius = 8, Components = 1, Gamma = 1 }, - new() { Radius = 16, Components = 1, Gamma = 3 }, - new() { Radius = 16, Components = 2, Gamma = 3 } + new BokehBlurInfo { Radius = 8, Components = 1, Gamma = 1 }, + new BokehBlurInfo { Radius = 16, Components = 1, Gamma = 3 }, + new BokehBlurInfo { Radius = 16, Components = 2, Gamma = 3 } }; public static readonly string[] TestFiles = diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs index 0cb56b732..468965f1e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionTests.cs @@ -12,7 +12,7 @@ public class ConvolutionTests { private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); - public static readonly TheoryData> Values = new TheoryData> + public static readonly TheoryData> Values = new() { // Sharpening kernel. new float[,] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index 2da74377a..04344e130 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -22,16 +22,16 @@ public class DetectEdgesTest public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; public static readonly TheoryData DetectEdgesFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Laplacian3x3, nameof(KnownEdgeDetectorKernels.Laplacian3x3) }, { KnownEdgeDetectorKernels.Laplacian5x5, nameof(KnownEdgeDetectorKernels.Laplacian5x5) }, { KnownEdgeDetectorKernels.LaplacianOfGaussian, nameof(KnownEdgeDetectorKernels.LaplacianOfGaussian) }, }; public static readonly TheoryData DetectEdges2DFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kayyali, nameof(KnownEdgeDetectorKernels.Kayyali) }, { KnownEdgeDetectorKernels.Prewitt, nameof(KnownEdgeDetectorKernels.Prewitt) }, { KnownEdgeDetectorKernels.RobertsCross, nameof(KnownEdgeDetectorKernels.RobertsCross) }, @@ -40,8 +40,8 @@ public class DetectEdgesTest }; public static readonly TheoryData DetectEdgesCompassFilters - = new TheoryData - { + = new() + { { KnownEdgeDetectorKernels.Kirsch, nameof(KnownEdgeDetectorKernels.Kirsch) }, { KnownEdgeDetectorKernels.Robinson, nameof(KnownEdgeDetectorKernels.Robinson) }, }; @@ -55,7 +55,7 @@ public class DetectEdgesTest ctx => { Size size = ctx.GetCurrentSize(); - Rectangle bounds = new Rectangle(10, 10, size.Width / 2, size.Height / 2); + Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2); ctx.DetectEdges(bounds); }, comparer: OpaqueComparer, @@ -158,7 +158,7 @@ public class DetectEdgesTest { using (Image image = provider.GetImage()) { - Rectangle bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); + Rectangle bounds = new(10, 10, image.Width / 2, image.Height / 2); image.Mutate(x => x.DetectEdges(bounds)); image.DebugSave(provider); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 9e47f54cc..3cc965334 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -17,7 +17,7 @@ public class DitherTests public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; public static readonly TheoryData ErrorDiffusers - = new TheoryData + = new() { { KnownDitherings.Atkinson, nameof(KnownDitherings.Atkinson) }, { KnownDitherings.Burks, nameof(KnownDitherings.Burks) }, @@ -31,7 +31,7 @@ public class DitherTests }; public static readonly TheoryData OrderedDitherers - = new TheoryData + = new() { { KnownDitherings.Bayer2x2, nameof(KnownDitherings.Bayer2x2) }, { KnownDitherings.Bayer4x4, nameof(KnownDitherings.Bayer4x4) }, @@ -41,7 +41,7 @@ public class DitherTests }; public static readonly TheoryData DefaultInstanceDitherers - = new TheoryData + = new() { default(ErrorDither), default(OrderedDither) @@ -186,7 +186,7 @@ public class DitherTests { void Command() { - using Image image = new Image(10, 10); + using Image image = new(10, 10); image.Mutate(x => x.Dither(dither)); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index 06d3850a4..f3d8fd63a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -49,7 +49,7 @@ public class OilPaintTest [Fact] public void Issue2518_PixelComponentOutsideOfRange_ThrowsImageProcessingException() { - using Image image = new(10, 10, new(1, 1, 100)); + using Image image = new(10, 10, new RgbaVector(1, 1, 100)); Assert.Throws(() => image.Mutate(ctx => ctx.OilPaint())); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs index 963394e7d..b88ab37fe 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelShaderTest.cs @@ -24,7 +24,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new(avg); + span[i] = new Vector4(avg); } }), appendPixelTypeToFileName: false); @@ -43,7 +43,7 @@ public class PixelShaderTest { Vector4 v4 = span[i]; float avg = (v4.X + v4.Y + v4.Z) / 3f; - span[i] = new(avg); + span[i] = new Vector4(avg); } }, rect)); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs index 29b952403..fff7ba018 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/PixelateTest.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; [GroupOutput("Effects")] public class PixelateTest { - public static readonly TheoryData PixelateValues = new TheoryData { 4, 8 }; + public static readonly TheoryData PixelateValues = new() { 4, 8 }; [Theory] [WithFile(TestImages.Png.Ducky, nameof(PixelateValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs index 7da96d13d..4663aa868 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/BrightnessTest.cs @@ -14,7 +14,7 @@ public class BrightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData BrightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs index 0727a5b97..1f2afb97f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ColorBlindnessTest.cs @@ -14,7 +14,7 @@ public class ColorBlindnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.03F); public static readonly TheoryData ColorBlindnessFilters - = new TheoryData + = new() { ColorBlindnessMode.Achromatomaly, ColorBlindnessMode.Achromatopsia, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs index 5e2a7f55d..6ff10bbd8 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/ContrastTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class ContrastTest { public static readonly TheoryData ContrastValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs index 50a262152..15ef7f7c3 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/GrayscaleTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class GrayscaleTest { public static readonly TheoryData GrayscaleModeTypes - = new TheoryData + = new() { GrayscaleMode.Bt601, GrayscaleMode.Bt709 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs index 65ac4245d..1838cc33d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/HueTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class HueTest { public static readonly TheoryData HueValues - = new TheoryData + = new() { 180, -180 diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs index 39e69aa4a..49e2c8546 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/LightnessTest.cs @@ -14,7 +14,7 @@ public class LightnessTest private readonly ImageComparer imageComparer = ImageComparer.Tolerant(0.007F); public static readonly TheoryData LightnessValues - = new TheoryData + = new() { .5F, 1.5F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs index 10ddf3a47..8a1bbfe3f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/OpacityTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class OpacityTest { public static readonly TheoryData AlphaValues - = new TheoryData + = new() { 20 / 100F, 80 / 100F diff --git a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs index 8632d4625..642c79819 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Filters/SaturateTest.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Filters; public class SaturateTest { public static readonly TheoryData SaturationValues - = new TheoryData + = new() { .5F, 1.5F, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs index cabfe3059..c9f3daf0f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/OctreeQuantizerTests.cs @@ -19,18 +19,18 @@ public class OctreeQuantizerTests Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new() { Dither = null }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = null }; + quantizer = new OctreeQuantizer(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; + quantizer = new OctreeQuantizer(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new OctreeQuantizer(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -46,14 +46,14 @@ public class OctreeQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(new() { Dither = null }); + quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(new() { Dither = KnownDitherings.Atkinson }); + quantizer = new OctreeQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index ed9254605..d58a5280d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -21,18 +21,18 @@ public class PaletteQuantizerTests Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new() { Dither = null }; - quantizer = new(Palette, expected); + expected = new QuantizerOptions { Dither = null }; + quantizer = new PaletteQuantizer(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson }; - quantizer = new(Palette, expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; + quantizer = new PaletteQuantizer(Palette, expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new(Palette, expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new PaletteQuantizer(Palette, expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -48,14 +48,14 @@ public class PaletteQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(Palette, new() { Dither = null }); + quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(Palette, new() { Dither = KnownDitherings.Atkinson }); + quantizer = new PaletteQuantizer(Palette, new QuantizerOptions { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs index 6e43fe252..2d270b2a4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/WuQuantizerTests.cs @@ -19,18 +19,18 @@ public class WuQuantizerTests Assert.Equal(expected.MaxColors, quantizer.Options.MaxColors); Assert.Equal(QuantizerConstants.DefaultDither, quantizer.Options.Dither); - expected = new() { Dither = null }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = null }; + quantizer = new WuQuantizer(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Null(quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson }; + quantizer = new WuQuantizer(expected); Assert.Equal(QuantizerConstants.MaxColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); - expected = new() { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; - quantizer = new(expected); + expected = new QuantizerOptions { Dither = KnownDitherings.Atkinson, MaxColors = 0 }; + quantizer = new WuQuantizer(expected); Assert.Equal(QuantizerConstants.MinColors, quantizer.Options.MaxColors); Assert.Equal(KnownDitherings.Atkinson, quantizer.Options.Dither); } @@ -46,14 +46,14 @@ public class WuQuantizerTests Assert.Equal(QuantizerConstants.DefaultDither, frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(new() { Dither = null }); + quantizer = new WuQuantizer(new QuantizerOptions { Dither = null }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Null(frameQuantizer.Options.Dither); frameQuantizer.Dispose(); - quantizer = new(new() { Dither = KnownDitherings.Atkinson }); + quantizer = new WuQuantizer(new QuantizerOptions { Dither = KnownDitherings.Atkinson }); frameQuantizer = quantizer.CreatePixelSpecificQuantizer(Configuration.Default); Assert.NotNull(frameQuantizer); Assert.Equal(KnownDitherings.Atkinson, frameQuantizer.Options.Dither); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index 34a8b1e58..a7855e23a 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -213,7 +213,7 @@ public class AffineTransformTests public void Issue1911() { using Image image = new(100, 100); - image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix3x2.Identity, new(99, 100), KnownResamplers.Lanczos2)); + image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix3x2.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -227,7 +227,7 @@ public class AffineTransformTests using Image image = provider.GetImage(); AffineTransformBuilder builder = - new AffineTransformBuilder().AppendRotationDegrees(270, new(3.5f, 3.5f)); + new AffineTransformBuilder().AppendRotationDegrees(270, new Vector2(3.5f, 3.5f)); image.Mutate(x => x.BackgroundColor(Color.Red)); image.Mutate(x => x = x.Transform(builder)); @@ -246,7 +246,7 @@ public class AffineTransformTests Matrix3x2 m = Matrix3x2.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -260,9 +260,9 @@ public class AffineTransformTests { using Image image = provider.GetImage(); - Matrix3x2 m = Matrix3x2.CreateRotation(radians, new(50, 50)); + Matrix3x2 m = Matrix3x2.CreateRotation(radians, new Vector2(50, 50)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 21e218d4c..984e3bc75 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -44,7 +44,7 @@ public class AutoOrientTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - image.Metadata.ExifProfile = new(); + image.Metadata.ExifProfile = new ExifProfile(); image.Metadata.ExifProfile.SetValue(ExifTag.Orientation, orientation); image.Mutate(x => x.AutoOrient()); @@ -79,7 +79,7 @@ public class AutoOrientTests using Image image = provider.GetImage(); using Image reference = image.Clone(); - image.Metadata.ExifProfile = new(bytes); + image.Metadata.ExifProfile = new ExifProfile(bytes); image.Mutate(x => x.AutoOrient()); image.DebugSave(provider, $"{dataType}-{orientationCode}", appendPixelTypeToFileName: false); ImageComparer.Exact.VerifySimilarity(image, reference); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs index 619610cc2..f4a0aeb0c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest public void Crop(TestImageProvider provider, int x, int y, int w, int h) where TPixel : unmanaged, IPixel { - Rectangle rect = new Rectangle(x, y, w, h); + Rectangle rect = new(x, y, w, h); FormattableString info = $"X{x}Y{y}.W{w}H{h}"; provider.RunValidatingProcessorTest( ctx => ctx.Crop(rect), diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index d587bc7e0..3e986f0cb 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [GroupOutput("Transforms")] public class EntropyCropTest { - public static readonly TheoryData EntropyCropValues = new TheoryData { .25F, .75F }; + public static readonly TheoryData EntropyCropValues = new() { .25F, .75F }; public static readonly string[] InputImages = { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs index 717582274..5c545147e 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs @@ -12,8 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class FlipTests { public static readonly TheoryData FlipValues = - new TheoryData - { + new() + { FlipMode.None, FlipMode.Vertical, FlipMode.Horizontal, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs index 96e7702d8..e3e7118c0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeHelperTests.cs @@ -39,14 +39,14 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.Min, Size = target }); Assert.Equal(sourceSize, size); - Assert.Equal(new(0, 0, sourceSize.Width, sourceSize.Height), rectangle); + Assert.Equal(new Rectangle(0, 0, sourceSize.Width, sourceSize.Height), rectangle); } [Fact] @@ -60,7 +60,7 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.Max, Size = target @@ -81,7 +81,7 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.Crop, Size = target @@ -102,7 +102,7 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.BoxPad, Size = target @@ -123,7 +123,7 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.Pad, Size = target @@ -144,7 +144,7 @@ public class ResizeHelperTests (Size size, Rectangle rectangle) = ResizeHelper.CalculateTargetLocationAndBounds( sourceSize, - new() + new ResizeOptions { Mode = ResizeMode.Stretch, Size = target diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 2c897588e..1a4610bf6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -80,10 +80,10 @@ public partial class ResizeKernelMapTests float[] floatVals = values.Select(v => (float)v).ToArray(); - result.Add(new(left, floatVals)); + result.Add(new ReferenceKernel(left, floatVals)); } - return new(result.ToArray()); + return new ReferenceKernelMap(result.ToArray()); } } @@ -103,7 +103,7 @@ public partial class ResizeKernelMapTests public static implicit operator ReferenceKernel(ResizeKernel orig) { - return new(orig.StartIndex, orig.Values.ToArray()); + return new ReferenceKernel(orig.StartIndex, orig.Values.ToArray()); } } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index f1309f331..d6990782b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -22,8 +22,8 @@ public partial class ResizeKernelMapTests /// resamplerName, srcSize, destSize /// public static readonly TheoryData KernelMapData - = new TheoryData - { + = new() + { { KnownResamplers.Bicubic, 15, 10 }, { KnownResamplers.Bicubic, 10, 15 }, { KnownResamplers.Bicubic, 20, 20 }, @@ -124,7 +124,7 @@ public partial class ResizeKernelMapTests this.Output.WriteLine($"Expected KernelMap:\n{PrintKernelMap(referenceMap)}\n"); this.Output.WriteLine($"Actual KernelMap:\n{PrintKernelMap(kernelMap)}\n"); #endif - ApproximateFloatComparer comparer = new ApproximateFloatComparer(1e-6f); + ApproximateFloatComparer comparer = new(1e-6f); for (int i = 0; i < kernelMap.DestinationLength; i++) { @@ -163,7 +163,7 @@ public partial class ResizeKernelMapTests Func getDestinationSize, Func getKernel) { - StringBuilder bld = new StringBuilder(); + StringBuilder bld = new(); if (kernelMap is ResizeKernelMap actualMap) { @@ -193,7 +193,7 @@ public partial class ResizeKernelMapTests private static TheoryData GenerateImageResizeData() { - TheoryData result = new TheoryData(); + TheoryData result = new(); string[] resamplerNames = TestUtils.GetAllResamplerNames(false); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index b4cf08975..859634e37 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -346,7 +346,7 @@ public class ResizeTests "invalid dimensional input for Resize_WorksWithAllResamplers!"); } - newSize = new(specificDestWidth.Value, specificDestHeight.Value); + newSize = new SizeF(specificDestWidth.Value, specificDestHeight.Value); destSizeInfo = $"{newSize.Width}x{newSize.Height}"; } @@ -439,7 +439,7 @@ public class ResizeTests using Image image = provider.GetImage(); ResizeOptions options = new() { - Size = new(image.Width + 200, image.Height + 200), + Size = new Size(image.Width + 200, image.Height + 200), Mode = ResizeMode.BoxPad, PadColor = Color.HotPink }; @@ -456,7 +456,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() { Size = new(image.Width, image.Height / 2) }; + ResizeOptions options = new() { Size = new Size(image.Width, image.Height / 2) }; image.Mutate(x => x.Resize(options)); @@ -470,7 +470,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() { Size = new(image.Width / 2, image.Height) }; + ResizeOptions options = new() { Size = new Size(image.Width / 2, image.Height) }; image.Mutate(x => x.Resize(options)); @@ -486,7 +486,7 @@ public class ResizeTests using Image image = provider.GetImage(); ResizeOptions options = new() { - Size = new(480, 600), + Size = new Size(480, 600), Mode = ResizeMode.Crop }; @@ -502,7 +502,7 @@ public class ResizeTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - ResizeOptions options = new() { Size = new(300, 300), Mode = ResizeMode.Max }; + ResizeOptions options = new() { Size = new Size(300, 300), Mode = ResizeMode.Max }; image.Mutate(x => x.Resize(options)); @@ -518,7 +518,7 @@ public class ResizeTests using Image image = provider.GetImage(); ResizeOptions options = new() { - Size = new((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), + Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)), Mode = ResizeMode.Min }; @@ -536,7 +536,7 @@ public class ResizeTests using Image image = provider.GetImage(); ResizeOptions options = new() { - Size = new(image.Width + 200, image.Height), + Size = new Size(image.Width + 200, image.Height), Mode = ResizeMode.Pad, PadColor = Color.Lavender }; @@ -555,7 +555,7 @@ public class ResizeTests using Image image = provider.GetImage(); ResizeOptions options = new() { - Size = new(image.Width / 2, image.Height), + Size = new Size(image.Width / 2, image.Height), Mode = ResizeMode.Stretch }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index 55d26974a..cc3ea0322 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -12,8 +12,8 @@ public class RotateFlipTests public static readonly string[] FlipFiles = { TestImages.Bmp.F }; public static readonly TheoryData RotateFlipValues - = new TheoryData - { + = new() + { { RotateMode.None, FlipMode.Vertical }, { RotateMode.None, FlipMode.Horizontal }, { RotateMode.Rotate90, FlipMode.None }, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index b150da1d8..7c3a97a44 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -11,14 +11,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class RotateTests { public static readonly TheoryData RotateAngles - = new TheoryData - { + = new() + { 50, -50, 170, -170 }; public static readonly TheoryData RotateEnumValues - = new TheoryData - { + = new() + { RotateMode.None, RotateMode.Rotate90, RotateMode.Rotate180, diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs index 1e217ae24..30dec4685 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs @@ -33,8 +33,8 @@ public class SkewTests nameof(KnownResamplers.Welch), }; - public static readonly TheoryData SkewValues = new TheoryData - { + public static readonly TheoryData SkewValues = new() + { { 20, 10 }, { -20, -10 } }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs index b831b0a6c..dee698db0 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SwizzleTests.cs @@ -16,7 +16,7 @@ public class SwizzleTests { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } @@ -34,7 +34,7 @@ public class SwizzleTests using Image expectedImage = provider.GetImage(); using Image image = provider.GetImage(); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); image.DebugSave( provider, @@ -42,7 +42,7 @@ public class SwizzleTests appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); - image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new(image.Width, image.Height)))); + image.Mutate(ctx => ctx.Swizzle(new InvertXAndYSwizzler(new Size(image.Width, image.Height)))); image.DebugSave( provider, diff --git a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs index 4b1ca92dd..232571d4d 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/AffineTransformBuilderTests.cs @@ -8,8 +8,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; public class AffineTransformBuilderTests : TransformBuilderTestBase { - protected override AffineTransformBuilder CreateBuilder() - => new AffineTransformBuilder(); + protected override AffineTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(AffineTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs index 6e35fca29..c56df3152 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs @@ -17,7 +17,7 @@ public class CropTest : BaseImageOperationsExtensionTest this.operations.Crop(width, height); CropProcessor processor = this.Verify(); - Assert.Equal(new(0, 0, width, height), processor.CropRectangle); + Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle); } [Theory] diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs index 7d0c0dc58..a0380033f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformBuilderTests.cs @@ -9,8 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms; [Trait("Category", "Processors")] public class ProjectiveTransformBuilderTests : TransformBuilderTestBase { - protected override ProjectiveTransformBuilder CreateBuilder() - => new ProjectiveTransformBuilder(); + protected override ProjectiveTransformBuilder CreateBuilder() => new(); protected override void AppendRotationDegrees(ProjectiveTransformBuilder builder, float degrees) => builder.AppendRotationDegrees(degrees); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs index 0eb32dff7..6ba04f79a 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ProjectiveTransformTests.cs @@ -57,10 +57,10 @@ public class ProjectiveTransformTests public static readonly TheoryData QuadDistortionData = new() { - { new(0, 0), new(150, 0), new(150, 150), new(0, 150) }, // source == destination - { new(25, 50), new(210, 25), new(140, 210), new(15, 125) }, // Distortion - { new(-50, -50), new(200, -50), new(200, 200), new(-50, 200) }, // Scaling - { new(150, 0), new(150, 150), new(0, 150), new(0, 0) }, // Rotation + { new PointF(0, 0), new PointF(150, 0), new PointF(150, 150), new PointF(0, 150) }, // source == destination + { new PointF(25, 50), new PointF(210, 25), new PointF(140, 210), new PointF(15, 125) }, // Distortion + { new PointF(-50, -50), new PointF(200, -50), new PointF(200, 200), new PointF(-50, 200) }, // Scaling + { new PointF(150, 0), new PointF(150, 150), new PointF(0, 150), new PointF(0, 0) }, // Rotation }; public ProjectiveTransformTests(ITestOutputHelper output) => this.Output = output; @@ -175,7 +175,7 @@ public class ProjectiveTransformTests public void Issue1911() { using Image image = new(100, 100); - image.Mutate(x => x = x.Transform(new(0, 0, 99, 100), Matrix4x4.Identity, new(99, 100), KnownResamplers.Lanczos2)); + image.Mutate(x => x = x.Transform(new Rectangle(0, 0, 99, 100), Matrix4x4.Identity, new Size(99, 100), KnownResamplers.Lanczos2)); Assert.Equal(99, image.Width); Assert.Equal(100, image.Height); @@ -190,7 +190,7 @@ public class ProjectiveTransformTests Matrix4x4 m = Matrix4x4.Identity; Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider); image.CompareToReferenceOutput(ValidatorComparer, provider); } @@ -204,9 +204,9 @@ public class ProjectiveTransformTests { using Image image = provider.GetImage(); - Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new(50, 50, 1F)); + Matrix4x4 m = Matrix4x4.CreateRotationX(radians, new Vector3(50, 50, 1F)) * Matrix4x4.CreateRotationY(radians, new Vector3(50, 50, 1F)); Rectangle r = new(25, 25, 50, 50); - image.Mutate(x => x.Transform(r, m, new(100, 100), KnownResamplers.Bicubic)); + image.Mutate(x => x.Transform(r, m, new Size(100, 100), KnownResamplers.Bicubic)); image.DebugSave(provider, testOutputDetails: radians); image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } @@ -246,7 +246,7 @@ public class ProjectiveTransformTests if (property is null) { - throw new($"No resampler named {name}"); + throw new Exception($"No resampler named {name}"); } return (IResampler)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index d38658bbd..1d445b980 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -66,7 +66,7 @@ public class ResizeTests : BaseImageOperationsExtensionTest ResizeOptions resizeOptions = new() { - Size = new(width, height), + Size = new Size(width, height), Sampler = sampler, Compand = compand, Mode = mode diff --git a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs index a4f4f152b..8475ce5ab 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/SwizzleTests.cs @@ -13,7 +13,7 @@ public class SwizzleTests : BaseImageOperationsExtensionTest { public InvertXAndYSwizzler(Size sourceSize) { - this.DestinationSize = new(sourceSize.Height, sourceSize.Width); + this.DestinationSize = new Size(sourceSize.Height, sourceSize.Width); } public Size DestinationSize { get; } @@ -27,7 +27,7 @@ public class SwizzleTests : BaseImageOperationsExtensionTest int width = 5; int height = 10; - this.operations.Swizzle(new InvertXAndYSwizzler(new(width, height))); + this.operations.Swizzle(new InvertXAndYSwizzler(new Size(width, height))); SwizzleProcessor processor = this.Verify>(); Assert.Equal(processor.Swizzler.DestinationSize.Width, height); diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index cdc49e2a3..5caf071ac 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -17,9 +17,9 @@ public abstract class TransformBuilderTestBase { // scale, translate, source, expectedDest { Vector2.One, Vector2.Zero, Vector2.Zero, Vector2.Zero }, - { Vector2.One, Vector2.Zero, new(10, 20), new(10, 20) }, - { Vector2.One, new(3, 1), new(10, 20), new(13, 21) }, - { new(2, 0.5f), new(3, 1), new(10, 20), new(23, 11) }, + { Vector2.One, Vector2.Zero, new Vector2(10, 20), new Vector2(10, 20) }, + { Vector2.One, new Vector2(3, 1), new Vector2(10, 20), new Vector2(13, 21) }, + { new Vector2(2, 0.5f), new Vector2(3, 1), new Vector2(10, 20), new Vector2(23, 11) }, }; [Theory] @@ -32,10 +32,10 @@ public abstract class TransformBuilderTestBase Size size = new(123, 321); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new(scale)); + this.AppendScale(builder, new SizeF(scale)); this.AppendTranslation(builder, translate); - Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); Assert.True(Comparer.Equals(expectedDest, actualDest)); } @@ -44,8 +44,8 @@ public abstract class TransformBuilderTestBase { // translate, scale, source, expectedDest { Vector2.Zero, Vector2.One, Vector2.Zero, Vector2.Zero }, - { Vector2.Zero, Vector2.One, new(10, 20), new(10, 20) }, - { new(3, 1), new(2, 0.5f), new(10, 20), new(26, 10.5f) }, + { Vector2.Zero, Vector2.One, new Vector2(10, 20), new Vector2(10, 20) }, + { new Vector2(3, 1), new Vector2(2, 0.5f), new Vector2(10, 20), new Vector2(26, 10.5f) }, }; [Theory] @@ -59,9 +59,9 @@ public abstract class TransformBuilderTestBase TBuilder builder = this.CreateBuilder(); this.AppendTranslation(builder, translate); - this.AppendScale(builder, new(scale)); + this.AppendScale(builder, new SizeF(scale)); - Vector2 actualDest = this.Execute(builder, new(Point.Empty, size), source); + Vector2 actualDest = this.Execute(builder, new Rectangle(Point.Empty, size), source); Assert.Equal(expectedDest, actualDest, Comparer); } @@ -73,7 +73,7 @@ public abstract class TransformBuilderTestBase Rectangle rectangle = new(locationX, locationY, 10, 10); TBuilder builder = this.CreateBuilder(); - this.AppendScale(builder, new(2, 2)); + this.AppendScale(builder, new SizeF(2, 2)); Vector2 actual = this.Execute(builder, rectangle, Vector2.One); Vector2 expected = new Vector2(-locationX + 1, -locationY + 1) * 2; @@ -102,7 +102,7 @@ public abstract class TransformBuilderTestBase Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); + Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -130,7 +130,7 @@ public abstract class TransformBuilderTestBase Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); + Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -156,7 +156,7 @@ public abstract class TransformBuilderTestBase Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); + Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -184,7 +184,7 @@ public abstract class TransformBuilderTestBase Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); - Vector2 actual = this.Execute(builder, new(Point.Empty, size), position); + Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); } @@ -201,21 +201,21 @@ public abstract class TransformBuilderTestBase // Forwards this.AppendRotationRadians(b1, pi); this.AppendSkewRadians(b1, pi, pi); - this.AppendScale(b1, new(2, 0.5f)); - this.AppendRotationRadians(b1, pi / 2, new(-0.5f, -0.1f)); - this.AppendSkewRadians(b1, pi, pi / 2, new(-0.5f, -0.1f)); - this.AppendTranslation(b1, new(123, 321)); + this.AppendScale(b1, new SizeF(2, 0.5f)); + this.AppendRotationRadians(b1, pi / 2, new Vector2(-0.5f, -0.1f)); + this.AppendSkewRadians(b1, pi, pi / 2, new Vector2(-0.5f, -0.1f)); + this.AppendTranslation(b1, new PointF(123, 321)); // Backwards - this.PrependTranslation(b2, new(123, 321)); - this.PrependSkewRadians(b2, pi, pi / 2, new(-0.5f, -0.1f)); - this.PrependRotationRadians(b2, pi / 2, new(-0.5f, -0.1f)); - this.PrependScale(b2, new(2, 0.5f)); + this.PrependTranslation(b2, new PointF(123, 321)); + this.PrependSkewRadians(b2, pi, pi / 2, new Vector2(-0.5f, -0.1f)); + this.PrependRotationRadians(b2, pi / 2, new Vector2(-0.5f, -0.1f)); + this.PrependScale(b2, new SizeF(2, 0.5f)); this.PrependSkewRadians(b2, pi, pi); this.PrependRotationRadians(b2, pi); - Vector2 p1 = this.Execute(b1, rectangle, new(32, 65)); - Vector2 p2 = this.Execute(b2, rectangle, new(32, 65)); + Vector2 p1 = this.Execute(b1, rectangle, new Vector2(32, 65)); + Vector2 p2 = this.Execute(b2, rectangle, new Vector2(32, 65)); Assert.Equal(p1, p2, Comparer); } @@ -232,7 +232,7 @@ public abstract class TransformBuilderTestBase () => { TBuilder builder = this.CreateBuilder(); - this.Execute(builder, new(Point.Empty, size), Vector2.Zero); + this.Execute(builder, new Rectangle(Point.Empty, size), Vector2.Zero); }); } @@ -244,7 +244,7 @@ public abstract class TransformBuilderTestBase { TBuilder builder = this.CreateBuilder(); this.AppendSkewDegrees(builder, 45, 45); - this.Execute(builder, new(0, 0, 150, 150), Vector2.Zero); + this.Execute(builder, new Rectangle(0, 0, 150, 150), Vector2.Zero); }); } diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs index fa3fcec41..209dd361e 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs @@ -28,7 +28,7 @@ public class LoadResizeSaveProfilingBenchmarks : MeasureFixture byte[] imageBytes = TestFile.Create(imagePath).Bytes; - using MemoryStream ms = new MemoryStream(); + using MemoryStream ms = new(); this.Measure( 30, () => diff --git a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs index df531ae4c..bab11b0f9 100644 --- a/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs @@ -28,7 +28,7 @@ public class ResizeProfilingBenchmarks : MeasureFixture this.ExecutionCount, () => { - using (Image image = new Image(this.configuration, width, height)) + using (Image image = new(this.configuration, width, height)) { image.Mutate(x => x.Resize(width / 5, height / 5)); } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 18bcbffae..75c096b1f 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -106,7 +106,7 @@ public class QuantizedImageTests { using Image image = provider.GetImage(); OctreeQuantizer octreeQuantizer = new(); - IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new() { MaxColors = 128 }); + IQuantizer quantizer = octreeQuantizer.CreatePixelSpecificQuantizer(Configuration.Default, new QuantizerOptions { MaxColors = 128 }); ImageFrame frame = image.Frames[0]; quantizer.BuildPaletteAndQuantizeFrame(frame, frame.Bounds); } diff --git a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs index d6960d778..28a7c49e5 100644 --- a/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Quantization/WuQuantizerTests.cs @@ -12,7 +12,7 @@ public class WuQuantizerTests public void SinglePixelOpaque() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new() { Dither = null }); + WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); using Image image = new(config, 1, 1, Color.Black.ToPixel()); ImageFrame frame = image.Frames.RootFrame; @@ -32,7 +32,7 @@ public class WuQuantizerTests public void SinglePixelTransparent() { Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new() { Dither = null }); + WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); using Image image = new(config, 1, 1, default(Rgba32)); ImageFrame frame = image.Frames.RootFrame; @@ -49,19 +49,19 @@ public class WuQuantizerTests } [Fact] - public void GrayScale() => TestScale(c => new(c, c, c, 128)); + public void GrayScale() => TestScale(c => new Rgba32(c, c, c, 128)); [Fact] - public void RedScale() => TestScale(c => new(c, 0, 0, 128)); + public void RedScale() => TestScale(c => new Rgba32(c, 0, 0, 128)); [Fact] - public void GreenScale() => TestScale(c => new(0, c, 0, 128)); + public void GreenScale() => TestScale(c => new Rgba32(0, c, 0, 128)); [Fact] - public void BlueScale() => TestScale(c => new(0, 0, c, 128)); + public void BlueScale() => TestScale(c => new Rgba32(0, 0, c, 128)); [Fact] - public void AlphaScale() => TestScale(c => new(0, 0, 0, c)); + public void AlphaScale() => TestScale(c => new Rgba32(0, 0, 0, c)); [Fact] public void Palette256() @@ -75,11 +75,11 @@ public class WuQuantizerTests byte b = (byte)(((i / 16) % 4) * 85); byte a = (byte)((i / 64) * 85); - image[0, i] = new(r, g, b, a); + image[0, i] = new Rgba32(r, g, b, a); } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; @@ -125,7 +125,7 @@ public class WuQuantizerTests // See https://github.com/SixLabors/ImageSharp/issues/866 using Image image = provider.GetImage(); Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new() { Dither = null }); + WuQuantizer quantizer = new(new QuantizerOptions { Dither = null }); ImageFrame frame = image.Frames.RootFrame; using IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config); @@ -152,7 +152,7 @@ public class WuQuantizerTests } Configuration config = Configuration.Default; - WuQuantizer quantizer = new(new() { Dither = null, TransparencyThreshold = 0 }); + WuQuantizer quantizer = new(new QuantizerOptions { Dither = null, TransparencyThreshold = 0 }); ImageFrame frame = image.Frames.RootFrame; using (IQuantizer frameQuantizer = quantizer.CreatePixelSpecificQuantizer(config)) diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs index 094ba7626..40f54ea74 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutEntry.cs @@ -52,7 +52,7 @@ public class IccConversionDataLutEntry values[i] = 0.1f + (i / (float)length); } - return new(values); + return new IccLut(values); } private static IccLut CreateIdentityLut(float min, float max) => new([min, max]); diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs index 57618b957..f79666e3e 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMultiProcessElement.cs @@ -49,13 +49,13 @@ public class IccConversionDataMultiProcessElement private static IccCurveSetProcessElement Create1DSingleCurveSet(IccCurveSegment segment) { IccOneDimensionalCurve curve = new(new float[0], new[] { segment }); - return new(new[] { curve }); + return new IccCurveSetProcessElement(new[] { curve }); } private static IccCurveSetProcessElement Create1DMultiCurveSet(float[] breakPoints, params IccCurveSegment[] segments) { IccOneDimensionalCurve curve = new(breakPoints, segments); - return new(new[] { curve }); + return new IccCurveSetProcessElement(new[] { curve }); } public static object[][] MpeCurveConversionTestData = diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index cf7a99b63..6cd99367a 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -12,11 +12,11 @@ public static class IccConversionDataTrc internal static IccCurveTagDataEntry Gamma2Curve = new(2); internal static IccCurveTagDataEntry LutCurve = new(new float[] { 0, 0.7f, 1 }); - internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new(2.2f)); - internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new(2.2f, 1.5f, -0.5f)); - internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new(2.2f, 1.5f, -0.5f, 0.3f)); - internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); - internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new IccParametricCurve(2.2f)); + internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f)); + internal static IccParametricCurveTagDataEntry ParamCurve3 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f, 0.3f)); + internal static IccParametricCurveTagDataEntry ParamCurve4 = new(new IccParametricCurve(2.4f, 1 / 1.055f, 0.055f / 1.055f, 1 / 12.92f, 0.04045f)); + internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); public static object[][] TrcArrayConversionTestData { get; } = { diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index c47f6357b..2bd47e449 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -18,7 +18,7 @@ internal static class IccTestDataLut result[i] = i / 255f; } - return new(result); + return new IccLut(result); } private static byte[] CreateLut8() diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index a31f1d05f..7441bede8 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -23,7 +23,7 @@ internal static class IccTestDataProfiles public static readonly IccProfileHeader HeaderRandomWrite = CreateHeaderRandomValue( 562, // should be overwritten - new(1, 2, 3, 4), // should be overwritten + new IccProfileId(1, 2, 3, 4), // should be overwritten "ijkl"); // should be overwritten to "acsp" public static readonly IccProfileHeader HeaderRandomRead = CreateHeaderRandomValue(132, HeaderRandomIdValue, "acsp"); @@ -34,7 +34,7 @@ internal static class IccTestDataProfiles { Class = IccProfileClass.DisplayDevice, CmmType = "abcd", - CreationDate = new(1990, 11, 26, 7, 21, 42), + CreationDate = new DateTime(1990, 11, 26, 7, 21, 42), CreatorSignature = "dcba", DataColorSpace = IccColorSpaceType.Rgb, DeviceAttributes = IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.OpacityTransparent, @@ -43,12 +43,12 @@ internal static class IccTestDataProfiles FileSignature = "acsp", Flags = IccProfileFlag.Embedded | IccProfileFlag.Independent, Id = id, - PcsIlluminant = new(4, 5, 6), + PcsIlluminant = new Vector3(4, 5, 6), PrimaryPlatformSignature = IccPrimaryPlatformType.MicrosoftCorporation, ProfileConnectionSpace = IccColorSpaceType.CieXyz, RenderingIntent = IccRenderingIntent.AbsoluteColorimetric, Size = size, - Version = new(4, 3, 0), + Version = new IccVersion(4, 3, 0), }; public static byte[] CreateHeaderRandomArray(uint size, uint nrOfEntries, byte[] profileId) => ArrayHelper.Concat( diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index 7e5294f85..a83dc3575 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -339,7 +339,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new(language); + culture = new CultureInfo(language); } catch (CultureNotFoundException) { @@ -350,7 +350,7 @@ internal static class IccTestDataTagDataEntry { try { - culture = new($"{language}-{country}"); + culture = new CultureInfo($"{language}-{country}"); } catch (CultureNotFoundException) { @@ -358,7 +358,7 @@ internal static class IccTestDataTagDataEntry } } - return new(culture, text); + return new IccLocalizedString(culture, text); } private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = new[] diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index 01c5fdae3..1177152c0 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -79,7 +79,7 @@ public sealed class TestFile /// The . /// public static TestFile Create(string file) - => Cache.GetOrAdd(file, (string fileName) => new(GetInputFileFullPath(fileName))); + => Cache.GetOrAdd(file, (string fileName) => new TestFile(GetInputFileFullPath(fileName))); /// /// Gets the file name. @@ -117,7 +117,7 @@ public sealed class TestFile /// The . /// public Image CreateRgba32Image(IImageDecoder decoder) - => this.CreateRgba32Image(decoder, new()); + => this.CreateRgba32Image(decoder, new DecoderOptions()); /// /// Creates a new image. diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index 32cac0b05..d575489be 100644 --- a/tests/ImageSharp.Tests/TestFontUtilities.cs +++ b/tests/ImageSharp.Tests/TestFontUtilities.cs @@ -59,7 +59,7 @@ public static class TestFontUtilities return directory; } - throw new($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); + throw new Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); } /// diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 8b2a9a9be..92b74cde1 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -24,8 +24,8 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestFormat() { - this.Encoder = new(this); - this.Decoder = new(this); + this.Encoder = new TestEncoder(this); + this.Decoder = new TestDecoder(this); } public List DecodeCalls { get; } = new(); @@ -205,7 +205,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; @@ -220,7 +220,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat using MemoryStream ms = new(); stream.CopyTo(ms, configuration.StreamProcessingBufferSize); byte[] marker = ms.ToArray().Skip(this.testFormat.header.Length).ToArray(); - this.testFormat.DecodeCalls.Add(new() + this.testFormat.DecodeCalls.Add(new DecodeOperation { Marker = marker, Config = configuration, diff --git a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs index 45e1425c7..548354450 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ByteBuffer.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; public class ByteBuffer { - private readonly List bytes = new List(); + private readonly List bytes = new(); private readonly bool isLittleEndian; public ByteBuffer(bool isLittleEndian) diff --git a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs index 45a5ab5f5..c5ffdd648 100644 --- a/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs +++ b/tests/ImageSharp.Tests/TestUtilities/EofHitCounter.cs @@ -31,7 +31,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(Configuration.Default, new MemoryStream(imageData)); Image image = Image.Load(stream); - return new(stream, image); + return new EofHitCounter(stream, image); } public static EofHitCounter RunDecoder(byte[] imageData, T decoder, TO options) @@ -40,7 +40,7 @@ internal class EofHitCounter : IDisposable { BufferedReadStream stream = new(options.GeneralOptions.Configuration, new MemoryStream(imageData)); Image image = decoder.Decode(options, stream); - return new(stream, image); + return new EofHitCounter(stream, image); } public void Dispose() diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index a02ea399f..63126dcbc 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -67,7 +67,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -109,7 +109,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, intrinsic.Key.ToString(), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -153,7 +153,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, BasicSerializer.Serialize(serializable), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -198,7 +198,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(serializable), intrinsic.Key.ToString(), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -247,7 +247,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), BasicSerializer.Serialize(arg2), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -294,7 +294,7 @@ public static class FeatureTestRunner action, BasicSerializer.Serialize(arg1), arg2, - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -338,7 +338,7 @@ public static class FeatureTestRunner RemoteExecutor.Invoke( action, serializable.ToString(), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) @@ -385,7 +385,7 @@ public static class FeatureTestRunner action, arg0.ToString(), arg1.ToString(), - new() + new RemoteInvokeOptions { StartInfo = processStartInfo }) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 12f8ef773..1d35a6200 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -46,12 +46,12 @@ public class ExactImageComparer : ImageComparer if (aPixel != bPixel) { - PixelDifference diff = new(new(x, y), aPixel, bPixel); + PixelDifference diff = new(new Point(x, y), aPixel, bPixel); differences.Add(diff); } } } - return new(index, expected, actual, differences); + return new ImageSimilarityReport(index, expected, actual, differences); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index dee12915b..c8e11e69c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -159,7 +159,7 @@ public static class ImageComparerExtensions if (outsideChanges.Any()) { - cleanedReports.Add(new(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); + cleanedReports.Add(new ImageSimilarityReport(r.Index, r.ExpectedImage, r.ActualImage, outsideChanges, null)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs index 410ada05a..05f65cfbb 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparingUtils.cs @@ -19,7 +19,7 @@ public static class ImageComparingUtils ?? throw new InvalidOperationException("CompareToOriginal() works only with file providers!"); TestFile testFile = TestFile.Create(path); - using Image magickImage = DecodeWithMagick(new(testFile.FullPath)); + using Image magickImage = DecodeWithMagick(new FileInfo(testFile.FullPath)); if (useExactComparer) { ImageComparer.Exact.VerifySimilarity(magickImage, image); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs index 8c72bbf54..1594258e0 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageSimilarityReport.cs @@ -61,7 +61,7 @@ public class ImageSimilarityReport private string PrintDifference() { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new(); if (this.TotalNormalizedDifference.HasValue) { sb.AppendLine(); @@ -103,7 +103,7 @@ public class ImageSimilarityReport : ImageSimilarityReport } public static ImageSimilarityReport Empty => - new ImageSimilarityReport(0, null, null, Enumerable.Empty(), 0f); + new(0, null, null, Enumerable.Empty(), 0f); public new ImageFrame ExpectedImage => (ImageFrame)base.ExpectedImage; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index 004c26a8f..c9f13ca2f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -89,7 +89,7 @@ public class TolerantImageComparer : ImageComparer if (d > this.PerPixelManhattanThreshold) { - PixelDifference diff = new(new(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new(new Point(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); totalDifference += d; @@ -102,7 +102,7 @@ public class TolerantImageComparer : ImageComparer if (normalizedDifference > this.ImageThreshold) { - return new(index, expected, actual, differences, normalizedDifference); + return new ImageSimilarityReport(index, expected, actual, differences, normalizedDifference); } else { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs index d861d293b..813ed505d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs @@ -78,6 +78,6 @@ public abstract partial class TestImageProvider : IXunitSerializable return x < midX ? BottomLeftColor : BottomRightColor; } - private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new(1f, 0f, 1f, 0.5f)); + private static TPixel GetBottomRightColor() => TPixel.FromScaledVector4(new Vector4(1f, 0f, 1f, 0.5f)); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs index 5a31707bf..c8c3e09c3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs @@ -33,7 +33,7 @@ public abstract partial class TestImageProvider : IXunitSerializable protected int Width { get; private set; } - public override Image GetImage() => new Image(this.Configuration, this.Width, this.Height); + public override Image GetImage() => new(this.Configuration, this.Width, this.Height); public override void Deserialize(IXunitSerializationInfo info) { diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs index caa54feae..3f6e78a34 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs @@ -32,7 +32,7 @@ public abstract partial class TestImageProvider : IXunitSerializable ISpecializedDecoderOptions specialized) { Type customType = customDecoder?.GetType(); - this.commonValues = new( + this.commonValues = new Tuple( pixelType, filePath, customType); diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs index 88ebd6c7f..ab624126b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs @@ -88,10 +88,10 @@ public abstract partial class TestImageProvider : ITestImageProvider, IX public abstract Image GetImage(); public Image GetImage(IImageDecoder decoder) - => this.GetImage(decoder, new()); + => this.GetImage(decoder, new DecoderOptions()); public Task> GetImageAsync(IImageDecoder decoder) - => this.GetImageAsync(decoder, new()); + => this.GetImageAsync(decoder, new DecoderOptions()); public virtual Image GetImage(IImageDecoder decoder, DecoderOptions options) => throw new NotSupportedException($"Decoder specific GetImage() is not supported with {this.GetType().Name}!"); @@ -152,7 +152,7 @@ public abstract partial class TestImageProvider : ITestImageProvider, IX this.MethodName = methodName; this.OutputSubfolderName = outputSubfolderName; - this.Utility = new() + this.Utility = new ImagingTestCaseUtility { SourceFileOrDescription = this.SourceFileOrDescription, PixelTypeName = this.PixelType.ToString() diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs index b5fad3929..81f16cf6b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs +++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs @@ -60,7 +60,7 @@ public class MeasureGuard : IDisposable { private readonly string operation; - private readonly Stopwatch stopwatch = new Stopwatch(); + private readonly Stopwatch stopwatch = new(); public MeasureGuard(ITestOutputHelper output, string operation) { diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs index 049fda727..d1149dd00 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedMemoryStream.cs @@ -92,9 +92,9 @@ public class PausedMemoryStream : MemoryStream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs index 54aa77be2..42ed6b0d5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PausedStream.cs @@ -94,9 +94,9 @@ public class PausedStream : Stream, IPausedStream try { int bytesRead; - while ((bytesRead = await this.ReadAsync(new(buffer), cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await this.ReadAsync(new Memory(buffer), cancellationToken).ConfigureAwait(false)) != 0) { - await destination.WriteAsync(new(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } } finally diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs index bdc78f3f5..862d4b64d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs @@ -32,15 +32,15 @@ public class MagickReferenceDecoder : ImageDecoder this.validate = validate; } - public static MagickReferenceDecoder Png { get; } = new MagickReferenceDecoder(PngFormat.Instance); + public static MagickReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static MagickReferenceDecoder Bmp { get; } = new MagickReferenceDecoder(BmpFormat.Instance); + public static MagickReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); - public static MagickReferenceDecoder Jpeg { get; } = new MagickReferenceDecoder(JpegFormat.Instance); + public static MagickReferenceDecoder Jpeg { get; } = new(JpegFormat.Instance); - public static MagickReferenceDecoder Tiff { get; } = new MagickReferenceDecoder(TiffFormat.Instance); + public static MagickReferenceDecoder Tiff { get; } = new(TiffFormat.Instance); - public static MagickReferenceDecoder WebP { get; } = new MagickReferenceDecoder(WebpFormat.Instance); + public static MagickReferenceDecoder WebP { get; } = new(WebpFormat.Instance); protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { @@ -103,7 +103,7 @@ public class MagickReferenceDecoder : ImageDecoder } } - return ReferenceCodecUtilities.EnsureDecodedMetadata(new(configuration, metadata, framesList), this.imageFormat); + return ReferenceCodecUtilities.EnsureDecodedMetadata(new Image(configuration, metadata, framesList), this.imageFormat); } protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) @@ -113,7 +113,7 @@ public class MagickReferenceDecoder : ImageDecoder { using Image image = this.Decode(options, stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs index 78014b7af..84be9e3a9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs @@ -27,7 +27,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format32bppArgb) { @@ -37,7 +37,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - Image image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -86,7 +86,7 @@ public static class SystemDrawingBridge int w = bmp.Width; int h = bmp.Height; - System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); if (bmp.PixelFormat != PixelFormat.Format24bppRgb) { @@ -96,7 +96,7 @@ public static class SystemDrawingBridge } BitmapData data = bmp.LockBits(fullRect, ImageLockMode.ReadWrite, bmp.PixelFormat); - Image image = new Image(w, h); + Image image = new(w, h); try { byte* sourcePtrBase = (byte*)data.Scan0; @@ -138,8 +138,8 @@ public static class SystemDrawingBridge int w = image.Width; int h = image.Height; - Bitmap resultBitmap = new Bitmap(w, h, PixelFormat.Format32bppArgb); - System.Drawing.Rectangle fullRect = new System.Drawing.Rectangle(0, 0, w, h); + Bitmap resultBitmap = new(w, h, PixelFormat.Format32bppArgb); + System.Drawing.Rectangle fullRect = new(0, 0, w, h); BitmapData data = resultBitmap.LockBits(fullRect, ImageLockMode.ReadWrite, resultBitmap.PixelFormat); try { diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs index 14a655823..fce2da05f 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceDecoder.cs @@ -18,15 +18,15 @@ public class SystemDrawingReferenceDecoder : ImageDecoder public SystemDrawingReferenceDecoder(IImageFormat imageFormat) => this.imageFormat = imageFormat; - public static SystemDrawingReferenceDecoder Png { get; } = new SystemDrawingReferenceDecoder(PngFormat.Instance); + public static SystemDrawingReferenceDecoder Png { get; } = new(PngFormat.Instance); - public static SystemDrawingReferenceDecoder Bmp { get; } = new SystemDrawingReferenceDecoder(BmpFormat.Instance); + public static SystemDrawingReferenceDecoder Bmp { get; } = new(BmpFormat.Instance); protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) { using Image image = this.Decode(options, stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs index 0789ab263..f9769b891 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingReferenceEncoder.cs @@ -15,9 +15,9 @@ public class SystemDrawingReferenceEncoder : IImageEncoder public SystemDrawingReferenceEncoder(ImageFormat imageFormat) => this.imageFormat = imageFormat; - public static SystemDrawingReferenceEncoder Png { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Png); + public static SystemDrawingReferenceEncoder Png { get; } = new(ImageFormat.Png); - public static SystemDrawingReferenceEncoder Bmp { get; } = new SystemDrawingReferenceEncoder(ImageFormat.Bmp); + public static SystemDrawingReferenceEncoder Bmp { get; } = new(ImageFormat.Bmp); public bool SkipMetadata { get; init; } diff --git a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs index 873d5bfde..d8b0ff785 100644 --- a/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs +++ b/tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs @@ -18,7 +18,7 @@ public class SixLaborsXunitTestFramework : XunitTestFramework public SixLaborsXunitTestFramework(IMessageSink messageSink) : base(messageSink) { - DiagnosticMessage message = new DiagnosticMessage(HostEnvironmentInfo.GetInformation()); + DiagnosticMessage message = new(HostEnvironmentInfo.GetInformation()); messageSink.OnMessage(message); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index aa94ce469..8eed0a1c1 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -198,7 +198,7 @@ public static partial class TestEnvironment "Microsoft SDKs", "Windows"); - FileInfo corFlagsFile = Find(new(windowsSdksDir), "CorFlags.exe"); + FileInfo corFlagsFile = Find(new DirectoryInfo(windowsSdksDir), "CorFlags.exe"); string remoteExecutorPath = Path.Combine(TestAssemblyFile.DirectoryName, "Microsoft.DotNet.RemoteExecutor.exe"); @@ -230,7 +230,7 @@ public static partial class TestEnvironment if (proc.ExitCode != 0) { - throw new( + throw new Exception( $@"Failed to run {si.FileName} {si.Arguments}:\n STDOUT: {standardOutput}\n STDERR: {standardError}"); } diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 6a5f7f892..994aa670c 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -774,7 +774,7 @@ public static class TestImageExtensions { TestMemoryAllocator allocator = new(); provider.Configuration.MemoryAllocator = allocator; - return new(allocator, Unsafe.SizeOf()); + return new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf()); } private class MakeOpaqueProcessor : IImageProcessor diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs index 6ef2c1824..a0ff4a466 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryAllocator.cs @@ -33,8 +33,8 @@ internal class TestMemoryAllocator : MemoryAllocator public void EnableNonThreadSafeLogging() { - this.allocationLog = new(); - this.returnLog = new(); + this.allocationLog = new List(); + this.returnLog = new List(); } public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) @@ -61,7 +61,7 @@ internal class TestMemoryAllocator : MemoryAllocator private void Return(BasicArrayBuffer buffer) where T : struct { - this.returnLog?.Add(new(buffer.Array.GetHashCode())); + this.returnLog?.Add(new ReturnRequest(buffer.Array.GetHashCode())); } public struct AllocationRequest @@ -83,7 +83,7 @@ internal class TestMemoryAllocator : MemoryAllocator { Type type = typeof(T); int elementSize = Marshal.SizeOf(type); - return new(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); + return new AllocationRequest(type, allocationOptions, length, length * elementSize, buffer.GetHashCode()); } public Type ElementType { get; } @@ -150,7 +150,7 @@ internal class TestMemoryAllocator : MemoryAllocator } void* ptr = (void*)this.pinHandle.AddrOfPinnedObject(); - return new(ptr, pinnable: this); + return new MemoryHandle(ptr, pinnable: this); } public override void Unpin() diff --git a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs index 2604aa1de..7f25fd5aa 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestMemoryManager.cs @@ -36,7 +36,7 @@ public class TestMemoryManager : MemoryManager { T[] pixelArray = new T[copyThisBuffer.Length]; copyThisBuffer.CopyTo(pixelArray); - return new(pixelArray); + return new TestMemoryManager(pixelArray); } protected override void Dispose(bool disposing) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs index 42b2b2a25..f0344e2b9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestPixel.cs @@ -35,7 +35,7 @@ public class TestPixel : IXunitSerializable public float Alpha { get; set; } - public TPixel AsPixel() => TPixel.FromScaledVector4(new(this.Red, this.Green, this.Blue, this.Alpha)); + public TPixel AsPixel() => TPixel.FromScaledVector4(new Vector4(this.Red, this.Green, this.Blue, this.Alpha)); internal Span AsSpan() => new([this.AsPixel()]); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index 39c8c4c94..fbdfb9d61 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -69,7 +69,7 @@ public static class TestUtils Span row = accessor.GetRowSpan(y); for (int x = 0; x < row.Length; x++) { - row[x] = new(expected[cnt++], expected[cnt++]); + row[x] = new La16(expected[cnt++], expected[cnt++]); } } }); @@ -393,7 +393,7 @@ public static class TestUtils if (property is null) { - throw new($"No dither named '{name}"); + throw new Exception($"No dither named '{name}"); } return (IDither)property.GetValue(null); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs index 4130d89da..350333965 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestVector4.cs @@ -35,7 +35,7 @@ public class TestVector4 : IXunitSerializable public Vector4 AsVector() { - return new(this.X, this.Y, this.Z, this.W); + return new Vector4(this.X, this.Y, this.Z, this.W); } public void Deserialize(IXunitSerializationInfo info) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs index f4944992a..1b5b43f03 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs @@ -51,7 +51,7 @@ public class BasicSerializerTests [Fact] public void SerializeDeserialize_ShouldPreserveValues() { - DerivedObj obj = new DerivedObj() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; + DerivedObj obj = new() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; string str = BasicSerializer.Serialize(obj); BaseObj mirrorBase = BasicSerializer.Deserialize(str); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs index 649c626a1..349dd258e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs @@ -72,7 +72,7 @@ public class ImageComparerTests () => comparer.VerifySimilarity(image, clone)); PixelDifference diff = ex.Reports.Single().Differences.Single(); - Assert.Equal(new(3, 1), diff.Position); + Assert.Equal(new Point(3, 1), diff.Position); } } } @@ -131,7 +131,7 @@ public class ImageComparerTests IEnumerable reports = ImageComparer.Exact.CompareImages(image, clone); PixelDifference difference = reports.Single().Differences.Single(); - Assert.Equal(new(42, 43), difference.Position); + Assert.Equal(new Point(42, 43), difference.Position); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 90e726194..4329a6be3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -76,7 +76,7 @@ public class ReferenceDecoderBenchmarks private void BenchmarkDecoderImpl(IEnumerable testFiles, IImageDecoder decoder, string info, int times = DefaultExecutionCount) { - MeasureFixture measure = new MeasureFixture(this.Output); + MeasureFixture measure = new(this.Output); measure.Measure( times, () => diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs index e080bda9b..f0a5f4eb4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SemaphoreReadMemoryStreamTests.cs @@ -5,8 +5,8 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; public class SemaphoreReadMemoryStreamTests { - private readonly SemaphoreSlim continueSemaphore = new SemaphoreSlim(0); - private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new SemaphoreSlim(0); + private readonly SemaphoreSlim continueSemaphore = new(0); + private readonly SemaphoreSlim notifyWaitPositionReachedSemaphore = new(0); private readonly byte[] buffer = new byte[128]; [Fact] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs index 4a88cfb1b..555041890 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs @@ -36,7 +36,7 @@ public class SystemDrawingReferenceCodecTests { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); - using Bitmap sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image image = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); image.DebugSave(dummyProvider); } @@ -50,7 +50,7 @@ public class SystemDrawingReferenceCodecTests sourceImage.Mutate(c => c.MakeOpaque()); } - PngEncoder encoder = new PngEncoder { ColorType = pngColorType }; + PngEncoder encoder = new() { ColorType = pngColorType }; return provider.Utility.SaveTestOutputFile(sourceImage, "png", encoder); } @@ -66,7 +66,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.RgbWithAlpha); - using Bitmap sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image original = provider.GetImage(); using Image resaved = SystemDrawingBridge.From32bppArgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; @@ -81,7 +81,7 @@ public class SystemDrawingReferenceCodecTests string path = SavePng(provider, PngColorType.Rgb); using Image original = provider.GetImage(); - using Bitmap sdBitmap = new System.Drawing.Bitmap(path); + using Bitmap sdBitmap = new(path); using Image resaved = SystemDrawingBridge.From24bppRgbSystemDrawingBitmap(sdBitmap); ImageComparer comparer = ImageComparer.Exact; comparer.VerifySimilarity(original, resaved); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index f33811206..72ed27e8e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -368,7 +368,7 @@ public class TestImageProviderTests { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; @@ -415,7 +415,7 @@ public class TestImageProviderTests { using Image image = this.Decode(this.CreateDefaultSpecializedOptions(options), stream, cancellationToken); ImageMetadata metadata = image.Metadata; - return new(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) + return new ImageInfo(image.Size, metadata, new List(image.Frames.Select(x => x.Metadata))) { PixelType = metadata.GetDecodedPixelTypeInfo() }; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 520f40e72..46fb7159e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -83,7 +83,7 @@ public class TestUtilityExtensionsTests PixelTypes pt, IEnumerable> pixelTypesExp) { - Assert.Contains(new(pt, typeof(T)), pixelTypesExp); + Assert.Contains(new KeyValuePair(pt, typeof(T)), pixelTypesExp); } [Fact] From 4378e8d428bcf7ea48d437440046f8cd0f1aa8fa Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 29 Jun 2025 16:16:44 +0200 Subject: [PATCH 019/112] Update shared-infrastructure --- shared-infrastructure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-infrastructure b/shared-infrastructure index 5e13cde85..132a8232b 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 5e13cde851a3d6e95d0dfdde2a57071f1efda9c3 +Subproject commit 132a8232bd61471e9e9df727fb7a112800030327 From 5de26525fee985b870375219bd0dcc0352afb73f Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Wed, 25 Jun 2025 18:21:51 +0200 Subject: [PATCH 020/112] Convert CodeBase to collection Expressions --- .editorconfig | 5 + src/ImageSharp/Color/Color.WebSafePalette.cs | 6 +- src/ImageSharp/Color/Color.WernerPalette.cs | 6 +- src/ImageSharp/Common/Helpers/HexConverter.cs | 8 +- src/ImageSharp/Common/InlineArray.cs | 2 +- src/ImageSharp/Common/InlineArray.tt | 2 +- src/ImageSharp/Compression/Zlib/Adler32.cs | 6 +- .../Compression/Zlib/DeflaterConstants.cs | 10 +- .../Compression/Zlib/DeflaterHuffman.cs | 36 +- src/ImageSharp/Formats/Bmp/BmpConstants.cs | 8 +- src/ImageSharp/Formats/Gif/GifConstants.cs | 22 +- src/ImageSharp/Formats/Gif/LzwEncoder.cs | 4 +- .../Sections/GifXmpApplicationExtension.cs | 2 +- .../Components/Decoder/ProfileResolver.cs | 54 +- .../Jpeg/Components/Encoder/HuffmanSpec.cs | 40 +- .../Jpeg/Components/FloatingPointDCT.cs | 8 +- .../Formats/Jpeg/Components/Quantization.cs | 16 +- .../Formats/Jpeg/Components/ZigZag.cs | 12 +- src/ImageSharp/Formats/Jpeg/JpegConstants.cs | 4 +- src/ImageSharp/Formats/Pbm/PbmConstants.cs | 4 +- src/ImageSharp/Formats/Png/Adam7.cs | 8 +- src/ImageSharp/Formats/Png/PngConstants.cs | 26 +- src/ImageSharp/Formats/Qoi/QoiConstants.cs | 4 +- src/ImageSharp/Formats/Tga/TgaConstants.cs | 4 +- .../Compressors/T6BitCompressor.cs | 4 +- .../Compressors/TiffCcittCompressor.cs | 4 +- .../Formats/Tiff/Ifd/DirectoryReader.cs | 2 +- .../YCbCrConverter.cs | 8 +- .../Tiff/TiffEncoderEntriesCollector.cs | 2 +- .../Formats/Tiff/Writers/TiffStreamWriter.cs | 2 +- .../Formats/Webp/BitReader/Vp8LBitReader.cs | 4 +- .../Formats/Webp/Lossless/HuffmanUtils.cs | 4 +- .../Formats/Webp/Lossless/PredictorEncoder.cs | 12 +- .../Webp/Lossless/WebpLosslessDecoder.cs | 9 +- src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs | 4 +- .../Formats/Webp/Lossy/Vp8EncIterator.cs | 4 +- .../Formats/Webp/Lossy/Vp8Encoder.cs | 2 +- .../Formats/Webp/Lossy/Vp8Encoding.cs | 7 +- .../Formats/Webp/Lossy/Vp8Matrix.cs | 14 +- src/ImageSharp/Formats/Webp/WebpConstants.cs | 52 +- .../Formats/Webp/WebpLookupTables.cs | 558 +++++++++--------- .../Formats/_Generated/_Formats.ttinclude | 12 +- src/ImageSharp/IO/ChunkedMemoryStream.cs | 2 +- src/ImageSharp/ImageExtensions.cs | 2 +- .../Internals/UniformUnmanagedMemoryPool.cs | 2 +- .../DiscontiguousBuffers/MemoryGroup{T}.cs | 4 +- .../Metadata/Profiles/Exif/ExifConstants.cs | 14 +- .../DataReader/IccDataReader.NonPrimitives.cs | 2 +- .../DataReader/IccDataReader.TagDataEntry.cs | 2 +- .../Metadata/Profiles/ICC/IccReader.cs | 2 +- .../Metadata/Profiles/ICC/IccWriter.cs | 2 +- .../IccChromaticityTagDataEntry.cs | 48 +- .../TagDataEntries/IccCurveTagDataEntry.cs | 10 +- .../Metadata/Profiles/IPTC/IptcProfile.cs | 6 +- .../Metadata/Profiles/IPTC/IptcValue.cs | 4 +- .../Generated/_Common.ttinclude | 20 +- .../Kernels/EdgeDetectorCompassKernel.cs | 7 +- .../Parameters/BokehBlurKernelDataProvider.cs | 36 +- .../Transforms/Resize/ResizeKernel.cs | 8 +- .../ImageSharp.Benchmarks/Bulk/FromVector4.cs | 3 +- .../Codecs/Bmp/EncodeBmpMultiple.cs | 2 +- .../Codecs/Gif/EncodeGifMultiple.cs | 2 +- .../General/BasicMath/ClampFloat.cs | 2 +- .../General/BasicMath/ClampVector4.cs | 2 +- .../LoadResizeSaveStressBenchmarks.cs | 4 +- .../LoadResizeSaveStressRunner.cs | 6 +- .../Program.cs | 2 +- .../Color/ReferencePalette.cs | 8 +- .../Formats/GeneralFormatTests.cs | 17 +- .../Formats/Gif/GifDecoderTests.cs | 4 +- .../Formats/ImageFormatManagerTests.cs | 2 +- .../Formats/Jpg/AdobeMarkerTests.cs | 6 +- .../Formats/Jpg/JFifMarkerTests.cs | 8 +- .../Formats/Jpg/JpegDecoderTests.Images.cs | 20 +- .../Formats/Jpg/JpegDecoderTests.Internal.cs | 2 +- .../Formats/Jpg/JpegDecoderTests.cs | 6 +- .../Formats/Jpg/JpegEncoderTests.cs | 4 +- .../Formats/Jpg/SpectralJpegTests.cs | 14 +- .../Jpg/SpectralToPixelConversionTests.cs | 4 +- .../Formats/Png/Adler32Tests.cs | 2 +- .../Formats/Png/PngDecoderFilterTests.cs | 44 +- .../Formats/Png/PngDecoderTests.Chunks.cs | 20 +- .../Formats/Png/PngDecoderTests.cs | 24 +- .../Formats/Png/PngEncoderTests.Chunks.cs | 18 +- .../Formats/Png/PngEncoderTests.cs | 12 +- .../BlackIsZeroTiffColorTests.cs | 134 ++--- .../PaletteTiffColorTests.cs | 58 +- .../RgbPlanarTiffColorTests.cs | 152 ++--- .../RgbTiffColorTests.cs | 110 ++-- .../WhiteIsZeroTiffColorTests.cs | 134 ++--- .../Formats/Tiff/TiffMetadataTests.cs | 4 +- .../WebP/ColorSpaceTransformUtilsTests.cs | 16 +- .../Formats/WebP/LosslessUtilsTests.cs | 61 +- .../Formats/WebP/LossyUtilsTests.cs | 43 +- .../Formats/WebP/PredictorEncoderTests.cs | 8 +- .../Formats/WebP/QuantEncTests.cs | 13 +- .../Formats/WebP/Vp8EncodingTests.cs | 42 +- .../Formats/WebP/Vp8LHistogramTests.cs | 8 +- .../Formats/WebP/Vp8ResidualTests.cs | 2 +- .../Formats/WebP/WebpCommonUtilsTests.cs | 12 +- .../Formats/WebP/YuvConversionTests.cs | 24 +- .../IO/ChunkedMemoryStreamTests.cs | 26 +- .../ImageFrameCollectionTests.Generic.cs | 14 +- .../ImageFrameCollectionTests.NonGeneric.cs | 2 +- .../Image/ImageTests.Identify.cs | 14 +- .../Image/ImageTests.LoadPixelData.cs | 9 +- ...ts.Load_FromStream_ThrowsRightException.cs | 2 +- .../Allocators/MemoryDiagnosticsTests.cs | 2 +- .../UniformUnmanagedMemoryPoolTests.Trim.cs | 2 +- ...niformUnmanagedPoolMemoryAllocatorTests.cs | 2 +- .../Metadata/ImageFrameMetadataTests.cs | 2 +- .../Profiles/Exif/ExifProfileTests.cs | 6 +- .../Profiles/Exif/Values/ExifValuesTests.cs | 18 +- .../IccDataWriterPrimitivesTests.cs | 4 +- .../Profiles/IPTC/IptcProfileTests.cs | 4 +- .../Generated/_Common.ttinclude | 16 +- .../Convolution/KernelSamplingMapTest.cs | 126 ++-- .../Processing/Dithering/DitherTest.cs | 4 +- .../Processing/FakeImageOperationsProvider.cs | 4 +- .../Processing/Filters/ColorBlindnessTest.cs | 22 +- .../Processing/Filters/GrayscaleTest.cs | 8 +- .../HistogramEqualizationTests.cs | 8 +- .../Binarization/BinaryDitherTests.cs | 6 +- .../Binarization/BinaryThresholdTest.cs | 6 +- .../Basic1ParameterConvolutionTests.cs | 4 +- .../Processors/Convolution/DetectEdgesTest.cs | 2 +- .../Processors/Dithering/DitherTests.cs | 2 +- .../Processors/Effects/BackgroundColorTest.cs | 6 +- .../Processors/Effects/OilPaintTest.cs | 6 +- .../Processors/Overlays/OverlayTestBase.cs | 4 +- .../Quantization/PaletteQuantizerTests.cs | 2 +- .../Processors/Quantization/QuantizerTests.cs | 4 +- .../Processors/Transforms/AutoOrientTests.cs | 4 +- .../Processors/Transforms/EntropyCropTest.cs | 6 +- .../Processors/Transforms/PadTest.cs | 4 +- ...ResizeKernelMapTests.ReferenceKernelMap.cs | 2 +- .../Transforms/ResizeKernelMapTests.cs | 6 +- .../Processors/Transforms/RotateFlipTests.cs | 2 +- .../Processors/Transforms/SkewTests.cs | 10 +- .../Conversion/IccConversionDataLut.cs | 32 +- .../Conversion/IccConversionDataLutAB.cs | 26 +- .../Conversion/IccConversionDataMatrix.cs | 22 +- .../Conversion/IccConversionDataTrc.cs | 84 ++- .../TestDataIcc/IccTestDataArray.cs | 48 +- .../TestDataIcc/IccTestDataCurves.cs | 94 ++- .../TestDataIcc/IccTestDataLut.cs | 84 ++- .../TestDataIcc/IccTestDataMatrix.cs | 48 +- .../IccTestDataMultiProcessElements.cs | 49 +- .../TestDataIcc/IccTestDataNonPrimitives.cs | 173 +++--- .../TestDataIcc/IccTestDataPrimitives.cs | 370 ++++++------ .../TestDataIcc/IccTestDataProfiles.cs | 60 +- .../TestDataIcc/IccTestDataTagDataEntry.cs | 420 +++++++------ tests/ImageSharp.Tests/TestFontUtilities.cs | 14 +- tests/ImageSharp.Tests/TestFormat.cs | 10 +- tests/ImageSharp.Tests/TestImages.cs | 31 +- .../Attributes/ImageDataAttributeBase.cs | 2 +- .../WithBasicTestPatternImagesAttribute.cs | 3 +- .../Attributes/WithBlankImagesAttribute.cs | 3 +- .../Attributes/WithFileAttribute.cs | 2 +- .../Attributes/WithMemberFactoryAttribute.cs | 2 +- .../WithSolidFilledImagesAttribute.cs | 2 +- .../WithTestPatternImagesAttribute.cs | 3 +- .../ImageComparison/ExactImageComparer.cs | 2 +- .../ImageComparison/ImageComparer.cs | 2 +- .../ImageComparison/TolerantImageComparer.cs | 2 +- .../TestUtilities/TestEnvironment.cs | 2 +- .../TestUtilities/TestImageExtensions.cs | 2 +- .../TestUtilities/TestUtils.cs | 4 +- .../Tests/FeatureTestRunnerTests.cs | 6 +- .../Tests/ReferenceDecoderBenchmarks.cs | 12 +- 170 files changed, 2114 insertions(+), 2102 deletions(-) diff --git a/.editorconfig b/.editorconfig index 74a363eef..d6bd9e592 100644 --- a/.editorconfig +++ b/.editorconfig @@ -177,6 +177,11 @@ csharp_using_directive_placement = outside_namespace:warning csharp_prefer_static_local_function = true:warning # Primary constructor preferences csharp_style_prefer_primary_constructors = false:none +# Collection preferences +dotnet_style_prefer_collection_expression = true:error +resharper_use_collection_expression_highlighting =true:error + + ########################################## # Unnecessary Code Rules diff --git a/src/ImageSharp/Color/Color.WebSafePalette.cs b/src/ImageSharp/Color/Color.WebSafePalette.cs index b805d63f9..bd17d9a76 100644 --- a/src/ImageSharp/Color/Color.WebSafePalette.cs +++ b/src/ImageSharp/Color/Color.WebSafePalette.cs @@ -15,8 +15,8 @@ public partial struct Color /// public static ReadOnlyMemory WebSafePalette => WebSafePaletteLazy.Value; - private static Color[] CreateWebSafePalette() => new[] - { + private static Color[] CreateWebSafePalette() => + [ AliceBlue, AntiqueWhite, Aqua, @@ -159,5 +159,5 @@ public partial struct Color WhiteSmoke, Yellow, YellowGreen - }; + ]; } diff --git a/src/ImageSharp/Color/Color.WernerPalette.cs b/src/ImageSharp/Color/Color.WernerPalette.cs index 6f0e3744f..583c71379 100644 --- a/src/ImageSharp/Color/Color.WernerPalette.cs +++ b/src/ImageSharp/Color/Color.WernerPalette.cs @@ -16,8 +16,8 @@ public partial struct Color /// public static ReadOnlyMemory WernerPalette => WernerPaletteLazy.Value; - private static Color[] CreateWernerPalette() => new[] - { + private static Color[] CreateWernerPalette() => + [ ParseHex("#f1e9cd"), ParseHex("#f2e7cf"), ParseHex("#ece6d0"), @@ -128,5 +128,5 @@ public partial struct Color ParseHex("#9b856b"), ParseHex("#766051"), ParseHex("#453b32") - }; + ]; } diff --git a/src/ImageSharp/Common/Helpers/HexConverter.cs b/src/ImageSharp/Common/Helpers/HexConverter.cs index 8c473688f..a6face960 100644 --- a/src/ImageSharp/Common/Helpers/HexConverter.cs +++ b/src/ImageSharp/Common/Helpers/HexConverter.cs @@ -35,8 +35,8 @@ internal static class HexConverter { // Map from an ASCII char to its hex value, e.g. arr['b'] == 11. 0xFF means it's not a hex digit. // This doesn't actually allocate. - ReadOnlySpan charToHexLookup = new byte[] - { + ReadOnlySpan charToHexLookup = + [ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47 @@ -52,8 +52,8 @@ internal static class HexConverter 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 207 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 223 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 239 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 255 - }; + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 255 + ]; return (uint)c >= (uint)charToHexLookup.Length ? 0xFF : charToHexLookup[c]; } diff --git a/src/ImageSharp/Common/InlineArray.cs b/src/ImageSharp/Common/InlineArray.cs index c20c0d875..778981fd9 100644 --- a/src/ImageSharp/Common/InlineArray.cs +++ b/src/ImageSharp/Common/InlineArray.cs @@ -1,4 +1,4 @@ -// Copyright (c) Six Labors. +// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. // diff --git a/src/ImageSharp/Common/InlineArray.tt b/src/ImageSharp/Common/InlineArray.tt index ab488591a..6dc17b9a9 100644 --- a/src/ImageSharp/Common/InlineArray.tt +++ b/src/ImageSharp/Common/InlineArray.tt @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp; <#GenerateInlineArrays();#> <#+ -private static int[] Lengths = new int[] {4, 8, 16 }; +private static int[] Lengths = [4, 8, 16 ]; void GenerateInlineArrays() { diff --git a/src/ImageSharp/Compression/Zlib/Adler32.cs b/src/ImageSharp/Compression/Zlib/Adler32.cs index dd8217541..6f2185081 100644 --- a/src/ImageSharp/Compression/Zlib/Adler32.cs +++ b/src/ImageSharp/Compression/Zlib/Adler32.cs @@ -32,11 +32,11 @@ internal static class Adler32 private const int BlockSize = 1 << 5; // The C# compiler emits this as a compile-time constant embedded in the PE file. - private static ReadOnlySpan Tap1Tap2 => new byte[] - { + private static ReadOnlySpan Tap1Tap2 => + [ 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, // tap1 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 // tap2 - }; + ]; /// /// Calculates the Adler32 checksum with the bytes taken from the span. diff --git a/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs b/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs index b62314947..fbc2083b3 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterConstants.cs @@ -124,25 +124,25 @@ internal static class DeflaterConstants /// /// Internal compression engine constant /// - public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; + public static int[] GOOD_LENGTH = [0, 4, 4, 4, 4, 8, 8, 8, 32, 32]; /// /// Internal compression engine constant /// - public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 }; + public static int[] MAX_LAZY = [0, 4, 5, 6, 4, 16, 16, 32, 128, 258]; /// /// Internal compression engine constant /// - public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 }; + public static int[] NICE_LENGTH = [0, 8, 16, 32, 16, 32, 128, 128, 258, 258]; /// /// Internal compression engine constant /// - public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 }; + public static int[] MAX_CHAIN = [0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096]; /// /// Internal compression engine constant /// - public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; + public static int[] COMPR_FUNC = [0, 1, 1, 1, 1, 2, 2, 2, 2, 2]; } diff --git a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs index e4dc1945a..17cb1925d 100644 --- a/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs +++ b/src/ImageSharp/Compression/Zlib/DeflaterHuffman.cs @@ -77,8 +77,8 @@ internal sealed unsafe class DeflaterHuffman : IDisposable // See RFC 1951 3.2.6 // Literal codes - private static readonly short[] StaticLCodes = new short[] - { + private static readonly short[] StaticLCodes = + [ 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, @@ -97,10 +97,10 @@ internal sealed unsafe class DeflaterHuffman : IDisposable 31, 287, 159, 415, 95, 351, 223, 479, 63, 319, 191, 447, 127, 383, 255, 511, 0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120, 4, 68, 36, 100, 20, 84, 52, 116, 3, 131, 67, 195, 35, 163 - }; + ]; - private static ReadOnlySpan StaticLLength => new byte[] - { + private static ReadOnlySpan StaticLLength => + [ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, @@ -119,34 +119,34 @@ internal sealed unsafe class DeflaterHuffman : IDisposable 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8 - }; + ]; // Distance codes and lengths. - private static readonly short[] StaticDCodes = new short[] - { + private static readonly short[] StaticDCodes = + [ 0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23 - }; + ]; - private static ReadOnlySpan StaticDLength => new byte[] - { + private static ReadOnlySpan StaticDLength => + [ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 - }; + ]; #pragma warning restore SA1201 // Elements should appear in the correct order /// /// Gets the lengths of the bit length codes are sent in order of decreasing probability, to avoid transmitting the lengths for unused bit length codes. /// - private static ReadOnlySpan BitLengthOrder => new byte[] - { + private static ReadOnlySpan BitLengthOrder => + [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 - }; + ]; - private static ReadOnlySpan Bit4Reverse => new byte[] - { + private static ReadOnlySpan Bit4Reverse => + [ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 - }; + ]; /// /// Gets the pending buffer to use. diff --git a/src/ImageSharp/Formats/Bmp/BmpConstants.cs b/src/ImageSharp/Formats/Bmp/BmpConstants.cs index 62edfdfdf..1ac79a9e2 100644 --- a/src/ImageSharp/Formats/Bmp/BmpConstants.cs +++ b/src/ImageSharp/Formats/Bmp/BmpConstants.cs @@ -11,17 +11,17 @@ internal static class BmpConstants /// /// The list of mimetypes that equate to a bmp. /// - public static readonly IEnumerable MimeTypes = new[] - { + public static readonly IEnumerable MimeTypes = + [ "image/bmp", "image/x-windows-bmp", "image/x-win-bitmap" - }; + ]; /// /// The list of file extensions that equate to a bmp. /// - public static readonly IEnumerable FileExtensions = new[] { "bm", "bmp", "dip" }; + public static readonly IEnumerable FileExtensions = ["bm", "bmp", "dip"]; /// /// Valid magic bytes markers identifying a Bitmap file. diff --git a/src/ImageSharp/Formats/Gif/GifConstants.cs b/src/ImageSharp/Formats/Gif/GifConstants.cs index 796b5506c..d2121adce 100644 --- a/src/ImageSharp/Formats/Gif/GifConstants.cs +++ b/src/ImageSharp/Formats/Gif/GifConstants.cs @@ -93,41 +93,41 @@ internal static class GifConstants /// /// The collection of mimetypes that equate to a Gif. /// - public static readonly IEnumerable MimeTypes = new[] { "image/gif" }; + public static readonly IEnumerable MimeTypes = ["image/gif"]; /// /// The collection of file extensions that equate to a Gif. /// - public static readonly IEnumerable FileExtensions = new[] { "gif" }; + public static readonly IEnumerable FileExtensions = ["gif"]; /// /// Gets the ASCII encoded bytes used to identify the GIF file (combining and ). /// - internal static ReadOnlySpan MagicNumber => new[] - { + internal static ReadOnlySpan MagicNumber => + [ (byte)'G', (byte)'I', (byte)'F', (byte)'8', (byte)'9', (byte)'a' - }; + ]; /// /// Gets the ASCII encoded application identification bytes (representing ). /// - internal static ReadOnlySpan NetscapeApplicationIdentificationBytes => new[] - { + internal static ReadOnlySpan NetscapeApplicationIdentificationBytes => + [ (byte)'N', (byte)'E', (byte)'T', (byte)'S', (byte)'C', (byte)'A', (byte)'P', (byte)'E', (byte)'2', (byte)'.', (byte)'0' - }; + ]; /// /// Gets the ASCII encoded application identification bytes. /// - internal static ReadOnlySpan XmpApplicationIdentificationBytes => new[] - { + internal static ReadOnlySpan XmpApplicationIdentificationBytes => + [ (byte)'X', (byte)'M', (byte)'P', (byte)' ', (byte)'D', (byte)'a', (byte)'t', (byte)'a', (byte)'X', (byte)'M', (byte)'P' - }; + ]; } diff --git a/src/ImageSharp/Formats/Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs index d4050810d..08daf3899 100644 --- a/src/ImageSharp/Formats/Gif/LzwEncoder.cs +++ b/src/ImageSharp/Formats/Gif/LzwEncoder.cs @@ -47,7 +47,7 @@ internal sealed class LzwEncoder : IDisposable /// Mask used when shifting pixel values /// private static readonly int[] Masks = - { + [ 0b0, 0b1, 0b11, @@ -65,7 +65,7 @@ internal sealed class LzwEncoder : IDisposable 0b11111111111111, 0b111111111111111, 0b1111111111111111 - }; + ]; /// /// The maximum number of bits/code. diff --git a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs index 1c1127c3b..dc78f28bf 100644 --- a/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs +++ b/src/ImageSharp/Formats/Gif/Sections/GifXmpApplicationExtension.cs @@ -34,7 +34,7 @@ internal readonly struct GifXmpApplicationExtension : IGifExtension // Exclude the "magic trailer", see XMP Specification Part 3, 1.1.2 GIF int xmpLength = xmpBytes.Length - 256; // 257 - unread 0x0 - byte[] buffer = Array.Empty(); + byte[] buffer = []; if (xmpLength > 0) { buffer = new byte[xmpLength]; diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs index c11679feb..b83c01064 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs @@ -11,80 +11,80 @@ internal static class ProfileResolver /// /// Gets the JFIF specific markers. /// - public static ReadOnlySpan JFifMarker => new[] - { + public static ReadOnlySpan JFifMarker => + [ (byte)'J', (byte)'F', (byte)'I', (byte)'F', (byte)'\0' - }; + ]; /// /// Gets the JFXX specific markers. /// - public static ReadOnlySpan JFxxMarker => new[] - { + public static ReadOnlySpan JFxxMarker => + [ (byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0' - }; + ]; /// /// Gets the ICC specific markers. /// - public static ReadOnlySpan IccMarker => new[] - { + public static ReadOnlySpan IccMarker => + [ (byte)'I', (byte)'C', (byte)'C', (byte)'_', (byte)'P', (byte)'R', (byte)'O', (byte)'F', (byte)'I', (byte)'L', (byte)'E', (byte)'\0' - }; + ]; /// /// Gets the adobe photoshop APP13 marker which can contain IPTC meta data. /// - public static ReadOnlySpan AdobePhotoshopApp13Marker => new[] - { + public static ReadOnlySpan AdobePhotoshopApp13Marker => + [ (byte)'P', (byte)'h', (byte)'o', (byte)'t', (byte)'o', (byte)'s', (byte)'h', (byte)'o', (byte)'p', (byte)' ', (byte)'3', (byte)'.', (byte)'0', (byte)'\0' - }; + ]; /// /// Gets the 8BIM marker, which signals the start of a adobe specific image resource block. /// - public static ReadOnlySpan AdobeImageResourceBlockMarker => new[] - { + public static ReadOnlySpan AdobeImageResourceBlockMarker => + [ (byte)'8', (byte)'B', (byte)'I', (byte)'M' - }; + ]; /// /// Gets a IPTC Image resource ID. /// - public static ReadOnlySpan AdobeIptcMarker => new[] - { + public static ReadOnlySpan AdobeIptcMarker => + [ (byte)4, (byte)4 - }; + ]; /// /// Gets the EXIF specific markers. /// - public static ReadOnlySpan ExifMarker => new[] - { + public static ReadOnlySpan ExifMarker => + [ (byte)'E', (byte)'x', (byte)'i', (byte)'f', (byte)'\0', (byte)'\0' - }; + ]; /// /// Gets the XMP specific markers. /// - public static ReadOnlySpan XmpMarker => new[] - { + public static ReadOnlySpan XmpMarker => + [ (byte)'h', (byte)'t', (byte)'t', (byte)'p', (byte)':', (byte)'/', (byte)'/', (byte)'n', (byte)'s', (byte)'.', (byte)'a', (byte)'d', (byte)'o', (byte)'b', (byte)'e', (byte)'.', (byte)'c', (byte)'o', (byte)'m', (byte)'/', (byte)'x', (byte)'a', (byte)'p', (byte)'/', (byte)'1', (byte)'.', (byte)'0', (byte)'/', (byte)0 - }; + ]; /// /// Gets the Adobe specific markers . /// - public static ReadOnlySpan AdobeMarker => new[] - { + public static ReadOnlySpan AdobeMarker => + [ (byte)'A', (byte)'d', (byte)'o', (byte)'b', (byte)'e' - }; + ]; /// /// Returns a value indicating whether the passed bytes are a match to the profile identifier. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs index f5666f779..502b91917 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs @@ -15,15 +15,13 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec LuminanceDC = new( - new byte[] - { + [ 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 - }, - new byte[] - { + ], + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - }); + ]); /// /// Huffman talbe specification for luminance AC. @@ -32,13 +30,11 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec LuminanceAC = new( - new byte[] - { + [ 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125 - }, - new byte[] - { + ], + [ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, @@ -63,7 +59,7 @@ internal readonly struct HuffmanSpec 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa - }); + ]); /// /// Huffman talbe specification for chrominance DC. @@ -72,15 +68,13 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec ChrominanceDC = new( - new byte[] - { + [ 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 - }, - new byte[] - { + ], + [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 - }); + ]); /// /// Huffman talbe specification for chrominance DC. @@ -89,13 +83,11 @@ internal readonly struct HuffmanSpec /// This is an example specification taken from the jpeg specification paper. /// public static readonly HuffmanSpec ChrominanceAC = new( - new byte[] - { + [ 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119 - }, - new byte[] - { + ], + [ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, @@ -120,7 +112,7 @@ internal readonly struct HuffmanSpec 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa - }); + ]); /// /// Initializes a new instance of the struct. diff --git a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs index 8122d8daa..eb2d0b2eb 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/FloatingPointDCT.cs @@ -49,8 +49,8 @@ internal static partial class FloatingPointDCT /// /// /// - private static readonly float[] AdjustmentCoefficients = new float[] - { + private static readonly float[] AdjustmentCoefficients = + [ 1f, 1.3870399f, 1.306563f, 1.1758755f, 1f, 0.78569496f, 0.5411961f, 0.27589938f, 1.3870399f, 1.9238797f, 1.812255f, 1.6309863f, 1.3870399f, 1.0897902f, 0.7506606f, 0.38268346f, 1.306563f, 1.812255f, 1.707107f, 1.5363555f, 1.306563f, 1.02656f, 0.7071068f, 0.36047992f, @@ -58,8 +58,8 @@ internal static partial class FloatingPointDCT 1f, 1.3870399f, 1.306563f, 1.1758755f, 1f, 0.78569496f, 0.5411961f, 0.27589938f, 0.78569496f, 1.0897902f, 1.02656f, 0.9238795f, 0.78569496f, 0.61731654f, 0.42521507f, 0.21677275f, 0.5411961f, 0.7506606f, 0.7071068f, 0.63637924f, 0.5411961f, 0.42521507f, 0.29289323f, 0.14931567f, - 0.27589938f, 0.38268346f, 0.36047992f, 0.32442334f, 0.27589938f, 0.21677275f, 0.14931567f, 0.076120466f, - }; + 0.27589938f, 0.38268346f, 0.36047992f, 0.32442334f, 0.27589938f, 0.21677275f, 0.14931567f, 0.076120466f + ]; /// /// Adjusts given quantization table for usage with . diff --git a/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs b/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs index 7dca1cf5e..644cf2df5 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Quantization.cs @@ -46,8 +46,8 @@ internal static class Quantization // The C# compiler emits this as a compile-time constant embedded in the PE file. // This is effectively compiled down to: return new ReadOnlySpan(&data, length) // More details can be found: https://github.com/dotnet/roslyn/pull/24621 - public static ReadOnlySpan LuminanceTable => new byte[] - { + public static ReadOnlySpan LuminanceTable => + [ 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, 14, 13, 16, 24, 40, 57, 69, 56, @@ -55,8 +55,8 @@ internal static class Quantization 18, 22, 37, 56, 68, 109, 103, 77, 24, 35, 55, 64, 81, 104, 113, 92, 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99, - }; + 72, 92, 95, 98, 112, 100, 103, 99 + ]; /// /// Gets unscaled chrominance quantization table. @@ -67,8 +67,8 @@ internal static class Quantization // The C# compiler emits this as a compile-time constant embedded in the PE file. // This is effectively compiled down to: return new ReadOnlySpan(&data, length) // More details can be found: https://github.com/dotnet/roslyn/pull/24621 - public static ReadOnlySpan ChrominanceTable => new byte[] - { + public static ReadOnlySpan ChrominanceTable => + [ 17, 18, 24, 47, 99, 99, 99, 99, 18, 21, 26, 66, 99, 99, 99, 99, 24, 26, 56, 99, 99, 99, 99, 99, @@ -76,8 +76,8 @@ internal static class Quantization 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - }; + 99, 99, 99, 99, 99, 99, 99, 99 + ]; /// Ported from JPEGsnoop: /// https://github.com/ImpulseAdventure/JPEGsnoop/blob/9732ee0961f100eb69bbff4a0c47438d5997abee/source/JfifDecode.cpp#L4570-L4694 diff --git a/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs b/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs index 7b0e096e2..630017082 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/ZigZag.cs @@ -18,8 +18,8 @@ internal static partial class ZigZag /// The worst case would be a run-length of 15, which means we need 16 /// fake entries. /// - public static ReadOnlySpan ZigZagOrder => new byte[] - { + public static ReadOnlySpan ZigZagOrder => + [ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, @@ -32,7 +32,7 @@ internal static partial class ZigZag // Extra entries for safety in decoder 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 - }; + ]; /// /// Gets span of zig-zag with fused transpose step ordering indices. @@ -47,8 +47,8 @@ internal static partial class ZigZag /// The worst case would be a run-length of 15, which means we need 16 /// fake entries. /// - public static ReadOnlySpan TransposingOrder => new byte[] - { + public static ReadOnlySpan TransposingOrder => + [ 0, 8, 1, 2, 9, 16, 24, 17, 10, 3, 4, 11, 18, 25, 32, 40, 33, 26, 19, 12, 5, 6, 13, 20, @@ -61,5 +61,5 @@ internal static partial class ZigZag // Extra entries for safety in decoder 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 - }; + ]; } diff --git a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs index 7a627b7b8..50b7de68e 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs @@ -18,12 +18,12 @@ internal static class JpegConstants /// /// The list of mimetypes that equate to a jpeg. /// - public static readonly IEnumerable MimeTypes = new[] { "image/jpeg", "image/pjpeg" }; + public static readonly IEnumerable MimeTypes = ["image/jpeg", "image/pjpeg"]; /// /// The list of file extensions that equate to a jpeg. /// - public static readonly IEnumerable FileExtensions = new[] { "jpg", "jpeg", "jfif" }; + public static readonly IEnumerable FileExtensions = ["jpg", "jpeg", "jfif"]; /// /// Contains marker specific constants. diff --git a/src/ImageSharp/Formats/Pbm/PbmConstants.cs b/src/ImageSharp/Formats/Pbm/PbmConstants.cs index fe0088c3c..4a3a44497 100644 --- a/src/ImageSharp/Formats/Pbm/PbmConstants.cs +++ b/src/ImageSharp/Formats/Pbm/PbmConstants.cs @@ -16,10 +16,10 @@ internal static class PbmConstants /// /// The list of mimetypes that equate to a ppm. /// - public static readonly IEnumerable MimeTypes = new[] { "image/x-portable-pixmap", "image/x-portable-anymap" }; + public static readonly IEnumerable MimeTypes = ["image/x-portable-pixmap", "image/x-portable-anymap"]; /// /// The list of file extensions that equate to a ppm. /// - public static readonly IEnumerable FileExtensions = new[] { "ppm", "pbm", "pgm" }; + public static readonly IEnumerable FileExtensions = ["ppm", "pbm", "pgm"]; } diff --git a/src/ImageSharp/Formats/Png/Adam7.cs b/src/ImageSharp/Formats/Png/Adam7.cs index 8310ca64c..5da2fdd2e 100644 --- a/src/ImageSharp/Formats/Png/Adam7.cs +++ b/src/ImageSharp/Formats/Png/Adam7.cs @@ -13,22 +13,22 @@ internal static class Adam7 /// /// The amount to increment when processing each column per scanline for each interlaced pass. /// - public static readonly int[] ColumnIncrement = { 8, 8, 4, 4, 2, 2, 1 }; + public static readonly int[] ColumnIncrement = [8, 8, 4, 4, 2, 2, 1]; /// /// The index to start at when processing each column per scanline for each interlaced pass. /// - public static readonly int[] FirstColumn = { 0, 4, 0, 2, 0, 1, 0 }; + public static readonly int[] FirstColumn = [0, 4, 0, 2, 0, 1, 0]; /// /// The index to start at when processing each row per scanline for each interlaced pass. /// - public static readonly int[] FirstRow = { 0, 0, 4, 0, 2, 0, 1 }; + public static readonly int[] FirstRow = [0, 0, 4, 0, 2, 0, 1]; /// /// The amount to increment when processing each row per scanline for each interlaced pass. /// - public static readonly int[] RowIncrement = { 8, 8, 8, 4, 4, 2, 2 }; + public static readonly int[] RowIncrement = [8, 8, 8, 4, 4, 2, 2]; /// /// Gets the width of the block. diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 43f2b0fb2..17d13e86d 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -28,12 +28,12 @@ internal static class PngConstants /// /// The list of mimetypes that equate to a Png. /// - public static readonly IEnumerable MimeTypes = new[] { "image/png", "image/apng" }; + public static readonly IEnumerable MimeTypes = ["image/png", "image/apng"]; /// /// The list of file extensions that equate to a Png. /// - public static readonly IEnumerable FileExtensions = new[] { "png", "apng" }; + public static readonly IEnumerable FileExtensions = ["png", "apng"]; /// /// The header bytes as a big-endian coded ulong. @@ -45,11 +45,11 @@ internal static class PngConstants /// public static readonly Dictionary ColorTypes = new() { - [PngColorType.Grayscale] = new byte[] { 1, 2, 4, 8, 16 }, - [PngColorType.Rgb] = new byte[] { 8, 16 }, - [PngColorType.Palette] = new byte[] { 1, 2, 4, 8 }, - [PngColorType.GrayscaleWithAlpha] = new byte[] { 8, 16 }, - [PngColorType.RgbWithAlpha] = new byte[] { 8, 16 } + [PngColorType.Grayscale] = [1, 2, 4, 8, 16], + [PngColorType.Rgb] = [8, 16], + [PngColorType.Palette] = [1, 2, 4, 8], + [PngColorType.GrayscaleWithAlpha] = [8, 16], + [PngColorType.RgbWithAlpha] = [8, 16] }; /// @@ -65,8 +65,8 @@ internal static class PngConstants /// /// Gets the header bytes identifying a Png. /// - public static ReadOnlySpan HeaderBytes => new byte[] - { + public static ReadOnlySpan HeaderBytes => + [ 0x89, // Set the high bit. 0x50, // P 0x4E, // N @@ -75,13 +75,13 @@ internal static class PngConstants 0x0A, // Line ending CRLF 0x1A, // EOF 0x0A // LF - }; + ]; /// /// Gets the keyword of the XMP metadata, encoded in an iTXT chunk. /// - public static ReadOnlySpan XmpKeyword => new[] - { + public static ReadOnlySpan XmpKeyword => + [ (byte)'X', (byte)'M', (byte)'L', @@ -99,5 +99,5 @@ internal static class PngConstants (byte)'x', (byte)'m', (byte)'p' - }; + ]; } diff --git a/src/ImageSharp/Formats/Qoi/QoiConstants.cs b/src/ImageSharp/Formats/Qoi/QoiConstants.cs index 9643ccef0..3c64128ee 100644 --- a/src/ImageSharp/Formats/Qoi/QoiConstants.cs +++ b/src/ImageSharp/Formats/Qoi/QoiConstants.cs @@ -18,10 +18,10 @@ internal static class QoiConstants /// Gets the list of mimetypes that equate to a QOI. /// See https://github.com/phoboslab/qoi/issues/167 /// - public static string[] MimeTypes { get; } = { "image/qoi", "image/x-qoi", "image/vnd.qoi" }; + public static string[] MimeTypes { get; } = ["image/qoi", "image/x-qoi", "image/vnd.qoi"]; /// /// Gets the list of file extensions that equate to a QOI. /// - public static string[] FileExtensions { get; } = { "qoi" }; + public static string[] FileExtensions { get; } = ["qoi"]; } diff --git a/src/ImageSharp/Formats/Tga/TgaConstants.cs b/src/ImageSharp/Formats/Tga/TgaConstants.cs index ac7d83798..c4663ac09 100644 --- a/src/ImageSharp/Formats/Tga/TgaConstants.cs +++ b/src/ImageSharp/Formats/Tga/TgaConstants.cs @@ -8,12 +8,12 @@ internal static class TgaConstants /// /// The list of mimetypes that equate to a targa file. /// - public static readonly IEnumerable MimeTypes = new[] { "image/x-tga", "image/x-targa" }; + public static readonly IEnumerable MimeTypes = ["image/x-tga", "image/x-targa"]; /// /// The list of file extensions that equate to a targa file. /// - public static readonly IEnumerable FileExtensions = new[] { "tga", "vda", "icb", "vst" }; + public static readonly IEnumerable FileExtensions = ["tga", "vda", "icb", "vst"]; /// /// The file header length of a tga image in bytes. diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs index 692e088d1..cffc96fcd 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs @@ -17,7 +17,7 @@ internal sealed class T6BitCompressor : TiffCcittCompressor /// Vertical codes from -3 to +3. /// private static readonly (uint Length, uint Code)[] VerticalCodes = - { + [ (7u, 3u), (6u, 3u), (3u, 3u), @@ -25,7 +25,7 @@ internal sealed class T6BitCompressor : TiffCcittCompressor (3u, 2u), (6u, 2u), (7u, 2u) - }; + ]; private IMemoryOwner referenceLineBuffer; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs index 4e04f9cf1..8e2227cba 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffCcittCompressor.cs @@ -17,9 +17,9 @@ internal abstract class TiffCcittCompressor : TiffBaseCompressor protected const uint BlackZeroRunTermCode = 0x37; private static readonly uint[] MakeupRunLength = - { + [ 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 1664, 1728, 1792, 1856, 1920, 1984, 2048, 2112, 2176, 2240, 2304, 2368, 2432, 2496, 2560 - }; + ]; private static readonly Dictionary WhiteLen4TermCodes = new() { diff --git a/src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs b/src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs index 114fc12b2..18c0f2e0d 100644 --- a/src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs +++ b/src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs @@ -73,7 +73,7 @@ internal class DirectoryReader private List ReadIfds(bool isBigTiff) { - List readers = new(); + List readers = []; while (this.nextIfdOffset != 0 && this.nextIfdOffset < (ulong)this.stream.Length) { EntryReader reader = new(this.stream, this.ByteOrder, this.allocator); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index d41749be6..744cba35f 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -17,18 +17,18 @@ internal class YCbCrConverter private readonly YCbCrToRgbConverter converter; private static readonly Rational[] DefaultLuma = - { + [ new(299, 1000), new(587, 1000), new(114, 1000) - }; + ]; private static readonly Rational[] DefaultReferenceBlackWhite = - { + [ new(0, 1), new(255, 1), new(128, 1), new(255, 1), new(128, 1), new(255, 1) - }; + ]; public YCbCrConverter(Rational[] referenceBlackAndWhite, Rational[] coefficients) { diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs index eeb4afebf..86c6b0c4a 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderEntriesCollector.cs @@ -16,7 +16,7 @@ internal class TiffEncoderEntriesCollector { private const string SoftwareValue = "ImageSharp"; - public List Entries { get; } = new(); + public List Entries { get; } = []; public void ProcessMetadata(Image image, bool skipMetadata) => new MetadataProcessor(this).Process(image, skipMetadata); diff --git a/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs b/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs index 3c2ad6084..f88083411 100644 --- a/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs +++ b/src/ImageSharp/Formats/Tiff/Writers/TiffStreamWriter.cs @@ -110,7 +110,7 @@ internal sealed class TiffStreamWriter : IDisposable if (value.Length % 4 != 0) { // No allocation occurs, refers directly to assembly's data segment. - ReadOnlySpan paddingBytes = new byte[4] { 0x00, 0x00, 0x00, 0x00 }; + ReadOnlySpan paddingBytes = [0x00, 0x00, 0x00, 0x00]; paddingBytes = paddingBytes[..(4 - (value.Length % 4))]; this.BaseStream.Write(paddingBytes); } diff --git a/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs b/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs index 6d3cab151..c7e145591 100644 --- a/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs +++ b/src/ImageSharp/Formats/Webp/BitReader/Vp8LBitReader.cs @@ -28,7 +28,7 @@ internal class Vp8LBitReader : BitReaderBase private const int Wbits = 32; private static readonly uint[] BitMask = - { + [ 0, 0x000001, 0x000003, 0x000007, 0x00000f, 0x00001f, 0x00003f, 0x00007f, 0x0000ff, @@ -36,7 +36,7 @@ internal class Vp8LBitReader : BitReaderBase 0x001fff, 0x003fff, 0x007fff, 0x00ffff, 0x01ffff, 0x03ffff, 0x07ffff, 0x0fffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff - }; + ]; /// /// Pre-fetched bits. diff --git a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs index 027d4f7ee..f15bf263f 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/HuffmanUtils.cs @@ -20,10 +20,10 @@ internal static class HuffmanUtils // Pre-reversed 4-bit values. private static readonly byte[] ReversedBits = - { + [ 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf - }; + ]; public static void CreateHuffmanTree(Span histogram, int treeDepthLimit, bool[] bufRle, Span huffTree, HuffmanTreeCode huffCode) { diff --git a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs index 19dc08fc5..0e3b27491 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs @@ -12,9 +12,9 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless; internal static unsafe class PredictorEncoder { private static readonly sbyte[][] Offset = - { - new sbyte[] { 0, -1 }, new sbyte[] { 0, 1 }, new sbyte[] { -1, 0 }, new sbyte[] { 1, 0 }, new sbyte[] { -1, -1 }, new sbyte[] { -1, 1 }, new sbyte[] { 1, -1 }, new sbyte[] { 1, 1 } - }; + [ + [0, -1], [0, 1], [-1, 0], [1, 0], [-1, -1], [-1, 1], [1, -1], [1, 1] + ]; private const int GreenRedToBlueNumAxis = 8; @@ -29,7 +29,7 @@ internal static unsafe class PredictorEncoder private const int PredLowEffort = 11; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan DeltaLut => new sbyte[] { 16, 16, 8, 4, 2, 2, 2 }; + private static ReadOnlySpan DeltaLut => [16, 16, 8, 4, 2, 2, 2]; /// /// Finds the best predictor for each tile, and converts the image to residuals @@ -58,12 +58,12 @@ internal static unsafe class PredictorEncoder // TODO: Can we optimize this? int[][] histo = - { + [ new int[256], new int[256], new int[256], new int[256] - }; + ]; if (lowEffort) { diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs index 6de3ae749..875149b1b 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs @@ -49,7 +49,7 @@ internal sealed class WebpLosslessDecoder private const int FixedTableSize = (630 * 3) + 410; private static readonly int[] TableSize = - { + [ FixedTableSize + 654, FixedTableSize + 656, FixedTableSize + 658, @@ -62,7 +62,7 @@ internal sealed class WebpLosslessDecoder FixedTableSize + 1168, FixedTableSize + 1680, FixedTableSize + 2704 - }; + ]; private static readonly int NumCodeLengthCodes = CodeLengthCodeOrder.Length; @@ -80,10 +80,11 @@ internal sealed class WebpLosslessDecoder } // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan CodeLengthCodeOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + private static ReadOnlySpan CodeLengthCodeOrder => [17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan LiteralMap => new byte[] { 0, 1, 1, 1, 0 }; + private static ReadOnlySpan LiteralMap => [0, 1, 1, 1, 0]; /// /// Decodes the lossless webp image from the stream. diff --git a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs index ed1ed52ab..ab83e1641 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy; /// internal static unsafe class QuantEnc { - private static readonly ushort[] WeightY = { 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2 }; + private static readonly ushort[] WeightY = [38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2]; private const int MaxLevel = 2047; @@ -26,7 +26,7 @@ internal static unsafe class QuantEnc private const int DSCALE = 1; // storage descaling, needed to make the error fit byte // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan Zigzag => new byte[] { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 }; + private static ReadOnlySpan Zigzag => [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15]; public static void PickBestIntra16(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8SegmentInfo[] segmentInfos, Vp8EncProba proba) { diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs index a7c96edb7..fa68144fb 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8EncIterator.cs @@ -36,12 +36,12 @@ internal class Vp8EncIterator /// Array to record the position of the top sample to pass to the prediction functions. /// private readonly byte[] vp8TopLeftI4 = - { + [ 17, 21, 25, 29, 13, 17, 21, 25, 9, 13, 17, 21, 5, 9, 13, 17 - }; + ]; private int currentMbIdx; diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs index e4ebe1473..85739a3e2 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoder.cs @@ -196,7 +196,7 @@ internal class Vp8Encoder : IDisposable } // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan AverageBytesPerMb => new byte[] { 50, 24, 16, 9, 7, 5, 3, 2 }; + private static ReadOnlySpan AverageBytesPerMb => [50, 24, 16, 9, 7, 5, 3, 2]; public int BaseQuant { get; set; } diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs index 7fe71588c..9085c0929 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Encoding.cs @@ -37,9 +37,9 @@ internal static unsafe class Vp8Encoding private const int C8HE8 = C8VE8 + (1 * 16); - public static readonly int[] Vp8I16ModeOffsets = { I16DC16, I16TM16, I16VE16, I16HE16 }; + public static readonly int[] Vp8I16ModeOffsets = [I16DC16, I16TM16, I16VE16, I16HE16]; - public static readonly int[] Vp8UvModeOffsets = { C8DC8, C8TM8, C8VE8, C8HE8 }; + public static readonly int[] Vp8UvModeOffsets = [C8DC8, C8TM8, C8VE8, C8HE8]; private const int I4DC4 = (3 * 16 * WebpConstants.Bps) + 0; @@ -61,7 +61,8 @@ internal static unsafe class Vp8Encoding private const int I4HU4 = I4HD4 + 4; - public static readonly int[] Vp8I4ModeOffsets = { I4DC4, I4TM4, I4VE4, I4HE4, I4RD4, I4VR4, I4LD4, I4VL4, I4HD4, I4HU4 }; + public static readonly int[] Vp8I4ModeOffsets = [I4DC4, I4TM4, I4VE4, I4HE4, I4RD4, I4VR4, I4LD4, I4VL4, I4HD4, I4HU4 + ]; private static byte[] GetClip1() { diff --git a/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs b/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs index 7ba15a6d6..5cd8812c9 100644 --- a/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs +++ b/src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs @@ -5,13 +5,13 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy; internal unsafe struct Vp8Matrix { + // [luma-ac,luma-dc,chroma][dc,ac] private static readonly int[][] BiasMatrices = - { - // [luma-ac,luma-dc,chroma][dc,ac] - new[] { 96, 110 }, - new[] { 96, 108 }, - new[] { 110, 115 } - }; + [ + [96, 110], + [96, 108], + [110, 115] + ]; /// /// Number of descaling bits for sharpening bias. @@ -46,7 +46,7 @@ internal unsafe struct Vp8Matrix // Sharpening by (slightly) raising the hi-frequency coeffs. // Hack-ish but helpful for mid-bitrate range. Use with care. // This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs. - private static ReadOnlySpan FreqSharpening => new byte[] { 0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90 }; + private static ReadOnlySpan FreqSharpening => [0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90]; /// /// Returns the average quantizer. diff --git a/src/ImageSharp/Formats/Webp/WebpConstants.cs b/src/ImageSharp/Formats/Webp/WebpConstants.cs index 818c843ea..f489899c6 100644 --- a/src/ImageSharp/Formats/Webp/WebpConstants.cs +++ b/src/ImageSharp/Formats/Webp/WebpConstants.cs @@ -11,22 +11,22 @@ internal static class WebpConstants /// /// The list of file extensions that equate to Webp. /// - public static readonly IEnumerable FileExtensions = new[] { "webp" }; + public static readonly IEnumerable FileExtensions = ["webp"]; /// /// The list of mimetypes that equate to a jpeg. /// - public static readonly IEnumerable MimeTypes = new[] { "image/webp", }; + public static readonly IEnumerable MimeTypes = ["image/webp"]; /// /// Signature which identifies a VP8 header. /// public static readonly byte[] Vp8HeaderMagicBytes = - { + [ 0x9D, 0x01, 0x2A - }; + ]; /// /// Signature byte which identifies a VP8L header. @@ -37,23 +37,23 @@ internal static class WebpConstants /// The header bytes identifying RIFF file. /// public static readonly byte[] RiffFourCc = - { + [ 0x52, // R 0x49, // I 0x46, // F 0x46 // F - }; + ]; /// /// The header bytes identifying a Webp. /// public static readonly byte[] WebpHeader = - { + [ 0x57, // W 0x45, // E 0x42, // B 0x50 // P - }; + ]; /// /// The header bytes identifying a Webp. @@ -164,16 +164,16 @@ internal static class WebpConstants public const int CodeLengthRepeatCode = 16; - public static readonly int[] CodeLengthExtraBits = { 2, 3, 7 }; + public static readonly int[] CodeLengthExtraBits = [2, 3, 7]; - public static readonly int[] CodeLengthRepeatOffsets = { 3, 3, 11 }; + public static readonly int[] CodeLengthRepeatOffsets = [3, 3, 11]; public static readonly int[] AlphabetSize = - { + [ NumLiteralCodes + NumLengthCodes, NumLiteralCodes, NumLiteralCodes, NumLiteralCodes, NumDistanceCodes - }; + ]; public const int NumMbSegments = 4; @@ -270,9 +270,9 @@ internal static class WebpConstants /// public const int Vp8MaxPartition0Size = 1 << 19; - public static readonly short[] Vp8FixedCostsUv = { 302, 984, 439, 642 }; + public static readonly short[] Vp8FixedCostsUv = [302, 984, 439, 642]; - public static readonly short[] Vp8FixedCostsI16 = { 663, 919, 872, 919 }; + public static readonly short[] Vp8FixedCostsI16 = [663, 919, 872, 919]; /// /// Distortion multiplier (equivalent of lambda). @@ -284,31 +284,31 @@ internal static class WebpConstants /// Simple filter(1): up to 2 luma samples are read and 1 is written. /// Complex filter(2): up to 4 luma samples are read and 3 are written. Same for U/V, so it's 8 samples total (because of the 2x upsampling). /// - public static readonly byte[] FilterExtraRows = { 0, 2, 8 }; + public static readonly byte[] FilterExtraRows = [0, 2, 8]; // Paragraph 9.9 public static readonly int[] Vp8EncBands = - { + [ 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0 - }; + ]; public static readonly short[] Scan = - { + [ 0 + (0 * Bps), 4 + (0 * Bps), 8 + (0 * Bps), 12 + (0 * Bps), 0 + (4 * Bps), 4 + (4 * Bps), 8 + (4 * Bps), 12 + (4 * Bps), 0 + (8 * Bps), 4 + (8 * Bps), 8 + (8 * Bps), 12 + (8 * Bps), 0 + (12 * Bps), 4 + (12 * Bps), 8 + (12 * Bps), 12 + (12 * Bps) - }; + ]; // Residual decoding (Paragraph 13.2 / 13.3) - public static readonly byte[] Cat3 = { 173, 148, 140 }; - public static readonly byte[] Cat4 = { 176, 155, 140, 135 }; - public static readonly byte[] Cat5 = { 180, 157, 141, 134, 130 }; - public static readonly byte[] Cat6 = { 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129 }; - public static readonly byte[] Zigzag = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 }; + public static readonly byte[] Cat3 = [173, 148, 140]; + public static readonly byte[] Cat4 = [176, 155, 140, 135]; + public static readonly byte[] Cat5 = [180, 157, 141, 134, 130]; + public static readonly byte[] Cat6 = [254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129]; + public static readonly byte[] Zigzag = [0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15]; public static readonly sbyte[] YModesIntra4 = - { + [ -0, 1, -1, 2, -2, 3, @@ -318,5 +318,5 @@ internal static class WebpConstants -6, 7, -7, 8, -8, -9 - }; + ]; } diff --git a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs index a69bcfd00..64c97f7d8 100644 --- a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs +++ b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs @@ -19,7 +19,8 @@ internal static class WebpLookupTables // Compute susceptibility based on DCT-coeff histograms: // the higher, the "easier" the macroblock is to compress. public static readonly int[] Vp8DspScan = - { + [ + // Luma 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps), @@ -28,22 +29,23 @@ internal static class WebpLookupTables 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), // U 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps) // V - }; + ]; public static readonly short[] Vp8Scan = - { + [ + // Luma 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps), 0 + (8 * WebpConstants.Bps), 4 + (8 * WebpConstants.Bps), 8 + (8 * WebpConstants.Bps), 12 + (8 * WebpConstants.Bps), - 0 + (12 * WebpConstants.Bps), 4 + (12 * WebpConstants.Bps), 8 + (12 * WebpConstants.Bps), 12 + (12 * WebpConstants.Bps), - }; + 0 + (12 * WebpConstants.Bps), 4 + (12 * WebpConstants.Bps), 8 + (12 * WebpConstants.Bps), 12 + (12 * WebpConstants.Bps) + ]; public static readonly short[] Vp8ScanUv = - { + [ 0 + (0 * WebpConstants.Bps), 4 + (0 * WebpConstants.Bps), 0 + (4 * WebpConstants.Bps), 4 + (4 * WebpConstants.Bps), // U 8 + (0 * WebpConstants.Bps), 12 + (0 * WebpConstants.Bps), 8 + (4 * WebpConstants.Bps), 12 + (4 * WebpConstants.Bps) // V - }; + ]; [MethodImpl(InliningOptions.ShortMethod)] public static byte Abs0(int x) => Abs0Table[x + 255]; @@ -60,7 +62,7 @@ internal static class WebpLookupTables // fixed costs for coding levels, deduce from the coding tree. // This is only the part that doesn't depend on the probability state. public static readonly short[] Vp8LevelFixedCosts = - { + [ 0, 256, 256, 256, 256, 432, 618, 630, 731, 640, 640, 828, 901, 948, 1021, 1101, 1174, 1221, 1294, 1042, 1085, 1115, 1158, 1202, 1245, 1275, 1318, 1337, 1380, 1410, 1453, 1497, 1540, 1570, 1613, 1280, 1295, 1317, 1332, 1358, 1373, 1395, 1410, 1454, 1469, 1491, 1506, 1532, 1547, 1569, 1584, 1601, 1616, 1638, @@ -182,7 +184,7 @@ internal static class WebpLookupTables 7403, 7409, 7429, 7435, 7444, 7450, 7461, 7467, 7476, 7482, 7505, 7511, 7520, 7526, 7537, 7543, 7552, 7558, 7578, 7584, 7593, 7599, 7610, 7616, 7625, 7631, 7656, 7662, 7671, 7677, 7688, 7694, 7703, 7709, 7729, 7735, 7744, 7750, 7761 - }; + ]; // This table gives, for a given sharpness, the filtering strength to be // used (at least) in order to filter a given edge step delta. @@ -239,8 +241,9 @@ internal static class WebpLookupTables }; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan Norm => new byte[] - { + public static ReadOnlySpan Norm => + [ + // renorm_sizes[i] = 8 - log2(i) 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -251,11 +254,12 @@ internal static class WebpLookupTables 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan NewRange => new byte[] - { + public static ReadOnlySpan NewRange => + [ + // range = ((range + 1) << kVP8Log2Range[range]) - 1 127, 127, 191, 127, 159, 191, 223, 127, 143, 159, 175, 191, 207, 223, 239, 127, 135, 143, 151, 159, 167, 175, 183, 191, 199, 207, 215, 223, 231, 239, @@ -266,10 +270,10 @@ internal static class WebpLookupTables 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 127 - }; + ]; public static readonly ushort[] Vp8EntropyCost = - { + [ 1792, 1792, 1792, 1536, 1536, 1408, 1366, 1280, 1280, 1216, 1178, 1152, 1110, 1076, 1061, 1024, 1024, 992, 968, 951, 939, 911, 896, 878, 871, 854, 838, 820, 811, 794, @@ -296,35 +300,35 @@ internal static class WebpLookupTables 41, 40, 38, 36, 35, 33, 32, 30, 29, 27, 25, 24, 22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6, 4, 3 - }; + ]; public static readonly ushort[][] Vp8LevelCodes = - { - new ushort[] { 0x001, 0x000 }, new ushort[] { 0x007, 0x001 }, new ushort[] { 0x00f, 0x005 }, - new ushort[] { 0x00f, 0x00d }, new ushort[] { 0x033, 0x003 }, new ushort[] { 0x033, 0x003 }, new ushort[] { 0x033, 0x023 }, - new ushort[] { 0x033, 0x023 }, new ushort[] { 0x033, 0x023 }, new ushort[] { 0x033, 0x023 }, new ushort[] { 0x0d3, 0x013 }, - new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, - new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x013 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, - new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x0d3, 0x093 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, - new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x053 }, new ushort[] { 0x153, 0x153 }, - }; + [ + [0x001, 0x000], [0x007, 0x001], [0x00f, 0x005], + [0x00f, 0x00d], [0x033, 0x003], [0x033, 0x003], [0x033, 0x023], + [0x033, 0x023], [0x033, 0x023], [0x033, 0x023], [0x0d3, 0x013], + [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], + [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x013], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], + [0x0d3, 0x093], [0x0d3, 0x093], [0x0d3, 0x093], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], + [0x153, 0x053], [0x153, 0x053], [0x153, 0x053], [0x153, 0x153] + ]; /// /// Lookup table for small values of log2(int). /// public static readonly float[] Log2Table = - { - 0.0000000000000000f, 0.0000000000000000f, + [ + 0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, 1.5849625007211560f, 2.0000000000000000f, 2.3219280948873621f, 2.5849625007211560f, 2.8073549220576041f, @@ -452,11 +456,11 @@ internal static class WebpLookupTables 7.9657842846620869f, 7.9715435539507719f, 7.9772799234999167f, 7.9829935746943103f, 7.9886846867721654f, 7.9943534368588577f - }; + ]; public static readonly float[] SLog2Table = - { - 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f, + [ + 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f, 8.00000000f, 11.60964047f, 15.50977500f, 19.65148445f, 24.00000000f, 28.52932501f, 33.21928095f, 38.05374781f, 43.01955001f, 48.10571634f, 53.30296891f, 58.60335893f, @@ -520,10 +524,10 @@ internal static class WebpLookupTables 1935.09991037f, 1944.47629506f, 1953.85856831f, 1963.24670620f, 1972.64068498f, 1982.04048108f, 1991.44607117f, 2000.85743204f, 2010.27454072f, 2019.69737440f, 2029.12591044f, 2038.56012640f - }; + ]; public static readonly int[] CodeToPlane = - { + [ 0x18, 0x07, 0x17, 0x19, 0x28, 0x06, 0x27, 0x29, 0x16, 0x1a, 0x26, 0x2a, 0x38, 0x05, 0x37, 0x39, 0x15, 0x1b, 0x36, 0x3a, 0x25, 0x2b, 0x48, 0x04, 0x47, 0x49, 0x14, 0x1c, 0x35, 0x3b, @@ -536,10 +540,10 @@ internal static class WebpLookupTables 0x31, 0x3f, 0x63, 0x6d, 0x52, 0x5e, 0x00, 0x74, 0x7c, 0x41, 0x4f, 0x10, 0x20, 0x62, 0x6e, 0x30, 0x73, 0x7d, 0x51, 0x5f, 0x40, 0x72, 0x7e, 0x61, 0x6f, 0x50, 0x71, 0x7f, 0x60, 0x70 - }; + ]; public static readonly uint[] PlaneToCodeLut = - { + [ 96, 73, 55, 39, 23, 13, 5, 1, 255, 255, 255, 255, 255, 255, 255, 255, 101, 78, 58, 42, 26, 16, 8, 2, 0, 3, 9, 17, 27, 43, 59, 79, 102, 86, 62, 46, 32, 20, 10, 6, 4, 7, 11, 21, 33, 47, 63, 87, @@ -548,11 +552,11 @@ internal static class WebpLookupTables 115, 108, 94, 76, 64, 50, 44, 40, 34, 41, 45, 51, 65, 77, 95, 109, 118, 113, 103, 92, 80, 68, 60, 56, 54, 57, 61, 69, 81, 93, 104, 114, 119, 116, 111, 106, 97, 88, 84, 74, 72, 75, 85, 89, 98, 107, 112, 117 - }; + ]; // 31 ^ clz(i) - public static ReadOnlySpan LogTable8Bit => new byte[] - { + public static ReadOnlySpan LogTable8Bit => + [ 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -569,12 +573,12 @@ internal static class WebpLookupTables 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 - }; + ]; // Paragraph 14.1 // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan DcTable => new byte[] - { + public static ReadOnlySpan DcTable => + [ 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 21, 22, 22, @@ -591,11 +595,11 @@ internal static class WebpLookupTables 104, 106, 108, 110, 112, 114, 116, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157 - }; + ]; // Paragraph 14.1 public static readonly ushort[] AcTable = - { + [ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, @@ -612,10 +616,10 @@ internal static class WebpLookupTables 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284 - }; + ]; public static readonly ushort[] AcTable2 = - { + [ 8, 8, 9, 10, 12, 13, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 31, 32, 34, 35, 37, 38, 40, 41, @@ -632,7 +636,7 @@ internal static class WebpLookupTables 280, 286, 292, 299, 305, 311, 317, 323, 330, 336, 342, 348, 354, 362, 370, 379, 385, 393, 401, 409, 416, 424, 432, 440 - }; + ]; // Paragraph 13 public static readonly byte[,,,] CoeffsUpdateProba = @@ -981,7 +985,7 @@ internal static class WebpLookupTables }; public static readonly (int Code, int ExtraBits)[] PrefixEncodeCode = - { + [ (0, 0), (0, 0), (1, 0), (2, 0), (3, 0), (4, 1), (4, 1), (5, 1), (5, 1), (6, 2), (6, 2), (6, 2), (6, 2), (7, 2), (7, 2), (7, 2), (7, 2), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), (8, 3), @@ -1045,13 +1049,13 @@ internal static class WebpLookupTables (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), - (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), - }; + (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7), (17, 7) + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - public static ReadOnlySpan PrefixEncodeExtraBitsValue => new byte[] - { - 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, + public static ReadOnlySpan PrefixEncodeExtraBitsValue => + [ + 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -1084,7 +1088,7 @@ internal static class WebpLookupTables 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126 - }; + ]; // Following table is (1 << AlphaFix) / a. The (v * InvAlpha[a]) >> AlphaFix // formula is then equal to v / a in most (99.6%) cases. Note that this table @@ -1094,7 +1098,7 @@ internal static class WebpLookupTables // with ai in [0..255] and pi in [0..1< Abs0Table => new byte[] - { + private static ReadOnlySpan Abs0Table => + [ 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xdf, 0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd9, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce, 0xcd, @@ -1278,11 +1282,11 @@ internal static class WebpLookupTables 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Clip1Table => new byte[] - { + private static ReadOnlySpan Clip1Table => + [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -1329,11 +1333,11 @@ internal static class WebpLookupTables 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Sclip1Table => new sbyte[] - { + private static ReadOnlySpan Sclip1Table => + [ -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, @@ -1441,11 +1445,11 @@ internal static class WebpLookupTables 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 - }; + ]; // This uses C#'s compiler optimization to refer to assembly's static data directly. - private static ReadOnlySpan Sclip2Table => new sbyte[] - { + private static ReadOnlySpan Sclip2Table => + [ -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, -16, @@ -1456,214 +1460,214 @@ internal static class WebpLookupTables 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15 - }; + ]; private static void InitializeModesProbabilities() { // Paragraph 11.5 - ModesProba[0, 0] = new byte[] { 231, 120, 48, 89, 115, 113, 120, 152, 112 }; - ModesProba[0, 1] = new byte[] { 152, 179, 64, 126, 170, 118, 46, 70, 95 }; - ModesProba[0, 2] = new byte[] { 175, 69, 143, 80, 85, 82, 72, 155, 103 }; - ModesProba[0, 3] = new byte[] { 56, 58, 10, 171, 218, 189, 17, 13, 152 }; - ModesProba[0, 4] = new byte[] { 114, 26, 17, 163, 44, 195, 21, 10, 173 }; - ModesProba[0, 5] = new byte[] { 121, 24, 80, 195, 26, 62, 44, 64, 85 }; - ModesProba[0, 6] = new byte[] { 144, 71, 10, 38, 171, 213, 144, 34, 26 }; - ModesProba[0, 7] = new byte[] { 170, 46, 55, 19, 136, 160, 33, 206, 71 }; - ModesProba[0, 8] = new byte[] { 63, 20, 8, 114, 114, 208, 12, 9, 226 }; - ModesProba[0, 9] = new byte[] { 81, 40, 11, 96, 182, 84, 29, 16, 36 }; - ModesProba[1, 0] = new byte[] { 134, 183, 89, 137, 98, 101, 106, 165, 148 }; - ModesProba[1, 1] = new byte[] { 72, 187, 100, 130, 157, 111, 32, 75, 80 }; - ModesProba[1, 2] = new byte[] { 66, 102, 167, 99, 74, 62, 40, 234, 128 }; - ModesProba[1, 3] = new byte[] { 41, 53, 9, 178, 241, 141, 26, 8, 107 }; - ModesProba[1, 4] = new byte[] { 74, 43, 26, 146, 73, 166, 49, 23, 157 }; - ModesProba[1, 5] = new byte[] { 65, 38, 105, 160, 51, 52, 31, 115, 128 }; - ModesProba[1, 6] = new byte[] { 104, 79, 12, 27, 217, 255, 87, 17, 7 }; - ModesProba[1, 7] = new byte[] { 87, 68, 71, 44, 114, 51, 15, 186, 23 }; - ModesProba[1, 8] = new byte[] { 47, 41, 14, 110, 182, 183, 21, 17, 194 }; - ModesProba[1, 9] = new byte[] { 66, 45, 25, 102, 197, 189, 23, 18, 22 }; - ModesProba[2, 0] = new byte[] { 88, 88, 147, 150, 42, 46, 45, 196, 205 }; - ModesProba[2, 1] = new byte[] { 43, 97, 183, 117, 85, 38, 35, 179, 61 }; - ModesProba[2, 2] = new byte[] { 39, 53, 200, 87, 26, 21, 43, 232, 171 }; - ModesProba[2, 3] = new byte[] { 56, 34, 51, 104, 114, 102, 29, 93, 77 }; - ModesProba[2, 4] = new byte[] { 39, 28, 85, 171, 58, 165, 90, 98, 64 }; - ModesProba[2, 5] = new byte[] { 34, 22, 116, 206, 23, 34, 43, 166, 73 }; - ModesProba[2, 6] = new byte[] { 107, 54, 32, 26, 51, 1, 81, 43, 31 }; - ModesProba[2, 7] = new byte[] { 68, 25, 106, 22, 64, 171, 36, 225, 114 }; - ModesProba[2, 8] = new byte[] { 34, 19, 21, 102, 132, 188, 16, 76, 124 }; - ModesProba[2, 9] = new byte[] { 62, 18, 78, 95, 85, 57, 50, 48, 51 }; - ModesProba[3, 0] = new byte[] { 193, 101, 35, 159, 215, 111, 89, 46, 111 }; - ModesProba[3, 1] = new byte[] { 60, 148, 31, 172, 219, 228, 21, 18, 111 }; - ModesProba[3, 2] = new byte[] { 112, 113, 77, 85, 179, 255, 38, 120, 114 }; - ModesProba[3, 3] = new byte[] { 40, 42, 1, 196, 245, 209, 10, 25, 109 }; - ModesProba[3, 4] = new byte[] { 88, 43, 29, 140, 166, 213, 37, 43, 154 }; - ModesProba[3, 5] = new byte[] { 61, 63, 30, 155, 67, 45, 68, 1, 209 }; - ModesProba[3, 6] = new byte[] { 100, 80, 8, 43, 154, 1, 51, 26, 71 }; - ModesProba[3, 7] = new byte[] { 142, 78, 78, 16, 255, 128, 34, 197, 171 }; - ModesProba[3, 8] = new byte[] { 41, 40, 5, 102, 211, 183, 4, 1, 221 }; - ModesProba[3, 9] = new byte[] { 51, 50, 17, 168, 209, 192, 23, 25, 82 }; - ModesProba[4, 0] = new byte[] { 138, 31, 36, 171, 27, 166, 38, 44, 229 }; - ModesProba[4, 1] = new byte[] { 67, 87, 58, 169, 82, 115, 26, 59, 179 }; - ModesProba[4, 2] = new byte[] { 63, 59, 90, 180, 59, 166, 93, 73, 154 }; - ModesProba[4, 3] = new byte[] { 40, 40, 21, 116, 143, 209, 34, 39, 175 }; - ModesProba[4, 4] = new byte[] { 47, 15, 16, 183, 34, 223, 49, 45, 183 }; - ModesProba[4, 5] = new byte[] { 46, 17, 33, 183, 6, 98, 15, 32, 183 }; - ModesProba[4, 6] = new byte[] { 57, 46, 22, 24, 128, 1, 54, 17, 37 }; - ModesProba[4, 7] = new byte[] { 65, 32, 73, 115, 28, 128, 23, 128, 205 }; - ModesProba[4, 8] = new byte[] { 40, 3, 9, 115, 51, 192, 18, 6, 223 }; - ModesProba[4, 9] = new byte[] { 87, 37, 9, 115, 59, 77, 64, 21, 47 }; - ModesProba[5, 0] = new byte[] { 104, 55, 44, 218, 9, 54, 53, 130, 226 }; - ModesProba[5, 1] = new byte[] { 64, 90, 70, 205, 40, 41, 23, 26, 57 }; - ModesProba[5, 2] = new byte[] { 54, 57, 112, 184, 5, 41, 38, 166, 213 }; - ModesProba[5, 3] = new byte[] { 30, 34, 26, 133, 152, 116, 10, 32, 134 }; - ModesProba[5, 4] = new byte[] { 39, 19, 53, 221, 26, 114, 32, 73, 255 }; - ModesProba[5, 5] = new byte[] { 31, 9, 65, 234, 2, 15, 1, 118, 73 }; - ModesProba[5, 6] = new byte[] { 75, 32, 12, 51, 192, 255, 160, 43, 51 }; - ModesProba[5, 7] = new byte[] { 88, 31, 35, 67, 102, 85, 55, 186, 85 }; - ModesProba[5, 8] = new byte[] { 56, 21, 23, 111, 59, 205, 45, 37, 192 }; - ModesProba[5, 9] = new byte[] { 55, 38, 70, 124, 73, 102, 1, 34, 98 }; - ModesProba[6, 0] = new byte[] { 125, 98, 42, 88, 104, 85, 117, 175, 82 }; - ModesProba[6, 1] = new byte[] { 95, 84, 53, 89, 128, 100, 113, 101, 45 }; - ModesProba[6, 2] = new byte[] { 75, 79, 123, 47, 51, 128, 81, 171, 1 }; - ModesProba[6, 3] = new byte[] { 57, 17, 5, 71, 102, 57, 53, 41, 49 }; - ModesProba[6, 4] = new byte[] { 38, 33, 13, 121, 57, 73, 26, 1, 85 }; - ModesProba[6, 5] = new byte[] { 41, 10, 67, 138, 77, 110, 90, 47, 114 }; - ModesProba[6, 6] = new byte[] { 115, 21, 2, 10, 102, 255, 166, 23, 6 }; - ModesProba[6, 7] = new byte[] { 101, 29, 16, 10, 85, 128, 101, 196, 26 }; - ModesProba[6, 8] = new byte[] { 57, 18, 10, 102, 102, 213, 34, 20, 43 }; - ModesProba[6, 9] = new byte[] { 117, 20, 15, 36, 163, 128, 68, 1, 26 }; - ModesProba[7, 0] = new byte[] { 102, 61, 71, 37, 34, 53, 31, 243, 192 }; - ModesProba[7, 1] = new byte[] { 69, 60, 71, 38, 73, 119, 28, 222, 37 }; - ModesProba[7, 2] = new byte[] { 68, 45, 128, 34, 1, 47, 11, 245, 171 }; - ModesProba[7, 3] = new byte[] { 62, 17, 19, 70, 146, 85, 55, 62, 70 }; - ModesProba[7, 4] = new byte[] { 37, 43, 37, 154, 100, 163, 85, 160, 1 }; - ModesProba[7, 5] = new byte[] { 63, 9, 92, 136, 28, 64, 32, 201, 85 }; - ModesProba[7, 6] = new byte[] { 75, 15, 9, 9, 64, 255, 184, 119, 16 }; - ModesProba[7, 7] = new byte[] { 86, 6, 28, 5, 64, 255, 25, 248, 1 }; - ModesProba[7, 8] = new byte[] { 56, 8, 17, 132, 137, 255, 55, 116, 128 }; - ModesProba[7, 9] = new byte[] { 58, 15, 20, 82, 135, 57, 26, 121, 40 }; - ModesProba[8, 0] = new byte[] { 164, 50, 31, 137, 154, 133, 25, 35, 218 }; - ModesProba[8, 1] = new byte[] { 51, 103, 44, 131, 131, 123, 31, 6, 158 }; - ModesProba[8, 2] = new byte[] { 86, 40, 64, 135, 148, 224, 45, 183, 128 }; - ModesProba[8, 3] = new byte[] { 22, 26, 17, 131, 240, 154, 14, 1, 209 }; - ModesProba[8, 4] = new byte[] { 45, 16, 21, 91, 64, 222, 7, 1, 197 }; - ModesProba[8, 5] = new byte[] { 56, 21, 39, 155, 60, 138, 23, 102, 213 }; - ModesProba[8, 6] = new byte[] { 83, 12, 13, 54, 192, 255, 68, 47, 28 }; - ModesProba[8, 7] = new byte[] { 85, 26, 85, 85, 128, 128, 32, 146, 171 }; - ModesProba[8, 8] = new byte[] { 18, 11, 7, 63, 144, 171, 4, 4, 246 }; - ModesProba[8, 9] = new byte[] { 35, 27, 10, 146, 174, 171, 12, 26, 128 }; - ModesProba[9, 0] = new byte[] { 190, 80, 35, 99, 180, 80, 126, 54, 45 }; - ModesProba[9, 1] = new byte[] { 85, 126, 47, 87, 176, 51, 41, 20, 32 }; - ModesProba[9, 2] = new byte[] { 101, 75, 128, 139, 118, 146, 116, 128, 85 }; - ModesProba[9, 3] = new byte[] { 56, 41, 15, 176, 236, 85, 37, 9, 62 }; - ModesProba[9, 4] = new byte[] { 71, 30, 17, 119, 118, 255, 17, 18, 138 }; - ModesProba[9, 5] = new byte[] { 101, 38, 60, 138, 55, 70, 43, 26, 142 }; - ModesProba[9, 6] = new byte[] { 146, 36, 19, 30, 171, 255, 97, 27, 20 }; - ModesProba[9, 7] = new byte[] { 138, 45, 61, 62, 219, 1, 81, 188, 64 }; - ModesProba[9, 8] = new byte[] { 32, 41, 20, 117, 151, 142, 20, 21, 163 }; - ModesProba[9, 9] = new byte[] { 112, 19, 12, 61, 195, 128, 48, 4, 24 }; + ModesProba[0, 0] = [231, 120, 48, 89, 115, 113, 120, 152, 112]; + ModesProba[0, 1] = [152, 179, 64, 126, 170, 118, 46, 70, 95]; + ModesProba[0, 2] = [175, 69, 143, 80, 85, 82, 72, 155, 103]; + ModesProba[0, 3] = [56, 58, 10, 171, 218, 189, 17, 13, 152]; + ModesProba[0, 4] = [114, 26, 17, 163, 44, 195, 21, 10, 173]; + ModesProba[0, 5] = [121, 24, 80, 195, 26, 62, 44, 64, 85]; + ModesProba[0, 6] = [144, 71, 10, 38, 171, 213, 144, 34, 26]; + ModesProba[0, 7] = [170, 46, 55, 19, 136, 160, 33, 206, 71]; + ModesProba[0, 8] = [63, 20, 8, 114, 114, 208, 12, 9, 226]; + ModesProba[0, 9] = [81, 40, 11, 96, 182, 84, 29, 16, 36]; + ModesProba[1, 0] = [134, 183, 89, 137, 98, 101, 106, 165, 148]; + ModesProba[1, 1] = [72, 187, 100, 130, 157, 111, 32, 75, 80]; + ModesProba[1, 2] = [66, 102, 167, 99, 74, 62, 40, 234, 128]; + ModesProba[1, 3] = [41, 53, 9, 178, 241, 141, 26, 8, 107]; + ModesProba[1, 4] = [74, 43, 26, 146, 73, 166, 49, 23, 157]; + ModesProba[1, 5] = [65, 38, 105, 160, 51, 52, 31, 115, 128]; + ModesProba[1, 6] = [104, 79, 12, 27, 217, 255, 87, 17, 7]; + ModesProba[1, 7] = [87, 68, 71, 44, 114, 51, 15, 186, 23]; + ModesProba[1, 8] = [47, 41, 14, 110, 182, 183, 21, 17, 194]; + ModesProba[1, 9] = [66, 45, 25, 102, 197, 189, 23, 18, 22]; + ModesProba[2, 0] = [88, 88, 147, 150, 42, 46, 45, 196, 205]; + ModesProba[2, 1] = [43, 97, 183, 117, 85, 38, 35, 179, 61]; + ModesProba[2, 2] = [39, 53, 200, 87, 26, 21, 43, 232, 171]; + ModesProba[2, 3] = [56, 34, 51, 104, 114, 102, 29, 93, 77]; + ModesProba[2, 4] = [39, 28, 85, 171, 58, 165, 90, 98, 64]; + ModesProba[2, 5] = [34, 22, 116, 206, 23, 34, 43, 166, 73]; + ModesProba[2, 6] = [107, 54, 32, 26, 51, 1, 81, 43, 31]; + ModesProba[2, 7] = [68, 25, 106, 22, 64, 171, 36, 225, 114]; + ModesProba[2, 8] = [34, 19, 21, 102, 132, 188, 16, 76, 124]; + ModesProba[2, 9] = [62, 18, 78, 95, 85, 57, 50, 48, 51]; + ModesProba[3, 0] = [193, 101, 35, 159, 215, 111, 89, 46, 111]; + ModesProba[3, 1] = [60, 148, 31, 172, 219, 228, 21, 18, 111]; + ModesProba[3, 2] = [112, 113, 77, 85, 179, 255, 38, 120, 114]; + ModesProba[3, 3] = [40, 42, 1, 196, 245, 209, 10, 25, 109]; + ModesProba[3, 4] = [88, 43, 29, 140, 166, 213, 37, 43, 154]; + ModesProba[3, 5] = [61, 63, 30, 155, 67, 45, 68, 1, 209]; + ModesProba[3, 6] = [100, 80, 8, 43, 154, 1, 51, 26, 71]; + ModesProba[3, 7] = [142, 78, 78, 16, 255, 128, 34, 197, 171]; + ModesProba[3, 8] = [41, 40, 5, 102, 211, 183, 4, 1, 221]; + ModesProba[3, 9] = [51, 50, 17, 168, 209, 192, 23, 25, 82]; + ModesProba[4, 0] = [138, 31, 36, 171, 27, 166, 38, 44, 229]; + ModesProba[4, 1] = [67, 87, 58, 169, 82, 115, 26, 59, 179]; + ModesProba[4, 2] = [63, 59, 90, 180, 59, 166, 93, 73, 154]; + ModesProba[4, 3] = [40, 40, 21, 116, 143, 209, 34, 39, 175]; + ModesProba[4, 4] = [47, 15, 16, 183, 34, 223, 49, 45, 183]; + ModesProba[4, 5] = [46, 17, 33, 183, 6, 98, 15, 32, 183]; + ModesProba[4, 6] = [57, 46, 22, 24, 128, 1, 54, 17, 37]; + ModesProba[4, 7] = [65, 32, 73, 115, 28, 128, 23, 128, 205]; + ModesProba[4, 8] = [40, 3, 9, 115, 51, 192, 18, 6, 223]; + ModesProba[4, 9] = [87, 37, 9, 115, 59, 77, 64, 21, 47]; + ModesProba[5, 0] = [104, 55, 44, 218, 9, 54, 53, 130, 226]; + ModesProba[5, 1] = [64, 90, 70, 205, 40, 41, 23, 26, 57]; + ModesProba[5, 2] = [54, 57, 112, 184, 5, 41, 38, 166, 213]; + ModesProba[5, 3] = [30, 34, 26, 133, 152, 116, 10, 32, 134]; + ModesProba[5, 4] = [39, 19, 53, 221, 26, 114, 32, 73, 255]; + ModesProba[5, 5] = [31, 9, 65, 234, 2, 15, 1, 118, 73]; + ModesProba[5, 6] = [75, 32, 12, 51, 192, 255, 160, 43, 51]; + ModesProba[5, 7] = [88, 31, 35, 67, 102, 85, 55, 186, 85]; + ModesProba[5, 8] = [56, 21, 23, 111, 59, 205, 45, 37, 192]; + ModesProba[5, 9] = [55, 38, 70, 124, 73, 102, 1, 34, 98]; + ModesProba[6, 0] = [125, 98, 42, 88, 104, 85, 117, 175, 82]; + ModesProba[6, 1] = [95, 84, 53, 89, 128, 100, 113, 101, 45]; + ModesProba[6, 2] = [75, 79, 123, 47, 51, 128, 81, 171, 1]; + ModesProba[6, 3] = [57, 17, 5, 71, 102, 57, 53, 41, 49]; + ModesProba[6, 4] = [38, 33, 13, 121, 57, 73, 26, 1, 85]; + ModesProba[6, 5] = [41, 10, 67, 138, 77, 110, 90, 47, 114]; + ModesProba[6, 6] = [115, 21, 2, 10, 102, 255, 166, 23, 6]; + ModesProba[6, 7] = [101, 29, 16, 10, 85, 128, 101, 196, 26]; + ModesProba[6, 8] = [57, 18, 10, 102, 102, 213, 34, 20, 43]; + ModesProba[6, 9] = [117, 20, 15, 36, 163, 128, 68, 1, 26]; + ModesProba[7, 0] = [102, 61, 71, 37, 34, 53, 31, 243, 192]; + ModesProba[7, 1] = [69, 60, 71, 38, 73, 119, 28, 222, 37]; + ModesProba[7, 2] = [68, 45, 128, 34, 1, 47, 11, 245, 171]; + ModesProba[7, 3] = [62, 17, 19, 70, 146, 85, 55, 62, 70]; + ModesProba[7, 4] = [37, 43, 37, 154, 100, 163, 85, 160, 1]; + ModesProba[7, 5] = [63, 9, 92, 136, 28, 64, 32, 201, 85]; + ModesProba[7, 6] = [75, 15, 9, 9, 64, 255, 184, 119, 16]; + ModesProba[7, 7] = [86, 6, 28, 5, 64, 255, 25, 248, 1]; + ModesProba[7, 8] = [56, 8, 17, 132, 137, 255, 55, 116, 128]; + ModesProba[7, 9] = [58, 15, 20, 82, 135, 57, 26, 121, 40]; + ModesProba[8, 0] = [164, 50, 31, 137, 154, 133, 25, 35, 218]; + ModesProba[8, 1] = [51, 103, 44, 131, 131, 123, 31, 6, 158]; + ModesProba[8, 2] = [86, 40, 64, 135, 148, 224, 45, 183, 128]; + ModesProba[8, 3] = [22, 26, 17, 131, 240, 154, 14, 1, 209]; + ModesProba[8, 4] = [45, 16, 21, 91, 64, 222, 7, 1, 197]; + ModesProba[8, 5] = [56, 21, 39, 155, 60, 138, 23, 102, 213]; + ModesProba[8, 6] = [83, 12, 13, 54, 192, 255, 68, 47, 28]; + ModesProba[8, 7] = [85, 26, 85, 85, 128, 128, 32, 146, 171]; + ModesProba[8, 8] = [18, 11, 7, 63, 144, 171, 4, 4, 246]; + ModesProba[8, 9] = [35, 27, 10, 146, 174, 171, 12, 26, 128]; + ModesProba[9, 0] = [190, 80, 35, 99, 180, 80, 126, 54, 45]; + ModesProba[9, 1] = [85, 126, 47, 87, 176, 51, 41, 20, 32]; + ModesProba[9, 2] = [101, 75, 128, 139, 118, 146, 116, 128, 85]; + ModesProba[9, 3] = [56, 41, 15, 176, 236, 85, 37, 9, 62]; + ModesProba[9, 4] = [71, 30, 17, 119, 118, 255, 17, 18, 138]; + ModesProba[9, 5] = [101, 38, 60, 138, 55, 70, 43, 26, 142]; + ModesProba[9, 6] = [146, 36, 19, 30, 171, 255, 97, 27, 20]; + ModesProba[9, 7] = [138, 45, 61, 62, 219, 1, 81, 188, 64]; + ModesProba[9, 8] = [32, 41, 20, 117, 151, 142, 20, 21, 163]; + ModesProba[9, 9] = [112, 19, 12, 61, 195, 128, 48, 4, 24]; } private static void InitializeFixedCostsI4() { - Vp8FixedCostsI4[0, 0] = new short[] { 40, 1151, 1723, 1874, 2103, 2019, 1628, 1777, 2226, 2137 }; - Vp8FixedCostsI4[0, 1] = new short[] { 192, 469, 1296, 1308, 1849, 1794, 1781, 1703, 1713, 1522 }; - Vp8FixedCostsI4[0, 2] = new short[] { 142, 910, 762, 1684, 1849, 1576, 1460, 1305, 1801, 1657 }; - Vp8FixedCostsI4[0, 3] = new short[] { 559, 641, 1370, 421, 1182, 1569, 1612, 1725, 863, 1007 }; - Vp8FixedCostsI4[0, 4] = new short[] { 299, 1059, 1256, 1108, 636, 1068, 1581, 1883, 869, 1142 }; - Vp8FixedCostsI4[0, 5] = new short[] { 277, 1111, 707, 1362, 1089, 672, 1603, 1541, 1545, 1291 }; - Vp8FixedCostsI4[0, 6] = new short[] { 214, 781, 1609, 1303, 1632, 2229, 726, 1560, 1713, 918 }; - Vp8FixedCostsI4[0, 7] = new short[] { 152, 1037, 1046, 1759, 1983, 2174, 1358, 742, 1740, 1390 }; - Vp8FixedCostsI4[0, 8] = new short[] { 512, 1046, 1420, 753, 752, 1297, 1486, 1613, 460, 1207 }; - Vp8FixedCostsI4[0, 9] = new short[] { 424, 827, 1362, 719, 1462, 1202, 1199, 1476, 1199, 538 }; - Vp8FixedCostsI4[1, 0] = new short[] { 240, 402, 1134, 1491, 1659, 1505, 1517, 1555, 1979, 2099 }; - Vp8FixedCostsI4[1, 1] = new short[] { 467, 242, 960, 1232, 1714, 1620, 1834, 1570, 1676, 1391 }; - Vp8FixedCostsI4[1, 2] = new short[] { 500, 455, 463, 1507, 1699, 1282, 1564, 982, 2114, 2114 }; - Vp8FixedCostsI4[1, 3] = new short[] { 672, 643, 1372, 331, 1589, 1667, 1453, 1938, 996, 876 }; - Vp8FixedCostsI4[1, 4] = new short[] { 458, 783, 1037, 911, 738, 968, 1165, 1518, 859, 1033 }; - Vp8FixedCostsI4[1, 5] = new short[] { 504, 815, 504, 1139, 1219, 719, 1506, 1085, 1268, 1268 }; - Vp8FixedCostsI4[1, 6] = new short[] { 333, 630, 1445, 1239, 1883, 3672, 799, 1548, 1865, 598 }; - Vp8FixedCostsI4[1, 7] = new short[] { 399, 644, 746, 1342, 1856, 1350, 1493, 613, 1855, 1015 }; - Vp8FixedCostsI4[1, 8] = new short[] { 622, 749, 1205, 608, 1066, 1408, 1290, 1406, 546, 971 }; - Vp8FixedCostsI4[1, 9] = new short[] { 500, 753, 1041, 668, 1230, 1617, 1297, 1425, 1383, 523 }; - Vp8FixedCostsI4[2, 0] = new short[] { 394, 553, 523, 1502, 1536, 981, 1608, 1142, 1666, 2181 }; - Vp8FixedCostsI4[2, 1] = new short[] { 655, 430, 375, 1411, 1861, 1220, 1677, 1135, 1978, 1553 }; - Vp8FixedCostsI4[2, 2] = new short[] { 690, 640, 245, 1954, 2070, 1194, 1528, 982, 1972, 2232 }; - Vp8FixedCostsI4[2, 3] = new short[] { 559, 834, 741, 867, 1131, 980, 1225, 852, 1092, 784 }; - Vp8FixedCostsI4[2, 4] = new short[] { 690, 875, 516, 959, 673, 894, 1056, 1190, 1528, 1126 }; - Vp8FixedCostsI4[2, 5] = new short[] { 740, 951, 384, 1277, 1177, 492, 1579, 1155, 1846, 1513 }; - Vp8FixedCostsI4[2, 6] = new short[] { 323, 775, 1062, 1776, 3062, 1274, 813, 1188, 1372, 655 }; - Vp8FixedCostsI4[2, 7] = new short[] { 488, 971, 484, 1767, 1515, 1775, 1115, 503, 1539, 1461 }; - Vp8FixedCostsI4[2, 8] = new short[] { 740, 1006, 998, 709, 851, 1230, 1337, 788, 741, 721 }; - Vp8FixedCostsI4[2, 9] = new short[] { 522, 1073, 573, 1045, 1346, 887, 1046, 1146, 1203, 697 }; - Vp8FixedCostsI4[3, 0] = new short[] { 105, 864, 1442, 1009, 1934, 1840, 1519, 1920, 1673, 1579 }; - Vp8FixedCostsI4[3, 1] = new short[] { 534, 305, 1193, 683, 1388, 2164, 1802, 1894, 1264, 1170 }; - Vp8FixedCostsI4[3, 2] = new short[] { 305, 518, 877, 1108, 1426, 3215, 1425, 1064, 1320, 1242 }; - Vp8FixedCostsI4[3, 3] = new short[] { 683, 732, 1927, 257, 1493, 2048, 1858, 1552, 1055, 947 }; - Vp8FixedCostsI4[3, 4] = new short[] { 394, 814, 1024, 660, 959, 1556, 1282, 1289, 893, 1047 }; - Vp8FixedCostsI4[3, 5] = new short[] { 528, 615, 996, 940, 1201, 635, 1094, 2515, 803, 1358 }; - Vp8FixedCostsI4[3, 6] = new short[] { 347, 614, 1609, 1187, 3133, 1345, 1007, 1339, 1017, 667 }; - Vp8FixedCostsI4[3, 7] = new short[] { 218, 740, 878, 1605, 3650, 3650, 1345, 758, 1357, 1617 }; - Vp8FixedCostsI4[3, 8] = new short[] { 672, 750, 1541, 558, 1257, 1599, 1870, 2135, 402, 1087 }; - Vp8FixedCostsI4[3, 9] = new short[] { 592, 684, 1161, 430, 1092, 1497, 1475, 1489, 1095, 822 }; - Vp8FixedCostsI4[4, 0] = new short[] { 228, 1056, 1059, 1368, 752, 982, 1512, 1518, 987, 1782 }; - Vp8FixedCostsI4[4, 1] = new short[] { 494, 514, 818, 942, 965, 892, 1610, 1356, 1048, 1363 }; - Vp8FixedCostsI4[4, 2] = new short[] { 512, 648, 591, 1042, 761, 991, 1196, 1454, 1309, 1463 }; - Vp8FixedCostsI4[4, 3] = new short[] { 683, 749, 1043, 676, 841, 1396, 1133, 1138, 654, 939 }; - Vp8FixedCostsI4[4, 4] = new short[] { 622, 1101, 1126, 994, 361, 1077, 1203, 1318, 877, 1219 }; - Vp8FixedCostsI4[4, 5] = new short[] { 631, 1068, 857, 1650, 651, 477, 1650, 1419, 828, 1170 }; - Vp8FixedCostsI4[4, 6] = new short[] { 555, 727, 1068, 1335, 3127, 1339, 820, 1331, 1077, 429 }; - Vp8FixedCostsI4[4, 7] = new short[] { 504, 879, 624, 1398, 889, 889, 1392, 808, 891, 1406 }; - Vp8FixedCostsI4[4, 8] = new short[] { 683, 1602, 1289, 977, 578, 983, 1280, 1708, 406, 1122 }; - Vp8FixedCostsI4[4, 9] = new short[] { 399, 865, 1433, 1070, 1072, 764, 968, 1477, 1223, 678 }; - Vp8FixedCostsI4[5, 0] = new short[] { 333, 760, 935, 1638, 1010, 529, 1646, 1410, 1472, 2219 }; - Vp8FixedCostsI4[5, 1] = new short[] { 512, 494, 750, 1160, 1215, 610, 1870, 1868, 1628, 1169 }; - Vp8FixedCostsI4[5, 2] = new short[] { 572, 646, 492, 1934, 1208, 603, 1580, 1099, 1398, 1995 }; - Vp8FixedCostsI4[5, 3] = new short[] { 786, 789, 942, 581, 1018, 951, 1599, 1207, 731, 768 }; - Vp8FixedCostsI4[5, 4] = new short[] { 690, 1015, 672, 1078, 582, 504, 1693, 1438, 1108, 2897 }; - Vp8FixedCostsI4[5, 5] = new short[] { 768, 1267, 571, 2005, 1243, 244, 2881, 1380, 1786, 1453 }; - Vp8FixedCostsI4[5, 6] = new short[] { 452, 899, 1293, 903, 1311, 3100, 465, 1311, 1319, 813 }; - Vp8FixedCostsI4[5, 7] = new short[] { 394, 927, 942, 1103, 1358, 1104, 946, 593, 1363, 1109 }; - Vp8FixedCostsI4[5, 8] = new short[] { 559, 1005, 1007, 1016, 658, 1173, 1021, 1164, 623, 1028 }; - Vp8FixedCostsI4[5, 9] = new short[] { 564, 796, 632, 1005, 1014, 863, 2316, 1268, 938, 764 }; - Vp8FixedCostsI4[6, 0] = new short[] { 266, 606, 1098, 1228, 1497, 1243, 948, 1030, 1734, 1461 }; - Vp8FixedCostsI4[6, 1] = new short[] { 366, 585, 901, 1060, 1407, 1247, 876, 1134, 1620, 1054 }; - Vp8FixedCostsI4[6, 2] = new short[] { 452, 565, 542, 1729, 1479, 1479, 1016, 886, 2938, 1150 }; - Vp8FixedCostsI4[6, 3] = new short[] { 555, 1088, 1533, 950, 1354, 895, 834, 1019, 1021, 496 }; - Vp8FixedCostsI4[6, 4] = new short[] { 704, 815, 1193, 971, 973, 640, 1217, 2214, 832, 578 }; - Vp8FixedCostsI4[6, 5] = new short[] { 672, 1245, 579, 871, 875, 774, 872, 1273, 1027, 949 }; - Vp8FixedCostsI4[6, 6] = new short[] { 296, 1134, 2050, 1784, 1636, 3425, 442, 1550, 2076, 722 }; - Vp8FixedCostsI4[6, 7] = new short[] { 342, 982, 1259, 1846, 1848, 1848, 622, 568, 1847, 1052 }; - Vp8FixedCostsI4[6, 8] = new short[] { 555, 1064, 1304, 828, 746, 1343, 1075, 1329, 1078, 494 }; - Vp8FixedCostsI4[6, 9] = new short[] { 288, 1167, 1285, 1174, 1639, 1639, 833, 2254, 1304, 509 }; - Vp8FixedCostsI4[7, 0] = new short[] { 342, 719, 767, 1866, 1757, 1270, 1246, 550, 1746, 2151 }; - Vp8FixedCostsI4[7, 1] = new short[] { 483, 653, 694, 1509, 1459, 1410, 1218, 507, 1914, 1266 }; - Vp8FixedCostsI4[7, 2] = new short[] { 488, 757, 447, 2979, 1813, 1268, 1654, 539, 1849, 2109 }; - Vp8FixedCostsI4[7, 3] = new short[] { 522, 1097, 1085, 851, 1365, 1111, 851, 901, 961, 605 }; - Vp8FixedCostsI4[7, 4] = new short[] { 709, 716, 841, 728, 736, 945, 941, 862, 2845, 1057 }; - Vp8FixedCostsI4[7, 5] = new short[] { 512, 1323, 500, 1336, 1083, 681, 1342, 717, 1604, 1350 }; - Vp8FixedCostsI4[7, 6] = new short[] { 452, 1155, 1372, 1900, 1501, 3290, 311, 944, 1919, 922 }; - Vp8FixedCostsI4[7, 7] = new short[] { 403, 1520, 977, 2132, 1733, 3522, 1076, 276, 3335, 1547 }; - Vp8FixedCostsI4[7, 8] = new short[] { 559, 1374, 1101, 615, 673, 2462, 974, 795, 984, 984 }; - Vp8FixedCostsI4[7, 9] = new short[] { 547, 1122, 1062, 812, 1410, 951, 1140, 622, 1268, 651 }; - Vp8FixedCostsI4[8, 0] = new short[] { 165, 982, 1235, 938, 1334, 1366, 1659, 1578, 964, 1612 }; - Vp8FixedCostsI4[8, 1] = new short[] { 592, 422, 925, 847, 1139, 1112, 1387, 2036, 861, 1041 }; - Vp8FixedCostsI4[8, 2] = new short[] { 403, 837, 732, 770, 941, 1658, 1250, 809, 1407, 1407 }; - Vp8FixedCostsI4[8, 3] = new short[] { 896, 874, 1071, 381, 1568, 1722, 1437, 2192, 480, 1035 }; - Vp8FixedCostsI4[8, 4] = new short[] { 640, 1098, 1012, 1032, 684, 1382, 1581, 2106, 416, 865 }; - Vp8FixedCostsI4[8, 5] = new short[] { 559, 1005, 819, 914, 710, 770, 1418, 920, 838, 1435 }; - Vp8FixedCostsI4[8, 6] = new short[] { 415, 1258, 1245, 870, 1278, 3067, 770, 1021, 1287, 522 }; - Vp8FixedCostsI4[8, 7] = new short[] { 406, 990, 601, 1009, 1265, 1265, 1267, 759, 1017, 1277 }; - Vp8FixedCostsI4[8, 8] = new short[] { 968, 1182, 1329, 788, 1032, 1292, 1705, 1714, 203, 1403 }; - Vp8FixedCostsI4[8, 9] = new short[] { 732, 877, 1279, 471, 901, 1161, 1545, 1294, 755, 755 }; - Vp8FixedCostsI4[9, 0] = new short[] { 111, 931, 1378, 1185, 1933, 1648, 1148, 1714, 1873, 1307 }; - Vp8FixedCostsI4[9, 1] = new short[] { 406, 414, 1030, 1023, 1910, 1404, 1313, 1647, 1509, 793 }; - Vp8FixedCostsI4[9, 2] = new short[] { 342, 640, 575, 1088, 1241, 1349, 1161, 1350, 1756, 1502 }; - Vp8FixedCostsI4[9, 3] = new short[] { 559, 766, 1185, 357, 1682, 1428, 1329, 1897, 1219, 802 }; - Vp8FixedCostsI4[9, 4] = new short[] { 473, 909, 1164, 771, 719, 2508, 1427, 1432, 722, 782 }; - Vp8FixedCostsI4[9, 5] = new short[] { 342, 892, 785, 1145, 1150, 794, 1296, 1550, 973, 1057 }; - Vp8FixedCostsI4[9, 6] = new short[] { 208, 1036, 1326, 1343, 1606, 3395, 815, 1455, 1618, 712 }; - Vp8FixedCostsI4[9, 7] = new short[] { 228, 928, 890, 1046, 3499, 1711, 994, 829, 1720, 1318 }; - Vp8FixedCostsI4[9, 8] = new short[] { 768, 724, 1058, 636, 991, 1075, 1319, 1324, 616, 825 }; - Vp8FixedCostsI4[9, 9] = new short[] { 305, 1167, 1358, 899, 1587, 1587, 987, 1988, 1332, 501 }; + Vp8FixedCostsI4[0, 0] = [40, 1151, 1723, 1874, 2103, 2019, 1628, 1777, 2226, 2137]; + Vp8FixedCostsI4[0, 1] = [192, 469, 1296, 1308, 1849, 1794, 1781, 1703, 1713, 1522]; + Vp8FixedCostsI4[0, 2] = [142, 910, 762, 1684, 1849, 1576, 1460, 1305, 1801, 1657]; + Vp8FixedCostsI4[0, 3] = [559, 641, 1370, 421, 1182, 1569, 1612, 1725, 863, 1007]; + Vp8FixedCostsI4[0, 4] = [299, 1059, 1256, 1108, 636, 1068, 1581, 1883, 869, 1142]; + Vp8FixedCostsI4[0, 5] = [277, 1111, 707, 1362, 1089, 672, 1603, 1541, 1545, 1291]; + Vp8FixedCostsI4[0, 6] = [214, 781, 1609, 1303, 1632, 2229, 726, 1560, 1713, 918]; + Vp8FixedCostsI4[0, 7] = [152, 1037, 1046, 1759, 1983, 2174, 1358, 742, 1740, 1390]; + Vp8FixedCostsI4[0, 8] = [512, 1046, 1420, 753, 752, 1297, 1486, 1613, 460, 1207]; + Vp8FixedCostsI4[0, 9] = [424, 827, 1362, 719, 1462, 1202, 1199, 1476, 1199, 538]; + Vp8FixedCostsI4[1, 0] = [240, 402, 1134, 1491, 1659, 1505, 1517, 1555, 1979, 2099]; + Vp8FixedCostsI4[1, 1] = [467, 242, 960, 1232, 1714, 1620, 1834, 1570, 1676, 1391]; + Vp8FixedCostsI4[1, 2] = [500, 455, 463, 1507, 1699, 1282, 1564, 982, 2114, 2114]; + Vp8FixedCostsI4[1, 3] = [672, 643, 1372, 331, 1589, 1667, 1453, 1938, 996, 876]; + Vp8FixedCostsI4[1, 4] = [458, 783, 1037, 911, 738, 968, 1165, 1518, 859, 1033]; + Vp8FixedCostsI4[1, 5] = [504, 815, 504, 1139, 1219, 719, 1506, 1085, 1268, 1268]; + Vp8FixedCostsI4[1, 6] = [333, 630, 1445, 1239, 1883, 3672, 799, 1548, 1865, 598]; + Vp8FixedCostsI4[1, 7] = [399, 644, 746, 1342, 1856, 1350, 1493, 613, 1855, 1015]; + Vp8FixedCostsI4[1, 8] = [622, 749, 1205, 608, 1066, 1408, 1290, 1406, 546, 971]; + Vp8FixedCostsI4[1, 9] = [500, 753, 1041, 668, 1230, 1617, 1297, 1425, 1383, 523]; + Vp8FixedCostsI4[2, 0] = [394, 553, 523, 1502, 1536, 981, 1608, 1142, 1666, 2181]; + Vp8FixedCostsI4[2, 1] = [655, 430, 375, 1411, 1861, 1220, 1677, 1135, 1978, 1553]; + Vp8FixedCostsI4[2, 2] = [690, 640, 245, 1954, 2070, 1194, 1528, 982, 1972, 2232]; + Vp8FixedCostsI4[2, 3] = [559, 834, 741, 867, 1131, 980, 1225, 852, 1092, 784]; + Vp8FixedCostsI4[2, 4] = [690, 875, 516, 959, 673, 894, 1056, 1190, 1528, 1126]; + Vp8FixedCostsI4[2, 5] = [740, 951, 384, 1277, 1177, 492, 1579, 1155, 1846, 1513]; + Vp8FixedCostsI4[2, 6] = [323, 775, 1062, 1776, 3062, 1274, 813, 1188, 1372, 655]; + Vp8FixedCostsI4[2, 7] = [488, 971, 484, 1767, 1515, 1775, 1115, 503, 1539, 1461]; + Vp8FixedCostsI4[2, 8] = [740, 1006, 998, 709, 851, 1230, 1337, 788, 741, 721]; + Vp8FixedCostsI4[2, 9] = [522, 1073, 573, 1045, 1346, 887, 1046, 1146, 1203, 697]; + Vp8FixedCostsI4[3, 0] = [105, 864, 1442, 1009, 1934, 1840, 1519, 1920, 1673, 1579]; + Vp8FixedCostsI4[3, 1] = [534, 305, 1193, 683, 1388, 2164, 1802, 1894, 1264, 1170]; + Vp8FixedCostsI4[3, 2] = [305, 518, 877, 1108, 1426, 3215, 1425, 1064, 1320, 1242]; + Vp8FixedCostsI4[3, 3] = [683, 732, 1927, 257, 1493, 2048, 1858, 1552, 1055, 947]; + Vp8FixedCostsI4[3, 4] = [394, 814, 1024, 660, 959, 1556, 1282, 1289, 893, 1047]; + Vp8FixedCostsI4[3, 5] = [528, 615, 996, 940, 1201, 635, 1094, 2515, 803, 1358]; + Vp8FixedCostsI4[3, 6] = [347, 614, 1609, 1187, 3133, 1345, 1007, 1339, 1017, 667]; + Vp8FixedCostsI4[3, 7] = [218, 740, 878, 1605, 3650, 3650, 1345, 758, 1357, 1617]; + Vp8FixedCostsI4[3, 8] = [672, 750, 1541, 558, 1257, 1599, 1870, 2135, 402, 1087]; + Vp8FixedCostsI4[3, 9] = [592, 684, 1161, 430, 1092, 1497, 1475, 1489, 1095, 822]; + Vp8FixedCostsI4[4, 0] = [228, 1056, 1059, 1368, 752, 982, 1512, 1518, 987, 1782]; + Vp8FixedCostsI4[4, 1] = [494, 514, 818, 942, 965, 892, 1610, 1356, 1048, 1363]; + Vp8FixedCostsI4[4, 2] = [512, 648, 591, 1042, 761, 991, 1196, 1454, 1309, 1463]; + Vp8FixedCostsI4[4, 3] = [683, 749, 1043, 676, 841, 1396, 1133, 1138, 654, 939]; + Vp8FixedCostsI4[4, 4] = [622, 1101, 1126, 994, 361, 1077, 1203, 1318, 877, 1219]; + Vp8FixedCostsI4[4, 5] = [631, 1068, 857, 1650, 651, 477, 1650, 1419, 828, 1170]; + Vp8FixedCostsI4[4, 6] = [555, 727, 1068, 1335, 3127, 1339, 820, 1331, 1077, 429]; + Vp8FixedCostsI4[4, 7] = [504, 879, 624, 1398, 889, 889, 1392, 808, 891, 1406]; + Vp8FixedCostsI4[4, 8] = [683, 1602, 1289, 977, 578, 983, 1280, 1708, 406, 1122]; + Vp8FixedCostsI4[4, 9] = [399, 865, 1433, 1070, 1072, 764, 968, 1477, 1223, 678]; + Vp8FixedCostsI4[5, 0] = [333, 760, 935, 1638, 1010, 529, 1646, 1410, 1472, 2219]; + Vp8FixedCostsI4[5, 1] = [512, 494, 750, 1160, 1215, 610, 1870, 1868, 1628, 1169]; + Vp8FixedCostsI4[5, 2] = [572, 646, 492, 1934, 1208, 603, 1580, 1099, 1398, 1995]; + Vp8FixedCostsI4[5, 3] = [786, 789, 942, 581, 1018, 951, 1599, 1207, 731, 768]; + Vp8FixedCostsI4[5, 4] = [690, 1015, 672, 1078, 582, 504, 1693, 1438, 1108, 2897]; + Vp8FixedCostsI4[5, 5] = [768, 1267, 571, 2005, 1243, 244, 2881, 1380, 1786, 1453]; + Vp8FixedCostsI4[5, 6] = [452, 899, 1293, 903, 1311, 3100, 465, 1311, 1319, 813]; + Vp8FixedCostsI4[5, 7] = [394, 927, 942, 1103, 1358, 1104, 946, 593, 1363, 1109]; + Vp8FixedCostsI4[5, 8] = [559, 1005, 1007, 1016, 658, 1173, 1021, 1164, 623, 1028]; + Vp8FixedCostsI4[5, 9] = [564, 796, 632, 1005, 1014, 863, 2316, 1268, 938, 764]; + Vp8FixedCostsI4[6, 0] = [266, 606, 1098, 1228, 1497, 1243, 948, 1030, 1734, 1461]; + Vp8FixedCostsI4[6, 1] = [366, 585, 901, 1060, 1407, 1247, 876, 1134, 1620, 1054]; + Vp8FixedCostsI4[6, 2] = [452, 565, 542, 1729, 1479, 1479, 1016, 886, 2938, 1150]; + Vp8FixedCostsI4[6, 3] = [555, 1088, 1533, 950, 1354, 895, 834, 1019, 1021, 496]; + Vp8FixedCostsI4[6, 4] = [704, 815, 1193, 971, 973, 640, 1217, 2214, 832, 578]; + Vp8FixedCostsI4[6, 5] = [672, 1245, 579, 871, 875, 774, 872, 1273, 1027, 949]; + Vp8FixedCostsI4[6, 6] = [296, 1134, 2050, 1784, 1636, 3425, 442, 1550, 2076, 722]; + Vp8FixedCostsI4[6, 7] = [342, 982, 1259, 1846, 1848, 1848, 622, 568, 1847, 1052]; + Vp8FixedCostsI4[6, 8] = [555, 1064, 1304, 828, 746, 1343, 1075, 1329, 1078, 494]; + Vp8FixedCostsI4[6, 9] = [288, 1167, 1285, 1174, 1639, 1639, 833, 2254, 1304, 509]; + Vp8FixedCostsI4[7, 0] = [342, 719, 767, 1866, 1757, 1270, 1246, 550, 1746, 2151]; + Vp8FixedCostsI4[7, 1] = [483, 653, 694, 1509, 1459, 1410, 1218, 507, 1914, 1266]; + Vp8FixedCostsI4[7, 2] = [488, 757, 447, 2979, 1813, 1268, 1654, 539, 1849, 2109]; + Vp8FixedCostsI4[7, 3] = [522, 1097, 1085, 851, 1365, 1111, 851, 901, 961, 605]; + Vp8FixedCostsI4[7, 4] = [709, 716, 841, 728, 736, 945, 941, 862, 2845, 1057]; + Vp8FixedCostsI4[7, 5] = [512, 1323, 500, 1336, 1083, 681, 1342, 717, 1604, 1350]; + Vp8FixedCostsI4[7, 6] = [452, 1155, 1372, 1900, 1501, 3290, 311, 944, 1919, 922]; + Vp8FixedCostsI4[7, 7] = [403, 1520, 977, 2132, 1733, 3522, 1076, 276, 3335, 1547]; + Vp8FixedCostsI4[7, 8] = [559, 1374, 1101, 615, 673, 2462, 974, 795, 984, 984]; + Vp8FixedCostsI4[7, 9] = [547, 1122, 1062, 812, 1410, 951, 1140, 622, 1268, 651]; + Vp8FixedCostsI4[8, 0] = [165, 982, 1235, 938, 1334, 1366, 1659, 1578, 964, 1612]; + Vp8FixedCostsI4[8, 1] = [592, 422, 925, 847, 1139, 1112, 1387, 2036, 861, 1041]; + Vp8FixedCostsI4[8, 2] = [403, 837, 732, 770, 941, 1658, 1250, 809, 1407, 1407]; + Vp8FixedCostsI4[8, 3] = [896, 874, 1071, 381, 1568, 1722, 1437, 2192, 480, 1035]; + Vp8FixedCostsI4[8, 4] = [640, 1098, 1012, 1032, 684, 1382, 1581, 2106, 416, 865]; + Vp8FixedCostsI4[8, 5] = [559, 1005, 819, 914, 710, 770, 1418, 920, 838, 1435]; + Vp8FixedCostsI4[8, 6] = [415, 1258, 1245, 870, 1278, 3067, 770, 1021, 1287, 522]; + Vp8FixedCostsI4[8, 7] = [406, 990, 601, 1009, 1265, 1265, 1267, 759, 1017, 1277]; + Vp8FixedCostsI4[8, 8] = [968, 1182, 1329, 788, 1032, 1292, 1705, 1714, 203, 1403]; + Vp8FixedCostsI4[8, 9] = [732, 877, 1279, 471, 901, 1161, 1545, 1294, 755, 755]; + Vp8FixedCostsI4[9, 0] = [111, 931, 1378, 1185, 1933, 1648, 1148, 1714, 1873, 1307]; + Vp8FixedCostsI4[9, 1] = [406, 414, 1030, 1023, 1910, 1404, 1313, 1647, 1509, 793]; + Vp8FixedCostsI4[9, 2] = [342, 640, 575, 1088, 1241, 1349, 1161, 1350, 1756, 1502]; + Vp8FixedCostsI4[9, 3] = [559, 766, 1185, 357, 1682, 1428, 1329, 1897, 1219, 802]; + Vp8FixedCostsI4[9, 4] = [473, 909, 1164, 771, 719, 2508, 1427, 1432, 722, 782]; + Vp8FixedCostsI4[9, 5] = [342, 892, 785, 1145, 1150, 794, 1296, 1550, 973, 1057]; + Vp8FixedCostsI4[9, 6] = [208, 1036, 1326, 1343, 1606, 3395, 815, 1455, 1618, 712]; + Vp8FixedCostsI4[9, 7] = [228, 928, 890, 1046, 3499, 1711, 994, 829, 1720, 1318]; + Vp8FixedCostsI4[9, 8] = [768, 724, 1058, 636, 991, 1075, 1319, 1324, 616, 825]; + Vp8FixedCostsI4[9, 9] = [305, 1167, 1358, 899, 1587, 1587, 987, 1988, 1332, 501]; } } diff --git a/src/ImageSharp/Formats/_Generated/_Formats.ttinclude b/src/ImageSharp/Formats/_Generated/_Formats.ttinclude index 89940d406..2d6129c4c 100644 --- a/src/ImageSharp/Formats/_Generated/_Formats.ttinclude +++ b/src/ImageSharp/Formats/_Generated/_Formats.ttinclude @@ -3,7 +3,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. <#+ - private static readonly string[] formats = new []{ + private static readonly string[] formats = [ "Bmp", "Cur", "Gif", @@ -14,15 +14,15 @@ "Qoi", "Tga", "Tiff", - "Webp", - }; + "Webp" + ]; - private static readonly string[] frameFormats = new []{ + private static readonly string[] frameFormats = [ "Cur", "Ico", "Gif", "Png", "Tiff", - "Webp", - }; + "Webp" + ]; #> diff --git a/src/ImageSharp/IO/ChunkedMemoryStream.cs b/src/ImageSharp/IO/ChunkedMemoryStream.cs index d62a64c23..c164045df 100644 --- a/src/ImageSharp/IO/ChunkedMemoryStream.cs +++ b/src/ImageSharp/IO/ChunkedMemoryStream.cs @@ -387,7 +387,7 @@ internal sealed class ChunkedMemoryStream : Stream private sealed class MemoryChunkBuffer : IDisposable { - private readonly List memoryChunks = new(); + private readonly List memoryChunks = []; private readonly MemoryAllocator allocator; private readonly int allocatorCapacity; private bool isDisposed; diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs index 6c769a9d1..c6853b40c 100644 --- a/src/ImageSharp/ImageExtensions.cs +++ b/src/ImageSharp/ImageExtensions.cs @@ -179,6 +179,6 @@ public static partial class ImageExtensions // Always available. stream.TryGetBuffer(out ArraySegment buffer); - return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(buffer.Array ?? Array.Empty(), 0, (int)stream.Length)}"; + return $"data:{format.DefaultMimeType};base64,{Convert.ToBase64String(buffer.Array ?? [], 0, (int)stream.Length)}"; } } diff --git a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs index 5e15e46e9..d4ad22060 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UniformUnmanagedMemoryPool.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Memory.Internals; internal partial class UniformUnmanagedMemoryPool : System.Runtime.ConstrainedExecution.CriticalFinalizerObject { private static int minTrimPeriodMilliseconds = int.MaxValue; - private static readonly List> AllPools = new(); + private static readonly List> AllPools = []; private static Timer? trimTimer; private static readonly Stopwatch Stopwatch = Stopwatch.StartNew(); diff --git a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs index d08bf248b..6dd99fcb0 100644 --- a/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs +++ b/src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroup{T}.cs @@ -97,7 +97,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable if (totalLengthInElements == 0) { - IMemoryOwner[] buffers0 = new IMemoryOwner[1] { allocator.Allocate(0, options) }; + IMemoryOwner[] buffers0 = [allocator.Allocate(0, options)]; return new Owned(buffers0, 0, 0, true); } @@ -142,7 +142,7 @@ internal abstract partial class MemoryGroup : IMemoryGroup, IDisposable } int length = buffer.Memory.Length; - IMemoryOwner[] buffers = new IMemoryOwner[1] { buffer }; + IMemoryOwner[] buffers = [buffer]; return new Owned(buffers, length, length, true); } diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs index 725533ea5..df6f7bdf8 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs @@ -7,21 +7,21 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif; internal static class ExifConstants { - public static ReadOnlySpan LittleEndianByteOrderMarker => new byte[] - { + public static ReadOnlySpan LittleEndianByteOrderMarker => + [ (byte)'I', (byte)'I', 0x2A, - 0x00, - }; + 0x00 + ]; - public static ReadOnlySpan BigEndianByteOrderMarker => new byte[] - { + public static ReadOnlySpan BigEndianByteOrderMarker => + [ (byte)'M', (byte)'M', 0x00, 0x2A - }; + ]; // UTF-8 is better than ASCII, UTF-8 encodes the ASCII codes the same way public static Encoding DefaultEncoding => Encoding.UTF8; diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs index 58b759555..219e78559 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.NonPrimitives.cs @@ -103,7 +103,7 @@ internal sealed partial class IccDataReader public IccNamedColor ReadNamedColor(uint deviceCoordCount) { string name = this.ReadAsciiString(32); - ushort[] pcsCoord = { this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16() }; + ushort[] pcsCoord = [this.ReadUInt16(), this.ReadUInt16(), this.ReadUInt16()]; ushort[] deviceCoord = new ushort[deviceCoordCount]; for (int i = 0; i < deviceCoordCount; i++) diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs index 88281452e..9e89d24ff 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs @@ -154,7 +154,7 @@ internal sealed partial class IccDataReader double[][] values = new double[channelCount][]; for (int i = 0; i < channelCount; i++) { - values[i] = new double[] { this.ReadUFix16(), this.ReadUFix16() }; + values[i] = [this.ReadUFix16(), this.ReadUFix16()]; } return new IccChromaticityTagDataEntry(values); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs index 074712d30..084ec388d 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccReader.cs @@ -115,7 +115,7 @@ internal sealed class IccReader // A normal profile usually has 5-15 entries if (tagCount > 100) { - return Array.Empty(); + return []; } List table = new((int)tagCount); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs index 5e73e2dd0..6bc0560f0 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccWriter.cs @@ -71,7 +71,7 @@ internal sealed class IccWriter // (Header size) + (entry count) + (nr of entries) * (size of table entry) writer.SetIndex(128 + 4 + (entries.Length * 12)); - List table = new(); + List table = []; foreach (IGrouping group in grouped) { writer.WriteTagDataEntry(group.Key, out IccTagTableEntry tableEntry); diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs index cc4476291..1938ad630 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs @@ -112,33 +112,33 @@ internal sealed class IccChromaticityTagDataEntry : IccTagDataEntry, IEquatable< switch (colorantType) { case IccColorantEncoding.EbuTech3213E: - return new[] - { - new[] { 0.640, 0.330 }, - new[] { 0.290, 0.600 }, - new[] { 0.150, 0.060 }, - }; + return + [ + [0.640, 0.330], + [0.290, 0.600], + [0.150, 0.060] + ]; case IccColorantEncoding.ItuRBt709_2: - return new[] - { - new[] { 0.640, 0.330 }, - new[] { 0.300, 0.600 }, - new[] { 0.150, 0.060 }, - }; + return + [ + [0.640, 0.330], + [0.300, 0.600], + [0.150, 0.060] + ]; case IccColorantEncoding.P22: - return new[] - { - new[] { 0.625, 0.340 }, - new[] { 0.280, 0.605 }, - new[] { 0.155, 0.070 }, - }; + return + [ + [0.625, 0.340], + [0.280, 0.605], + [0.155, 0.070] + ]; case IccColorantEncoding.SmpteRp145: - return new[] - { - new[] { 0.630, 0.340 }, - new[] { 0.310, 0.595 }, - new[] { 0.155, 0.070 }, - }; + return + [ + [0.630, 0.340], + [0.310, 0.595], + [0.155, 0.070] + ]; default: throw new ArgumentException("Unrecognized colorant encoding"); } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs index 5605d9255..7330cbdf0 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs @@ -12,7 +12,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatable class. /// public IccCurveTagDataEntry() - : this(Array.Empty(), IccProfileTag.Unknown) + : this([], IccProfileTag.Unknown) { } @@ -21,7 +21,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatable /// Gamma value public IccCurveTagDataEntry(float gamma) - : this(new[] { gamma }, IccProfileTag.Unknown) + : this([gamma], IccProfileTag.Unknown) { } @@ -39,7 +39,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatable /// Tag Signature public IccCurveTagDataEntry(IccProfileTag tagSignature) - : this(Array.Empty(), tagSignature) + : this([], tagSignature) { } @@ -49,7 +49,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatableGamma value /// Tag Signature public IccCurveTagDataEntry(float gamma, IccProfileTag tagSignature) - : this(new[] { gamma }, tagSignature) + : this([gamma], tagSignature) { } @@ -61,7 +61,7 @@ internal sealed class IccCurveTagDataEntry : IccTagDataEntry, IEquatable(); + this.CurveData = curveData ?? []; } /// diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs index 85c23d174..306924e62 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcProfile.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; /// public sealed class IptcProfile : IDeepCloneable { - private readonly Collection values = new(); + private readonly Collection values = []; private const byte IptcTagMarkerByte = 0x1c; @@ -67,7 +67,7 @@ public sealed class IptcProfile : IDeepCloneable /// /// Gets a byte array marking that UTF-8 encoding is used in application records. /// - private static ReadOnlySpan CodedCharacterSetUtf8Value => new byte[] { 0x1B, 0x25, 0x47 }; // Uses C#'s optimization to refer to the data segment in the assembly directly, no allocation occurs. + private static ReadOnlySpan CodedCharacterSetUtf8Value => [0x1B, 0x25, 0x47]; // Uses C#'s optimization to refer to the data segment in the assembly directly, no allocation occurs. /// /// Gets the byte data of the IPTC profile. @@ -89,7 +89,7 @@ public sealed class IptcProfile : IDeepCloneable /// The values found with the specified tag. public List GetValues(IptcTag tag) { - List iptcValues = new(); + List iptcValues = []; foreach (IptcValue iptcValue in this.Values) { if (iptcValue.Tag == tag) diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 7c5662e1f..7735810b3 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; [DebuggerDisplay("{Tag} = {ToString(),nq} ({GetType().Name,nq})")] public sealed class IptcValue : IDeepCloneable { - private byte[] data = Array.Empty(); + private byte[] data = []; private Encoding encoding; internal IptcValue(IptcValue other) @@ -91,7 +91,7 @@ public sealed class IptcValue : IDeepCloneable { if (string.IsNullOrEmpty(value)) { - this.data = Array.Empty(); + this.data = []; } else { diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude index c4d5a6b95..ae29223de 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude +++ b/src/ImageSharp/PixelFormats/PixelImplementations/PixelOperations/Generated/_Common.ttinclude @@ -14,8 +14,8 @@ using System.Runtime.InteropServices; using SixLabors.ImageSharp.PixelFormats.Utils; <#+ private static readonly string[] CommonPixelTypes = - { - "Argb32", + [ + "Argb32", "Abgr32", "Bgr24", "Bgra32", @@ -28,27 +28,27 @@ using SixLabors.ImageSharp.PixelFormats.Utils; "Rgb48", "Rgba64", "Bgra5551" - }; + ]; private static readonly string[] OptimizedPixelTypes = - { - "Rgba32", + [ + "Rgba32", "Argb32", "Abgr32", "Bgra32", "Rgb24", "Bgr24" - }; + ]; // Types with Rgba32-combatable to/from Vector4 conversion private static readonly string[] Rgba32CompatibleTypes = - { - "Argb32", + [ + "Argb32", "Abgr32", "Bgra32", "Rgb24", "Bgr24" - }; + ]; void GenerateGenericConverterMethods(string pixelType) { @@ -187,7 +187,7 @@ using SixLabors.ImageSharp.PixelFormats.Utils; var matching32BitTypes = OptimizedPixelTypes.Contains(pixelType) ? OptimizedPixelTypes.Where(p => p != pixelType) : - Enumerable.Empty(); + []; foreach (string destPixelType in matching32BitTypes) { diff --git a/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs b/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs index 0c456eb88..1dbc666f6 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Kernels/EdgeDetectorCompassKernel.cs @@ -152,9 +152,8 @@ public readonly struct EdgeDetectorCompassKernel : IEquatable[] Flatten() => - new[] - { - this.North, this.NorthWest, this.West, this.SouthWest, + [ + this.North, this.NorthWest, this.West, this.SouthWest, this.South, this.SouthEast, this.East, this.NorthEast - }; + ]; } diff --git a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs index ae4483f2e..4b3dd7fe7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Parameters/BokehBlurKernelDataProvider.cs @@ -21,61 +21,57 @@ internal static class BokehBlurKernelDataProvider /// /// Gets the kernel scales to adjust the component values in each kernel /// - private static float[] KernelScales { get; } = new[] { 1.4f, 1.2f, 1.2f, 1.2f, 1.2f, 1.2f }; + private static float[] KernelScales { get; } = [1.4f, 1.2f, 1.2f, 1.2f, 1.2f, 1.2f]; /// /// Gets the available bokeh blur kernel parameters /// - private static Vector4[][] KernelComponents { get; } = new[] - { + private static Vector4[][] KernelComponents { get; } = + [ + // 1 component - new[] { new Vector4(0.862325f, 1.624835f, 0.767583f, 1.862321f) }, + [new Vector4(0.862325f, 1.624835f, 0.767583f, 1.862321f)], // 2 components - new[] - { + [ new Vector4(0.886528f, 5.268909f, 0.411259f, -0.548794f), new Vector4(1.960518f, 1.558213f, 0.513282f, 4.56111f) - }, + ], // 3 components - new[] - { + [ new Vector4(2.17649f, 5.043495f, 1.621035f, -2.105439f), new Vector4(1.019306f, 9.027613f, -0.28086f, -0.162882f), new Vector4(2.81511f, 1.597273f, -0.366471f, 10.300301f) - }, + ], // 4 components - new[] - { + [ new Vector4(4.338459f, 1.553635f, -5.767909f, 46.164397f), new Vector4(3.839993f, 4.693183f, 9.795391f, -15.227561f), new Vector4(2.791880f, 8.178137f, -3.048324f, 0.302959f), new Vector4(1.342190f, 12.328289f, 0.010001f, 0.244650f) - }, + ], // 5 components - new[] - { + [ new Vector4(4.892608f, 1.685979f, -22.356787f, 85.91246f), new Vector4(4.71187f, 4.998496f, 35.918936f, -28.875618f), new Vector4(4.052795f, 8.244168f, -13.212253f, -1.578428f), new Vector4(2.929212f, 11.900859f, 0.507991f, 1.816328f), new Vector4(1.512961f, 16.116382f, 0.138051f, -0.01f) - }, + ], // 6 components - new[] - { + [ new Vector4(5.143778f, 2.079813f, -82.326596f, 111.231024f), new Vector4(5.612426f, 6.153387f, 113.878661f, 58.004879f), new Vector4(5.982921f, 9.802895f, 39.479083f, -162.028887f), new Vector4(6.505167f, 11.059237f, -71.286026f, 95.027069f), new Vector4(3.869579f, 14.81052f, 1.405746f, -3.704914f), new Vector4(2.201904f, 19.032909f, -0.152784f, -0.107988f) - } - }; + ] + ]; /// /// Gets the bokeh blur kernel data for the specified parameters. diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs index 51a739d35..26cf60034 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernel.cs @@ -74,13 +74,13 @@ internal readonly unsafe struct ResizeKernel float* bufferEnd = bufferStart + (this.Length & ~3); Vector256 result256_0 = Vector256.Zero; Vector256 result256_1 = Vector256.Zero; - ReadOnlySpan maskBytes = new byte[] - { + ReadOnlySpan maskBytes = + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 1, 0, 0, 0, - }; + 1, 0, 0, 0, 1, 0, 0, 0 + ]; Vector256 mask = Unsafe.ReadUnaligned>(ref MemoryMarshal.GetReference(maskBytes)); while (bufferStart < bufferEnd) diff --git a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs index 53c26a57e..80b096344 100644 --- a/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs +++ b/tests/ImageSharp.Benchmarks/Bulk/FromVector4.cs @@ -73,7 +73,8 @@ public class FromVector4Rgba32 : FromVector4 SimdUtils.HwIntrinsics.NormalizedFloatToByteSaturate(sBytes, dFloats); } - private static ReadOnlySpan PermuteMaskDeinterleave8x32 => new byte[] { 0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0 }; + private static ReadOnlySpan PermuteMaskDeinterleave8x32 => [0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0 + ]; [Benchmark] public void UseAvx2_Grouped() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs index fdef1b2bf..ce54c133b 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs; [Config(typeof(Config.Short))] public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded { - protected override IEnumerable InputImageSubfoldersOrFiles => new[] { "Bmp/", "Jpg/baseline" }; + protected override IEnumerable InputImageSubfoldersOrFiles => ["Bmp/", "Jpg/baseline"]; [Benchmark(Description = "EncodeBmpMultiple - ImageSharp")] public void EncodeBmpImageSharp() diff --git a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs index 303272837..1eca07ec7 100644 --- a/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Codecs/Gif/EncodeGifMultiple.cs @@ -15,7 +15,7 @@ public class EncodeGifMultiple : MultiImageBenchmarkBase.WithImagesPreloaded [Params(InputImageCategory.AllImages)] public override InputImageCategory InputCategory { get; set; } - protected override IEnumerable InputImageSubfoldersOrFiles => new[] { "Gif/" }; + protected override IEnumerable InputImageSubfoldersOrFiles => ["Gif/"]; [Benchmark(Description = "EncodeGifMultiple - ImageSharp")] public void EncodeGifImageSharp() diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs index dd0bc2878..317295144 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampFloat.cs @@ -10,7 +10,7 @@ public class ClampFloat { private readonly float min = -1.5f; private readonly float max = 2.5f; - private static readonly float[] Values = { -10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10 }; + private static readonly float[] Values = [-10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10]; [Benchmark(Baseline = true)] public float UsingMathF() diff --git a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs index 186f88bb7..4969c3ef7 100644 --- a/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs +++ b/tests/ImageSharp.Benchmarks/General/BasicMath/ClampVector4.cs @@ -11,7 +11,7 @@ public class ClampVector4 { private readonly float min = -1.5f; private readonly float max = 2.5f; - private static readonly float[] Values = { -10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10 }; + private static readonly float[] Values = [-10, -5, -3, -1.5f, -0.5f, 0f, 1f, 1.5f, 2.5f, 3, 10]; [Benchmark(Baseline = true)] public Vector4 UsingVectorClamp() diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs index 5d137a615..0731c7c00 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressBenchmarks.cs @@ -34,12 +34,12 @@ public class LoadResizeSaveStressBenchmarks } public int[] ParallelismValues { get; } = - { + [ // Environment.ProcessorCount, // Environment.ProcessorCount / 2, // Environment.ProcessorCount / 4, 1 - }; + ]; [Benchmark] [ArgumentsSource(nameof(ParallelismValues))] diff --git a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs index 75bc5289c..f8bf19d57 100644 --- a/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs +++ b/tests/ImageSharp.Benchmarks/LoadResizeSave/LoadResizeSaveStressRunner.cs @@ -53,7 +53,7 @@ public class LoadResizeSaveStressRunner public int ThumbnailSize { get; set; } = 150; private static readonly string[] ProgressiveFiles = - { + [ "ancyloscelis-apiformis-m-paraguay-face_2014-08-08-095255-zs-pmax_15046500892_o.jpg", "acanthopus-excellens-f-face-brasil_2014-08-06-132105-zs-pmax_14792513890_o.jpg", "bee-ceratina-monster-f-ukraine-face_2014-08-09-123342-zs-pmax_15068816101_o.jpg", @@ -84,8 +84,8 @@ public class LoadResizeSaveStressRunner "triepeolus-simplex-m-face-md-kent-county_2014-07-22-100937-zs-pmax_14805405233_o.jpg", "washed-megachile-f-face-chile_2014-08-06-103414-zs-pmax_14977843152_o.jpg", "xylocopa-balck-violetwing-f-kyrgystan-angle_2014-08-09-182433-zs-pmax_15123416061_o.jpg", - "xylocopa-india-yellow-m-india-face_2014-08-10-111701-zs-pmax_15166559172_o.jpg", - }; + "xylocopa-india-yellow-m-india-face_2014-08-10-111701-zs-pmax_15166559172_o.jpg" + ]; public void Init() { diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs index 3e4f77f9e..8ba862560 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs +++ b/tests/ImageSharp.Tests.ProfilingSandbox/Program.cs @@ -52,7 +52,7 @@ public class Program { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; Console.WriteLine(assembly.Location); - string[] assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) { diff --git a/tests/ImageSharp.Tests/Color/ReferencePalette.cs b/tests/ImageSharp.Tests/Color/ReferencePalette.cs index 2db2aae19..88787afd4 100644 --- a/tests/ImageSharp.Tests/Color/ReferencePalette.cs +++ b/tests/ImageSharp.Tests/Color/ReferencePalette.cs @@ -9,7 +9,7 @@ internal static class ReferencePalette /// Gets a collection of named, web safe, colors as defined in the CSS Color Module Level 4. /// public static readonly Color[] WebSafeColors = - { + [ Color.AliceBlue, Color.AntiqueWhite, Color.Aqua, @@ -152,14 +152,14 @@ internal static class ReferencePalette Color.WhiteSmoke, Color.Yellow, Color.YellowGreen - }; + ]; /// /// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821. /// The hex codes were collected and defined by Nicholas Rougeux /// public static readonly Color[] WernerColors = - { + [ Color.ParseHex("#f1e9cd"), Color.ParseHex("#f2e7cf"), Color.ParseHex("#ece6d0"), @@ -270,7 +270,7 @@ internal static class ReferencePalette Color.ParseHex("#9b856b"), Color.ParseHex("#766051"), Color.ParseHex("#453b32") - }; + ]; public static readonly Dictionary ColorNames = new(StringComparer.OrdinalIgnoreCase) diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 27511f7be..072b04fa0 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -16,24 +16,23 @@ public class GeneralFormatTests /// A collection made up of one file for each image format. /// public static readonly IEnumerable DefaultFiles = - new[] - { - TestImages.Bmp.Car, + [ + TestImages.Bmp.Car, TestImages.Jpeg.Baseline.Calliphora, TestImages.Png.Splash, TestImages.Gif.Trans - }; + ]; /// /// The collection of image files to test against. /// - protected static readonly List Files = new() - { + protected static readonly List Files = + [ TestFile.Create(TestImages.Jpeg.Baseline.Calliphora), TestFile.Create(TestImages.Bmp.Car), TestFile.Create(TestImages.Png.Splash), - TestFile.Create(TestImages.Gif.Rings), - }; + TestFile.Create(TestImages.Gif.Rings) + ]; [Theory] [WithFileCollection(nameof(DefaultFiles), PixelTypes.Rgba32)] @@ -151,7 +150,7 @@ public class GeneralFormatTests private static IQuantizer GetQuantizer(string name) { PropertyInfo property = typeof(KnownQuantizers).GetTypeInfo().GetProperty(name); - return (IQuantizer)property.GetMethod.Invoke(null, Array.Empty()); + return (IQuantizer)property.GetMethod.Invoke(null, []); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 48253bee7..7bb711f3f 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -20,9 +20,9 @@ public class GifDecoderTests private const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.RgbaVector | PixelTypes.Argb32; public static readonly string[] MultiFrameTestFiles = - { + [ TestImages.Gif.Giphy, TestImages.Gif.Kumin - }; + ]; [Theory] [WithFileCollection(nameof(MultiFrameTestFiles), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs index 324bd4783..9c8f45f78 100644 --- a/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs +++ b/tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs @@ -123,7 +123,7 @@ public class ImageFormatManagerTests IImageFormat format = Image.DetectFormat(jpegImage); Assert.IsType(format); - byte[] invalidImage = { 1, 2, 3 }; + byte[] invalidImage = [1, 2, 3]; Assert.Throws(() => Image.DetectFormat(invalidImage)); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs index 740b410fe..aee064ccc 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs @@ -10,10 +10,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class AdobeMarkerTests { // Taken from actual test image - private readonly byte[] bytes = { 0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x2 }; + private readonly byte[] bytes = [0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x2]; // Altered components - private readonly byte[] bytes2 = { 0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x1, 0x1, 0x1 }; + private readonly byte[] bytes2 = [0x41, 0x64, 0x6F, 0x62, 0x65, 0x0, 0x64, 0x0, 0x0, 0x1, 0x1, 0x1]; [Fact] public void MarkerLengthIsCorrect() @@ -36,7 +36,7 @@ public class AdobeMarkerTests [Fact] public void MarkerIgnoresIncorrectValue() { - bool isAdobe = AdobeMarker.TryParse(new byte[] { 0, 0, 0, 0 }, out AdobeMarker marker); + bool isAdobe = AdobeMarker.TryParse([0, 0, 0, 0], out AdobeMarker marker); Assert.False(isAdobe); Assert.Equal(default, marker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs index 3b7e20eb4..22b25a2be 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs @@ -10,13 +10,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class JFifMarkerTests { // Taken from actual test image - private readonly byte[] bytes = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x60, 0x0, 0x60, 0x0 }; + private readonly byte[] bytes = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x60, 0x0, 0x60, 0x0]; // Altered components - private readonly byte[] bytes2 = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x48, 0x0, 0x48, 0x0 }; + private readonly byte[] bytes2 = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x48, 0x0, 0x48, 0x0]; // Incorrect density values. Zero is invalid. - private readonly byte[] bytes3 = { 0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0 }; + private readonly byte[] bytes3 = [0x4A, 0x46, 0x49, 0x46, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0]; [Fact] public void MarkerLengthIsCorrect() @@ -40,7 +40,7 @@ public class JFifMarkerTests [Fact] public void MarkerIgnoresIncorrectValue() { - bool isJFif = JFifMarker.TryParse(new byte[] { 0, 0, 0, 0 }, out JFifMarker marker); + bool isJFif = JFifMarker.TryParse([0, 0, 0, 0], out JFifMarker marker); Assert.False(isJFif); Assert.Equal(default, marker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs index 85fad3f82..a4a71c673 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs @@ -7,7 +7,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public partial class JpegDecoderTests { public static string[] BaselineTestJpegs = - { + [ TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Ycck, @@ -41,11 +41,11 @@ public partial class JpegDecoderTests TestImages.Jpeg.Baseline.Testorig12bit, // Grayscale jpeg with 2x2 sampling factors (not a usual thing to encounter in the wild) - TestImages.Jpeg.Baseline.GrayscaleSampling2x2, - }; + TestImages.Jpeg.Baseline.GrayscaleSampling2x2 + ]; public static string[] ProgressiveTestJpegs = - { + [ TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, TestImages.Jpeg.Progressive.Festzug, @@ -61,20 +61,20 @@ public partial class JpegDecoderTests TestImages.Jpeg.Issues.OrderedInterleavedProgressive723A, TestImages.Jpeg.Issues.OrderedInterleavedProgressive723B, TestImages.Jpeg.Issues.OrderedInterleavedProgressive723C - }; + ]; public static string[] UnsupportedTestJpegs = - { + [ // Invalid componentCount value (2 or > 4) TestImages.Jpeg.Issues.Fuzz.NullReferenceException823, TestImages.Jpeg.Issues.MalformedUnsupportedComponentCount, // Lossless jpeg TestImages.Jpeg.Baseline.Lossless - }; + ]; public static string[] UnrecoverableTestJpegs = - { + [ TestImages.Jpeg.Issues.CriticalEOF214, TestImages.Jpeg.Issues.Fuzz.NullReferenceException797, TestImages.Jpeg.Issues.Fuzz.AccessViolationException798, @@ -98,8 +98,8 @@ public partial class JpegDecoderTests TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException1693A, TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException1693B, TestImages.Jpeg.Issues.Fuzz.IndexOutOfRangeException824C, - TestImages.Jpeg.Issues.Fuzz.NullReferenceException2085, - }; + TestImages.Jpeg.Issues.Fuzz.NullReferenceException2085 + ]; private static readonly Dictionary CustomToleranceValues = new() { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs index 6cf6250cb..b780b14fb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Internal.cs @@ -19,7 +19,7 @@ public partial class JpegDecoderTests [InlineData(4, JpegConstants.Adobe.ColorTransformYcck, JpegColorSpace.Ycck)] internal void DeduceJpegColorSpaceAdobeMarker_ShouldReturnValidColorSpace(byte componentCount, byte adobeFlag, JpegColorSpace expectedColorSpace) { - byte[] adobeMarkerPayload = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, adobeFlag }; + byte[] adobeMarkerPayload = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, adobeFlag]; ProfileResolver.AdobeMarker.CopyTo(adobeMarkerPayload); _ = AdobeMarker.TryParse(adobeMarkerPayload, out AdobeMarker adobeMarker); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 8126a37fe..2856abe5c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -44,8 +44,8 @@ public partial class JpegDecoderTests private static bool SkipTest(ITestImageProvider provider) { string[] largeImagesToSkipOn32Bit = - { - TestImages.Jpeg.Baseline.Jpeg420Exif, + [ + TestImages.Jpeg.Baseline.Jpeg420Exif, TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159, TestImages.Jpeg.Issues.BadZigZagProgressive385, TestImages.Jpeg.Issues.NoEoiProgressive517, @@ -53,7 +53,7 @@ public partial class JpegDecoderTests TestImages.Jpeg.Issues.InvalidEOI695, TestImages.Jpeg.Issues.ExifResizeOutOfRange696, TestImages.Jpeg.Issues.ExifGetString750Transform - }; + ]; return !TestEnvironment.Is64BitProcess && largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index 58b437af0..ede147dbe 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -258,8 +258,8 @@ where TPixel : unmanaged, IPixel using Image image = provider.GetImage(); image.Mutate(x => x.Crop(132, 1606)); - int[] quality = new int[] { 100, 50 }; - JpegColorType[] colors = new[] { JpegColorType.YCbCrRatio444, JpegColorType.YCbCrRatio420 }; + int[] quality = [100, 50]; + JpegColorType[] colors = [JpegColorType.YCbCrRatio444, JpegColorType.YCbCrRatio420]; for (int i = 0; i < quality.Length; i++) { int q = quality[i]; diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 60de0a204..903a6b076 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -22,19 +22,19 @@ public class SpectralJpegTests private ITestOutputHelper Output { get; } public static readonly string[] BaselineTestJpegs = - { - TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, + [ + TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444, TestImages.Jpeg.Baseline.Testorig420, TestImages.Jpeg.Baseline.Jpeg420Small, TestImages.Jpeg.Baseline.Bad.BadEOF, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; public static readonly string[] ProgressiveTestJpegs = - { - TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, + [ + TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, TestImages.Jpeg.Progressive.Festzug, TestImages.Jpeg.Progressive.Bad.BadEOF, - TestImages.Jpeg.Progressive.Bad.ExifUndefType, - }; + TestImages.Jpeg.Progressive.Bad.ExifUndefType + ]; public static readonly string[] AllTestJpegs = BaselineTestJpegs.Concat(ProgressiveTestJpegs).ToArray(); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs index d55a25453..13300ee80 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs @@ -15,12 +15,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg; public class SpectralToPixelConversionTests { public static readonly string[] BaselineTestJpegs = - { + [ TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444, TestImages.Jpeg.Baseline.Testorig420, TestImages.Jpeg.Baseline.Jpeg420Small, TestImages.Jpeg.Baseline.Bad.BadEOF, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; public SpectralToPixelConversionTests(ITestOutputHelper output) => this.Output = output; diff --git a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs index 53f9a0278..c2b640a1d 100644 --- a/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs @@ -60,7 +60,7 @@ public class Adler32Tests private static void RunCalculateAdlerTest() { - int[] testData = { 0, 8, 215, 1024, 1024 + 15, 2034, 4096 }; + int[] testData = [0, 8, 215, 1024, 1024 + 15, 2034, 4096]; for (int i = 0; i < testData.Length; i++) { CalculateAdlerAndCompareToReference(testData[i]); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs index f5c42c734..00db13d4b 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs @@ -13,33 +13,33 @@ public class PngDecoderFilterTests { // arrange byte[] scanline = - { + [ 3, 39, 39, 39, 0, 4, 4, 4, 0, 1, 1, 1, 0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2, 0, 4, 4, 4, 0, 2, 2, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 2, 2, 2, 0, 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 1, 1, 1, 0, 3, 3, 3, 0, 3, 3, 3, 0, 254, 254, 254, 0, 6, 6, 6, 14, 71, 71, 71, 157, 254, 254, 254, 28, 251, 251, 251, 0, 4, 4, 4, 0, 2, 2, 2, 0, 11, 11, 11, 0, 226, 226, 226, 0, 255, 128, 234 - }; + ]; byte[] previousScanline = - { + [ 3, 74, 74, 74, 0, 73, 73, 73, 0, 73, 73, 73, 0, 74, 74, 74, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, 72, 0, 72, 72, 72, 0, 73, 73, 73, 0, 74, 74, 74, 0, 73, 73, 73, 0, 72, 72, 72, 0, 72, 72, 72, 0, 74, 74, 74, 0, 72, 72, 72, 0, 73, 73, 73, 0, 75, 75, 75, 0, 73, 73, 73, 0, 74, 74, 74, 0, 72, 72, 72, 0, 73, 73, 73, 0, 73, 73, 73, 0, 72, 72, 72, 0, 74, 74, 74, 0, 61, 61, 61, 0, 101, 101, 101, 78, 197, 197, 197, 251, 152, 152, 152, 255, 155, 155, 155, 255, 162, 162, 162, 255, 175, 175, 175, 255, 160, 160, 160, 255, 139, 128, 134 - }; + ]; byte[] expected = - { + [ 3, 76, 76, 76, 0, 78, 78, 78, 0, 76, 76, 76, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 78, 78, 78, 0, 77, 77, 77, 0, 78, 78, 78, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 77, 77, 77, 0, 78, 78, 78, 0, 77, 77, 77, 0, 77, 77, 77, 0, 76, 76, 76, 0, 77, 77, 77, 0, 77, 77, 77, 0, 73, 73, 73, 0, 73, 73, 73, 14, 158, 158, 158, 203, 175, 175, 175, 255, 158, 158, 158, 255, 160, 160, 160, 255, 163, 163, 163, 255, 180, 180, 180, 255, 140, 140, 140, 255, 138, 6, 115 - }; + ]; // act AverageFilter.Decode(scanline, previousScanline, 4); @@ -52,25 +52,25 @@ public class PngDecoderFilterTests { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] previousScanline = - { + [ 214, 103, 135, 26, 133, 179, 134, 168, 175, 114, 118, 99, 167, 129, 55, 105, 129, 154, 173, 235, 179, 191, 41, 137, 253, 0, 81, 198, 159, 228, 224, 245, 14, 113, 5, 45, 126, 239, 233, 179, 229, 62, 66, 155, 207, 117, 128, 56, 181, 190, 160, 96, 11, 248, 74, 23, 62, 253, 29, 132, 98, 192, 9, 202 - }; + ]; byte[] expected = - { + [ 62, 126, 65, 176, 51, 183, 83, 227, 72, 248, 20, 185, 151, 46, 246, 163, 240, 81, 250, 16, 8, 214, 134, 85, 107, 139, 90, 218, 246, 126, 144, 43, 221, 71, 45, 56, 49, 182, 240, 142, 147, 48, 178, 119, 100, 122, 137, 166, 28, 41, 135, 81, 24, 62, 34, 62, 248, 234, 68, 166, 93, 121, 237, 200 - }; + ]; // act UpFilter.Decode(scanline, previousScanline); @@ -83,18 +83,18 @@ public class PngDecoderFilterTests { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] expected = - { + [ 62, 23, 186, 150, 174, 27, 135, 209, 71, 161, 37, 39, 55, 78, 228, 97, 166, 5, 49, 134, 251, 28, 142, 82, 105, 167, 151, 102, 192, 65, 71, 156, 143, 23, 111, 167, 66, 222, 118, 130, 240, 208, 230, 94, 133, 213, 239, 204, 236, 64, 214, 189, 249, 134, 174, 228, 179, 115, 213, 6, 174, 44, 185, 4 - }; + ]; // act SubFilter.Decode(scanline, 4); @@ -107,25 +107,25 @@ public class PngDecoderFilterTests { // arrange byte[] scanline = - { + [ 62, 23, 186, 150, 174, 4, 205, 59, 153, 134, 158, 86, 240, 173, 191, 58, 111, 183, 77, 37, 85, 23, 93, 204, 110, 139, 9, 20, 87, 154, 176, 54, 207, 214, 40, 11, 179, 199, 7, 219, 174, 242, 112, 220, 149, 5, 9, 110, 103, 107, 231, 241, 13, 70, 216, 39, 186, 237, 39, 34, 251, 185, 228, 254 - }; + ]; byte[] previousScanline = - { + [ 214, 103, 135, 26, 133, 179, 134, 168, 175, 114, 118, 99, 167, 129, 55, 105, 129, 154, 173, 235, 179, 191, 41, 137, 253, 0, 81, 198, 159, 228, 224, 245, 14, 113, 5, 45, 126, 239, 233, 179, 229, 62, 66, 155, 207, 117, 128, 56, 181, 190, 160, 96, 11, 248, 74, 23, 62, 253, 29, 132, 98, 192, 9, 202 - }; + ]; byte[] expected = - { + [ 62, 126, 65, 176, 51, 183, 14, 235, 30, 248, 172, 254, 14, 165, 53, 56, 125, 92, 250, 16, 8, 177, 10, 220, 118, 139, 50, 240, 205, 126, 144, 43, 221, 71, 45, 54, 144, 182, 240, 142, 147, 48, 178, 106, 40, 122, 187, 166, 143, 41, 162, 151, 24, 111, 34, 135, 248, 92, 68, 169, 243, 21, 1, 200 - }; + ]; // act PaethFilter.Decode(scanline, previousScanline, 4); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs index 829cc64ff..8dfa98748 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs @@ -14,12 +14,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png; public partial class PngDecoderTests { // Represents ASCII string of "123456789" - private readonly byte[] check = { 49, 50, 51, 52, 53, 54, 55, 56, 57 }; + private readonly byte[] check = [49, 50, 51, 52, 53, 54, 55, 56, 57]; // Contains the png marker, IHDR and pHYs chunks of a 1x1 pixel 32bit png 1 a single black pixel. private static readonly byte[] Raw1X1PngIhdrAndpHYs = - { - // PNG Identifier + [ + // PNG Identifier 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, // IHDR @@ -36,12 +36,12 @@ public partial class PngDecoderTests // pHYS CRC 0xC7, 0x6F, 0xA8, 0x64 - }; + ]; // Contains the png marker, IDAT and IEND chunks of a 1x1 pixel 32bit png 1 a single black pixel. private static readonly byte[] Raw1X1PngIdatAndIend = - { - // IDAT + [ + // IDAT 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, @@ -54,7 +54,7 @@ public partial class PngDecoderTests // IEND CRC 0xAE, 0x42, 0x60, 0x82 - }; + ]; [Theory] [InlineData((uint)PngChunkType.Header)] // IHDR @@ -94,10 +94,10 @@ public partial class PngDecoderTests private static void WriteChunk(MemoryStream memStream, string chunkName) { // Needs a minimum length of 9 for pHYs chunk. - memStream.Write(new byte[] { 0, 0, 0, 9 }, 0, 4); + memStream.Write([0, 0, 0, 9], 0, 4); memStream.Write(Encoding.ASCII.GetBytes(chunkName), 0, 4); // 4 bytes chunk header - memStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 9); // 9 bytes of chunk data - memStream.Write(new byte[] { 0, 0, 0, 0 }, 0, 4); // Junk Crc + memStream.Write([0, 0, 0, 0, 0, 0, 0, 0, 0], 0, 9); // 9 bytes of chunk data + memStream.Write([0, 0, 0, 0], 0, 4); // Junk Crc } private static void WriteDataChunk(MemoryStream memStream) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 1a74fe5b2..3589a25a2 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -21,7 +21,7 @@ public partial class PngDecoderTests private const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.RgbaVector | PixelTypes.Argb32; public static readonly string[] CommonTestImages = - { + [ TestImages.Png.Splash, TestImages.Png.FilterVar, @@ -35,29 +35,29 @@ public partial class PngDecoderTests TestImages.Png.Rgb24BppTrans, TestImages.Png.Bad.ChunkLength1, - TestImages.Png.Bad.ChunkLength2, - }; + TestImages.Png.Bad.ChunkLength2 + ]; public static readonly string[] TestImagesIssue1014 = - { + [ TestImages.Png.Issue1014_1, TestImages.Png.Issue1014_2, TestImages.Png.Issue1014_3, TestImages.Png.Issue1014_4, TestImages.Png.Issue1014_5, TestImages.Png.Issue1014_6 - }; + ]; public static readonly string[] TestImagesIssue1177 = - { + [ TestImages.Png.Issue1177_1, TestImages.Png.Issue1177_2 - }; + ]; public static readonly string[] CorruptedTestImages = - { + [ TestImages.Png.Bad.CorruptedChunk, TestImages.Png.Bad.ZlibOverflow, TestImages.Png.Bad.ZlibOverflow2, - TestImages.Png.Bad.ZlibZtxtBadHeader, - }; + TestImages.Png.Bad.ZlibZtxtBadHeader + ]; public static readonly TheoryData PixelFormatRange = new() { @@ -79,7 +79,7 @@ public partial class PngDecoderTests }; public static readonly string[] MultiFrameTestFiles = - { + [ TestImages.Png.APng, TestImages.Png.SplitIDatZeroLength, TestImages.Png.DisposeNone, @@ -90,7 +90,7 @@ public partial class PngDecoderTests TestImages.Png.BlendOverMultiple, TestImages.Png.FrameOffset, TestImages.Png.DefaultNotAnimated - }; + ]; [Theory] [MemberData(nameof(PixelFormatRange))] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs index 76fd260dd..fdaa70e03 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.Chunks.cs @@ -188,15 +188,15 @@ public partial class PngEncoderTests { PngChunkType.Data, false }, { PngChunkType.End, false } }; - List excludedChunkTypes = new() - { + List excludedChunkTypes = + [ PngChunkType.Gamma, PngChunkType.Exif, PngChunkType.Physical, PngChunkType.Text, PngChunkType.InternationalText, - PngChunkType.CompressedText, - }; + PngChunkType.CompressedText + ]; // act input.Save(memStream, encoder); @@ -252,7 +252,7 @@ public partial class PngEncoderTests { PngChunkType.Data, false }, { PngChunkType.End, false } }; - List excludedChunkTypes = new(); + List excludedChunkTypes = []; switch (chunkFilter) { case PngChunkFilter.ExcludeGammaChunk: @@ -326,8 +326,8 @@ public partial class PngEncoderTests using Image input = testFile.CreateRgba32Image(); using MemoryStream memStream = new(); PngEncoder encoder = new() { ChunkFilter = PngChunkFilter.None, TextCompressionThreshold = 8 }; - List expectedChunkTypes = new() - { + List expectedChunkTypes = + [ PngChunkType.Header, PngChunkType.Gamma, PngChunkType.EmbeddedColorProfile, @@ -338,8 +338,8 @@ public partial class PngEncoderTests PngChunkType.Exif, PngChunkType.Physical, PngChunkType.Data, - PngChunkType.End, - }; + PngChunkType.End + ]; // act input.Save(memStream, encoder); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index f1dcb357c..0d666d8c8 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -88,11 +88,11 @@ public partial class PngEncoderTests 80, 100, 120, 230 }; - public static readonly PngInterlaceMode[] InterlaceMode = new[] - { + public static readonly PngInterlaceMode[] InterlaceMode = + [ PngInterlaceMode.None, PngInterlaceMode.Adam7 - }; + ]; public static readonly TheoryData RatioFiles = new() @@ -289,8 +289,8 @@ public partial class PngEncoderTests byte[] data = ms.ToArray().Take(8).ToArray(); byte[] expected = - { - 0x89, // Set the high bit. + [ + 0x89, // Set the high bit. 0x50, // P 0x4E, // N 0x47, // G @@ -298,7 +298,7 @@ public partial class PngEncoderTests 0x0A, // Line ending CRLF 0x1A, // EOF 0x0A // LF - }; + ]; Assert.Equal(expected, data); } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs index 0fa7e01e8..54c8172b8 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/BlackIsZeroTiffColorTests.cs @@ -20,100 +20,100 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Bit1 = new(255, 255, 255, 255); private static readonly byte[] BilevelBytes4X4 = - { + [ 0b01010000, 0b11110000, 0b01110000, 0b10010000 - }; + ]; private static readonly Rgba32[][] BilevelResult4X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 } - }; + [ + [Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit1], + [Bit1, Bit0, Bit0, Bit1] + ]; private static readonly byte[] BilevelBytes12X4 = - { + [ 0b01010101, 0b01010000, 0b11111111, 0b11111111, 0b01101001, 0b10100000, 0b10010000, 0b01100000 - }; + ]; private static readonly Rgba32[][] BilevelResult12X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 } - }; + [ + [Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0], + [Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0] + ]; private static readonly byte[] Grayscale4Bytes4X4 = - { + [ 0x8F, 0x0F, 0xFF, 0xFF, 0x08, 0x8F, 0xF0, 0xF8 - }; + ]; private static readonly Rgba32[][] Grayscale4Result4X4 = - { - new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 } - }; + [ + [Gray8, GrayF, Gray0, GrayF], + [GrayF, GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8, GrayF], + [GrayF, Gray0, GrayF, Gray8] + ]; private static readonly byte[] Grayscale4Bytes3X4 = - { + [ 0x8F, 0x00, 0xFF, 0xF0, 0x08, 0x80, 0xF0, 0xF0 - }; + ]; private static readonly Rgba32[][] Grayscale4Result3X4 = - { - new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF } - }; + [ + [Gray8, GrayF, Gray0], + [GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8], + [GrayF, Gray0, GrayF] + ]; private static readonly byte[] Grayscale8Bytes4X4 = - { + [ 128, 255, 000, 255, 255, 255, 255, 255, 000, 128, 128, 255, 255, 000, 255, 128 - }; + ]; private static readonly Rgba32[][] Grayscale8Result4X4 = - { - new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 } - }; + [ + [Gray128, Gray255, Gray000, Gray255], + [Gray255, Gray255, Gray255, Gray255], + [Gray000, Gray128, Gray128, Gray255], + [Gray255, Gray000, Gray255, Gray128] + ]; public static IEnumerable BilevelData { get { - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4 }; - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6) }; - - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4 }; - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6) }; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4]; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6)]; + + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4]; + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6)]; } } @@ -121,17 +121,17 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase { get { - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4 }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4 }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6) }; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4]; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6)]; + + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4]; + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6)]; } } @@ -139,11 +139,11 @@ public class BlackIsZeroTiffColorTests : PhotometricInterpretationTestBase { get { - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4 }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6) }; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4]; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6)]; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index 13be77a29..a645f2edd 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -15,39 +15,43 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public static ushort[] Palette4ColorMap => GenerateColorMap(Palette4ColorPalette); private static readonly byte[] Palette4Bytes4X4 = - { + [ 0x01, 0x23, 0x4A, 0xD2, 0x12, 0x34, 0xAB, 0xEF - }; + ]; private static readonly Rgba32[][] Palette4Result4X4 = GenerateResult( Palette4ColorPalette, - new[] { new[] { 0x00, 0x01, 0x02, 0x03 }, new[] { 0x04, 0x0A, 0x0D, 0x02 }, new[] { 0x01, 0x02, 0x03, 0x04 }, new[] { 0x0A, 0x0B, 0x0E, 0x0F } }); + [ + [0x00, 0x01, 0x02, 0x03], [0x04, 0x0A, 0x0D, 0x02], [0x01, 0x02, 0x03, 0x04], [0x0A, 0x0B, 0x0E, 0x0F] + ]); private static readonly byte[] Palette4Bytes3X4 = - { + [ 0x01, 0x20, 0x4A, 0xD0, 0x12, 0x30, 0xAB, 0xE0 - }; + ]; - private static readonly Rgba32[][] Palette4Result3X4 = GenerateResult(Palette4ColorPalette, new[] { new[] { 0x00, 0x01, 0x02 }, new[] { 0x04, 0x0A, 0x0D }, new[] { 0x01, 0x02, 0x03 }, new[] { 0x0A, 0x0B, 0x0E } }); + private static readonly Rgba32[][] Palette4Result3X4 = GenerateResult(Palette4ColorPalette, [ + [0x00, 0x01, 0x02], [0x04, 0x0A, 0x0D], [0x01, 0x02, 0x03], [0x0A, 0x0B, 0x0E] + ]); public static IEnumerable Palette4Data { get { - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Palette4Result4X4 }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Offset(Palette4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 1, 0, 4, 4, Offset(Palette4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 0, 1, 4, 4, Offset(Palette4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Palette4Bytes4X4, 4, Palette4ColorMap, 1, 1, 4, 4, Offset(Palette4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Palette4Result3X4 }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Offset(Palette4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 1, 0, 3, 4, Offset(Palette4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 0, 1, 3, 4, Offset(Palette4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Palette4Bytes3X4, 4, Palette4ColorMap, 1, 1, 3, 4, Offset(Palette4Result3X4, 1, 1, 6, 6) }; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Palette4Result4X4]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 0, 4, 4, Offset(Palette4Result4X4, 0, 0, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 1, 0, 4, 4, Offset(Palette4Result4X4, 1, 0, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 0, 1, 4, 4, Offset(Palette4Result4X4, 0, 1, 6, 6)]; + yield return [Palette4Bytes4X4, 4, Palette4ColorMap, 1, 1, 4, 4, Offset(Palette4Result4X4, 1, 1, 6, 6)]; + + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Palette4Result3X4]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 0, 3, 4, Offset(Palette4Result3X4, 0, 0, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 1, 0, 3, 4, Offset(Palette4Result3X4, 1, 0, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 0, 1, 3, 4, Offset(Palette4Result3X4, 0, 1, 6, 6)]; + yield return [Palette4Bytes3X4, 4, Palette4ColorMap, 1, 1, 3, 4, Offset(Palette4Result3X4, 1, 1, 6, 6)]; } } @@ -56,24 +60,26 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public static ushort[] Palette8ColorMap => GenerateColorMap(Palette8ColorPalette); private static readonly byte[] Palette8Bytes4X4 = - { + [ 000, 001, 002, 003, 100, 110, 120, 130, 000, 255, 128, 255, 050, 100, 150, 200 - }; + ]; - private static readonly Rgba32[][] Palette8Result4X4 = GenerateResult(Palette8ColorPalette, new[] { new[] { 000, 001, 002, 003 }, new[] { 100, 110, 120, 130 }, new[] { 000, 255, 128, 255 }, new[] { 050, 100, 150, 200 } }); + private static readonly Rgba32[][] Palette8Result4X4 = GenerateResult(Palette8ColorPalette, [ + [000, 001, 002, 003], [100, 110, 120, 130], [000, 255, 128, 255], [050, 100, 150, 200] + ]); public static IEnumerable Palette8Data { get { - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Palette8Result4X4 }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Offset(Palette8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 1, 0, 4, 4, Offset(Palette8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 0, 1, 4, 4, Offset(Palette8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Palette8Bytes4X4, 8, Palette8ColorMap, 1, 1, 4, 4, Offset(Palette8Result4X4, 1, 1, 6, 6) }; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Palette8Result4X4]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 0, 4, 4, Offset(Palette8Result4X4, 0, 0, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 1, 0, 4, 4, Offset(Palette8Result4X4, 1, 0, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 0, 1, 4, 4, Offset(Palette8Result4X4, 0, 1, 6, 6)]; + yield return [Palette8Bytes4X4, 8, Palette8ColorMap, 1, 1, 4, 4, Offset(Palette8Result4X4, 1, 1, 6, 6)]; } } @@ -92,7 +98,7 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase for (uint i = 0; i < count; i++) { - palette[i] = new[] { (i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u }; + palette[i] = [(i * 2u) % 65536u, (i * 2625u) % 65536u, (i * 29401u) % 65536u]; } return palette; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs index 2ca9df3d0..5df7c4d62 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbPlanarTiffColorTests.cs @@ -27,88 +27,88 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4R = - { + [ 0x0F, 0x0F, 0xF0, 0x0F, 0x48, 0xC4, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb4Bytes4X4G = - { + [ 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x08, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb4Bytes4X4B = - { + [ 0x0F, 0x0F, 0x00, 0xFF, 0x00, 0x0C, 0x04, 0x8C - }; + ]; - private static readonly byte[][] Rgb4Bytes4X4 = { Rgb4Bytes4X4R, Rgb4Bytes4X4G, Rgb4Bytes4X4B }; + private static readonly byte[][] Rgb4Bytes4X4 = [Rgb4Bytes4X4R, Rgb4Bytes4X4G, Rgb4Bytes4X4B]; private static readonly Rgba32[][] Rgb4Result4X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F], + [Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C], + [Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC] + ]; private static readonly byte[] Rgb4Bytes3X4R = - { + [ 0x0F, 0x00, 0xF0, 0x00, 0x48, 0xC0, 0x04, 0x80 - }; + ]; private static readonly byte[] Rgb4Bytes3X4G = - { + [ 0x0F, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x04, 0x80 - }; + ]; private static readonly byte[] Rgb4Bytes3X4B = - { + [ 0x0F, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x04, 0x80 - }; + ]; - private static readonly byte[][] Rgb4Bytes3X4 = { Rgb4Bytes3X4R, Rgb4Bytes3X4G, Rgb4Bytes3X4B }; + private static readonly byte[][] Rgb4Bytes3X4 = [Rgb4Bytes3X4R, Rgb4Bytes3X4G, Rgb4Bytes3X4B]; private static readonly Rgba32[][] Rgb4Result3X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F], + [Rgb4_400, Rgb4_800, Rgb4_C00], + [Rgb4_000, Rgb4_444, Rgb4_888] + ]; public static IEnumerable Rgb4Data { get { - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4 }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4 }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6) }; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6)]; + + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6)]; } } @@ -127,51 +127,51 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4R = - { + [ 000, 255, 000, 255, 255, 000, 000, 255, 064, 128, 192, 064, 000, 064, 128, 192 - }; + ]; private static readonly byte[] Rgb8Bytes4X4G = - { + [ 000, 255, 000, 255, 000, 255, 000, 000, 000, 000, 000, 128, 000, 064, 128, 192 - }; + ]; private static readonly byte[] Rgb8Bytes4X4B = - { + [ 000, 255, 000, 255, 000, 000, 255, 255, 000, 000, 000, 192, 000, 064, 128, 192 - }; + ]; private static readonly byte[][] Rgb8Bytes4X4 = - { + [ Rgb8Bytes4X4R, Rgb8Bytes4X4G, Rgb8Bytes4X4B - }; + ]; private static readonly Rgba32[][] Rgb8Result4X4 = - { - new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC } - }; + [ + [Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF], + [Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F], + [Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C], + [Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC] + ]; public static IEnumerable Rgb8Data { get { - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4 }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6) }; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6)]; } } @@ -190,48 +190,52 @@ public class RgbPlanarTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4R = - { + [ 0x0F, 0x0F, 0xF0, 0x0F, 0x48, 0xC4, 0x04, 0x8C - }; + ]; private static readonly byte[] Rgb484Bytes4X4G = - { + [ 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x80, 0xC0 - }; + ]; private static readonly byte[] Rgb484Bytes4X4B = - { + [ 0x0F, 0x0F, 0x00, 0xFF, 0x00, 0x0C, 0x04, 0x8C - }; + ]; private static readonly Rgba32[][] Rgb484Result4X4 = - { - new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC } - }; + [ + [Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF], + [Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F], + [Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C], + [Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC] + ]; - private static readonly byte[][] Rgb484Bytes4X4 = { Rgb484Bytes4X4R, Rgb484Bytes4X4G, Rgb484Bytes4X4B }; + private static readonly byte[][] Rgb484Bytes4X4 = [Rgb484Bytes4X4R, Rgb484Bytes4X4G, Rgb484Bytes4X4B]; public static IEnumerable Rgb484_Data { get { - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4 }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) }; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) + ]; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs index 80a04a7d1..6935d504e 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/RgbTiffColorTests.cs @@ -25,52 +25,52 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb4_48C = new(68, 136, 204, 255); private static readonly byte[] Rgb4Bytes4X4 = - { + [ 0x00, 0x0F, 0xFF, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0xF0, 0x00, 0xFF, 0x0F, 0x40, 0x08, 0x00, 0xC0, 0x04, 0x8C, 0x00, 0x04, 0x44, 0x88, 0x8C, 0xCC - }; + ]; private static readonly Rgba32[][] Rgb4Result4X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000, Rgb4_FFF], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F, Rgb4_F0F], + [Rgb4_400, Rgb4_800, Rgb4_C00, Rgb4_48C], + [Rgb4_000, Rgb4_444, Rgb4_888, Rgb4_CCC] + ]; private static readonly byte[] Rgb4Bytes3X4 = - { + [ 0x00, 0x0F, 0xFF, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x40, 0x08, 0x00, 0xC0, 0x00, 0x00, 0x04, 0x44, 0x88, 0x80 - }; + ]; private static readonly Rgba32[][] Rgb4Result3X4 = - { - new[] { Rgb4_000, Rgb4_FFF, Rgb4_000 }, - new[] { Rgb4_F00, Rgb4_0F0, Rgb4_00F }, - new[] { Rgb4_400, Rgb4_800, Rgb4_C00 }, - new[] { Rgb4_000, Rgb4_444, Rgb4_888 } - }; + [ + [Rgb4_000, Rgb4_FFF, Rgb4_000], + [Rgb4_F00, Rgb4_0F0, Rgb4_00F], + [Rgb4_400, Rgb4_800, Rgb4_C00], + [Rgb4_000, Rgb4_444, Rgb4_888] + ]; public static IEnumerable Rgb4Data { get { - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4 }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4 }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6) }; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Rgb4Result4X4]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 4, 4, Offset(Rgb4Result4X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 4, 4, Offset(Rgb4Result4X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 4, 4, Offset(Rgb4Result4X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes4X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 4, 4, Offset(Rgb4Result4X4, 1, 1, 6, 6)]; + + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Rgb4Result3X4]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 0, 3, 4, Offset(Rgb4Result3X4, 0, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 0, 3, 4, Offset(Rgb4Result3X4, 1, 0, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 0, 1, 3, 4, Offset(Rgb4Result3X4, 0, 1, 6, 6)]; + yield return [Rgb4Bytes3X4, new TiffBitsPerSample(4, 4, 4), 1, 1, 3, 4, Offset(Rgb4Result3X4, 1, 1, 6, 6)]; } } @@ -89,30 +89,30 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb8_48C = new(64, 128, 192, 255); private static readonly byte[] Rgb8Bytes4X4 = - { + [ 000, 000, 000, 255, 255, 255, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 255, 000, 000, 000, 255, 255, 000, 255, 064, 000, 000, 128, 000, 000, 192, 000, 000, 064, 128, 192, 000, 000, 000, 064, 064, 064, 128, 128, 128, 192, 192, 192 - }; + ]; private static readonly Rgba32[][] Rgb8Result4X4 = - { - new[] { Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF }, - new[] { Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F }, - new[] { Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C }, - new[] { Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC } - }; + [ + [Rgb8_000, Rgb8_FFF, Rgb8_000, Rgb8_FFF], + [Rgb8_F00, Rgb8_0F0, Rgb8_00F, Rgb8_F0F], + [Rgb8_400, Rgb8_800, Rgb8_C00, Rgb8_48C], + [Rgb8_000, Rgb8_444, Rgb8_888, Rgb8_CCC] + ]; public static IEnumerable Rgb8Data { get { - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4 }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6) }; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Rgb8Result4X4]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 0, 4, 4, Offset(Rgb8Result4X4, 0, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 0, 4, 4, Offset(Rgb8Result4X4, 1, 0, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 0, 1, 4, 4, Offset(Rgb8Result4X4, 0, 1, 6, 6)]; + yield return [Rgb8Bytes4X4, new TiffBitsPerSample(8, 8, 8), 1, 1, 4, 4, Offset(Rgb8Result4X4, 1, 1, 6, 6)]; } } @@ -131,30 +131,34 @@ public class RgbTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Rgb484_48C = new(68, 128, 204, 255); private static readonly byte[] Rgb484Bytes4X4 = - { + [ 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x0F, 0x40, 0x00, 0x80, 0x00, 0xC0, 0x00, 0x48, 0x0C, 0x00, 0x00, 0x44, 0x04, 0x88, 0x08, 0xCC, 0x0C - }; + ]; private static readonly Rgba32[][] Rgb484Result4X4 = - { - new[] { Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF }, - new[] { Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F }, - new[] { Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C }, - new[] { Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC } - }; + [ + [Rgb484_000, Rgb484_FFF, Rgb484_000, Rgb484_FFF], + [Rgb484_F00, Rgb484_0F0, Rgb484_00F, Rgb484_F0F], + [Rgb484_400, Rgb484_800, Rgb484_C00, Rgb484_48C], + [Rgb484_000, Rgb484_444, Rgb484_888, Rgb484_CCC] + ]; public static IEnumerable Rgb484Data { get { - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4 }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) }; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Rgb484Result4X4]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 0, 4, 4, Offset(Rgb484Result4X4, 0, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 0, 4, 4, Offset(Rgb484Result4X4, 1, 0, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 0, 1, 4, 4, Offset(Rgb484Result4X4, 0, 1, 6, 6) + ]; + yield return [Rgb484Bytes4X4, new TiffBitsPerSample(4, 8, 4), 1, 1, 4, 4, Offset(Rgb484Result4X4, 1, 1, 6, 6) + ]; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs index fa193c184..7a09bfae7 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/WhiteIsZeroTiffColorTests.cs @@ -20,100 +20,100 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase private static readonly Rgba32 Bit1 = new(0, 0, 0, 255); private static readonly byte[] BilevelBytes4X4 = - { + [ 0b01010000, 0b11110000, 0b01110000, 0b10010000 - }; + ]; private static readonly Rgba32[][] BilevelResult4X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit1 }, - new[] { Bit1, Bit0, Bit0, Bit1 } - }; + [ + [Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit1], + [Bit1, Bit0, Bit0, Bit1] + ]; private static readonly byte[] BilevelBytes12X4 = - { + [ 0b01010101, 0b01010000, 0b11111111, 0b11111111, 0b01101001, 0b10100000, 0b10010000, 0b01100000 - }; + ]; private static readonly Rgba32[][] BilevelResult12X4 = - { - new[] { Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1 }, - new[] { Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1 }, - new[] { Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0 }, - new[] { Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0 } - }; + [ + [Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1, Bit0, Bit1], + [Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1, Bit1], + [Bit0, Bit1, Bit1, Bit0, Bit1, Bit0, Bit0, Bit1, Bit1, Bit0, Bit1, Bit0], + [Bit1, Bit0, Bit0, Bit1, Bit0, Bit0, Bit0, Bit0, Bit0, Bit1, Bit1, Bit0] + ]; private static readonly byte[] Grayscale4Bytes4X4 = - { + [ 0x8F, 0x0F, 0xFF, 0xFF, 0x08, 0x8F, 0xF0, 0xF8 - }; + ]; private static readonly Rgba32[][] Grayscale4Result4X4 = - { - new[] { Gray8, GrayF, Gray0, GrayF }, - new[] { GrayF, GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8, GrayF }, - new[] { GrayF, Gray0, GrayF, Gray8 } - }; + [ + [Gray8, GrayF, Gray0, GrayF], + [GrayF, GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8, GrayF], + [GrayF, Gray0, GrayF, Gray8] + ]; private static readonly byte[] Grayscale4Bytes3X4 = - { + [ 0x8F, 0x00, 0xFF, 0xF0, 0x08, 0x80, 0xF0, 0xF0 - }; + ]; private static readonly Rgba32[][] Grayscale4Result3X4 = - { - new[] { Gray8, GrayF, Gray0 }, - new[] { GrayF, GrayF, GrayF }, - new[] { Gray0, Gray8, Gray8 }, - new[] { GrayF, Gray0, GrayF } - }; + [ + [Gray8, GrayF, Gray0], + [GrayF, GrayF, GrayF], + [Gray0, Gray8, Gray8], + [GrayF, Gray0, GrayF] + ]; private static readonly byte[] Grayscale8Bytes4X4 = - { + [ 128, 255, 000, 255, 255, 255, 255, 255, 000, 128, 128, 255, 255, 000, 255, 128 - }; + ]; private static readonly Rgba32[][] Grayscale8Result4X4 = - { - new[] { Gray128, Gray255, Gray000, Gray255 }, - new[] { Gray255, Gray255, Gray255, Gray255 }, - new[] { Gray000, Gray128, Gray128, Gray255 }, - new[] { Gray255, Gray000, Gray255, Gray128 } - }; + [ + [Gray128, Gray255, Gray000, Gray255], + [Gray255, Gray255, Gray255, Gray255], + [Gray000, Gray128, Gray128, Gray255], + [Gray255, Gray000, Gray255, Gray128] + ]; public static IEnumerable BilevelData { get { - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4 }; - yield return new object[] { BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6) }; - yield return new object[] { BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6) }; - - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4 }; - yield return new object[] { BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6) }; - yield return new object[] { BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6) }; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, BilevelResult4X4]; + yield return [BilevelBytes4X4, 1, 0, 0, 4, 4, Offset(BilevelResult4X4, 0, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 0, 4, 4, Offset(BilevelResult4X4, 1, 0, 6, 6)]; + yield return [BilevelBytes4X4, 1, 0, 1, 4, 4, Offset(BilevelResult4X4, 0, 1, 6, 6)]; + yield return [BilevelBytes4X4, 1, 1, 1, 4, 4, Offset(BilevelResult4X4, 1, 1, 6, 6)]; + + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, BilevelResult12X4]; + yield return [BilevelBytes12X4, 1, 0, 0, 12, 4, Offset(BilevelResult12X4, 0, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 0, 12, 4, Offset(BilevelResult12X4, 1, 0, 18, 6)]; + yield return [BilevelBytes12X4, 1, 0, 1, 12, 4, Offset(BilevelResult12X4, 0, 1, 18, 6)]; + yield return [BilevelBytes12X4, 1, 1, 1, 12, 4, Offset(BilevelResult12X4, 1, 1, 18, 6)]; } } @@ -121,17 +121,17 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { get { - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4 }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6) }; - - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4 }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6) }; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Grayscale4Result4X4]; + yield return [Grayscale4Bytes4X4, 4, 0, 0, 4, 4, Offset(Grayscale4Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 0, 4, 4, Offset(Grayscale4Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 0, 1, 4, 4, Offset(Grayscale4Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes4X4, 4, 1, 1, 4, 4, Offset(Grayscale4Result4X4, 1, 1, 6, 6)]; + + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Grayscale4Result3X4]; + yield return [Grayscale4Bytes3X4, 4, 0, 0, 3, 4, Offset(Grayscale4Result3X4, 0, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 0, 3, 4, Offset(Grayscale4Result3X4, 1, 0, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 0, 1, 3, 4, Offset(Grayscale4Result3X4, 0, 1, 6, 6)]; + yield return [Grayscale4Bytes3X4, 4, 1, 1, 3, 4, Offset(Grayscale4Result3X4, 1, 1, 6, 6)]; } } @@ -139,11 +139,11 @@ public class WhiteIsZeroTiffColorTests : PhotometricInterpretationTestBase { get { - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4 }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6) }; - yield return new object[] { Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6) }; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Grayscale8Result4X4]; + yield return [Grayscale8Bytes4X4, 8, 0, 0, 4, 4, Offset(Grayscale8Result4X4, 0, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 0, 4, 4, Offset(Grayscale8Result4X4, 1, 0, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 0, 1, 4, 4, Offset(Grayscale8Result4X4, 0, 1, 6, 6)]; + yield return [Grayscale8Bytes4X4, 8, 1, 1, 4, 4, Offset(Grayscale8Result4X4, 1, 1, 6, 6)]; } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index e31487cd2..20b3ec2bb 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -208,8 +208,8 @@ public class TiffMetadataTests Rational expectedResolution = new(10, 1, simplify: false); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.XResolution).Value); Assert.Equal(expectedResolution, exifProfile.GetValue(ExifTag.YResolution).Value); - Assert.Equal(new Number[] { 8u }, exifProfile.GetValue(ExifTag.StripOffsets)?.Value, new NumberComparer()); - Assert.Equal(new Number[] { 285u }, exifProfile.GetValue(ExifTag.StripByteCounts)?.Value, new NumberComparer()); + Assert.Equal([8u], exifProfile.GetValue(ExifTag.StripOffsets)?.Value, new NumberComparer()); + Assert.Equal([285u], exifProfile.GetValue(ExifTag.StripByteCounts)?.Value, new NumberComparer()); Assert.Null(exifProfile.GetValue(ExifTag.ExtraSamples, false)?.Value); Assert.Equal(32u, exifProfile.GetValue(ExifTag.RowsPerStrip).Value); Assert.Null(exifProfile.GetValue(ExifTag.SampleFormat, false)); diff --git a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs index 6073888fe..66f320143 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs @@ -12,13 +12,13 @@ public class ColorSpaceTransformUtilsTests private static void RunCollectColorBlueTransformsTest() { uint[] pixelData = - { + [ 3074, 256, 256, 256, 0, 65280, 65280, 65280, 256, 256, 0, 256, 0, 65280, 0, 65280, 16711680, 256, 256, 0, 65024, 0, 256, 256, 0, 65280, 0, 65280, 0, 256, 0, 256 - }; + ]; int[] expectedOutput = - { + [ 31, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -27,7 +27,7 @@ public class ColorSpaceTransformUtilsTests 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] histo = new int[256]; ColorSpaceTransformUtils.CollectColorBlueTransforms(pixelData, 0, 32, 1, 0, 0, histo); @@ -38,13 +38,13 @@ public class ColorSpaceTransformUtilsTests private static void RunCollectColorRedTransformsTest() { uint[] pixelData = - { + [ 3074, 256, 256, 256, 0, 65280, 65280, 65280, 256, 256, 0, 256, 0, 65280, 0, 65280, 16711680, 256, 256, 0, 65024, 0, 256, 256, 0, 65280, 0, 65280, 0, 256, 0, 256 - }; + ]; int[] expectedOutput = - { + [ 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -53,7 +53,7 @@ public class ColorSpaceTransformUtilsTests 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 - }; + ]; int[] histo = new int[256]; ColorSpaceTransformUtils.CollectColorRedTransforms(pixelData, 0, 32, 1, 0, histo); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 09aa94c75..982f0a5d5 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -11,8 +11,10 @@ public class LosslessUtilsTests { private static void RunCombinedShannonEntropyTest() { - int[] x = { 3, 5, 2, 5, 3, 1, 2, 2, 3, 3, 1, 2, 1, 2, 1, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 2, 1, 1, 0, 3, 1, 2, 3, 2, 3 }; - int[] y = { 11, 12, 8, 3, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 1, 2, 4, 6, 4 }; + int[] x = [3, 5, 2, 5, 3, 1, 2, 2, 3, 3, 1, 2, 1, 2, 1, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 2, 1, 1, 0, 3, 1, 2, 3, 2, 3 + ]; + int[] y = [11, 12, 8, 3, 4, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 1, 2, 4, 6, 4 + ]; const float expected = 884.7585f; float actual = LosslessUtils.CombinedShannonEntropy(x, y); @@ -23,7 +25,7 @@ public class LosslessUtilsTests private static void RunSubtractGreenTest() { uint[] pixelData = - { + [ 4293035898, 4293101432, 4292903793, 4292838511, 4292837995, 4292771950, 4292903791, 4293299316, 4293563769, 4293629303, 4293363312, 4291913575, 4289282905, 4288692313, 4289349210, 4289809240, 4289743703, 4289874775, 4289940567, 4289743701, 4290137943, 4290860378, 4291058267, 4291386715, @@ -31,10 +33,10 @@ public class LosslessUtilsTests 4291913571, 4292044130, 4291978850, 4291847521, 4291847524, 4291847779, 4291913571, 4291848293, 4291651689, 4291585895, 4291519584, 4291715936, 4291520355, 4291650658, 4291847263, 4291913313, 4291847777, 4291781731, 4291783015 - }; + ]; uint[] expectedOutput = - { + [ 4284188659, 4284254193, 4284318702, 4284187883, 4284318441, 4284383470, 4284318700, 4284124392, 4283799012, 4283864546, 4284581610, 4285163264, 4284891926, 4284497945, 4284761620, 4284893965, 4284828428, 4284959500, 4284959755, 4284828426, 4284960520, 4285289733, 4285159937, 4285292030, @@ -42,7 +44,7 @@ public class LosslessUtilsTests 4285163516, 4285425149, 4285294332, 4285228540, 4285228543, 4285163261, 4285163516, 4285032701, 4284835841, 4284835584, 4284966140, 4285228029, 4284770300, 4285097214, 4285293819, 4285228795, 4285163259, 4285228287, 4284901886 - }; + ]; LosslessUtils.SubtractGreenFromBlueAndRed(pixelData); @@ -52,7 +54,7 @@ public class LosslessUtilsTests private static void RunAddGreenToBlueAndRedTest() { uint[] pixelData = - { + [ 4284188659, 4284254193, 4284318702, 4284187883, 4284318441, 4284383470, 4284318700, 4284124392, 4283799012, 4283864546, 4284581610, 4285163264, 4284891926, 4284497945, 4284761620, 4284893965, 4284828428, 4284959500, 4284959755, 4284828426, 4284960520, 4285289733, 4285159937, 4285292030, @@ -60,10 +62,10 @@ public class LosslessUtilsTests 4285163516, 4285425149, 4285294332, 4285228540, 4285228543, 4285163261, 4285163516, 4285032701, 4284835841, 4284835584, 4284966140, 4285228029, 4284770300, 4285097214, 4285293819, 4285228795, 4285163259, 4285228287, 4284901886 - }; + ]; uint[] expectedOutput = - { + [ 4293035898, 4293101432, 4292903793, 4292838511, 4292837995, 4292771950, 4292903791, 4293299316, 4293563769, 4293629303, 4293363312, 4291913575, 4289282905, 4288692313, 4289349210, 4289809240, 4289743703, 4289874775, 4289940567, 4289743701, 4290137943, 4290860378, 4291058267, 4291386715, @@ -71,7 +73,7 @@ public class LosslessUtilsTests 4291913571, 4292044130, 4291978850, 4291847521, 4291847524, 4291847779, 4291913571, 4291848293, 4291651689, 4291585895, 4291519584, 4291715936, 4291520355, 4291650658, 4291847263, 4291913313, 4291847777, 4291781731, 4291783015 - }; + ]; LosslessUtils.AddGreenToBlueAndRed(pixelData); @@ -81,13 +83,13 @@ public class LosslessUtilsTests private static void RunTransformColorTest() { uint[] pixelData = - { + [ 5998579, 65790, 130301, 16646653, 196350, 130565, 16712702, 16583164, 16452092, 65790, 782600, 647446, 16571414, 16448771, 263931, 132601, 16711935, 131072, 511, 16711679, 132350, 329469, 16647676, 132093, 66303, 16647169, 16515584, 196607, 196096, 16646655, 514, 131326, 16712192, 327169, 16646655, 16776960, 3, 16712190, 511, 16646401, 16580612, 65535, 196092, 327425, 16319743, 392450, 196861, 16712192, 16711680, 130564, 16451071 - }; + ]; Vp8LMultipliers m = new() { @@ -97,13 +99,13 @@ public class LosslessUtilsTests }; uint[] expectedOutput = - { + [ 100279, 65790, 16710907, 16712190, 130813, 65028, 131840, 264449, 133377, 65790, 61697, 15917319, 14801924, 16317698, 591614, 394748, 16711935, 131072, 65792, 16711679, 328704, 656896, 132607, 328703, 197120, 66563, 16646657, 196607, 130815, 16711936, 131587, 131326, 66049, 261632, 16711936, 16776960, 3, 511, 65792, 16711938, 16580612, 65535, 65019, 327425, 16516097, 261377, 196861, 66049, 16711680, 65027, 16712962 - }; + ]; LosslessUtils.TransformColor(m, pixelData, pixelData.Length); @@ -113,13 +115,13 @@ public class LosslessUtilsTests private static void RunTransformColorInverseTest() { uint[] pixelData = - { + [ 100279, 65790, 16710907, 16712190, 130813, 65028, 131840, 264449, 133377, 65790, 61697, 15917319, 14801924, 16317698, 591614, 394748, 16711935, 131072, 65792, 16711679, 328704, 656896, 132607, 328703, 197120, 66563, 16646657, 196607, 130815, 16711936, 131587, 131326, 66049, 261632, 16711936, 16776960, 3, 511, 65792, 16711938, 16580612, 65535, 65019, 327425, 16516097, 261377, 196861, 66049, 16711680, 65027, 16712962 - }; + ]; Vp8LMultipliers m = new() { @@ -129,13 +131,13 @@ public class LosslessUtilsTests }; uint[] expectedOutput = - { + [ 5998579, 65790, 130301, 16646653, 196350, 130565, 16712702, 16583164, 16452092, 65790, 782600, 647446, 16571414, 16448771, 263931, 132601, 16711935, 131072, 511, 16711679, 132350, 329469, 16647676, 132093, 66303, 16647169, 16515584, 196607, 196096, 16646655, 514, 131326, 16712192, 327169, 16646655, 16776960, 3, 16712190, 511, 16646401, 16580612, 65535, 196092, 327425, 16319743, 392450, 196861, 16712192, 16711680, 130564, 16451071 - }; + ]; LosslessUtils.TransformColorInverse(m, pixelData); @@ -145,7 +147,7 @@ public class LosslessUtilsTests private static void RunPredictor11Test() { // arrange - uint[] topData = { 4278258949, 4278258949 }; + uint[] topData = [4278258949, 4278258949]; const uint left = 4294839812; short[] scratch = new short[8]; const uint expectedResult = 4294839812; @@ -166,7 +168,7 @@ public class LosslessUtilsTests private static void RunPredictor12Test() { // arrange - uint[] topData = { 4294844413, 4294779388 }; + uint[] topData = [4294844413, 4294779388]; const uint left = 4294844413; const uint expectedResult = 4294779388; @@ -186,10 +188,10 @@ public class LosslessUtilsTests private static void RunPredictor13Test() { // arrange - uint[] topData0 = { 4278193922, 4278193666 }; + uint[] topData0 = [4278193922, 4278193666]; const uint left0 = 4278193410; const uint expectedResult0 = 4278193154; - uint[] topData1 = { 4294933015, 4278219803 }; + uint[] topData1 = [4294933015, 4278219803]; const uint left1 = 4278236686; const uint expectedResult1 = 4278231571; uint actual0 = 0; @@ -218,17 +220,18 @@ public class LosslessUtilsTests public void BundleColorMap_WithXbitsZero_Works() { // arrange - byte[] row = { 238, 238, 238, 238, 238, 238, 240, 237, 240, 235, 223, 223, 218, 220, 226, 219, 220, 204, 218, 211, 218, 221, 254, 255 }; + byte[] row = [238, 238, 238, 238, 238, 238, 240, 237, 240, 235, 223, 223, 218, 220, 226, 219, 220, 204, 218, 211, 218, 221, 254, 255 + ]; int xBits = 0; uint[] actual = new uint[row.Length]; uint[] expected = - { + [ 4278251008, 4278251008, 4278251008, 4278251008, 4278251008, 4278251008, 4278251520, 4278250752, 4278251520, 4278250240, 4278247168, 4278247168, 4278245888, 4278246400, 4278247936, 4278246144, 4278246400, 4278242304, 4278245888, 4278244096, 4278245888, 4278246656, 4278255104, 4278255360 - }; + ]; // act LosslessUtils.BundleColorMap(row, actual.Length, xBits, actual); @@ -242,7 +245,7 @@ public class LosslessUtilsTests { // arrange byte[] row = - { + [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -251,17 +254,17 @@ public class LosslessUtilsTests 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 - }; + ]; int xBits = 2; uint[] actual = new uint[row.Length]; uint[] expected = - { + [ 4278233600, 4278233600, 4278233600, 4278233600, 4278255360, 4278255360, 4278255360, 4278255360, 4278233600, 4278233600, 4278233600, 4278233600, 4278255360, 4278255360, 4278255360, 4278255360, 4278211840, 4278211840, 4278211840, 4278211840, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278255360, 4278206208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; // act LosslessUtils.BundleColorMap(row, actual.Length, xBits, actual); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs index 73e7044f5..f4189933f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LossyUtilsTests.cs @@ -13,9 +13,10 @@ public class LossyUtilsTests private static void RunTransformTwoTest() { // arrange - short[] src = { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 23, 0, 0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + short[] src = [19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 23, 0, 0, -23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = - { + [ 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, @@ -23,16 +24,16 @@ public class LossyUtilsTests 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; byte[] expected = - { + [ 105, 105, 105, 105, 105, 103, 100, 98, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 108, 105, 102, 100, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 111, 109, 106, 103, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 103, 103, 103, 103, 105, 105, 105, 105, 113, 111, 108, 106, 0, 0, 0, 0, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act @@ -45,9 +46,9 @@ public class LossyUtilsTests private static void RunTransformOneTest() { // arrange - short[] src = { -176, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + short[] src = [-176, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; byte[] dst = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, @@ -55,9 +56,9 @@ public class LossyUtilsTests 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129 - }; + ]; byte[] expected = - { + [ 111, 111, 111, 111, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 108, 108, 108, 108, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, @@ -65,7 +66,7 @@ public class LossyUtilsTests 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 101, 101, 101, 101, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0, 0, 129 - }; + ]; int[] scratch = new int[16]; // act @@ -86,7 +87,7 @@ public class LossyUtilsTests a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 2533110, 2818581, 2984663, 2891188, 2855134, 2634604, 2466504, 3061747, 2626010, 2640965 }; + int[] expected = [2533110, 2818581, 2984663, 2891188, 2855134, 2634604, 2466504, 3061747, 2626010, 2640965]; // act + assert int offset = 0; @@ -110,7 +111,7 @@ public class LossyUtilsTests a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 1298274, 1234836, 1325264, 1493317, 1551995, 1432668, 1407891, 1483297, 1537930, 1317204 }; + int[] expected = [1298274, 1234836, 1325264, 1493317, 1551995, 1432668, 1407891, 1483297, 1537930, 1317204]; // act + assert int offset = 0; @@ -134,7 +135,7 @@ public class LossyUtilsTests a[i] = (byte)rand.Next(byte.MaxValue); b[i] = (byte)rand.Next(byte.MaxValue); } - int[] expected = { 194133, 125861, 165966, 195688, 106491, 173015, 266960, 200272, 311224, 122545 }; + int[] expected = [194133, 125861, 165966, 195688, 106491, 173015, 266960, 200272, 311224, 122545]; // act + assert int offset = 0; @@ -151,7 +152,7 @@ public class LossyUtilsTests { // arrange byte[] input = - { + [ 154, 145, 102, 115, 127, 129, 126, 125, 126, 120, 133, 152, 157, 153, 119, 94, 104, 116, 111, 113, 113, 109, 105, 124, 173, 175, 177, 170, 175, 172, 166, 164, 151, 141, 99, 114, 125, 126, 135, 150, 133, 115, 127, 149, 141, 168, 100, 54, 110, 117, 115, 116, 119, 115, 117, 130, 174, 174, 174, 157, @@ -159,9 +160,9 @@ public class LossyUtilsTests 109, 115, 113, 120, 120, 117, 128, 115, 174, 173, 173, 161, 152, 148, 153, 162, 105, 140, 96, 114, 115, 122, 141, 173, 190, 190, 142, 106, 151, 78, 66, 141, 110, 117, 123, 136, 118, 124, 127, 114, 173, 175, 166, 155, 155, 159, 159, 158 - }; + ]; uint[] dc = new uint[4]; - uint[] expectedDc = { 1940, 2139, 2252, 1813 }; + uint[] expectedDc = [1940, 2139, 2252, 1813]; // act LossyUtils.Mean16x4(input, dc); @@ -174,24 +175,24 @@ public class LossyUtilsTests { // arrange byte[] a = - { + [ 27, 27, 28, 29, 29, 28, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 27, 27, 26, 26, 26, 26, 27, 27, 27, 28, 28, 29, 29, 28, 28, 27, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 28, 27, 27, 26, 26, 27, 27, 28, 27, 28, 28, 29, 29, 28, 28, 27 - }; + ]; byte[] b = - { + [ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28 - }; + ]; - ushort[] w = { 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2 }; + ushort[] w = [38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2]; int expected = 2; // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index b4279b045..23ef8e7b1 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -43,7 +43,7 @@ public class PredictorEncoderTests { // arrange uint[] expectedData = - { + [ 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4294577152, 4294707200, 4294707200, 4294707200, 4294707200, 4294837248, 4294837248, 4293926912, 4294316544, 4278191104, 4278191104, 4294837248, 4294837248, 4280287232, 4280350720, 4294447104, 4294707200, @@ -76,7 +76,7 @@ public class PredictorEncoderTests 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4279503872, 4279503872, 4280288256, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232 - }; + ]; // Convert image pixels to bgra array. byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Peak)); @@ -100,13 +100,13 @@ public class PredictorEncoderTests { // arrange uint[] expectedData = - { + [ 4278714368, 4278192876, 4278198304, 4278198304, 4278190304, 4278190080, 4278190080, 4278198272, 4278197760, 4278198816, 4278197794, 4278197774, 4278190080, 4278190080, 4278198816, 4278197281, 4278197280, 4278197792, 4278200353, 4278191343, 4278190304, 4294713873, 4278198784, 4294844416, 4278201578, 4278200044, 4278191343, 4278190288, 4294705200, 4294717139, 4278203628, 4278201064, 4278201586, 4278197792, 4279240909 - }; + ]; // Convert image pixels to bgra array. byte[] imgBytes = File.ReadAllBytes(TestImageFullPath(TestImages.Webp.Lossy.BikeSmall)); diff --git a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs index 59691204b..fc7da8cf6 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs @@ -12,13 +12,14 @@ public class QuantEncTests private static unsafe void RunQuantizeBlockTest() { // arrange - short[] input = { 378, 777, -851, 888, 259, 148, 0, -111, -185, -185, -74, -37, 148, 74, 111, 74 }; + short[] input = [378, 777, -851, 888, 259, 148, 0, -111, -185, -185, -74, -37, 148, 74, 111, 74]; short[] output = new short[16]; - ushort[] q = { 42, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 }; - ushort[] iq = { 3120, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542 }; - uint[] bias = { 49152, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296 }; - uint[] zthresh = { 26, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21 }; - short[] expectedOutput = { 9, 21, 7, -5, 4, -23, 24, 0, -5, 4, 2, -2, -3, -1, 3, 2 }; + ushort[] q = [42, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37]; + ushort[] iq = [3120, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542, 3542]; + uint[] bias = [49152, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296, 55296 + ]; + uint[] zthresh = [26, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]; + short[] expectedOutput = [9, 21, 7, -5, 4, -23, 24, 0, -5, 4, 2, -2, -3, -1, 3, 2]; int expectedResult = 1; Vp8Matrix vp8Matrix = default; for (int i = 0; i < 16; i++) diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs index dab071692..c0b14cdd7 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8EncodingTests.cs @@ -12,12 +12,14 @@ public class Vp8EncodingTests private static void RunFTransform2Test() { // arrange - byte[] src = { 154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, 170, 177, 170, 175, 151, 149, 150, 150, 147, 147, 156, 161, 161, 161, 151, 126, 93, 90, 102, 107, 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 }; - byte[] reference = { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 }; + byte[] src = [154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, 170, 177, 170, 175, 151, 149, 150, 150, 147, 147, 156, 161, 161, 161, 151, 126, 93, 90, 102, 107, 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 + ]; + byte[] reference = [128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 + ]; short[] actualOutput1 = new short[16]; short[] actualOutput2 = new short[16]; - short[] expectedOutput1 = { 182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1 }; - short[] expectedOutput2 = { 192, -34, 10, 1, -11, 8, 10, -7, 6, 3, -8, 4, 5, -3, -2, 6 }; + short[] expectedOutput1 = [182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1]; + short[] expectedOutput2 = [192, -34, 10, 1, -11, 8, 10, -7, 6, 3, -8, 4, 5, -3, -2, 6]; // act Vp8Encoding.FTransform2(src, reference, actualOutput1, actualOutput2, new int[16]); @@ -31,7 +33,7 @@ public class Vp8EncodingTests { // arrange byte[] src = - { + [ 154, 154, 151, 151, 149, 148, 151, 157, 163, 163, 154, 132, 102, 98, 104, 108, 107, 104, 104, 103, 101, 106, 123, 119, 170, 171, 172, 171, 168, 175, 171, 173, 151, 151, 149, 150, 147, 147, 146, 159, 164, 165, 154, 129, 92, 90, 101, 105, 104, 103, 104, 101, 100, 105, 123, 117, 172, 172, 172, 168, @@ -39,9 +41,9 @@ public class Vp8EncodingTests 104, 103, 104, 101, 104, 104, 122, 117, 172, 172, 170, 168, 170, 177, 172, 175, 150, 149, 152, 151, 148, 151, 160, 159, 157, 157, 148, 133, 96, 90, 103, 107, 104, 104, 101, 100, 102, 102, 121, 117, 170, 170, 169, 171, 171, 179, 173, 175 - }; + ]; byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -49,9 +51,9 @@ public class Vp8EncodingTests 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; + ]; short[] actualOutput = new short[16]; - short[] expectedOutput = { 182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1 }; + short[] expectedOutput = [182, 4, 1, 1, 6, 7, -1, -4, 5, 0, -2, 1, 2, 1, 1, 1]; // act Vp8Encoding.FTransform(src, reference, actualOutput, new int[16]); @@ -64,7 +66,7 @@ public class Vp8EncodingTests { // arrange byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -72,17 +74,18 @@ public class Vp8EncodingTests 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; - short[] input = { 1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ]; + short[] input = [1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = new byte[128]; byte[] expected = - { + [ 161, 160, 149, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 133, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, 147, 109, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 128, 87, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act @@ -96,7 +99,7 @@ public class Vp8EncodingTests { // arrange byte[] reference = - { + [ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, @@ -104,17 +107,18 @@ public class Vp8EncodingTests 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129 - }; - short[] input = { 1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ]; + short[] input = [1, 216, -48, 0, 96, -24, -48, 24, 0, -24, 24, 0, 0, 0, 0, 0, 38, -240, -72, -24, 0, -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; byte[] dst = new byte[128]; byte[] expected = - { + [ 161, 160, 149, 105, 78, 127, 156, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 133, 85, 81, 129, 155, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, 147, 109, 76, 85, 130, 153, 163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 152, 128, 87, 83, 88, 132, 152, 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; + ]; int[] scratch = new int[16]; // act diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs index 7777c6108..8d8bcb57c 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8LHistogramTests.cs @@ -14,7 +14,7 @@ public class Vp8LHistogramTests { // arrange uint[] pixelData = - { + [ 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4278191104, 4294577152, 4294707200, 4294707200, 4294707200, 4294707200, 4294837248, 4294837248, 4293926912, 4294316544, 4278191104, 4278191104, 4294837248, 4294837248, 4280287232, 4280350720, 4294447104, 4294707200, @@ -47,10 +47,10 @@ public class Vp8LHistogramTests 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4279503872, 4279503872, 4280288256, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232, 4280287232 - }; + ]; uint[] literals = - { + [ 198, 0, 14, 0, 46, 0, 22, 0, 36, 0, 24, 0, 12, 0, 10, 0, 10, 0, 2, 0, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 10, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -59,7 +59,7 @@ public class Vp8LHistogramTests 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 6, 0, 2, 0, 2, 0, 2, 0, 0, 0, 8, 0, 2, 0, 38, 0, 4 - }; + ]; uint[] expectedLiterals = new uint[1305]; diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index 4982929c2..62c67c2e0 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -239,7 +239,7 @@ public class Vp8ResidualTests { // arrange Vp8Residual residual = new(); - short[] coeffs = { 110, 0, -2, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0 }; + short[] coeffs = [110, 0, -2, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0]; // act residual.SetCoeffs(coeffs); diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs index 1491cd13c..ca1859e54 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs @@ -45,7 +45,7 @@ public class WebpCommonUtilsTests { // arrange byte[] rowBytes = - { + [ 122, 120, 101, 255, 171, 165, 151, 255, 209, 208, 210, 255, @@ -104,8 +104,8 @@ public class WebpCommonUtilsTests 171, 165, 151, 0, 209, 208, 210, 100, 174, 183, 189, 255, - 148, 158, 158, 255, - }; + 148, 158, 158, 255 + ]; ReadOnlySpan row = MemoryMarshal.Cast(rowBytes); bool noneOpaque; @@ -127,7 +127,7 @@ public class WebpCommonUtilsTests { // arrange byte[] rowBytes = - { + [ 122, 120, 101, 255, 171, 165, 151, 255, 209, 208, 210, 255, @@ -186,8 +186,8 @@ public class WebpCommonUtilsTests 171, 165, 151, 255, 209, 208, 210, 255, 174, 183, 189, 255, - 148, 158, 158, 255, - }; + 148, 158, 158, 255 + ]; ReadOnlySpan row = MemoryMarshal.Cast(rowBytes); bool noneOpaque; diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index 6a46b26f2..e86642fea 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -52,7 +52,7 @@ public class YuvConversionTests Span u = uBuffer.GetSpan(); Span v = vBuffer.GetSpan(); byte[] expectedY = - { + [ 82, 82, 82, 82, 128, 135, 134, 129, 167, 179, 176, 172, 192, 201, 200, 204, 188, 172, 175, 177, 168, 151, 154, 154, 153, 152, 151, 151, 152, 160, 160, 160, 160, 82, 82, 82, 82, 140, 137, 135, 116, 174, 183, 176, 162, 196, 199, 199, 210, 188, 166, 176, 181, 170, 145, 155, 154, 153, 154, 151, 151, 150, @@ -106,9 +106,9 @@ public class YuvConversionTests 86, 75, 72, 77, 106, 96, 97, 96, 97, 100, 100, 100, 160, 160, 160, 159, 169, 170, 168, 170, 129, 115, 117, 123, 90, 71, 76, 79, 62, 51, 51, 47, 59, 79, 75, 74, 81, 100, 97, 98, 98, 100, 100, 100, 100 - }; + ]; byte[] expectedU = - { + [ 90, 90, 59, 63, 36, 38, 23, 20, 34, 35, 47, 48, 70, 82, 104, 121, 121, 90, 90, 61, 69, 37, 42, 22, 18, 33, 32, 47, 47, 67, 75, 97, 113, 120, 59, 61, 30, 37, 22, 20, 38, 36, 50, 50, 78, 83, 113, 122, 142, 166, 164, 63, 69, 37, 43, 20, 18, 34, 32, 48, 47, 70, 73, 102, 110, 136, 166, 166, 36, 37, 22, @@ -123,9 +123,9 @@ public class YuvConversionTests 184, 212, 208, 227, 228, 227, 229, 218, 214, 196, 185, 188, 121, 113, 166, 166, 197, 191, 220, 217, 232, 237, 223, 222, 211, 208, 185, 173, 172, 121, 120, 164, 166, 193, 194, 217, 219, 232, 235, 224, 220, 212, 207, 188, 172, 172 - }; + ]; byte[] expectedV = - { + [ 240, 240, 201, 206, 172, 174, 136, 136, 92, 90, 55, 50, 37, 30, 26, 23, 23, 240, 240, 204, 213, 173, 179, 141, 141, 96, 98, 56, 54, 38, 31, 27, 25, 23, 201, 204, 164, 172, 129, 135, 82, 87, 46, 47, 33, 29, 25, 23, 20, 16, 16, 206, 213, 172, 180, 137, 141, 93, 99, 54, 54, 36, 31, 26, 25, 21, 17, 16, @@ -139,7 +139,7 @@ public class YuvConversionTests 118, 151, 164, 188, 205, 206, 26, 27, 20, 21, 43, 39, 74, 69, 103, 102, 138, 143, 174, 188, 204, 216, 218, 23, 25, 16, 17, 55, 48, 85, 81, 117, 118, 159, 164, 195, 205, 216, 227, 227, 23, 23, 16, 16, 51, 52, 81, 83, 116, 122, 157, 168, 194, 206, 218, 227, 227 - }; + ]; // act YuvConversion.ConvertRgbToYuv(image.Frames.RootFrame.PixelBuffer.GetRegion(), config, memoryAllocator, y, u, v); @@ -169,7 +169,7 @@ public class YuvConversionTests Span u = uBuffer.GetSpan(); Span v = vBuffer.GetSpan(); byte[] expectedY = - { + [ 16, 16, 16, 16, 16, 235, 235, 235, 235, 235, 16, 16, 16, 16, 16, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 16, 16, 16, 16, 16, 235, 235, 235, 235, 235, 16, 16, 16, 16, 16, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 152, 41, 41, 152, 16, 16, 16, 16, 16, 235, @@ -213,9 +213,9 @@ public class YuvConversionTests 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 29, 106, 183, 66, 143, 130, 78, 90, 168, 116, 103, 180, 63, 140, 152, 75, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 93, 171, 53, 131, 118, 66, 78, 155, 103, 90, 167, 50, 128, 140, 63, 75 - }; + ]; byte[] expectedU = - { + [ 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, 240, 139, 240, 139, 128, 128, 128, 128, 128, 128, 128, 139, 240, 139, 240, 139, @@ -229,9 +229,9 @@ public class YuvConversionTests 159, 159, 159, 159, 159, 159, 159, 161, 112, 113, 138, 87, 143, 112, 88, 161, 240, 240, 240, 240, 240, 240, 240, 137, 110, 162, 110, 140, 158, 104, 159, 137, 240, 240, 240, 240, 240, 240, 240, 109, 150, 108, 140, 161, 80, 157, 162, 128 - }; + ]; byte[] expectedV = - { + [ 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, 110, 189, 110, 189, 128, 128, 128, 128, 128, 128, 128, 189, 110, 189, 110, 189, @@ -245,7 +245,7 @@ public class YuvConversionTests 141, 165, 126, 147, 173, 101, 101, 101, 101, 101, 101, 101, 135, 109, 129, 122, 124, 107, 108, 128, 138, 110, 110, 110, 110, 110, 110, 110, 117, 137, 151, 127, 114, 131, 139, 142, 120, 110, 110, 110, 110, 110, 110, 110, 142, 156, 119, 137, 167, 141, 151, 66, 85 - }; + ]; // act YuvConversion.ConvertRgbToYuv(image.Frames.RootFrame.PixelBuffer.GetRegion(), config, memoryAllocator, y, u, v); diff --git a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs index 390170cfe..89256507e 100644 --- a/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs +++ b/tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs @@ -47,14 +47,14 @@ public class ChunkedMemoryStreamTests ChunkedMemoryStream ms2 = new(this.allocator); Assert.Throws(() => ms2.Read(null, 0, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, -1, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, -1)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 2, 0)); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, 2)); + Assert.Throws(() => ms2.Read([1], -1, 0)); + Assert.Throws(() => ms2.Read([1], 0, -1)); + Assert.Throws(() => ms2.Read([1], 2, 0)); + Assert.Throws(() => ms2.Read([1], 0, 2)); ms2.Dispose(); - Assert.Throws(() => ms2.Read(new byte[] { 1 }, 0, 1)); + Assert.Throws(() => ms2.Read([1], 0, 1)); } [Theory] @@ -229,7 +229,7 @@ public class ChunkedMemoryStreamTests { using ChunkedMemoryStream ms2 = new(this.allocator); byte[] bytArrRet; - byte[] bytArr = new byte[] { byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250 }; + byte[] bytArr = [byte.MinValue, byte.MaxValue, 1, 2, 3, 4, 5, 6, 128, 250]; for (int i = 0; i < bytArr.Length; i++) { @@ -254,7 +254,7 @@ public class ChunkedMemoryStreamTests using ChunkedMemoryStream ms2 = new(this.allocator); Assert.Throws(() => ms2.WriteTo(null)); - ms2.Write(new byte[] { 1 }, 0, 1); + ms2.Write([1], 0, 1); MemoryStream readonlyStream = new(new byte[1028], false); Assert.Throws(() => ms2.WriteTo(readonlyStream)); @@ -313,7 +313,7 @@ public class ChunkedMemoryStreamTests IEnumerable allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories) .Where(s => !s.EndsWith("txt", StringComparison.OrdinalIgnoreCase)); - List result = new(); + List result = []; foreach (string path in allImageFiles) { result.Add(path[TestEnvironment.InputImagesDirectoryFullPath.Length..]); @@ -396,22 +396,22 @@ public class ChunkedMemoryStreamTests public static IEnumerable CopyToData() { // Stream is positioned @ beginning of data - byte[] data1 = new byte[] { 1, 2, 3 }; + byte[] data1 = [1, 2, 3]; MemoryStream stream1 = new(data1); - yield return new object[] { stream1, data1 }; + yield return [stream1, data1]; // Stream is positioned in the middle of data - byte[] data2 = new byte[] { 0xff, 0xf3, 0xf0 }; + byte[] data2 = [0xff, 0xf3, 0xf0]; MemoryStream stream2 = new(data2) { Position = 1 }; - yield return new object[] { stream2, new byte[] { 0xf3, 0xf0 } }; + yield return [stream2, new byte[] { 0xf3, 0xf0 }]; // Stream is positioned after end of data byte[] data3 = data2; MemoryStream stream3 = new(data3) { Position = data3.Length + 1 }; - yield return new object[] { stream3, Array.Empty() }; + yield return [stream3, Array.Empty()]; } private byte[] CreateTestBuffer(int length) diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs index 71c9e07fc..d7f2c7d28 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.Generic.cs @@ -102,7 +102,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 1, 1); new ImageFrameCollection( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); }); Assert.StartsWith("Frame must have the same dimensions as the image.", ex.Message); @@ -114,7 +114,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame }); + [imageFrame]); InvalidOperationException ex = Assert.Throws( () => collection.RemoveFrame(0)); @@ -128,7 +128,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); collection.RemoveFrame(0); Assert.Equal(1, collection.Count); @@ -141,7 +141,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); Assert.Equal(collection.RootFrame, collection[0]); } @@ -153,7 +153,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); Assert.Equal(2, collection.Count); } @@ -165,7 +165,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); collection.Dispose(); @@ -179,7 +179,7 @@ public abstract partial class ImageFrameCollectionTests using ImageFrame imageFrame2 = new(Configuration.Default, 10, 10); ImageFrameCollection collection = new( this.Image, - new[] { imageFrame1, imageFrame2 }); + [imageFrame1, imageFrame2]); IPixelSource[] framesSnapShot = collection.OfType>().ToArray(); diff --git a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs index f70623f51..cd1213c23 100644 --- a/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs +++ b/tests/ImageSharp.Tests/Image/ImageFrameCollectionTests.NonGeneric.cs @@ -247,7 +247,7 @@ public abstract partial class ImageFrameCollectionTests { Image image = new(Configuration.Default, 10, 10); ImageFrameCollection frameCollection = image.Frames; - Rgba32[] rgba32Array = Array.Empty(); + Rgba32[] rgba32Array = []; image.Dispose(); // this should invalidate underlying collection as well diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 6a196fd16..490fa3b0b 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -141,9 +141,8 @@ public partial class ImageTests { // https://github.com/SixLabors/ImageSharp/issues/1903 using ZipArchive zipFile = new(new MemoryStream( - new byte[] - { - 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, + [ + 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6D, 0x79, 0x73, 0x74, 0x65, 0x72, 0x79, 0x50, 0x4B, 0x01, 0x02, 0x3F, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -153,7 +152,7 @@ public partial class ImageTests 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x55, 0xA1, 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x59, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00 - })); + ])); using Stream stream = zipFile.Entries[0].Open(); Assert.Throws(() => Image.Identify(stream)); @@ -210,9 +209,8 @@ public partial class ImageTests { // https://github.com/SixLabors/ImageSharp/issues/1903 using ZipArchive zipFile = new(new MemoryStream( - new byte[] - { - 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, + [ + 0x50, 0x4B, 0x03, 0x04, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6D, 0x79, 0x73, 0x74, 0x65, 0x72, 0x79, 0x50, 0x4B, 0x01, 0x02, 0x3F, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xAF, 0x94, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -222,7 +220,7 @@ public partial class ImageTests 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x55, 0xA1, 0xF9, 0x91, 0x27, 0xF6, 0xD7, 0x01, 0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x59, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00 - })); + ])); using Stream stream = zipFile.Entries[0].Open(); await Assert.ThrowsAsync(async () => await Image.IdentifyAsync(stream)); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs b/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs index 5762264d2..47ae0daf7 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.LoadPixelData.cs @@ -15,7 +15,8 @@ public partial class ImageTests [ValidateDisposedMemoryAllocations] public void FromPixels(bool useSpan) { - Rgba32[] data = { Color.Black.ToPixel(), Color.White.ToPixel(), Color.White.ToPixel(), Color.Black.ToPixel(), }; + Rgba32[] data = [Color.Black.ToPixel(), Color.White.ToPixel(), Color.White.ToPixel(), Color.Black.ToPixel() + ]; using Image img = useSpan ? Image.LoadPixelData(data.AsSpan(), 2, 2) @@ -34,12 +35,12 @@ public partial class ImageTests public void FromBytes(bool useSpan) { byte[] data = - { + [ 0, 0, 0, 255, // 0,0 255, 255, 255, 255, // 0,1 255, 255, 255, 255, // 1,0 - 0, 0, 0, 255, // 1,1 - }; + 0, 0, 0, 255 // 1,1 + ]; using Image img = useSpan ? Image.LoadPixelData(data.AsSpan(), 2, 2) diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs index a03157822..a064b6472 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs @@ -10,7 +10,7 @@ public partial class ImageTests { public class Load_FromStream_Throws : IDisposable { - private static readonly byte[] Data = new byte[] { 0x01 }; + private static readonly byte[] Data = [0x01]; private MemoryStream Stream { get; } = new(Data); diff --git a/tests/ImageSharp.Tests/Memory/Allocators/MemoryDiagnosticsTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/MemoryDiagnosticsTests.cs index b8dd4be8d..c4b75b5cf 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/MemoryDiagnosticsTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/MemoryDiagnosticsTests.cs @@ -27,7 +27,7 @@ public class MemoryDiagnosticsTests int leakCounter = 0; MemoryDiagnostics.UndisposedAllocation += _ => Interlocked.Increment(ref leakCounter); - List buffers = new(); + List buffers = []; Assert.Equal(0, MemoryDiagnostics.TotalUndisposedAllocationCount); for (int length = 1024; length <= 64 * OneMb; length *= 2) diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs index f518b2272..fd9760f48 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.Trim.cs @@ -111,7 +111,7 @@ public partial class UniformUnmanagedMemoryPoolTests } public static readonly bool Is32BitProcess = !Environment.Is64BitProcess; - private static readonly List PressureArrays = new(); + private static readonly List PressureArrays = []; [Fact] public static void GC_Collect_OnHighLoad_TrimsEntirePool() diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index f62e99a8b..6e7e9fea7 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -92,7 +92,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests 1024, 1024); - List> groups = new(); + List> groups = []; for (int i = 0; i < 16; i++) { int lengthInElements = 128 / Unsafe.SizeOf(); diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index 6d35517ac..cee37ca56 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -45,7 +45,7 @@ public class ImageFrameMetadataTests ExifProfile exifProfile = new(); exifProfile.SetValue(ExifTag.Software, "UnitTest"); exifProfile.SetValue(ExifTag.Artist, "UnitTest"); - XmpProfile xmpProfile = new(Array.Empty()); + XmpProfile xmpProfile = new([]); IccProfile iccProfile = new() { Header = new IccProfileHeader diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs index 6c499f40c..c098ace09 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs @@ -82,7 +82,7 @@ public class ExifProfileTests public void ConstructorEmpty() { new ExifProfile(null); - new ExifProfile(Array.Empty()); + new ExifProfile([]); } [Fact] @@ -231,7 +231,7 @@ public class ExifProfileTests IExifValue referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite); Assert.Null(referenceBlackWhite.Value); - Rational[] expectedLatitude = new Rational[] { new(12.3), new(4.56), new(789.0) }; + Rational[] expectedLatitude = [new(12.3), new(4.56), new(789.0)]; image.Metadata.ExifProfile.SetValue(ExifTag.GPSLatitude, expectedLatitude); IExifValue latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude); @@ -362,7 +362,7 @@ public class ExifProfileTests [Fact] public void ReadWriteLargeProfileJpg() { - ExifTag[] tags = { ExifTag.Software, ExifTag.Copyright, ExifTag.Model, ExifTag.ImageDescription }; + ExifTag[] tags = [ExifTag.Software, ExifTag.Copyright, ExifTag.Model, ExifTag.ImageDescription]; foreach (ExifTag tag in tags) { // Arrange diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs index cb006ba29..d7d6741ba 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs @@ -355,7 +355,7 @@ public class ExifValuesTests [MemberData(nameof(ByteArrayTags))] public void ExifByteArrayTests(ExifTag tag) { - byte[] expected = new[] { byte.MaxValue }; + byte[] expected = [byte.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -369,7 +369,7 @@ public class ExifValuesTests [MemberData(nameof(DoubleArrayTags))] public void ExifDoubleArrayTests(ExifTag tag) { - double[] expected = new[] { double.MaxValue }; + double[] expected = [double.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -397,7 +397,7 @@ public class ExifValuesTests [MemberData(nameof(LongArrayTags))] public void ExifLongArrayTests(ExifTag tag) { - uint[] expected = new[] { uint.MaxValue }; + uint[] expected = [uint.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -458,7 +458,7 @@ public class ExifValuesTests [MemberData(nameof(NumberArrayTags))] public void ExifNumberArrayTests(ExifTag tag) { - Number[] expected = new[] { new Number(uint.MaxValue) }; + Number[] expected = [new Number(uint.MaxValue)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -496,7 +496,7 @@ public class ExifValuesTests [MemberData(nameof(RationalArrayTags))] public void ExifRationalArrayTests(ExifTag tag) { - Rational[] expected = new[] { new Rational(21, 42) }; + Rational[] expected = [new Rational(21, 42)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -526,7 +526,7 @@ public class ExifValuesTests [MemberData(nameof(ShortArrayTags))] public void ExifShortArrayTests(ExifTag tag) { - ushort[] expected = new[] { ushort.MaxValue }; + ushort[] expected = [ushort.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -554,7 +554,7 @@ public class ExifValuesTests [MemberData(nameof(SignedRationalArrayTags))] public void ExifSignedRationalArrayTests(ExifTag tag) { - SignedRational[] expected = new[] { new SignedRational(21, 42) }; + SignedRational[] expected = [new SignedRational(21, 42)]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -569,7 +569,7 @@ public class ExifValuesTests [MemberData(nameof(SignedShortArrayTags))] public void ExifSignedShortArrayTests(ExifTag tag) { - short[] expected = new short[] { 21, 42 }; + short[] expected = [21, 42]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); @@ -612,7 +612,7 @@ public class ExifValuesTests [MemberData(nameof(UndefinedArrayTags))] public void ExifUndefinedArrayTests(ExifTag tag) { - byte[] expected = new[] { byte.MaxValue }; + byte[] expected = [byte.MaxValue]; ExifValue value = ExifValues.Create(tag); Assert.False(value.TrySetValue(expected.ToString())); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs index c8f46d3aa..0a9b888ed 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs @@ -42,7 +42,7 @@ public class IccDataWriterPrimitivesTests byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal(Array.Empty(), output); + Assert.Equal([], output); } [Fact] @@ -62,7 +62,7 @@ public class IccDataWriterPrimitivesTests byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal(Array.Empty(), output); + Assert.Equal([], output); } [Theory] diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs index c64fcab58..2dbe5d343 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/IPTC/IptcProfileTests.cs @@ -14,7 +14,7 @@ public class IptcProfileTests { foreach (object tag in Enum.GetValues(typeof(IptcTag))) { - yield return new object[] { tag }; + yield return [tag]; } } @@ -25,7 +25,7 @@ public class IptcProfileTests IptcProfile profile = new(); profile.SetValue(IptcTag.City, "ESPAÑA"); profile.UpdateData(); - byte[] expectedEnvelopeData = { 28, 1, 90, 0, 3, 27, 37, 71 }; + byte[] expectedEnvelopeData = [28, 1, 90, 0, 3, 27, 37, 71]; // act byte[] profileBytes = profile.Data; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude index 90cb3a866..ccf90fe40 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude @@ -13,8 +13,8 @@ using Xunit; using Xunit.Abstractions; <#+ private static readonly string[] UnassociatedAlphaPixelTypes = - { - "A8", + [ + "A8", "Argb32", "Abgr32", "Bgra32", @@ -31,13 +31,13 @@ using Xunit.Abstractions; "Rgba64", "RgbaVector", "Short4" - }; + ]; - private static readonly string[] AssociatedAlphaPixelTypes = Array.Empty(); + private static readonly string[] AssociatedAlphaPixelTypes = []; private static readonly string[] CommonPixelTypes = - { - "A8", + [ + "A8", "Argb32", "Abgr32", "Bgr24", @@ -65,8 +65,8 @@ using Xunit.Abstractions; "Rgba64", "RgbaVector", "Short2", - "Short4", - }; + "Short4" + ]; void GenerateSpecializedClass(string pixelType, string alpha) {#> diff --git a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs index d90ccee41..eb1d3031a 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/KernelSamplingMapTest.cs @@ -15,15 +15,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 0, 0, 0, 1, 2, 0, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 6, - 4, 5, 6, 6, 6, - }; + 4, 5, 6, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -34,15 +34,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 2, 1, 0, 1, 2, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 5, - 4, 5, 6, 5, 4, - }; + 4, 5, 6, 5, 4 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -53,15 +53,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 1, 0, 0, 1, 2, 0, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 6, - 4, 5, 6, 6, 5, - }; + 4, 5, 6, 6, 5 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -72,15 +72,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 5, 6, 0, 1, 2, 6, 0, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 0, - 4, 5, 6, 0, 1, - }; + 4, 5, 6, 0, 1 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -91,7 +91,7 @@ public class KernelSamplingMapTest Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -100,8 +100,8 @@ public class KernelSamplingMapTest 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 8, - 7, 8, 9, 8, 7, - }; + 7, 8, 9, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -112,7 +112,7 @@ public class KernelSamplingMapTest Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 2, 1, 1, 2, 3, 1, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -121,8 +121,8 @@ public class KernelSamplingMapTest 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 9, - 7, 8, 9, 9, 8, - }; + 7, 8, 9, 9, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -133,7 +133,7 @@ public class KernelSamplingMapTest Rectangle bounds = new(1, 1, 9, 9); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 8, 9, 1, 2, 3, 9, 1, 2, 3, 4, 1, 2, 3, 4, 5, @@ -142,8 +142,8 @@ public class KernelSamplingMapTest 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 1, - 7, 8, 9, 1, 2, - }; + 7, 8, 9, 1, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -154,15 +154,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 2, 2, 2, 3, 4, 2, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 8, - 6, 7, 8, 8, 8, - }; + 6, 7, 8, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -173,15 +173,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 4, 3, 2, 3, 4, 3, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 7, - 6, 7, 8, 7, 6, - }; + 6, 7, 8, 7, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -192,15 +192,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 3, 2, 2, 3, 4, 2, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 8, - 6, 7, 8, 8, 7, - }; + 6, 7, 8, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -211,15 +211,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 7, 8, 2, 3, 4, 8, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 2, - 6, 7, 8, 2, 3, - }; + 6, 7, 8, 2, 3 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -230,15 +230,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 6, - }; + 5, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -249,15 +249,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 5, - }; + 5, 6, 5 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -268,15 +268,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 6, - }; + 5, 6, 6 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -287,15 +287,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(0, 0, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 6, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 0, - }; + 5, 6, 0 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -306,15 +306,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Repeat; int[] expected = - { + [ 2, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 8, - }; + 7, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -325,15 +325,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Bounce; int[] expected = - { + [ 3, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 7, - }; + 7, 8, 7 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -344,15 +344,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Mirror; int[] expected = - { + [ 2, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 8, - }; + 7, 8, 8 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -363,15 +363,15 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 7); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] expected = - { + [ 8, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 2, - }; + 7, 8, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, expected, expected); } @@ -382,23 +382,23 @@ public class KernelSamplingMapTest Rectangle bounds = new(2, 2, 7, 5); BorderWrappingMode mode = BorderWrappingMode.Wrap; int[] xExpected = - { + [ 8, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, - 7, 8, 2, - }; + 7, 8, 2 + ]; int[] yExpected = - { + [ 6, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, - 5, 6, 2, - }; + 5, 6, 2 + ]; this.AssertOffsets(kernelSize, bounds, mode, mode, xExpected, yExpected); } diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs index 1b3d1bd9a..43785da6e 100644 --- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs @@ -20,11 +20,11 @@ public class DitherTest : BaseImageOperationsExtensionTest private readonly IDither orderedDither; private readonly IDither errorDiffuser; private readonly Color[] testPalette = - { + [ Color.Red, Color.Green, Color.Blue - }; + ]; public DitherTest() { diff --git a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs index 703a64333..f55500f99 100644 --- a/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs +++ b/tests/ImageSharp.Tests/Processing/FakeImageOperationsProvider.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing; internal class FakeImageOperationsProvider : IImageProcessingContextFactory { - private readonly List imageOperators = new(); + private readonly List imageOperators = []; public bool HasCreated(Image source) where TPixel : unmanaged, IPixel @@ -51,7 +51,7 @@ internal class FakeImageOperationsProvider : IImageProcessingContextFactory public Image Source { get; } - public List Applied { get; } = new(); + public List Applied { get; } = []; public Configuration Configuration { get; } diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs index 7fb93bba5..f00087e1c 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs @@ -11,17 +11,17 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters; [Trait("Category", "Processors")] public class ColorBlindnessTest : BaseImageOperationsExtensionTest { - public static IEnumerable TheoryData = new[] - { - new object[] { new TestType(), ColorBlindnessMode.Achromatomaly }, - new object[] { new TestType(), ColorBlindnessMode.Achromatopsia }, - new object[] { new TestType(), ColorBlindnessMode.Deuteranomaly }, - new object[] { new TestType(), ColorBlindnessMode.Deuteranopia }, - new object[] { new TestType(), ColorBlindnessMode.Protanomaly }, - new object[] { new TestType(), ColorBlindnessMode.Protanopia }, - new object[] { new TestType(), ColorBlindnessMode.Tritanomaly }, - new object[] { new TestType(), ColorBlindnessMode.Tritanopia } - }; + public static IEnumerable TheoryData = + [ + [new TestType(), ColorBlindnessMode.Achromatomaly], + [new TestType(), ColorBlindnessMode.Achromatopsia], + [new TestType(), ColorBlindnessMode.Deuteranomaly], + [new TestType(), ColorBlindnessMode.Deuteranopia], + [new TestType(), ColorBlindnessMode.Protanomaly], + [new TestType(), ColorBlindnessMode.Protanopia], + [new TestType(), ColorBlindnessMode.Tritanomaly], + [new TestType(), ColorBlindnessMode.Tritanopia] + ]; [Theory] [MemberData(nameof(TheoryData))] diff --git a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs index 36edc10e5..6f0f06535 100644 --- a/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/Filters/GrayscaleTest.cs @@ -11,10 +11,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters; [Trait("Category", "Processors")] public class GrayscaleTest : BaseImageOperationsExtensionTest { - public static IEnumerable ModeTheoryData = new[] - { - new object[] { new TestType(), GrayscaleMode.Bt709 } - }; + public static IEnumerable ModeTheoryData = + [ + [new TestType(), GrayscaleMode.Bt709] + ]; [Theory] [MemberData(nameof(ModeTheoryData))] diff --git a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs index 5c5fd20e4..c39648d01 100644 --- a/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs +++ b/tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs @@ -21,7 +21,7 @@ public class HistogramEqualizationTests { // Arrange byte[] pixels = - { + [ 52, 55, 61, 59, 70, 61, 76, 61, 62, 59, 55, 104, 94, 85, 59, 71, 63, 65, 66, 113, 144, 104, 63, 72, @@ -30,7 +30,7 @@ public class HistogramEqualizationTests 68, 79, 60, 79, 77, 66, 58, 75, 69, 85, 64, 58, 55, 61, 65, 83, 70, 87, 69, 68, 65, 73, 78, 90 - }; + ]; using (Image image = new(8, 8)) { @@ -44,7 +44,7 @@ public class HistogramEqualizationTests } byte[] expected = - { + [ 0, 12, 53, 32, 146, 53, 174, 53, 57, 32, 12, 227, 219, 202, 32, 154, 65, 85, 93, 239, 251, 227, 65, 158, @@ -53,7 +53,7 @@ public class HistogramEqualizationTests 117, 190, 36, 190, 178, 93, 20, 170, 130, 202, 73, 20, 12, 53, 85, 194, 146, 206, 130, 117, 85, 166, 182, 215 - }; + ]; // Act image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs index 64dd7a866..62682e837 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs @@ -13,9 +13,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization; public class BinaryDitherTests { public static readonly string[] CommonTestImages = - { - TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Bike + ]; public static readonly TheoryData OrderedDitherers = new() { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs index 9c63d0f7c..c9d3f6914 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryThresholdTest.cs @@ -19,10 +19,10 @@ public class BinaryThresholdTest }; public static readonly string[] CommonTestImages = - { + [ TestImages.Png.Rgb48Bpp, - TestImages.Png.ColorsSaturationLightness, - }; + TestImages.Png.ColorsSaturationLightness + ]; public const PixelTypes TestPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs index 455aa48ae..1eec35368 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/Basic1ParameterConvolutionTests.cs @@ -15,11 +15,11 @@ public abstract class Basic1ParameterConvolutionTests public static readonly TheoryData Values = new() { 3, 5 }; public static readonly string[] InputImages = - { + [ TestImages.Bmp.Car, TestImages.Png.CalliphoraPartial, TestImages.Png.Blur - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(Values), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs index 04344e130..be3fc1e50 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/DetectEdgesTest.cs @@ -17,7 +17,7 @@ public class DetectEdgesTest private static readonly ImageComparer TransparentComparer = ImageComparer.TolerantPercentage(0.5F); - public static readonly string[] TestImages = { Tests.TestImages.Png.Bike }; + public static readonly string[] TestImages = [Tests.TestImages.Png.Bike]; public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs index 3cc965334..25acd3aa6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs @@ -14,7 +14,7 @@ public class DitherTests public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Rgb24 | PixelTypes.RgbaVector; - public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial, TestImages.Png.Bike }; + public static readonly string[] CommonTestImages = [TestImages.Png.CalliphoraPartial, TestImages.Png.Bike]; public static readonly TheoryData ErrorDiffusers = new() diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs index ed3be0f67..ab379ad7c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/BackgroundColorTest.cs @@ -11,10 +11,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Effects; public class BackgroundColorTest { public static readonly string[] InputImages = - { - TestImages.Png.Splash, + [ + TestImages.Png.Splash, TestImages.Png.Ducky - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs index f3d8fd63a..b7e859785 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Effects/OilPaintTest.cs @@ -18,10 +18,10 @@ public class OilPaintTest }; public static readonly string[] InputImages = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Bmp.Car - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(OilPaintValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs index cf2b7d4da..3005867ca 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Overlays/OverlayTestBase.cs @@ -11,9 +11,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Overlays; [GroupOutput("Overlays")] public abstract class OverlayTestBase { - public static string[] ColorNames = { "Blue", "White" }; + public static string[] ColorNames = ["Blue", "White"]; - public static string[] InputImages = { TestImages.Png.Ducky, TestImages.Png.Splash }; + public static string[] InputImages = [TestImages.Png.Ducky, TestImages.Png.Splash]; private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs index d58a5280d..f2a4b079b 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/PaletteQuantizerTests.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization; [Trait("Category", "Processors")] public class PaletteQuantizerTests { - private static readonly Color[] Palette = { Color.Red, Color.Green, Color.Blue }; + private static readonly Color[] Palette = [Color.Red, Color.Green, Color.Blue]; [Fact] public void PaletteQuantizerConstructor() diff --git a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs index b8b4615b9..2ba757c11 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs @@ -13,10 +13,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Quantization; public class QuantizerTests { public static readonly string[] CommonTestImages = - { + [ TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + ]; private static readonly QuantizerOptions NoDitherOptions = new() { Dither = null }; private static readonly QuantizerOptions DiffuserDitherOptions = new() { Dither = KnownDitherings.FloydSteinberg }; diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs index 984e3bc75..ee21920d4 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs @@ -17,8 +17,8 @@ public class AutoOrientTests public static readonly TheoryData InvalidOrientationValues = new() { - { ExifDataType.Byte, new byte[] { 1 } }, - { ExifDataType.SignedByte, new byte[] { 2 } }, + { ExifDataType.Byte, [1] }, + { ExifDataType.SignedByte, [2] }, { ExifDataType.SignedShort, BitConverter.GetBytes((short)3) }, { ExifDataType.Long, BitConverter.GetBytes(4U) }, { ExifDataType.SignedLong, BitConverter.GetBytes(5) } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs index 3e986f0cb..ffa9be6ea 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs @@ -13,11 +13,11 @@ public class EntropyCropTest public static readonly TheoryData EntropyCropValues = new() { .25F, .75F }; public static readonly string[] InputImages = - { - TestImages.Png.Ducky, + [ + TestImages.Png.Ducky, TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.MultiScanBaselineCMYK - }; + ]; [Theory] [WithFileCollection(nameof(InputImages), nameof(EntropyCropValues), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs index 8949049fb..0b6f5702f 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs @@ -10,9 +10,9 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; public class PadTest { public static readonly string[] CommonTestImages = - { + [ TestImages.Png.CalliphoraPartial, TestImages.Png.Bike - }; + ]; [Theory] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs index 1a4610bf6..00ad71b4c 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.ReferenceKernelMap.cs @@ -39,7 +39,7 @@ public partial class ResizeKernelMapTests double radius = tolerantMath.Ceiling(scale * sampler.Radius); - List result = new(); + List result = []; for (int i = 0; i < destinationSize; i++) { diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs index d6990782b..0357dda04 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs @@ -198,14 +198,14 @@ public partial class ResizeKernelMapTests string[] resamplerNames = TestUtils.GetAllResamplerNames(false); int[] dimensionVals = - { - // Arbitrary, small dimensions: + [ + // Arbitrary, small dimensions: 9, 10, 11, 13, 49, 50, 53, 99, 100, 199, 200, 201, 299, 300, 301, // Typical image sizes: 640, 480, 800, 600, 1024, 768, 1280, 960, 1536, 1180, 1600, 1200, 2048, 1536, 2240, 1680, 2560, 1920, 3032, 2008, 3072, 2304, 3264, 2448 - }; + ]; IOrderedEnumerable<(int S, int D)> source2Dest = dimensionVals .SelectMany(s => dimensionVals.Select(d => (s, d))) diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs index cc3ea0322..523fd2bdd 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; [Trait("Category", "Processors")] public class RotateFlipTests { - public static readonly string[] FlipFiles = { TestImages.Bmp.F }; + public static readonly string[] FlipFiles = [TestImages.Bmp.F]; public static readonly TheoryData RotateFlipValues = new() diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs index 30dec4685..84401e846 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTests.cs @@ -14,9 +14,9 @@ public class SkewTests { private const PixelTypes CommonPixelTypes = PixelTypes.Bgra32 | PixelTypes.Rgb24; - public static readonly string[] ResamplerNames = new[] - { - nameof(KnownResamplers.Bicubic), + public static readonly string[] ResamplerNames = + [ + nameof(KnownResamplers.Bicubic), nameof(KnownResamplers.Box), nameof(KnownResamplers.CatmullRom), nameof(KnownResamplers.Hermite), @@ -30,8 +30,8 @@ public class SkewTests nameof(KnownResamplers.RobidouxSharp), nameof(KnownResamplers.Spline), nameof(KnownResamplers.Triangle), - nameof(KnownResamplers.Welch), - }; + nameof(KnownResamplers.Welch) + ]; public static readonly TheoryData SkewValues = new() { diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs index e910038ef..e3bc3bba6 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLut.cs @@ -5,26 +5,26 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; public class IccConversionDataLut { - private static readonly float[] LutEven = { 0, 0.5f, 1 }; + private static readonly float[] LutEven = [0, 0.5f, 1]; - private static readonly float[] LutUneven = { 0, 0.7f, 1 }; + private static readonly float[] LutUneven = [0, 0.7f, 1]; public static object[][] LutConversionTestData = - { - new object[] { LutEven, false, 0.5f, 0.5f }, - new object[] { LutEven, false, 0.25f, 0.25f }, - new object[] { LutEven, false, 0.75f, 0.75f }, + [ + [LutEven, false, 0.5f, 0.5f], + [LutEven, false, 0.25f, 0.25f], + [LutEven, false, 0.75f, 0.75f], - new object[] { LutEven, true, 0.5f, 0.5f }, - new object[] { LutEven, true, 0.25f, 0.25f }, - new object[] { LutEven, true, 0.75f, 0.75f }, + [LutEven, true, 0.5f, 0.5f], + [LutEven, true, 0.25f, 0.25f], + [LutEven, true, 0.75f, 0.75f], - new object[] { LutUneven, false, 0.1, 0.14 }, - new object[] { LutUneven, false, 0.5, 0.7 }, - new object[] { LutUneven, false, 0.75, 0.85 }, + [LutUneven, false, 0.1, 0.14], + [LutUneven, false, 0.5, 0.7], + [LutUneven, false, 0.75, 0.85], - new object[] { LutUneven, true, 0.14, 0.1 }, - new object[] { LutUneven, true, 0.7, 0.5 }, - new object[] { LutUneven, true, 0.85, 0.75 }, - }; + [LutUneven, true, 0.14, 0.1], + [LutUneven, true, 0.7, 0.5], + [LutUneven, true, 0.85, 0.75] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs index 02fc23735..f38bc68d1 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataLutAB.cs @@ -9,12 +9,11 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc.Conversion; public class IccConversionDataLutAB { private static readonly IccLutAToBTagDataEntry LutAtoBSingleCurve = new( - new IccTagDataEntry[] - { - IccConversionDataTrc.IdentityCurve, + [ + IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve - }, + ], null, null, null, @@ -26,12 +25,11 @@ public class IccConversionDataLutAB // # CurveA + CLUT + CurveB // # CurveA + CLUT + CurveM + Matrix + CurveB private static readonly IccLutBToATagDataEntry LutBtoASingleCurve = new( - new IccTagDataEntry[] - { - IccConversionDataTrc.IdentityCurve, + [ + IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve, IccConversionDataTrc.IdentityCurve - }, + ], null, null, null, @@ -39,12 +37,12 @@ public class IccConversionDataLutAB null); public static object[][] LutAToBConversionTestData = - { - new object[] { LutAtoBSingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, - }; + [ + [LutAtoBSingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0)] + ]; public static object[][] LutBToAConversionTestData = - { - new object[] { LutBtoASingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0) }, - }; + [ + [LutBtoASingleCurve, new Vector4(0.2f, 0.3f, 0.4f, 0), new Vector4(0.2f, 0.3f, 0.4f, 0)] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs index f91c32df8..5f1417461 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataMatrix.cs @@ -24,14 +24,20 @@ public class IccConversionDataMatrix }; public static object[][] MatrixConversionTestData = - { - new object[] { CreateMatrix(Matrix3x3Identity), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) }, - new object[] { CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.67f, 0.8f, 0.93f, 0) }, - new object[] { CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.77f, 1, 1.23f, 0) }, - }; + [ + [CreateMatrix(Matrix3x3Identity), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0) + ], + [CreateMatrix(Matrix3x3Identity), new Vector3(0.2f, 0.2f, 0.2f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.7f, 0.7f, 0) + ], + [CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.6f, 0.75f, 0.9f, 0) + ], + [CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.7f, 0.95f, 1.2f, 0) + ], + [CreateMatrix(Matrix3x3Random), Vector3Zero, new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.67f, 0.8f, 0.93f, 0) + ], + [CreateMatrix(Matrix3x3Random), new Vector3(0.1f, 0.2f, 0.3f), new Vector4(0.2f, 0.4f, 0.7f, 0), new Vector4(0.77f, 1, 1.23f, 0) + ] + ]; private static Matrix4x4 CreateMatrix(float[,] matrix) => new( matrix[0, 0], diff --git a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs index 6cd99367a..d0ba39e4c 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/Conversion/IccConversionDataTrc.cs @@ -10,7 +10,7 @@ public static class IccConversionDataTrc { internal static IccCurveTagDataEntry IdentityCurve = new(); internal static IccCurveTagDataEntry Gamma2Curve = new(2); - internal static IccCurveTagDataEntry LutCurve = new(new float[] { 0, 0.7f, 1 }); + internal static IccCurveTagDataEntry LutCurve = new([0, 0.7f, 1]); internal static IccParametricCurveTagDataEntry ParamCurve1 = new(new IccParametricCurve(2.2f)); internal static IccParametricCurveTagDataEntry ParamCurve2 = new(new IccParametricCurve(2.2f, 1.5f, -0.5f)); @@ -19,58 +19,56 @@ public static class IccConversionDataTrc internal static IccParametricCurveTagDataEntry ParamCurve5 = new(new IccParametricCurve(2.2f, 0.7f, 0.2f, 0.3f, 0.1f, 0.5f, 0.2f)); public static object[][] TrcArrayConversionTestData { get; } = - { - new object[] - { + [ + [ new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, false, new Vector4(2, 2, 0.5f, 0), - new Vector4(2, 4, 0.217637628f, 0), - }, - new object[] - { + new Vector4(2, 4, 0.217637628f, 0) + ], + [ new IccTagDataEntry[] { IdentityCurve, Gamma2Curve, ParamCurve1 }, true, new Vector4(1, 4, 0.217637628f, 0), - new Vector4(1, 2, 0.5f, 0), - }, - }; + new Vector4(1, 2, 0.5f, 0) + ] + ]; public static object[][] CurveConversionTestData { get; } = - { - new object[] { IdentityCurve, false, 2, 2 }, - new object[] { Gamma2Curve, false, 2, 4 }, - new object[] { LutCurve, false, 0.1, 0.14 }, - new object[] { LutCurve, false, 0.5, 0.7 }, - new object[] { LutCurve, false, 0.75, 0.85 }, + [ + [IdentityCurve, false, 2, 2], + [Gamma2Curve, false, 2, 4], + [LutCurve, false, 0.1, 0.14], + [LutCurve, false, 0.5, 0.7], + [LutCurve, false, 0.75, 0.85], - new object[] { IdentityCurve, true, 2, 2 }, - new object[] { Gamma2Curve, true, 4, 2 }, - new object[] { LutCurve, true, 0.14, 0.1 }, - new object[] { LutCurve, true, 0.7, 0.5 }, - new object[] { LutCurve, true, 0.85, 0.75 }, - }; + [IdentityCurve, true, 2, 2], + [Gamma2Curve, true, 4, 2], + [LutCurve, true, 0.14, 0.1], + [LutCurve, true, 0.7, 0.5], + [LutCurve, true, 0.85, 0.75] + ]; public static object[][] ParametricCurveConversionTestData { get; } = - { - new object[] { ParamCurve1, false, 0.5f, 0.217637628f }, - new object[] { ParamCurve2, false, 0.6f, 0.133208528f }, - new object[] { ParamCurve2, false, 0.21f, 0 }, - new object[] { ParamCurve3, false, 0.61f, 0.444446117f }, - new object[] { ParamCurve3, false, 0.22f, 0.3f }, - new object[] { ParamCurve4, false, 0.3f, 0.0732389539f }, - new object[] { ParamCurve4, false, 0.03f, 0.00232198136f }, - new object[] { ParamCurve5, false, 0.2f, 0.593165159f }, - new object[] { ParamCurve5, false, 0.05f, 0.215f }, + [ + [ParamCurve1, false, 0.5f, 0.217637628f], + [ParamCurve2, false, 0.6f, 0.133208528f], + [ParamCurve2, false, 0.21f, 0], + [ParamCurve3, false, 0.61f, 0.444446117f], + [ParamCurve3, false, 0.22f, 0.3f], + [ParamCurve4, false, 0.3f, 0.0732389539f], + [ParamCurve4, false, 0.03f, 0.00232198136f], + [ParamCurve5, false, 0.2f, 0.593165159f], + [ParamCurve5, false, 0.05f, 0.215f], - new object[] { ParamCurve1, true, 0.217637628f, 0.5f }, - new object[] { ParamCurve2, true, 0.133208528f, 0.6f }, - new object[] { ParamCurve2, true, 0, 1 / 3f }, - new object[] { ParamCurve3, true, 0.444446117f, 0.61f }, - new object[] { ParamCurve3, true, 0.3f, 1 / 3f }, - new object[] { ParamCurve4, true, 0.0732389539f, 0.3f }, - new object[] { ParamCurve4, true, 0.00232198136f, 0.03f }, - new object[] { ParamCurve5, true, 0.593165159f, 0.2f }, - new object[] { ParamCurve5, true, 0.215f, 0.05f }, - }; + [ParamCurve1, true, 0.217637628f, 0.5f], + [ParamCurve2, true, 0.133208528f, 0.6f], + [ParamCurve2, true, 0, 1 / 3f], + [ParamCurve3, true, 0.444446117f, 0.61f], + [ParamCurve3, true, 0.3f, 1 / 3f], + [ParamCurve4, true, 0.0732389539f, 0.3f], + [ParamCurve4, true, 0.00232198136f, 0.03f], + [ParamCurve5, true, 0.593165159f, 0.2f], + [ParamCurve5, true, 0.215f, 0.05f] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs index cedd20f2d..379964181 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataArray.cs @@ -5,14 +5,14 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataArray { - public static readonly byte[] UInt8 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly byte[] UInt8 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly object[][] UInt8TestData = - { - new object[] { UInt8, UInt8 } - }; + [ + [UInt8, UInt8] + ]; - public static readonly ushort[] UInt16Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly ushort[] UInt16Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt16Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt160, @@ -27,11 +27,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt169); public static readonly object[][] UInt16TestData = - { - new object[] { UInt16Arr, UInt16Val } - }; + [ + [UInt16Arr, UInt16Val] + ]; - public static readonly short[] Int16Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly short[] Int16Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] Int16Arr = ArrayHelper.Concat( IccTestDataPrimitives.Int160, @@ -46,11 +46,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.Int169); public static readonly object[][] Int16TestData = - { - new object[] { Int16Arr, Int16Val } - }; + [ + [Int16Arr, Int16Val] + ]; - public static readonly uint[] UInt32Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly uint[] UInt32Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt32Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt320, @@ -65,11 +65,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt329); public static readonly object[][] UInt32TestData = - { - new object[] { UInt32Arr, UInt32Val } - }; + [ + [UInt32Arr, UInt32Val] + ]; - public static readonly int[] Int32Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly int[] Int32Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] Int32Arr = ArrayHelper.Concat( IccTestDataPrimitives.Int320, @@ -84,11 +84,11 @@ internal static class IccTestDataArray IccTestDataPrimitives.Int329); public static readonly object[][] Int32TestData = - { - new object[] { Int32Arr, Int32Val } - }; + [ + [Int32Arr, Int32Val] + ]; - public static readonly ulong[] UInt64Val = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + public static readonly ulong[] UInt64Val = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; public static readonly byte[] UInt64Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt640, @@ -103,7 +103,7 @@ internal static class IccTestDataArray IccTestDataPrimitives.UInt649); public static readonly object[][] UInt64TestData = - { - new object[] { UInt64Arr, UInt64Val } - }; + [ + [UInt64Arr, UInt64Val] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs index 6f8244f1c..be0d077b6 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataCurves.cs @@ -12,18 +12,16 @@ internal static class IccTestDataCurves /// public static readonly IccResponseCurve ResponseValGrad = new( IccCurveMeasurementEncodings.StatusA, - new[] - { + [ IccTestDataNonPrimitives.XyzNumberValVar1, IccTestDataNonPrimitives.XyzNumberValVar2, IccTestDataNonPrimitives.XyzNumberValVar3 - }, - new[] - { - new[] { IccTestDataNonPrimitives.ResponseNumberVal1, IccTestDataNonPrimitives.ResponseNumberVal2 }, - new[] { IccTestDataNonPrimitives.ResponseNumberVal3, IccTestDataNonPrimitives.ResponseNumberVal4 }, - new[] { IccTestDataNonPrimitives.ResponseNumberVal5, IccTestDataNonPrimitives.ResponseNumberVal6 }, - }); + ], + [ + [IccTestDataNonPrimitives.ResponseNumberVal1, IccTestDataNonPrimitives.ResponseNumberVal2], + [IccTestDataNonPrimitives.ResponseNumberVal3, IccTestDataNonPrimitives.ResponseNumberVal4], + [IccTestDataNonPrimitives.ResponseNumberVal5, IccTestDataNonPrimitives.ResponseNumberVal6] + ]); /// /// Channels: 3 @@ -44,9 +42,9 @@ internal static class IccTestDataCurves IccTestDataNonPrimitives.ResponseNumber6); public static readonly object[][] ResponseCurveTestData = - { - new object[] { ResponseGrad, ResponseValGrad, 3 }, - }; + [ + [ResponseGrad, ResponseValGrad, 3] + ]; public static readonly IccParametricCurve ParametricValVar1 = new(1); public static readonly IccParametricCurve ParametricValVar2 = new(1, 2, 3); @@ -110,13 +108,13 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Fix167); public static readonly object[][] ParametricCurveTestData = - { - new object[] { ParametricVar1, ParametricValVar1 }, - new object[] { ParametricVar2, ParametricValVar2 }, - new object[] { ParametricVar3, ParametricValVar3 }, - new object[] { ParametricVar4, ParametricValVar4 }, - new object[] { ParametricVar5, ParametricValVar5 }, - }; + [ + [ParametricVar1, ParametricValVar1], + [ParametricVar2, ParametricValVar2], + [ParametricVar3, ParametricValVar3], + [ParametricVar4, ParametricValVar4], + [ParametricVar5, ParametricValVar5] + ]; // Formula Segment public static readonly IccFormulaCurveElement FormulaValVar1 = new(IccFormulaCurveType.Type1, 1, 2, 3, 4, 0, 0); @@ -159,15 +157,15 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Single6); public static readonly object[][] FormulaCurveSegmentTestData = - { - new object[] { FormulaVar1, FormulaValVar1 }, - new object[] { FormulaVar2, FormulaValVar2 }, - new object[] { FormulaVar3, FormulaValVar3 }, - }; + [ + [FormulaVar1, FormulaValVar1], + [FormulaVar2, FormulaValVar2], + [FormulaVar3, FormulaValVar3] + ]; // Sampled Segment - public static readonly IccSampledCurveElement SampledValGrad1 = new(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); - public static readonly IccSampledCurveElement SampledValGrad2 = new(new float[] { 9, 8, 7, 6, 5, 4, 3, 2, 1 }); + public static readonly IccSampledCurveElement SampledValGrad1 = new([1, 2, 3, 4, 5, 6, 7, 8, 9]); + public static readonly IccSampledCurveElement SampledValGrad2 = new([9, 8, 7, 6, 5, 4, 3, 2, 1]); public static readonly byte[] SampledGrad1 = ArrayHelper.Concat( IccTestDataPrimitives.UInt329, @@ -194,10 +192,10 @@ internal static class IccTestDataCurves IccTestDataPrimitives.Single1); public static readonly object[][] SampledCurveSegmentTestData = - { - new object[] { SampledGrad1, SampledValGrad1 }, - new object[] { SampledGrad2, SampledValGrad2 }, - }; + [ + [SampledGrad1, SampledValGrad1], + [SampledGrad2, SampledValGrad2] + ]; public static readonly IccCurveSegment SegmentValFormula1 = FormulaValVar1; public static readonly IccCurveSegment SegmentValFormula2 = FormulaValVar2; @@ -246,25 +244,25 @@ internal static class IccTestDataCurves SampledGrad2); public static readonly object[][] CurveSegmentTestData = - { - new object[] { SegmentFormula1, SegmentValFormula1 }, - new object[] { SegmentFormula2, SegmentValFormula2 }, - new object[] { SegmentFormula3, SegmentValFormula3 }, - new object[] { SegmentSampled1, SegmentValSampled1 }, - new object[] { SegmentSampled2, SegmentValSampled2 }, - }; + [ + [SegmentFormula1, SegmentValFormula1], + [SegmentFormula2, SegmentValFormula2], + [SegmentFormula3, SegmentValFormula3], + [SegmentSampled1, SegmentValSampled1], + [SegmentSampled2, SegmentValSampled2] + ]; public static readonly IccOneDimensionalCurve OneDimensionalValFormula1 = new( - new float[] { 0, 1 }, - new[] { SegmentValFormula1, SegmentValFormula2, SegmentValFormula3 }); + [0, 1], + [SegmentValFormula1, SegmentValFormula2, SegmentValFormula3]); public static readonly IccOneDimensionalCurve OneDimensionalValFormula2 = new( - new float[] { 0, 1 }, - new[] { SegmentValFormula3, SegmentValFormula2, SegmentValFormula1 }); + [0, 1], + [SegmentValFormula3, SegmentValFormula2, SegmentValFormula1]); public static readonly IccOneDimensionalCurve OneDimensionalValSampled = new( - new float[] { 0, 1 }, - new[] { SegmentValSampled1, SegmentValSampled2, SegmentValSampled1 }); + [0, 1], + [SegmentValSampled1, SegmentValSampled2, SegmentValSampled1]); public static readonly byte[] OneDimensionalFormula1 = ArrayHelper.Concat( new byte[] @@ -303,9 +301,9 @@ internal static class IccTestDataCurves SegmentSampled1); public static readonly object[][] OneDimensionalCurveTestData = - { - new object[] { OneDimensionalFormula1, OneDimensionalValFormula1 }, - new object[] { OneDimensionalFormula2, OneDimensionalValFormula2 }, - new object[] { OneDimensionalSampled, OneDimensionalValSampled }, - }; + [ + [OneDimensionalFormula1, OneDimensionalValFormula1], + [OneDimensionalFormula2, OneDimensionalValFormula2], + [OneDimensionalSampled, OneDimensionalValSampled] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs index 2bd47e449..c0404d5f1 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataLut.cs @@ -33,12 +33,11 @@ internal static class IccTestDataLut } public static readonly object[][] Lut8TestData = - { - new object[] { Lut8Grad, Lut8ValGrad }, - }; + [ + [Lut8Grad, Lut8ValGrad] + ]; - public static readonly IccLut Lut16ValGrad = new(new[] - { + public static readonly IccLut Lut16ValGrad = new([ 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue, @@ -50,7 +49,7 @@ internal static class IccTestDataLut 9f / ushort.MaxValue, 32768f / ushort.MaxValue, 1f - }); + ]); public static readonly byte[] Lut16Grad = ArrayHelper.Concat( IccTestDataPrimitives.UInt161, @@ -66,13 +65,12 @@ internal static class IccTestDataLut IccTestDataPrimitives.UInt16Max); public static readonly object[][] Lut16TestData = - { - new object[] { Lut16Grad, Lut16ValGrad, 11 }, - }; + [ + [Lut16Grad, Lut16ValGrad, 11] + ]; public static readonly IccClut Clut8ValGrad = new( - new[] - { + [ 1f / byte.MaxValue, 2f / byte.MaxValue, 3f / byte.MaxValue, 4f / byte.MaxValue, 5f / byte.MaxValue, 6f / byte.MaxValue, 7f / byte.MaxValue, 8f / byte.MaxValue, 9f / byte.MaxValue, @@ -83,9 +81,9 @@ internal static class IccTestDataLut 19f / byte.MaxValue, 20f / byte.MaxValue, 21f / byte.MaxValue, 22f / byte.MaxValue, 23f / byte.MaxValue, 24f / byte.MaxValue, - 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue, - }, - new byte[] { 3, 3 }, + 25f / byte.MaxValue, 26f / byte.MaxValue, 27f / byte.MaxValue + ], + [3, 3], IccClutDataType.UInt8, outputChannelCount: 3); @@ -95,7 +93,7 @@ internal static class IccTestDataLut /// Grid-point Count: { 3, 3 } /// public static readonly byte[] Clut8Grad = - { + [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, @@ -106,17 +104,16 @@ internal static class IccTestDataLut 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1A, 0x1B, - }; + 0x19, 0x1A, 0x1B + ]; public static readonly object[][] Clut8TestData = - { - new object[] { Clut8Grad, Clut8ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [Clut8Grad, Clut8ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; public static readonly IccClut Clut16ValGrad = new( - new[] - { + [ 1f / ushort.MaxValue, 2f / ushort.MaxValue, 3f / ushort.MaxValue, 4f / ushort.MaxValue, 5f / ushort.MaxValue, 6f / ushort.MaxValue, 7f / ushort.MaxValue, 8f / ushort.MaxValue, 9f / ushort.MaxValue, @@ -127,9 +124,9 @@ internal static class IccTestDataLut 19f / ushort.MaxValue, 20f / ushort.MaxValue, 21f / ushort.MaxValue, 22f / ushort.MaxValue, 23f / ushort.MaxValue, 24f / ushort.MaxValue, - 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue, - }, - new byte[] { 3, 3 }, + 25f / ushort.MaxValue, 26f / ushort.MaxValue, 27f / ushort.MaxValue + ], + [3, 3], IccClutDataType.UInt16, outputChannelCount: 3); @@ -139,7 +136,7 @@ internal static class IccTestDataLut /// Grid-point Count: { 3, 3 } /// public static readonly byte[] Clut16Grad = - { + [ 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, @@ -150,17 +147,16 @@ internal static class IccTestDataLut 0x00, 0x13, 0x00, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, - 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, - }; + 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B + ]; public static readonly object[][] Clut16TestData = - { - new object[] { Clut16Grad, Clut16ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [Clut16Grad, Clut16ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; public static readonly IccClut CluTf32ValGrad = new( - new[] - { + [ 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f, 9f, @@ -171,9 +167,9 @@ internal static class IccTestDataLut 1f, 2f, 3f, 4f, 5f, 6f, - 7f, 8f, 9f, - }, - new byte[] { 3, 3 }, + 7f, 8f, 9f + ], + [3, 3], IccClutDataType.Float, outputChannelCount: 3); @@ -212,9 +208,9 @@ internal static class IccTestDataLut IccTestDataPrimitives.Single9); public static readonly object[][] ClutF32TestData = - { - new object[] { CluTf32Grad, CluTf32ValGrad, 2, 3, new byte[] { 3, 3 } }, - }; + [ + [CluTf32Grad, CluTf32ValGrad, 2, 3, new byte[] { 3, 3 }] + ]; public static readonly IccClut ClutVal8 = Clut8ValGrad; public static readonly IccClut ClutVal16 = Clut16ValGrad; @@ -235,9 +231,9 @@ internal static class IccTestDataLut CluTf32Grad); public static readonly object[][] ClutTestData = - { - new object[] { Clut8, ClutVal8, 2, 3, false }, - new object[] { Clut16, ClutVal16, 2, 3, false }, - new object[] { ClutF32, ClutValf32, 2, 3, true }, - }; + [ + [Clut8, ClutVal8, 2, 3, false], + [Clut16, ClutVal16, 2, 3, false], + [ClutF32, ClutValf32, 2, 3, true] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs index 1a72d39b1..6a900a015 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMatrix.cs @@ -90,30 +90,30 @@ internal static class IccTestDataMatrix IccTestDataPrimitives.Single9); public static readonly object[][] Matrix2DFloatArrayTestData = - { - new object[] { Fix162DGrad, 3, 3, false, Single2DArrayValGrad }, - new object[] { Fix162DIdentity, 3, 3, false, Single2DArrayValIdentity }, - new object[] { Single2DGrad, 3, 3, true, Single2DArrayValGrad }, - }; + [ + [Fix162DGrad, 3, 3, false, Single2DArrayValGrad], + [Fix162DIdentity, 3, 3, false, Single2DArrayValIdentity], + [Single2DGrad, 3, 3, true, Single2DArrayValGrad] + ]; public static readonly object[][] Matrix2DDenseMatrixTestData = - { - new object[] { Fix162DGrad, 3, 3, false, SingleDenseMatrixValGrad }, - new object[] { Fix162DIdentity, 3, 3, false, SingleDenseMatrixValIdentity }, - new object[] { Single2DGrad, 3, 3, true, SingleDenseMatrixValGrad }, - }; + [ + [Fix162DGrad, 3, 3, false, SingleDenseMatrixValGrad], + [Fix162DIdentity, 3, 3, false, SingleDenseMatrixValIdentity], + [Single2DGrad, 3, 3, true, SingleDenseMatrixValGrad] + ]; public static readonly object[][] Matrix2DMatrix4X4TestData = - { - new object[] { Fix162DGrad, 3, 3, false, SingleMatrix4X4ValGrad }, - new object[] { Fix162DIdentity, 3, 3, false, SingleMatrix4X4ValIdentity }, - new object[] { Single2DGrad, 3, 3, true, SingleMatrix4X4ValGrad }, - }; + [ + [Fix162DGrad, 3, 3, false, SingleMatrix4X4ValGrad], + [Fix162DIdentity, 3, 3, false, SingleMatrix4X4ValIdentity], + [Single2DGrad, 3, 3, true, SingleMatrix4X4ValGrad] + ]; /// /// 3x1 Matrix /// - public static readonly float[] Single1DArrayValGrad = { 1, 4, 7 }; + public static readonly float[] Single1DArrayValGrad = [1, 4, 7]; /// /// 3x1 Matrix @@ -137,14 +137,14 @@ internal static class IccTestDataMatrix IccTestDataPrimitives.Single7); public static readonly object[][] Matrix1DArrayTestData = - { - new object[] { Fix161DGrad, 3, false, Single1DArrayValGrad }, - new object[] { Single1DGrad, 3, true, Single1DArrayValGrad }, - }; + [ + [Fix161DGrad, 3, false, Single1DArrayValGrad], + [Single1DGrad, 3, true, Single1DArrayValGrad] + ]; public static readonly object[][] Matrix1DVector3TestData = - { - new object[] { Fix161DGrad, 3, false, SingleVector3ValGrad }, - new object[] { Single1DGrad, 3, true, SingleVector3ValGrad }, - }; + [ + [Fix161DGrad, 3, false, SingleVector3ValGrad], + [Single1DGrad, 3, true, SingleVector3ValGrad] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs index 2e3679e3a..5219dfdac 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataMultiProcessElements.cs @@ -11,12 +11,11 @@ internal static class IccTestDataMultiProcessElements /// Input Channel Count: 3 /// Output Channel Count: 3 /// - public static readonly IccCurveSetProcessElement CurvePeValGrad = new(new[] - { + public static readonly IccCurveSetProcessElement CurvePeValGrad = new([ IccTestDataCurves.OneDimensionalValFormula1, IccTestDataCurves.OneDimensionalValFormula2, IccTestDataCurves.OneDimensionalValFormula1 - }); + ]); /// /// Input Channel Count: 3 @@ -28,9 +27,9 @@ internal static class IccTestDataMultiProcessElements IccTestDataCurves.OneDimensionalFormula1); public static readonly object[][] CurveSetTestData = - { - new object[] { CurvePeGrad, CurvePeValGrad, 3, 3 }, - }; + [ + [CurvePeGrad, CurvePeValGrad, 3, 3] + ]; /// /// Input Channel Count: 3 @@ -49,9 +48,9 @@ internal static class IccTestDataMultiProcessElements IccTestDataMatrix.Single1DGrad); public static readonly object[][] MatrixTestData = - { - new object[] { MatrixPeGrad, MatrixPeValGrad, 3, 3 }, - }; + [ + [MatrixPeGrad, MatrixPeValGrad, 3, 3] + ]; /// /// Input Channel Count: 2 @@ -66,9 +65,9 @@ internal static class IccTestDataMultiProcessElements public static readonly byte[] ClutpeGrad = IccTestDataLut.ClutF32; public static readonly object[][] ClutTestData = - { - new object[] { ClutpeGrad, ClutpeValGrad, 2, 3 }, - }; + [ + [ClutpeGrad, ClutpeValGrad, 2, 3] + ]; public static readonly IccMultiProcessElement MpeValMatrix = MatrixPeValGrad; public static readonly IccMultiProcessElement MpeValClut = ClutpeValGrad; @@ -104,27 +103,27 @@ internal static class IccTestDataMultiProcessElements CurvePeGrad); public static readonly byte[] MpeBAcs = - { + [ 0x62, 0x41, 0x43, 0x53, 0x00, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] MpeEAcs = - { + [ 0x65, 0x41, 0x43, 0x53, 0x00, 0x03, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]; public static readonly object[][] MultiProcessElementTestData = - { - new object[] { MpeMatrix, MpeValMatrix }, - new object[] { MpeClut, MpeValClut }, - new object[] { MpeCurve, MpeValCurve }, - new object[] { MpeBAcs, MpeValbAcs }, - new object[] { MpeEAcs, MpeValeAcs }, - }; + [ + [MpeMatrix, MpeValMatrix], + [MpeClut, MpeValClut], + [MpeCurve, MpeValCurve], + [MpeBAcs, MpeValbAcs], + [MpeEAcs, MpeValeAcs] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs index 067427424..34625aa1c 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataNonPrimitives.cs @@ -14,69 +14,69 @@ internal static class IccTestDataNonPrimitives public static readonly DateTime DateTimeValRand1 = new(1990, 11, 26, 3, 19, 47, DateTimeKind.Utc); public static readonly byte[] DateTimeMin = - { + [ 0x00, 0x01, // Year 1 0x00, 0x01, // Month 1 0x00, 0x01, // Day 1 0x00, 0x00, // Hour 0 0x00, 0x00, // Minute 0 - 0x00, 0x00, // Second 0 - }; + 0x00, 0x00 // Second 0 + ]; public static readonly byte[] DateTimeMax = - { - 0x27, 0x0F, // Year 9999 + [ + 0x27, 0x0F, // Year 9999 0x00, 0x0C, // Month 12 0x00, 0x1F, // Day 31 0x00, 0x17, // Hour 23 0x00, 0x3B, // Minute 59 - 0x00, 0x3B, // Second 59 - }; + 0x00, 0x3B // Second 59 + ]; public static readonly byte[] DateTimeInvalid = - { - 0xFF, 0xFF, // Year 65535 + [ + 0xFF, 0xFF, // Year 65535 0x00, 0x0E, // Month 14 0x00, 0x21, // Day 33 0x00, 0x19, // Hour 25 0x00, 0x3D, // Minute 61 - 0x00, 0x3D, // Second 61 - }; + 0x00, 0x3D // Second 61 + ]; public static readonly byte[] DateTimeRand1 = - { - 0x07, 0xC6, // Year 1990 + [ + 0x07, 0xC6, // Year 1990 0x00, 0x0B, // Month 11 0x00, 0x1A, // Day 26 0x00, 0x03, // Hour 3 0x00, 0x13, // Minute 19 - 0x00, 0x2F, // Second 47 - }; + 0x00, 0x2F // Second 47 + ]; public static readonly object[][] DateTimeTestData = - { - new object[] { DateTimeMin, DateTimeValMin }, - new object[] { DateTimeMax, DateTimeValMax }, - new object[] { DateTimeRand1, DateTimeValRand1 }, - }; + [ + [DateTimeMin, DateTimeValMin], + [DateTimeMax, DateTimeValMax], + [DateTimeRand1, DateTimeValRand1] + ]; public static readonly IccVersion VersionNumberValMin = new(0, 0, 0); public static readonly IccVersion VersionNumberVal211 = new(2, 1, 1); public static readonly IccVersion VersionNumberVal430 = new(4, 3, 0); public static readonly IccVersion VersionNumberValMax = new(255, 15, 15); - public static readonly byte[] VersionNumberMin = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] VersionNumber211 = { 0x02, 0x11, 0x00, 0x00 }; - public static readonly byte[] VersionNumber430 = { 0x04, 0x30, 0x00, 0x00 }; - public static readonly byte[] VersionNumberMax = { 0xFF, 0xFF, 0x00, 0x00 }; + public static readonly byte[] VersionNumberMin = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] VersionNumber211 = [0x02, 0x11, 0x00, 0x00]; + public static readonly byte[] VersionNumber430 = [0x04, 0x30, 0x00, 0x00]; + public static readonly byte[] VersionNumberMax = [0xFF, 0xFF, 0x00, 0x00]; public static readonly object[][] VersionNumberTestData = - { - new object[] { VersionNumberMin, VersionNumberValMin }, - new object[] { VersionNumber211, VersionNumberVal211 }, - new object[] { VersionNumber430, VersionNumberVal430 }, - new object[] { VersionNumberMax, VersionNumberValMax }, - }; + [ + [VersionNumberMin, VersionNumberValMin], + [VersionNumber211, VersionNumberVal211], + [VersionNumber430, VersionNumberVal430], + [VersionNumberMax, VersionNumberValMax] + ]; public static readonly Vector3 XyzNumberValMin = new(IccTestDataPrimitives.Fix16ValMin, IccTestDataPrimitives.Fix16ValMin, IccTestDataPrimitives.Fix16ValMin); public static readonly Vector3 XyzNumberVal0 = new(0, 0, 0); @@ -95,12 +95,12 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] XyzNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.Fix16Max, IccTestDataPrimitives.Fix16Max, IccTestDataPrimitives.Fix16Max); public static readonly object[][] XyzNumberTestData = - { - new object[] { XyzNumberMin, XyzNumberValMin }, - new object[] { XyzNumber0, XyzNumberVal0 }, - new object[] { XyzNumberVar1, XyzNumberValVar1 }, - new object[] { XyzNumberMax, XyzNumberValMax }, - }; + [ + [XyzNumberMin, XyzNumberValMin], + [XyzNumber0, XyzNumberVal0], + [XyzNumberVar1, XyzNumberValVar1], + [XyzNumberMax, XyzNumberValMax] + ]; public static readonly IccProfileId ProfileIdValMin = new(0, 0, 0, 0); public static readonly IccProfileId ProfileIdValRand = new(IccTestDataPrimitives.UInt32ValRand1, IccTestDataPrimitives.UInt32ValRand2, IccTestDataPrimitives.UInt32ValRand3, IccTestDataPrimitives.UInt32ValRand4); @@ -111,11 +111,11 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] ProfileIdMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max); public static readonly object[][] ProfileIdTestData = - { - new object[] { ProfileIdMin, ProfileIdValMin }, - new object[] { ProfileIdRand, ProfileIdValRand }, - new object[] { ProfileIdMax, ProfileIdValMax }, - }; + [ + [ProfileIdMin, ProfileIdValMin], + [ProfileIdRand, ProfileIdValRand], + [ProfileIdMax, ProfileIdValMax] + ]; public static readonly IccPositionNumber PositionNumberValMin = new(0, 0); public static readonly IccPositionNumber PositionNumberValRand = new(IccTestDataPrimitives.UInt32ValRand1, IccTestDataPrimitives.UInt32ValRand2); @@ -126,11 +126,11 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] PositionNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt32Max, IccTestDataPrimitives.UInt32Max); public static readonly object[][] PositionNumberTestData = - { - new object[] { PositionNumberMin, PositionNumberValMin }, - new object[] { PositionNumberRand, PositionNumberValRand }, - new object[] { PositionNumberMax, PositionNumberValMax }, - }; + [ + [PositionNumberMin, PositionNumberValMin], + [PositionNumberRand, PositionNumberValRand], + [PositionNumberMax, PositionNumberValMax] + ]; public static readonly IccResponseNumber ResponseNumberValMin = new(0, IccTestDataPrimitives.Fix16ValMin); public static readonly IccResponseNumber ResponseNumberVal1 = new(1, 1); @@ -157,27 +157,27 @@ internal static class IccTestDataNonPrimitives public static readonly byte[] ResponseNumberMax = ArrayHelper.Concat(IccTestDataPrimitives.UInt16Max, IccTestDataPrimitives.Fix16Max); public static readonly object[][] ResponseNumberTestData = - { - new object[] { ResponseNumberMin, ResponseNumberValMin }, - new object[] { ResponseNumber1, ResponseNumberVal1 }, - new object[] { ResponseNumber4, ResponseNumberVal4 }, - new object[] { ResponseNumberMax, ResponseNumberValMax }, - }; + [ + [ResponseNumberMin, ResponseNumberValMin], + [ResponseNumber1, ResponseNumberVal1], + [ResponseNumber4, ResponseNumberVal4], + [ResponseNumberMax, ResponseNumberValMax] + ]; public static readonly IccNamedColor NamedColorValMin = new( ArrayHelper.Fill('A', 31), - new ushort[] { 0, 0, 0 }, - new ushort[] { 0, 0, 0 }); + [0, 0, 0], + [0, 0, 0]); public static readonly IccNamedColor NamedColorValRand = new( ArrayHelper.Fill('5', 31), - new ushort[] { 10794, 10794, 10794 }, - new ushort[] { 17219, 17219, 17219, 17219, 17219 }); + [10794, 10794, 10794], + [17219, 17219, 17219, 17219, 17219]); public static readonly IccNamedColor NamedColorValMax = new( ArrayHelper.Fill('4', 31), - new[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }, - new[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue }); + [ushort.MaxValue, ushort.MaxValue, ushort.MaxValue], + [ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue]); public static readonly byte[] NamedColorMin = CreateNamedColor(3, 0x41, 0x00, 0x00); public static readonly byte[] NamedColorRand = CreateNamedColor(5, 0x35, 42, 67); @@ -210,11 +210,11 @@ internal static class IccTestDataNonPrimitives } public static readonly object[][] NamedColorTestData = - { - new object[] { NamedColorMin, NamedColorValMin, 3u }, - new object[] { NamedColorRand, NamedColorValRand, 5u }, - new object[] { NamedColorMax, NamedColorValMax, 4u }, - }; + [ + [NamedColorMin, NamedColorValMin, 3u], + [NamedColorRand, NamedColorValRand, 5u], + [NamedColorMax, NamedColorValMax, 4u] + ]; private static readonly CultureInfo CultureEnUs = new("en-US"); private static readonly CultureInfo CultureDeAt = new("de-AT"); @@ -222,19 +222,20 @@ internal static class IccTestDataNonPrimitives private static readonly IccLocalizedString LocalizedStringRand1 = new(CultureEnUs, IccTestDataPrimitives.UnicodeValRand2); private static readonly IccLocalizedString LocalizedStringRand2 = new(CultureDeAt, IccTestDataPrimitives.UnicodeValRand3); - private static readonly IccLocalizedString[] LocalizedStringRandArr1 = { + private static readonly IccLocalizedString[] LocalizedStringRandArr1 = + [ LocalizedStringRand1, - LocalizedStringRand2, - }; + LocalizedStringRand2 + ]; private static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal = new(LocalizedStringRandArr1); private static readonly byte[] MultiLocalizedUnicodeArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 - new[] { (byte)'d', (byte)'e', (byte)'A', (byte)'T' }, + [(byte)'d', (byte)'e', (byte)'A', (byte)'T'], new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 IccTestDataPrimitives.UnicodeRand2, @@ -251,7 +252,7 @@ internal static class IccTestDataNonPrimitives new byte[] { 0x00, 0x00, 0x00, 0x0B }, // 11 IccTestDataPrimitives.AsciiRand, new byte[] { 0x00 }, // Null terminator - new[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x07 }, // 7 IccTestDataPrimitives.UnicodeRand2, new byte[] { 0x00, 0x00 }, // Null terminator @@ -272,8 +273,8 @@ internal static class IccTestDataNonPrimitives 2, IccDeviceAttribute.ChromaBlackWhite | IccDeviceAttribute.ReflectivityMatte, IccProfileTag.ProfileDescription, - new[] { LocalizedStringRand1 }, - new[] { LocalizedStringRand1 }); + [LocalizedStringRand1], + [LocalizedStringRand1]); public static readonly byte[] ProfileDescriptionRand1 = ArrayHelper.Concat( IccTestDataPrimitives.UInt321, @@ -300,15 +301,15 @@ internal static class IccTestDataNonPrimitives TextDescriptionArr1); public static readonly object[][] ProfileDescriptionReadTestData = - { - new object[] { ProfileDescriptionRand1, ProfileDescriptionValRand1 }, - new object[] { ProfileDescriptionRand2, ProfileDescriptionValRand2 }, - }; + [ + [ProfileDescriptionRand1, ProfileDescriptionValRand1], + [ProfileDescriptionRand2, ProfileDescriptionValRand2] + ]; public static readonly object[][] ProfileDescriptionWriteTestData = - { - new object[] { ProfileDescriptionRand1, ProfileDescriptionValRand1 }, - }; + [ + [ProfileDescriptionRand1, ProfileDescriptionValRand1] + ]; public static readonly IccColorantTableEntry ColorantTableEntryValRand1 = new(ArrayHelper.Fill('A', 31), 1, 2, 3); public static readonly IccColorantTableEntry ColorantTableEntryValRand2 = new(ArrayHelper.Fill('4', 31), 4, 5, 6); @@ -328,10 +329,10 @@ internal static class IccTestDataNonPrimitives IccTestDataPrimitives.UInt166); public static readonly object[][] ColorantTableEntryTestData = - { - new object[] { ColorantTableEntryRand1, ColorantTableEntryValRand1 }, - new object[] { ColorantTableEntryRand2, ColorantTableEntryValRand2 }, - }; + [ + [ColorantTableEntryRand1, ColorantTableEntryValRand1], + [ColorantTableEntryRand2, ColorantTableEntryValRand2] + ]; public static readonly IccScreeningChannel ScreeningChannelValRand1 = new(4, 6, IccScreeningSpotType.Cross); public static readonly IccScreeningChannel ScreeningChannelValRand2 = new(8, 5, IccScreeningSpotType.Diamond); @@ -347,8 +348,8 @@ internal static class IccTestDataNonPrimitives IccTestDataPrimitives.Int323); public static readonly object[][] ScreeningChannelTestData = - { - new object[] { ScreeningChannelRand1, ScreeningChannelValRand1 }, - new object[] { ScreeningChannelRand2, ScreeningChannelValRand2 }, - }; + [ + [ScreeningChannelRand1, ScreeningChannelValRand1], + [ScreeningChannelRand2, ScreeningChannelValRand2] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs index 81cfea46f..5f9d70fb2 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataPrimitives.cs @@ -5,191 +5,191 @@ namespace SixLabors.ImageSharp.Tests.TestDataIcc; internal static class IccTestDataPrimitives { - public static readonly byte[] UInt160 = { 0x00, 0x00 }; - public static readonly byte[] UInt161 = { 0x00, 0x01 }; - public static readonly byte[] UInt162 = { 0x00, 0x02 }; - public static readonly byte[] UInt163 = { 0x00, 0x03 }; - public static readonly byte[] UInt164 = { 0x00, 0x04 }; - public static readonly byte[] UInt165 = { 0x00, 0x05 }; - public static readonly byte[] UInt166 = { 0x00, 0x06 }; - public static readonly byte[] UInt167 = { 0x00, 0x07 }; - public static readonly byte[] UInt168 = { 0x00, 0x08 }; - public static readonly byte[] UInt169 = { 0x00, 0x09 }; - public static readonly byte[] UInt1632768 = { 0x80, 0x00 }; - public static readonly byte[] UInt16Max = { 0xFF, 0xFF }; - - public static readonly byte[] Int16Min = { 0x80, 0x00 }; - public static readonly byte[] Int160 = { 0x00, 0x00 }; - public static readonly byte[] Int161 = { 0x00, 0x01 }; - public static readonly byte[] Int162 = { 0x00, 0x02 }; - public static readonly byte[] Int163 = { 0x00, 0x03 }; - public static readonly byte[] Int164 = { 0x00, 0x04 }; - public static readonly byte[] Int165 = { 0x00, 0x05 }; - public static readonly byte[] Int166 = { 0x00, 0x06 }; - public static readonly byte[] Int167 = { 0x00, 0x07 }; - public static readonly byte[] Int168 = { 0x00, 0x08 }; - public static readonly byte[] Int169 = { 0x00, 0x09 }; - public static readonly byte[] Int16Max = { 0x7F, 0xFF }; - - public static readonly byte[] UInt320 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt321 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt322 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt323 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt324 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt325 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt326 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt327 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt328 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt329 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt32Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UInt160 = [0x00, 0x00]; + public static readonly byte[] UInt161 = [0x00, 0x01]; + public static readonly byte[] UInt162 = [0x00, 0x02]; + public static readonly byte[] UInt163 = [0x00, 0x03]; + public static readonly byte[] UInt164 = [0x00, 0x04]; + public static readonly byte[] UInt165 = [0x00, 0x05]; + public static readonly byte[] UInt166 = [0x00, 0x06]; + public static readonly byte[] UInt167 = [0x00, 0x07]; + public static readonly byte[] UInt168 = [0x00, 0x08]; + public static readonly byte[] UInt169 = [0x00, 0x09]; + public static readonly byte[] UInt1632768 = [0x80, 0x00]; + public static readonly byte[] UInt16Max = [0xFF, 0xFF]; + + public static readonly byte[] Int16Min = [0x80, 0x00]; + public static readonly byte[] Int160 = [0x00, 0x00]; + public static readonly byte[] Int161 = [0x00, 0x01]; + public static readonly byte[] Int162 = [0x00, 0x02]; + public static readonly byte[] Int163 = [0x00, 0x03]; + public static readonly byte[] Int164 = [0x00, 0x04]; + public static readonly byte[] Int165 = [0x00, 0x05]; + public static readonly byte[] Int166 = [0x00, 0x06]; + public static readonly byte[] Int167 = [0x00, 0x07]; + public static readonly byte[] Int168 = [0x00, 0x08]; + public static readonly byte[] Int169 = [0x00, 0x09]; + public static readonly byte[] Int16Max = [0x7F, 0xFF]; + + public static readonly byte[] UInt320 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UInt321 = [0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] UInt322 = [0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] UInt323 = [0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] UInt324 = [0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] UInt325 = [0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] UInt326 = [0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] UInt327 = [0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] UInt328 = [0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] UInt329 = [0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] UInt32Max = [0xFF, 0xFF, 0xFF, 0xFF]; public static readonly uint UInt32ValRand1 = 1749014123; public static readonly uint UInt32ValRand2 = 3870560989; public static readonly uint UInt32ValRand3 = 1050090334; public static readonly uint UInt32ValRand4 = 3550252874; - public static readonly byte[] UInt32Rand1 = { 0x68, 0x3F, 0xD6, 0x6B }; - public static readonly byte[] UInt32Rand2 = { 0xE6, 0xB4, 0x12, 0xDD }; - public static readonly byte[] UInt32Rand3 = { 0x3E, 0x97, 0x1B, 0x5E }; - public static readonly byte[] UInt32Rand4 = { 0xD3, 0x9C, 0x8F, 0x4A }; - - public static readonly byte[] Int32Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int320 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int321 = { 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int322 = { 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int323 = { 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int324 = { 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int325 = { 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int326 = { 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int327 = { 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int328 = { 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int329 = { 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int32Max = { 0x7F, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] UInt640 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UInt641 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] UInt642 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] UInt643 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] UInt644 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] UInt645 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] UInt646 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] UInt647 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] UInt648 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] UInt649 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] UInt64Max = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] Int64Min = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int640 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Int641 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; - public static readonly byte[] Int642 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; - public static readonly byte[] Int643 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }; - public static readonly byte[] Int644 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 }; - public static readonly byte[] Int645 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; - public static readonly byte[] Int646 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06 }; - public static readonly byte[] Int647 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - public static readonly byte[] Int648 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; - public static readonly byte[] Int649 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - public static readonly byte[] Int64Max = { 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - - public static readonly byte[] SingleMin = { 0xFF, 0x7F, 0xFF, 0xFF }; - public static readonly byte[] Single0 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single1 = { 0x3F, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single2 = { 0x40, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single3 = { 0x40, 0x40, 0x00, 0x00 }; - public static readonly byte[] Single4 = { 0x40, 0x80, 0x00, 0x00 }; - public static readonly byte[] Single5 = { 0x40, 0xA0, 0x00, 0x00 }; - public static readonly byte[] Single6 = { 0x40, 0xC0, 0x00, 0x00 }; - public static readonly byte[] Single7 = { 0x40, 0xE0, 0x00, 0x00 }; - public static readonly byte[] Single8 = { 0x41, 0x00, 0x00, 0x00 }; - public static readonly byte[] Single9 = { 0x41, 0x10, 0x00, 0x00 }; - public static readonly byte[] SingleMax = { 0x7F, 0x7F, 0xFF, 0xFF }; - - public static readonly byte[] DoubleMin = { 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - public static readonly byte[] Double0 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Double1 = { 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] DoubleMax = { 0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UInt32Rand1 = [0x68, 0x3F, 0xD6, 0x6B]; + public static readonly byte[] UInt32Rand2 = [0xE6, 0xB4, 0x12, 0xDD]; + public static readonly byte[] UInt32Rand3 = [0x3E, 0x97, 0x1B, 0x5E]; + public static readonly byte[] UInt32Rand4 = [0xD3, 0x9C, 0x8F, 0x4A]; + + public static readonly byte[] Int32Min = [0x80, 0x00, 0x00, 0x00]; + public static readonly byte[] Int320 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int321 = [0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] Int322 = [0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] Int323 = [0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] Int324 = [0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] Int325 = [0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] Int326 = [0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] Int327 = [0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] Int328 = [0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] Int329 = [0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] Int32Max = [0x7F, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] UInt640 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UInt641 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] UInt642 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] UInt643 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] UInt644 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] UInt645 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] UInt646 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] UInt647 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] UInt648 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] UInt649 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] UInt64Max = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] Int64Min = [0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int640 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Int641 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]; + public static readonly byte[] Int642 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02]; + public static readonly byte[] Int643 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03]; + public static readonly byte[] Int644 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04]; + public static readonly byte[] Int645 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05]; + public static readonly byte[] Int646 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06]; + public static readonly byte[] Int647 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07]; + public static readonly byte[] Int648 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08]; + public static readonly byte[] Int649 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09]; + public static readonly byte[] Int64Max = [0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + + public static readonly byte[] SingleMin = [0xFF, 0x7F, 0xFF, 0xFF]; + public static readonly byte[] Single0 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Single1 = [0x3F, 0x80, 0x00, 0x00]; + public static readonly byte[] Single2 = [0x40, 0x00, 0x00, 0x00]; + public static readonly byte[] Single3 = [0x40, 0x40, 0x00, 0x00]; + public static readonly byte[] Single4 = [0x40, 0x80, 0x00, 0x00]; + public static readonly byte[] Single5 = [0x40, 0xA0, 0x00, 0x00]; + public static readonly byte[] Single6 = [0x40, 0xC0, 0x00, 0x00]; + public static readonly byte[] Single7 = [0x40, 0xE0, 0x00, 0x00]; + public static readonly byte[] Single8 = [0x41, 0x00, 0x00, 0x00]; + public static readonly byte[] Single9 = [0x41, 0x10, 0x00, 0x00]; + public static readonly byte[] SingleMax = [0x7F, 0x7F, 0xFF, 0xFF]; + + public static readonly byte[] DoubleMin = [0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + public static readonly byte[] Double0 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Double1 = [0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] DoubleMax = [0x7F, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; public const float Fix16ValMin = short.MinValue; public const float Fix16ValMax = short.MaxValue + (65535f / 65536f); - public static readonly byte[] Fix16Min = { 0x80, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix160 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] Fix161 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] Fix162 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] Fix163 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] Fix164 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] Fix165 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] Fix166 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] Fix167 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] Fix168 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] Fix169 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] Fix16Max = { 0x7F, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] Fix16Min = [0x80, 0x00, 0x00, 0x00]; + public static readonly byte[] Fix160 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] Fix161 = [0x00, 0x01, 0x00, 0x00]; + public static readonly byte[] Fix162 = [0x00, 0x02, 0x00, 0x00]; + public static readonly byte[] Fix163 = [0x00, 0x03, 0x00, 0x00]; + public static readonly byte[] Fix164 = [0x00, 0x04, 0x00, 0x00]; + public static readonly byte[] Fix165 = [0x00, 0x05, 0x00, 0x00]; + public static readonly byte[] Fix166 = [0x00, 0x06, 0x00, 0x00]; + public static readonly byte[] Fix167 = [0x00, 0x07, 0x00, 0x00]; + public static readonly byte[] Fix168 = [0x00, 0x08, 0x00, 0x00]; + public static readonly byte[] Fix169 = [0x00, 0x09, 0x00, 0x00]; + public static readonly byte[] Fix16Max = [0x7F, 0xFF, 0xFF, 0xFF]; public static readonly object[][] Fix16TestData = - { - new object[] { Fix16Min, Fix16ValMin }, - new object[] { Fix160, 0 }, - new object[] { Fix164, 4 }, - new object[] { Fix16Max, Fix16ValMax }, - }; + [ + [Fix16Min, Fix16ValMin], + [Fix160, 0], + [Fix164, 4], + [Fix16Max, Fix16ValMax] + ]; public const float UFix16ValMin = 0; public const float UFix16ValMax = ushort.MaxValue + (65535f / 65536f); - public static readonly byte[] UFix160 = { 0x00, 0x00, 0x00, 0x00 }; - public static readonly byte[] UFix161 = { 0x00, 0x01, 0x00, 0x00 }; - public static readonly byte[] UFix162 = { 0x00, 0x02, 0x00, 0x00 }; - public static readonly byte[] UFix163 = { 0x00, 0x03, 0x00, 0x00 }; - public static readonly byte[] UFix164 = { 0x00, 0x04, 0x00, 0x00 }; - public static readonly byte[] UFix165 = { 0x00, 0x05, 0x00, 0x00 }; - public static readonly byte[] UFix166 = { 0x00, 0x06, 0x00, 0x00 }; - public static readonly byte[] UFix167 = { 0x00, 0x07, 0x00, 0x00 }; - public static readonly byte[] UFix168 = { 0x00, 0x08, 0x00, 0x00 }; - public static readonly byte[] UFix169 = { 0x00, 0x09, 0x00, 0x00 }; - public static readonly byte[] UFix16Max = { 0xFF, 0xFF, 0xFF, 0xFF }; + public static readonly byte[] UFix160 = [0x00, 0x00, 0x00, 0x00]; + public static readonly byte[] UFix161 = [0x00, 0x01, 0x00, 0x00]; + public static readonly byte[] UFix162 = [0x00, 0x02, 0x00, 0x00]; + public static readonly byte[] UFix163 = [0x00, 0x03, 0x00, 0x00]; + public static readonly byte[] UFix164 = [0x00, 0x04, 0x00, 0x00]; + public static readonly byte[] UFix165 = [0x00, 0x05, 0x00, 0x00]; + public static readonly byte[] UFix166 = [0x00, 0x06, 0x00, 0x00]; + public static readonly byte[] UFix167 = [0x00, 0x07, 0x00, 0x00]; + public static readonly byte[] UFix168 = [0x00, 0x08, 0x00, 0x00]; + public static readonly byte[] UFix169 = [0x00, 0x09, 0x00, 0x00]; + public static readonly byte[] UFix16Max = [0xFF, 0xFF, 0xFF, 0xFF]; public static readonly object[][] UFix16TestData = - { - new object[] { UFix160, 0 }, - new object[] { UFix164, 4 }, - new object[] { UFix16Max, UFix16ValMax }, - }; + [ + [UFix160, 0], + [UFix164, 4], + [UFix16Max, UFix16ValMax] + ]; public const float U1Fix15ValMin = 0; public const float U1Fix15ValMax = 1f + (32767f / 32768f); - public static readonly byte[] U1Fix150 = { 0x00, 0x00 }; - public static readonly byte[] U1Fix151 = { 0x80, 0x00 }; - public static readonly byte[] U1Fix15Max = { 0xFF, 0xFF }; + public static readonly byte[] U1Fix150 = [0x00, 0x00]; + public static readonly byte[] U1Fix151 = [0x80, 0x00]; + public static readonly byte[] U1Fix15Max = [0xFF, 0xFF]; public static readonly object[][] U1Fix15TestData = - { - new object[] { U1Fix150, 0 }, - new object[] { U1Fix151, 1 }, - new object[] { U1Fix15Max, U1Fix15ValMax }, - }; + [ + [U1Fix150, 0], + [U1Fix151, 1], + [U1Fix15Max, U1Fix15ValMax] + ]; public const float UFix8ValMin = 0; public const float UFix8ValMax = byte.MaxValue + (255f / 256f); - public static readonly byte[] UFix80 = { 0x00, 0x00 }; - public static readonly byte[] UFix81 = { 0x01, 0x00 }; - public static readonly byte[] UFix82 = { 0x02, 0x00 }; - public static readonly byte[] UFix83 = { 0x03, 0x00 }; - public static readonly byte[] UFix84 = { 0x04, 0x00 }; - public static readonly byte[] UFix85 = { 0x05, 0x00 }; - public static readonly byte[] UFix86 = { 0x06, 0x00 }; - public static readonly byte[] UFix87 = { 0x07, 0x00 }; - public static readonly byte[] UFix88 = { 0x08, 0x00 }; - public static readonly byte[] UFix89 = { 0x09, 0x00 }; - public static readonly byte[] UFix8Max = { 0xFF, 0xFF }; + public static readonly byte[] UFix80 = [0x00, 0x00]; + public static readonly byte[] UFix81 = [0x01, 0x00]; + public static readonly byte[] UFix82 = [0x02, 0x00]; + public static readonly byte[] UFix83 = [0x03, 0x00]; + public static readonly byte[] UFix84 = [0x04, 0x00]; + public static readonly byte[] UFix85 = [0x05, 0x00]; + public static readonly byte[] UFix86 = [0x06, 0x00]; + public static readonly byte[] UFix87 = [0x07, 0x00]; + public static readonly byte[] UFix88 = [0x08, 0x00]; + public static readonly byte[] UFix89 = [0x09, 0x00]; + public static readonly byte[] UFix8Max = [0xFF, 0xFF]; public static readonly object[][] UFix8TestData = - { - new object[] { UFix80, 0 }, - new object[] { UFix84, 4 }, - new object[] { UFix8Max, UFix8ValMax }, - }; + [ + [UFix80, 0], + [UFix84, 4], + [UFix8Max, UFix8ValMax] + ]; public const string AsciiValRand = "aBcdEf1234"; public const string AsciiValRand1 = "Ecf3a"; @@ -199,14 +199,14 @@ internal static class IccTestDataPrimitives public const string AsciiValRandLength4 = "aBcd"; public const string AsciiValNullRand = "aBcd\0Ef\0123"; - public static readonly byte[] AsciiRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52 }; - public static readonly byte[] AsciiRand1 = { 69, 99, 102, 51, 97 }; - public static readonly byte[] AsciiRand2 = { 50, 66, 100, 52, 99 }; - public static readonly byte[] AsciiRand3 = { 99, 97, 100, 49, 52 }; - public static readonly byte[] AsciiRand4 = { 102, 100, 52, 69, 49 }; - public static readonly byte[] AsciiRandLength4 = { 97, 66, 99, 100 }; - public static readonly byte[] AsciiPaddedRand = { 97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0 }; - public static readonly byte[] AsciiNullRand = { 97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51 }; + public static readonly byte[] AsciiRand = [97, 66, 99, 100, 69, 102, 49, 50, 51, 52]; + public static readonly byte[] AsciiRand1 = [69, 99, 102, 51, 97]; + public static readonly byte[] AsciiRand2 = [50, 66, 100, 52, 99]; + public static readonly byte[] AsciiRand3 = [99, 97, 100, 49, 52]; + public static readonly byte[] AsciiRand4 = [102, 100, 52, 69, 49]; + public static readonly byte[] AsciiRandLength4 = [97, 66, 99, 100]; + public static readonly byte[] AsciiPaddedRand = [97, 66, 99, 100, 69, 102, 49, 50, 51, 52, 0, 0, 0, 0]; + public static readonly byte[] AsciiNullRand = [97, 66, 99, 100, 0, 69, 102, 0, 49, 50, 51]; public const int AsciiRandLength = 10; public const int AsciiPaddedRandLength = 14; @@ -214,30 +214,30 @@ internal static class IccTestDataPrimitives public const int AsciiNullRandLengthNoNull = 4; public static readonly object[][] AsciiTestData = - { - new object[] { AsciiRand, AsciiRandLength, AsciiValRand }, - new object[] { AsciiRand, 4, AsciiValRandLength4 }, - new object[] { AsciiNullRand, AsciiNullRandLengthNoNull, AsciiValRandLength4 }, - }; + [ + [AsciiRand, AsciiRandLength, AsciiValRand], + [AsciiRand, 4, AsciiValRandLength4], + [AsciiNullRand, AsciiNullRandLengthNoNull, AsciiValRandLength4] + ]; public static readonly object[][] AsciiWriteTestData = - { - new object[] { AsciiRand, AsciiValRand }, - new object[] { AsciiNullRand, AsciiValNullRand }, - }; + [ + [AsciiRand, AsciiValRand], + [AsciiNullRand, AsciiValNullRand] + ]; public static readonly object[][] AsciiPaddingTestData = - { - new object[] { AsciiPaddedRand, AsciiPaddedRandLength, AsciiValRand, true }, - new object[] { AsciiRandLength4, 4, AsciiValRand, false }, - }; + [ + [AsciiPaddedRand, AsciiPaddedRandLength, AsciiValRand, true], + [AsciiRandLength4, 4, AsciiValRand, false] + ]; public const string UnicodeValRand1 = ".6Abäñ$€βð·ð¤­¢"; public const string UnicodeValRand2 = ".6Abäñ"; public const string UnicodeValRand3 = "$€βð·ð¤­¢"; public static readonly byte[] UnicodeRand1 = - { + [ 0x00, 0x2e, // . 0x00, 0x36, // 6 0x00, 0x41, // A @@ -248,25 +248,25 @@ internal static class IccTestDataPrimitives 0x20, 0xAC, // € 0x03, 0xb2, // β 0xD8, 0x01, 0xDC, 0x37, // ð· - 0xD8, 0x52, 0xDF, 0x62, // 𤭢 - }; + 0xD8, 0x52, 0xDF, 0x62 // 𤭢 + ]; public static readonly byte[] UnicodeRand2 = - { + [ 0x00, 0x2e, // . 0x00, 0x36, // 6 0x00, 0x41, // A 0x00, 0x62, // b 0x00, 0xe4, // ä - 0x00, 0xf1, // ñ - }; + 0x00, 0xf1 // ñ + ]; public static readonly byte[] UnicodeRand3 = - { + [ 0x00, 0x24, // $ 0x20, 0xAC, // € 0x03, 0xb2, // β 0xD8, 0x01, 0xDC, 0x37, // ð· - 0xD8, 0x52, 0xDF, 0x62, // 𤭢 - }; + 0xD8, 0x52, 0xDF, 0x62 // 𤭢 + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs index 7441bede8..6e097a0be 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataProfiles.cs @@ -12,14 +12,14 @@ internal static class IccTestDataProfiles public static readonly IccProfileId ProfileRandomIdValue = new(0x917D6DE6, 0x84C958D1, 0x3BB0F5BB, 0xADD1134F); public static readonly byte[] HeaderRandomIdArray = - { - 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38, - }; + [ + 0x84, 0xA8, 0xD4, 0x60, 0xC7, 0x16, 0xB6, 0xF3, 0x9B, 0x0E, 0x4C, 0x3D, 0xAB, 0x95, 0xF8, 0x38 + ]; public static readonly byte[] ProfileRandomIdArray = - { - 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F, - }; + [ + 0x91, 0x7D, 0x6D, 0xE6, 0x84, 0xC9, 0x58, 0xD1, 0x3B, 0xB0, 0xF5, 0xBB, 0xAD, 0xD1, 0x13, 0x4F + ]; public static readonly IccProfileHeader HeaderRandomWrite = CreateHeaderRandomValue( 562, // should be overwritten @@ -106,10 +106,10 @@ internal static class IccTestDataProfiles 168, ProfileRandomIdValue, "acsp"), - new IccTagDataEntry[] { IccTestDataTagDataEntry.UnknownVal, IccTestDataTagDataEntry.UnknownVal }); + [IccTestDataTagDataEntry.UnknownVal, IccTestDataTagDataEntry.UnknownVal]); public static readonly byte[] HeaderCorruptDataColorSpaceArray = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x61, 0x62, 0x63, 0x64, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -134,11 +134,11 @@ internal static class IccTestDataProfiles 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] HeaderCorruptProfileConnectionSpaceArray = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x62, 0x63, 0x64, 0x65, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -163,11 +163,11 @@ internal static class IccTestDataProfiles 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] HeaderCorruptRenderingIntentArray = - { + [ 0x00, 0x00, 0x00, 0x80, // Size 0x63, 0x64, 0x65, 0x66, // CmmType 0x04, 0x30, 0x00, 0x00, // Version @@ -192,8 +192,8 @@ internal static class IccTestDataProfiles 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly byte[] HeaderDataTooSmallArray = new byte[127]; @@ -204,20 +204,20 @@ internal static class IccTestDataProfiles public static readonly byte[] HeaderSizeBiggerThanDataArray = CreateHeaderRandomArray(160, 0, HeaderRandomIdArray); public static readonly object[][] ProfileIdTestData = - { - new object[] { HeaderRandomArray, HeaderRandomIdValue }, - new object[] { ProfileRandomArray, ProfileRandomIdValue }, - }; + [ + [HeaderRandomArray, HeaderRandomIdValue], + [ProfileRandomArray, ProfileRandomIdValue] + ]; public static readonly object[][] ProfileValidityTestData = - { - new object[] { HeaderCorruptDataColorSpaceArray, false }, - new object[] { HeaderCorruptProfileConnectionSpaceArray, false }, - new object[] { HeaderCorruptRenderingIntentArray, false }, - new object[] { HeaderDataTooSmallArray, false }, - new object[] { HeaderInvalidSizeSmallArray, false }, - new object[] { HeaderInvalidSizeBigArray, false }, - new object[] { HeaderSizeBiggerThanDataArray, false }, - new object[] { HeaderRandomArray, true }, - }; + [ + [HeaderCorruptDataColorSpaceArray, false], + [HeaderCorruptProfileConnectionSpaceArray, false], + [HeaderCorruptRenderingIntentArray, false], + [HeaderDataTooSmallArray, false], + [HeaderInvalidSizeSmallArray, false], + [HeaderInvalidSizeBigArray, false], + [HeaderSizeBiggerThanDataArray, false], + [HeaderRandomArray, true] + ]; } diff --git a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs index a83dc3575..979b0044d 100644 --- a/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs +++ b/tests/ImageSharp.Tests/TestDataIcc/IccTestDataTagDataEntry.cs @@ -10,40 +10,40 @@ internal static class IccTestDataTagDataEntry { public static readonly IccTypeSignature TagDataEntryHeaderUnknownVal = IccTypeSignature.Unknown; public static readonly byte[] TagDataEntryHeaderUnknownArr = - { - 0x00, 0x00, 0x00, 0x00, + [ 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly IccTypeSignature TagDataEntryHeaderMultiLocalizedUnicodeVal = IccTypeSignature.MultiLocalizedUnicode; public static readonly byte[] TagDataEntryHeaderMultiLocalizedUnicodeArr = - { + [ 0x6D, 0x6C, 0x75, 0x63, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly IccTypeSignature TagDataEntryHeaderCurveVal = IccTypeSignature.Curve; public static readonly byte[] TagDataEntryHeaderCurveArr = - { + [ 0x63, 0x75, 0x72, 0x76, - 0x00, 0x00, 0x00, 0x00, - }; + 0x00, 0x00, 0x00, 0x00 + ]; public static readonly object[][] TagDataEntryHeaderTestData = - { - new object[] { TagDataEntryHeaderUnknownArr, TagDataEntryHeaderUnknownVal }, - new object[] { TagDataEntryHeaderMultiLocalizedUnicodeArr, TagDataEntryHeaderMultiLocalizedUnicodeVal }, - new object[] { TagDataEntryHeaderCurveArr, TagDataEntryHeaderCurveVal }, - }; + [ + [TagDataEntryHeaderUnknownArr, TagDataEntryHeaderUnknownVal], + [TagDataEntryHeaderMultiLocalizedUnicodeArr, TagDataEntryHeaderMultiLocalizedUnicodeVal], + [TagDataEntryHeaderCurveArr, TagDataEntryHeaderCurveVal] + ]; - public static readonly IccUnknownTagDataEntry UnknownVal = new(new byte[] { 0x00, 0x01, 0x02, 0x03 }); + public static readonly IccUnknownTagDataEntry UnknownVal = new([0x00, 0x01, 0x02, 0x03]); - public static readonly byte[] UnknownArr = { 0x00, 0x01, 0x02, 0x03 }; + public static readonly byte[] UnknownArr = [0x00, 0x01, 0x02, 0x03]; public static readonly object[][] UnknownTagDataEntryTestData = - { - new object[] { UnknownArr, UnknownVal, 12u }, - }; + [ + [UnknownArr, UnknownVal, 12u] + ]; public static readonly IccChromaticityTagDataEntry ChromaticityVal1 = new(IccColorantEncoding.ItuRBt709_2); public static readonly byte[] ChromaticityArr1 = ArrayHelper.Concat( @@ -57,11 +57,10 @@ internal static class IccTestDataTagDataEntry new byte[] { 0x00, 0x00, 0x0F, 0x5C }); // 0.060 public static readonly IccChromaticityTagDataEntry ChromaticityVal2 = new( - new[] - { - new double[] { 1, 2 }, - new double[] { 3, 4 }, - }); + [ + [1, 2], + [3, 4] + ]); public static readonly byte[] ChromaticityArr2 = ArrayHelper.Concat( IccTestDataPrimitives.UInt162, @@ -86,25 +85,24 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt169); public static readonly object[][] ChromaticityTagDataEntryTestData = - { - new object[] { ChromaticityArr1, ChromaticityVal1 }, - new object[] { ChromaticityArr2, ChromaticityVal2 }, - }; + [ + [ChromaticityArr1, ChromaticityVal1], + [ChromaticityArr2, ChromaticityVal2] + ]; - public static readonly IccColorantOrderTagDataEntry ColorantOrderVal = new(new byte[] { 0x00, 0x01, 0x02 }); + public static readonly IccColorantOrderTagDataEntry ColorantOrderVal = new([0x00, 0x01, 0x02]); public static readonly byte[] ColorantOrderArr = ArrayHelper.Concat(IccTestDataPrimitives.UInt323, new byte[] { 0x00, 0x01, 0x02 }); public static readonly object[][] ColorantOrderTagDataEntryTestData = - { - new object[] { ColorantOrderArr, ColorantOrderVal }, - }; + [ + [ColorantOrderArr, ColorantOrderVal] + ]; public static readonly IccColorantTableTagDataEntry ColorantTableVal = new( - new[] - { - IccTestDataNonPrimitives.ColorantTableEntryValRand1, + [ + IccTestDataNonPrimitives.ColorantTableEntryValRand1, IccTestDataNonPrimitives.ColorantTableEntryValRand2 - }); + ]); public static readonly byte[] ColorantTableArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt322, @@ -112,9 +110,9 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.ColorantTableEntryRand2); public static readonly object[][] ColorantTableTagDataEntryTestData = - { - new object[] { ColorantTableArr, ColorantTableVal }, - }; + [ + [ColorantTableArr, ColorantTableVal] + ]; public static readonly IccCurveTagDataEntry CurveVal0 = new(); public static readonly byte[] CurveArr0 = IccTestDataPrimitives.UInt320; @@ -124,7 +122,7 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt321, IccTestDataPrimitives.UFix81); - public static readonly IccCurveTagDataEntry CurveVal2 = new(new float[] { 1 / 65535f, 2 / 65535f, 3 / 65535f }); + public static readonly IccCurveTagDataEntry CurveVal2 = new([1 / 65535f, 2 / 65535f, 3 / 65535f]); public static readonly byte[] CurveArr2 = ArrayHelper.Concat( IccTestDataPrimitives.UInt323, IccTestDataPrimitives.UInt161, @@ -132,46 +130,47 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt163); public static readonly object[][] CurveTagDataEntryTestData = - { - new object[] { CurveArr0, CurveVal0 }, - new object[] { CurveArr1, CurveVal1 }, - new object[] { CurveArr2, CurveVal2 }, - }; + [ + [CurveArr0, CurveVal0], + [CurveArr1, CurveVal1], + [CurveArr2, CurveVal2] + ]; - public static readonly IccDataTagDataEntry DataValNoAscii = new(new byte[] { 0x01, 0x02, 0x03, 0x04 }, false); + public static readonly IccDataTagDataEntry DataValNoAscii = new([0x01, 0x02, 0x03, 0x04], false); public static readonly byte[] DataArrNoAscii = - { + [ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04 - }; + ]; - public static readonly IccDataTagDataEntry DataValAscii = new(new[] { (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' }, true); + public static readonly IccDataTagDataEntry DataValAscii = new([(byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' + ], true); public static readonly byte[] DataArrAscii = - { + [ 0x00, 0x00, 0x00, 0x01, (byte)'A', (byte)'S', (byte)'C', (byte)'I', (byte)'I' - }; + ]; public static readonly object[][] DataTagDataEntryTestData = - { - new object[] { DataArrNoAscii, DataValNoAscii, 16u }, - new object[] { DataArrAscii, DataValAscii, 17u }, - }; + [ + [DataArrNoAscii, DataValNoAscii, 16u], + [DataArrAscii, DataValAscii, 17u] + ]; public static readonly IccDateTimeTagDataEntry DateTimeVal = new(IccTestDataNonPrimitives.DateTimeValRand1); public static readonly byte[] DateTimeArr = IccTestDataNonPrimitives.DateTimeRand1; public static readonly object[][] DateTimeTagDataEntryTestData = - { - new object[] { DateTimeArr, DateTimeVal }, - }; + [ + [DateTimeArr, DateTimeVal] + ]; public static readonly IccLut16TagDataEntry Lut16Val = new( - new[] { IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad }, + [IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad], IccTestDataLut.Clut16ValGrad, - new[] { IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad }); + [IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad, IccTestDataLut.Lut16ValGrad]); public static readonly byte[] Lut16Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, @@ -185,14 +184,14 @@ internal static class IccTestDataTagDataEntry IccTestDataLut.Lut16Grad); public static readonly object[][] Lut16TagDataEntryTestData = - { - new object[] { Lut16Arr, Lut16Val }, - }; + [ + [Lut16Arr, Lut16Val] + ]; public static readonly IccLut8TagDataEntry Lut8Val = new( - new IccLut[] { IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad }, + [IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad], IccTestDataLut.Clut8ValGrad, - new IccLut[] { IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad }); + [IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad, IccTestDataLut.Lut8ValGrad]); public static readonly byte[] Lut8Arr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x03, 0x00 }, @@ -204,7 +203,7 @@ internal static class IccTestDataTagDataEntry IccTestDataLut.Lut8Grad, IccTestDataLut.Lut8Grad); - public static readonly object[][] Lut8TagDataEntryTestData = { new object[] { Lut8Arr, Lut8Val }, }; + public static readonly object[][] Lut8TagDataEntryTestData = [[Lut8Arr, Lut8Val]]; private static readonly byte[] CurveFull0 = ArrayHelper.Concat(TagDataEntryHeaderCurveArr, CurveArr0); @@ -214,17 +213,16 @@ internal static class IccTestDataTagDataEntry public static readonly IccLutAToBTagDataEntry LutAToBVal = new( - new[] - { - CurveVal0, + [ + CurveVal0, CurveVal1, - CurveVal2, - }, + CurveVal2 + ], IccTestDataMatrix.Single2DArrayValGrad, IccTestDataMatrix.Single1DArrayValGrad, - new[] { CurveVal1, CurveVal2, CurveVal0 }, + [CurveVal1, CurveVal2, CurveVal0], IccTestDataLut.ClutVal16, - new[] { CurveVal2, CurveVal1 }); + [CurveVal2, CurveVal1]); public static readonly byte[] LutAToBArr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x00, 0x00 }, @@ -262,19 +260,18 @@ internal static class IccTestDataTagDataEntry CurveFull1, // 14 bytes new byte[] { 0x00, 0x00 }); // Padding - public static readonly object[][] LutAToBTagDataEntryTestData = { new object[] { LutAToBArr, LutAToBVal }, }; + public static readonly object[][] LutAToBTagDataEntryTestData = [[LutAToBArr, LutAToBVal]]; public static readonly IccLutBToATagDataEntry LutBToAVal = new( - new[] - { + [ CurveVal0, - CurveVal1, - }, + CurveVal1 + ], null, null, null, IccTestDataLut.ClutVal16, - new[] { CurveVal2, CurveVal1, CurveVal0 }); + [CurveVal2, CurveVal1, CurveVal0]); public static readonly byte[] LutBToAArr = ArrayHelper.Concat( new byte[] { 0x02, 0x03, 0x00, 0x00 }, @@ -301,9 +298,9 @@ internal static class IccTestDataTagDataEntry CurveFull0); // 12 bytes public static readonly object[][] LutBToATagDataEntryTestData = - { - new object[] { LutBToAArr, LutBToAVal }, - }; + [ + [LutBToAArr, LutBToAVal] + ]; public static readonly IccMeasurementTagDataEntry MeasurementVal = new( IccStandardObserver.Cie1931Observer, @@ -320,9 +317,9 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt321); public static readonly object[][] MeasurementTagDataEntryTestData = - { - new object[] { MeasurementArr, MeasurementVal }, - }; + [ + [MeasurementArr, MeasurementVal] + ]; private static readonly IccLocalizedString LocalizedStringRandEnUs = CreateLocalizedString("en", "US", IccTestDataPrimitives.UnicodeValRand2); private static readonly IccLocalizedString LocalizedStringRandDeDe = CreateLocalizedString("de", "DE", IccTestDataPrimitives.UnicodeValRand3); @@ -361,34 +358,34 @@ internal static class IccTestDataTagDataEntry return new IccLocalizedString(culture, text); } - private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = new[] - { + private static readonly IccLocalizedString[] LocalizedStringRandArrEnUsDeDe = + [ LocalizedStringRandEnUs, - LocalizedStringRandDeDe, - }; + LocalizedStringRandDeDe + ]; - private static readonly IccLocalizedString[] LocalizedStringRandArrEnInvariant = new[] - { + private static readonly IccLocalizedString[] LocalizedStringRandArrEnInvariant = + [ LocalizedStringRandEn, - LocalizedStringRandInvariant, - }; + LocalizedStringRandInvariant + ]; - private static readonly IccLocalizedString[] LocalizedStringSameArrEnUsDeDeEsXlXyXl = new[] - { + private static readonly IccLocalizedString[] LocalizedStringSameArrEnUsDeDeEsXlXyXl = + [ LocalizedStringRandEnUs, LocalizedStringRand2DeDe, LocalizedStringRand2EsXl, - LocalizedStringRand2XyXl, - }; + LocalizedStringRand2XyXl + ]; public static readonly IccMultiLocalizedUnicodeTagDataEntry MultiLocalizedUnicodeVal = new(LocalizedStringRandArrEnUsDeDe); public static readonly byte[] MultiLocalizedUnicodeArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt322, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x28 }, // 40 - new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, + [(byte)'d', (byte)'e', (byte)'D', (byte)'E'], new byte[] { 0x00, 0x00, 0x00, 0x0E }, // 14 new byte[] { 0x00, 0x00, 0x00, 0x34 }, // 52 IccTestDataPrimitives.UnicodeRand2, @@ -423,40 +420,39 @@ internal static class IccTestDataTagDataEntry public static readonly byte[] MultiLocalizedUnicodeArr3 = ArrayHelper.Concat( IccTestDataPrimitives.UInt324, new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 - new byte[] { (byte)'e', (byte)'n', (byte)'U', (byte)'S' }, + [(byte)'e', (byte)'n', (byte)'U', (byte)'S'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'d', (byte)'e', (byte)'D', (byte)'E' }, + [(byte)'d', (byte)'e', (byte)'D', (byte)'E'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'e', (byte)'s', (byte)'X', (byte)'L' }, + [(byte)'e', (byte)'s', (byte)'X', (byte)'L'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 - new byte[] { (byte)'x', (byte)'y', (byte)'X', (byte)'L' }, + [(byte)'x', (byte)'y', (byte)'X', (byte)'L'], new byte[] { 0x00, 0x00, 0x00, 0x0C }, // 12 new byte[] { 0x00, 0x00, 0x00, 0x40 }, // 64 IccTestDataPrimitives.UnicodeRand2); public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestDataRead = - { - new object[] { MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal }, - new object[] { MultiLocalizedUnicodeArr2Read, MultiLocalizedUnicodeVal2 }, - new object[] { MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3 }, - }; + [ + [MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal], + [MultiLocalizedUnicodeArr2Read, MultiLocalizedUnicodeVal2], + [MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3] + ]; public static readonly object[][] MultiLocalizedUnicodeTagDataEntryTestDataWrite = - { - new object[] { MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal }, - new object[] { MultiLocalizedUnicodeArr2Write, MultiLocalizedUnicodeVal2 }, - new object[] { MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3 }, - }; + [ + [MultiLocalizedUnicodeArr, MultiLocalizedUnicodeVal], + [MultiLocalizedUnicodeArr2Write, MultiLocalizedUnicodeVal2], + [MultiLocalizedUnicodeArr3, MultiLocalizedUnicodeVal3] + ]; public static readonly IccMultiProcessElementsTagDataEntry MultiProcessElementsVal = new( - new IccMultiProcessElement[] - { - IccTestDataMultiProcessElements.MpeValClut, - IccTestDataMultiProcessElements.MpeValClut, - }); + [ + IccTestDataMultiProcessElements.MpeValClut, + IccTestDataMultiProcessElements.MpeValClut + ]); public static readonly byte[] MultiProcessElementsArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt162, @@ -470,15 +466,15 @@ internal static class IccTestDataTagDataEntry IccTestDataMultiProcessElements.MpeClut); public static readonly object[][] MultiProcessElementsTagDataEntryTestData = - { - new object[] { MultiProcessElementsArr, MultiProcessElementsVal }, - }; + [ + [MultiProcessElementsArr, MultiProcessElementsVal] + ]; public static readonly IccNamedColor2TagDataEntry NamedColor2Val = new( 16909060, ArrayHelper.Fill('A', 31), ArrayHelper.Fill('4', 31), - new IccNamedColor[] { IccTestDataNonPrimitives.NamedColorValMin, IccTestDataNonPrimitives.NamedColorValMin }); + [IccTestDataNonPrimitives.NamedColorValMin, IccTestDataNonPrimitives.NamedColorValMin]); public static readonly byte[] NamedColor2Arr = ArrayHelper.Concat( new byte[] { 0x01, 0x02, 0x03, 0x04 }, @@ -492,24 +488,23 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.NamedColorMin); public static readonly object[][] NamedColor2TagDataEntryTestData = - { - new object[] { NamedColor2Arr, NamedColor2Val }, - }; + [ + [NamedColor2Arr, NamedColor2Val] + ]; public static readonly IccParametricCurveTagDataEntry ParametricCurveVal = new(IccTestDataCurves.ParametricValVar1); public static readonly byte[] ParametricCurveArr = IccTestDataCurves.ParametricVar1; public static readonly object[][] ParametricCurveTagDataEntryTestData = - { - new object[] { ParametricCurveArr, ParametricCurveVal }, - }; + [ + [ParametricCurveArr, ParametricCurveVal] + ]; public static readonly IccProfileSequenceDescTagDataEntry ProfileSequenceDescVal = new( - new IccProfileDescription[] - { - IccTestDataNonPrimitives.ProfileDescriptionValRand1, + [ + IccTestDataNonPrimitives.ProfileDescriptionValRand1, IccTestDataNonPrimitives.ProfileDescriptionValRand1 - }); + ]); public static readonly byte[] ProfileSequenceDescArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt322, @@ -517,16 +512,15 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.ProfileDescriptionRand1); public static readonly object[][] ProfileSequenceDescTagDataEntryTestData = - { - new object[] { ProfileSequenceDescArr, ProfileSequenceDescVal }, - }; + [ + [ProfileSequenceDescArr, ProfileSequenceDescVal] + ]; public static readonly IccProfileSequenceIdentifierTagDataEntry ProfileSequenceIdentifier_Val = new( - new[] - { - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe), - new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe), - }); + [ + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe), + new IccProfileSequenceIdentifier(IccTestDataNonPrimitives.ProfileIdValRand, LocalizedStringRandArrEnUsDeDe) + ]); public static readonly byte[] ProfileSequenceIdentifierArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt322, @@ -544,16 +538,15 @@ internal static class IccTestDataTagDataEntry new byte[] { 0x00, 0x00 }); public static readonly object[][] ProfileSequenceIdentifierTagDataEntryTestData = - { - new object[] { ProfileSequenceIdentifierArr, ProfileSequenceIdentifier_Val }, - }; + [ + [ProfileSequenceIdentifierArr, ProfileSequenceIdentifier_Val] + ]; public static readonly IccResponseCurveSet16TagDataEntry ResponseCurveSet16Val = new( - new[] - { - IccTestDataCurves.ResponseValGrad, - IccTestDataCurves.ResponseValGrad, - }); + [ + IccTestDataCurves.ResponseValGrad, + IccTestDataCurves.ResponseValGrad + ]); public static readonly byte[] ResponseCurveSet16Arr = ArrayHelper.Concat( IccTestDataPrimitives.UInt163, @@ -564,88 +557,88 @@ internal static class IccTestDataTagDataEntry IccTestDataCurves.ResponseGrad); // 88 bytes public static readonly object[][] ResponseCurveSet16TagDataEntryTestData = - { - new object[] { ResponseCurveSet16Arr, ResponseCurveSet16Val }, - }; + [ + [ResponseCurveSet16Arr, ResponseCurveSet16Val] + ]; - public static readonly IccFix16ArrayTagDataEntry Fix16ArrayVal = new(new[] { 1 / 256f, 2 / 256f, 3 / 256f }); + public static readonly IccFix16ArrayTagDataEntry Fix16ArrayVal = new([1 / 256f, 2 / 256f, 3 / 256f]); public static readonly byte[] Fix16ArrayArr = ArrayHelper.Concat( IccTestDataPrimitives.Fix161, IccTestDataPrimitives.Fix162, IccTestDataPrimitives.Fix163); public static readonly object[][] Fix16ArrayTagDataEntryTestData = - { - new object[] { Fix16ArrayArr, Fix16ArrayVal, 20u }, - }; + [ + [Fix16ArrayArr, Fix16ArrayVal, 20u] + ]; public static readonly IccSignatureTagDataEntry SignatureVal = new("ABCD"); - public static readonly byte[] SignatureArr = { 0x41, 0x42, 0x43, 0x44, }; + public static readonly byte[] SignatureArr = [0x41, 0x42, 0x43, 0x44]; public static readonly object[][] SignatureTagDataEntryTestData = - { - new object[] { SignatureArr, SignatureVal }, - }; + [ + [SignatureArr, SignatureVal] + ]; public static readonly IccTextTagDataEntry TextVal = new("ABCD"); - public static readonly byte[] TextArr = { 0x41, 0x42, 0x43, 0x44 }; + public static readonly byte[] TextArr = [0x41, 0x42, 0x43, 0x44]; public static readonly object[][] TextTagDataEntryTestData = - { - new object[] { TextArr, TextVal, 12u }, - }; + [ + [TextArr, TextVal, 12u] + ]; - public static readonly IccUFix16ArrayTagDataEntry UFix16ArrayVal = new(new float[] { 1, 2, 3 }); + public static readonly IccUFix16ArrayTagDataEntry UFix16ArrayVal = new([1, 2, 3]); public static readonly byte[] UFix16ArrayArr = ArrayHelper.Concat( IccTestDataPrimitives.UFix161, IccTestDataPrimitives.UFix162, IccTestDataPrimitives.UFix163); public static readonly object[][] UFix16ArrayTagDataEntryTestData = - { - new object[] { UFix16ArrayArr, UFix16ArrayVal, 20u }, - }; + [ + [UFix16ArrayArr, UFix16ArrayVal, 20u] + ]; - public static readonly IccUInt16ArrayTagDataEntry UInt16ArrayVal = new(new ushort[] { 1, 2, 3 }); + public static readonly IccUInt16ArrayTagDataEntry UInt16ArrayVal = new([1, 2, 3]); public static readonly byte[] UInt16ArrayArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt161, IccTestDataPrimitives.UInt162, IccTestDataPrimitives.UInt163); public static readonly object[][] UInt16ArrayTagDataEntryTestData = - { - new object[] { UInt16ArrayArr, UInt16ArrayVal, 14u }, - }; + [ + [UInt16ArrayArr, UInt16ArrayVal, 14u] + ]; - public static readonly IccUInt32ArrayTagDataEntry UInt32ArrayVal = new(new uint[] { 1, 2, 3 }); + public static readonly IccUInt32ArrayTagDataEntry UInt32ArrayVal = new([1, 2, 3]); public static readonly byte[] UInt32ArrayArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt321, IccTestDataPrimitives.UInt322, IccTestDataPrimitives.UInt323); public static readonly object[][] UInt32ArrayTagDataEntryTestData = - { - new object[] { UInt32ArrayArr, UInt32ArrayVal, 20u }, - }; + [ + [UInt32ArrayArr, UInt32ArrayVal, 20u] + ]; - public static readonly IccUInt64ArrayTagDataEntry UInt64ArrayVal = new(new ulong[] { 1, 2, 3 }); + public static readonly IccUInt64ArrayTagDataEntry UInt64ArrayVal = new([1, 2, 3]); public static readonly byte[] UInt64ArrayArr = ArrayHelper.Concat( IccTestDataPrimitives.UInt641, IccTestDataPrimitives.UInt642, IccTestDataPrimitives.UInt643); public static readonly object[][] UInt64ArrayTagDataEntryTestData = - { - new object[] { UInt64ArrayArr, UInt64ArrayVal, 32u }, - }; + [ + [UInt64ArrayArr, UInt64ArrayVal, 32u] + ]; - public static readonly IccUInt8ArrayTagDataEntry UInt8ArrayVal = new(new byte[] { 1, 2, 3 }); - public static readonly byte[] UInt8ArrayArr = { 1, 2, 3 }; + public static readonly IccUInt8ArrayTagDataEntry UInt8ArrayVal = new([1, 2, 3]); + public static readonly byte[] UInt8ArrayArr = [1, 2, 3]; public static readonly object[][] UInt8ArrayTagDataEntryTestData = - { - new object[] { UInt8ArrayArr, UInt8ArrayVal, 11u }, - }; + [ + [UInt8ArrayArr, UInt8ArrayVal, 11u] + ]; public static readonly IccViewingConditionsTagDataEntry ViewingConditionsVal = new( IccTestDataNonPrimitives.XyzNumberValVar1, @@ -658,16 +651,15 @@ internal static class IccTestDataTagDataEntry IccTestDataPrimitives.UInt321); public static readonly object[][] ViewingConditionsTagDataEntryTestData = - { - new object[] { ViewingConditionsArr, ViewingConditionsVal }, - }; + [ + [ViewingConditionsArr, ViewingConditionsVal] + ]; - public static readonly IccXyzTagDataEntry XyzVal = new(new[] - { + public static readonly IccXyzTagDataEntry XyzVal = new([ IccTestDataNonPrimitives.XyzNumberValVar1, IccTestDataNonPrimitives.XyzNumberValVar2, - IccTestDataNonPrimitives.XyzNumberValVar3, - }); + IccTestDataNonPrimitives.XyzNumberValVar3 + ]); public static readonly byte[] XyzArr = ArrayHelper.Concat( IccTestDataNonPrimitives.XyzNumberVar1, @@ -675,9 +667,9 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.XyzNumberVar3); public static readonly object[][] XYZTagDataEntryTestData = - { - new object[] { XyzArr, XyzVal, 44u }, - }; + [ + [XyzArr, XyzVal, 44u] + ]; public static readonly IccTextDescriptionTagDataEntry TextDescriptionVal1 = new( IccTestDataPrimitives.AsciiValRand, @@ -709,10 +701,10 @@ internal static class IccTestDataTagDataEntry ArrayHelper.Fill((byte)0x00, 67)); public static readonly object[][] TextDescriptionTagDataEntryTestData = - { - new object[] { TextDescriptionArr1, TextDescriptionVal1 }, - new object[] { TextDescriptionArr2, TextDescriptionVal2 }, - }; + [ + [TextDescriptionArr1, TextDescriptionVal1], + [TextDescriptionArr2, TextDescriptionVal2] + ]; public static readonly IccCrdInfoTagDataEntry CrdInfoVal = new( IccTestDataPrimitives.AsciiValRand4, @@ -739,13 +731,13 @@ internal static class IccTestDataTagDataEntry new byte[] { 0 }); public static readonly object[][] CrdInfoTagDataEntryTestData = - { - new object[] { CrdInfoArr, CrdInfoVal }, - }; + [ + [CrdInfoArr, CrdInfoVal] + ]; public static readonly IccScreeningTagDataEntry ScreeningVal = new( IccScreeningFlag.DefaultScreens | IccScreeningFlag.UnitLinesPerCm, - new IccScreeningChannel[] { IccTestDataNonPrimitives.ScreeningChannelValRand1, IccTestDataNonPrimitives.ScreeningChannelValRand2 }); + [IccTestDataNonPrimitives.ScreeningChannelValRand1, IccTestDataNonPrimitives.ScreeningChannelValRand2]); public static readonly byte[] ScreeningArr = ArrayHelper.Concat( IccTestDataPrimitives.Int321, @@ -754,13 +746,13 @@ internal static class IccTestDataTagDataEntry IccTestDataNonPrimitives.ScreeningChannelRand2); public static readonly object[][] ScreeningTagDataEntryTestData = - { - new object[] { ScreeningArr, ScreeningVal }, - }; + [ + [ScreeningArr, ScreeningVal] + ]; public static readonly IccUcrBgTagDataEntry UcrBgVal = new( - new ushort[] { 3, 4, 6 }, - new ushort[] { 9, 7, 2, 5 }, + [3, 4, 6], + [9, 7, 2, 5], IccTestDataPrimitives.AsciiValRand); public static readonly byte[] UcrBgArr = ArrayHelper.Concat( @@ -777,9 +769,9 @@ internal static class IccTestDataTagDataEntry new byte[] { 0 }); public static readonly object[][] UcrBgTagDataEntryTestData = - { - new object[] { UcrBgArr, UcrBgVal, 41 }, - }; + [ + [UcrBgArr, UcrBgVal, 41] + ]; public static readonly IccTagDataEntry TagDataEntryCurveVal = CurveVal2; public static readonly byte[] TagDataEntryCurveArr = ArrayHelper.Concat( @@ -801,8 +793,8 @@ internal static class IccTestDataTagDataEntry public static readonly IccTagTableEntry TagDataEntryCurveTable = new(IccProfileTag.Unknown, 0, (uint)TagDataEntryCurveArr.Length - 2); public static readonly object[][] TagDataEntryTestData = - { - new object[] { TagDataEntryCurveArr, TagDataEntryCurveVal }, - new object[] { TagDataEntryMultiLocalizedUnicodeArr, TagDataEntryMultiLocalizedUnicodeVal }, - }; + [ + [TagDataEntryCurveArr, TagDataEntryCurveVal], + [TagDataEntryMultiLocalizedUnicodeArr, TagDataEntryMultiLocalizedUnicodeVal] + ]; } diff --git a/tests/ImageSharp.Tests/TestFontUtilities.cs b/tests/ImageSharp.Tests/TestFontUtilities.cs index d575489be..a2c203267 100644 --- a/tests/ImageSharp.Tests/TestFontUtilities.cs +++ b/tests/ImageSharp.Tests/TestFontUtilities.cs @@ -37,13 +37,13 @@ public static class TestFontUtilities /// private static string GetFontsDirectory() { - List directories = new() - { - "TestFonts/", // Here for code coverage tests. - "tests/ImageSharp.Tests/TestFonts/", // from travis/build script - "../../../../../ImageSharp.Tests/TestFonts/", // from Sandbox46 - "../../../../TestFonts/" - }; + List directories = + [ + "TestFonts/", // Here for code coverage tests. + "tests/ImageSharp.Tests/TestFonts/", // from travis/build script + "../../../../../ImageSharp.Tests/TestFonts/", // from Sandbox46 + "../../../../TestFonts/" + ]; directories = directories.SelectMany(x => new[] { diff --git a/tests/ImageSharp.Tests/TestFormat.cs b/tests/ImageSharp.Tests/TestFormat.cs index 92b74cde1..28bfcfaa8 100644 --- a/tests/ImageSharp.Tests/TestFormat.cs +++ b/tests/ImageSharp.Tests/TestFormat.cs @@ -28,7 +28,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat this.Decoder = new TestDecoder(this); } - public List DecodeCalls { get; } = new(); + public List DecodeCalls { get; } = []; public TestEncoder Encoder { get; } @@ -103,7 +103,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public string Extension => "test_ext"; - public IEnumerable SupportedExtensions => new[] { "test_ext" }; + public IEnumerable SupportedExtensions => ["test_ext"]; public int HeaderSize => this.header.Length; @@ -111,7 +111,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public string DefaultMimeType => this.MimeType; - public IEnumerable MimeTypes => new[] { this.MimeType }; + public IEnumerable MimeTypes => [this.MimeType]; public IEnumerable FileExtensions => this.SupportedExtensions; @@ -193,7 +193,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestDecoder(TestFormat testFormat) => this.testFormat = testFormat; - public IEnumerable MimeTypes => new[] { this.testFormat.MimeType }; + public IEnumerable MimeTypes => [this.testFormat.MimeType]; public IEnumerable FileExtensions => this.testFormat.SupportedExtensions; @@ -246,7 +246,7 @@ public class TestFormat : IImageFormatConfigurationModule, IImageFormat public TestEncoder(TestFormat testFormat) => this.testFormat = testFormat; - public IEnumerable MimeTypes => new[] { this.testFormat.MimeType }; + public IEnumerable MimeTypes => [this.testFormat.MimeType]; public IEnumerable FileExtensions => this.testFormat.SupportedExtensions; diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 021f02476..4ea77b41a 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -231,7 +231,7 @@ public static class TestImages public const string ExifUndefType = "Jpg/progressive/ExifUndefType.jpg"; } - public static readonly string[] All = { Fb, Progress, Festzug }; + public static readonly string[] All = [Fb, Progress, Festzug]; } public static class Baseline @@ -287,12 +287,12 @@ public static class TestImages public const string ArithmeticCodingWithRestart = "Jpg/baseline/Calliphora-arithmetic-restart.jpg"; public static readonly string[] All = - { + [ Cmyk, Ycck, Exif, Floorplan, Calliphora, Turtle420, GammaDalaiLamaGray, Hiyamugi, Jpeg400, Jpeg420Exif, Jpeg444, Ratio1x1, Testorig12bit, YcckSubsample1222 - }; + ]; } public static class Issues @@ -470,24 +470,24 @@ public static class TestImages public const string BlackWhitePalletDataMatrix = "Bmp/bit1datamatrix.bmp"; public static readonly string[] BitFields = - { - Rgb32bfdef, + [ + Rgb32bfdef, Rgb32bf, Rgb16565, Rgb16bfdef, Rgb16565pal, - Issue735, - }; + Issue735 + ]; public static readonly string[] Miscellaneous = - { + [ Car, F, NegHeight - }; + ]; public static readonly string[] Benchmark = - { + [ Car, F, NegHeight, @@ -504,7 +504,7 @@ public static class TestImages Bit16, Bit16Inverted, Bit32Rgb - }; + ]; } public static class Gif @@ -585,7 +585,7 @@ public static class TestImages } public static readonly string[] Animated = - { + [ M4nb, Giphy, Cheers, @@ -604,7 +604,7 @@ public static class TestImages Issues.Issue1530, Bit18RGBCube, Global256NoTrans - }; + ]; } public static class Tga @@ -1164,9 +1164,10 @@ public static class TestImages public const string Issue2909 = "Tiff/Issues/Issue2909.tiff"; - public static readonly string[] Multiframes = { MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ }; + public static readonly string[] Multiframes = [MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ + ]; - public static readonly string[] Metadata = { SampleMetadata }; + public static readonly string[] Metadata = [SampleMetadata]; } public static class BigTiff diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs index 592ebb4eb..7191f3ba7 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs @@ -70,7 +70,7 @@ public abstract class ImageDataAttributeBase : DataAttribute if (!addedRows.Any()) { - addedRows = new[] { Array.Empty() }; + addedRows = [[]]; } bool firstIsProvider = this.FirstIsProvider(testMethod); diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs index d82d5cd91..349db60f2 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBasicTestPatternImagesAttribute.cs @@ -31,5 +31,6 @@ public class WithBasicTestPatternImagesAttribute : ImageDataAttributeBase protected override string GetFactoryMethodName(MethodInfo testMethod) => "BasicTestPattern"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs index e9f57a7ab..ec637a7b6 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithBlankImagesAttribute.cs @@ -46,5 +46,6 @@ public class WithBlankImagesAttribute : ImageDataAttributeBase protected override string GetFactoryMethodName(MethodInfo testMethod) => "Blank"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs index cf472699a..3392d97ab 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithFileAttribute.cs @@ -39,7 +39,7 @@ public class WithFileAttribute : ImageDataAttributeBase this.fileName = fileName; } - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.fileName }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.fileName]; protected override string GetFactoryMethodName(MethodInfo testMethod) => "File"; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs index cd27eaf0b..59c092b40 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithMemberFactoryAttribute.cs @@ -29,7 +29,7 @@ public class WithMemberFactoryAttribute : ImageDataAttributeBase protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) { - return new object[] { testMethod.DeclaringType.FullName, this.memberMethodName }; + return [testMethod.DeclaringType.FullName, this.memberMethodName]; } protected override string GetFactoryMethodName(MethodInfo testMethod) => "Lambda"; diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs index a4149f735..cc4f6f7f3 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithSolidFilledImagesAttribute.cs @@ -160,7 +160,7 @@ public class WithSolidFilledImagesAttribute : WithBlankImagesAttribute public byte A { get; } protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) - => new object[] { this.Width, this.Height, this.R, this.G, this.B, this.A }; + => [this.Width, this.Height, this.R, this.G, this.B, this.A]; protected override string GetFactoryMethodName(MethodInfo testMethod) => "Solid"; } diff --git a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs index 4b016d5ea..2630acea8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Attributes/WithTestPatternImagesAttribute.cs @@ -50,5 +50,6 @@ public class WithTestPatternImagesAttribute : ImageDataAttributeBase protected override string GetFactoryMethodName(MethodInfo testMethod) => "TestPattern"; - protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => new object[] { this.Width, this.Height }; + protected override object[] GetFactoryMethodArgs(MethodInfo testMethod, Type factoryType) => [this.Width, this.Height + ]; } diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs index 1d35a6200..c6bb38dd8 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ExactImageComparer.cs @@ -26,7 +26,7 @@ public class ExactImageComparer : ImageComparer Rgba64[] aBuffer = new Rgba64[width]; Rgba64[] bBuffer = new Rgba64[width]; - List differences = new(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs index c8e11e69c..d7352de58 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/ImageComparer.cs @@ -51,7 +51,7 @@ public static class ImageComparerExtensions where TPixelA : unmanaged, IPixel where TPixelB : unmanaged, IPixel { - List> result = new(); + List> result = []; int expectedFrameCount = actual.Frames.Count; if (predicate != null) diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs index c9f13ca2f..47cf7e6a5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageComparison/TolerantImageComparer.cs @@ -70,7 +70,7 @@ public class TolerantImageComparer : ImageComparer float totalDifference = 0F; - List differences = new(); + List differences = []; Configuration configuration = expected.Configuration; Buffer2D expectedBuffer = expected.PixelBuffer; Buffer2D actualBuffer = actual.PixelBuffer; diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 8eed0a1c1..5eb5be0d9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -265,7 +265,7 @@ public static partial class TestEnvironment private static Version GetNetCoreVersion() { Assembly assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly; - string[] assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries); + string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App"); if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2) { diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs index 994aa670c..4a34529dd 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs @@ -375,7 +375,7 @@ public static class TestImageExtensions appendPixelTypeToFileName, predicate); - List> temporaryFrameImages = new(); + List> temporaryFrameImages = []; IImageDecoder decoder = TestEnvironment.GetReferenceDecoder(frameFiles[0].FileName); diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs index fbdfb9d61..2e2416952 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtils.cs @@ -26,7 +26,7 @@ public static class TestUtils private static readonly Dictionary PixelTypes2ClrTypes = new(); private static readonly PixelTypes[] AllConcretePixelTypes = GetAllPixelTypes() - .Except(new[] { PixelTypes.Undefined, PixelTypes.All }) + .Except([PixelTypes.Undefined, PixelTypes.All]) .ToArray(); static TestUtils() @@ -133,7 +133,7 @@ public static class TestUtils { if (pixelTypes == PixelTypes.Undefined) { - return Enumerable.Empty>(); + return []; } else if (pixelTypes == PixelTypes.All) { diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 34337600e..82b247d9d 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -14,9 +14,9 @@ public class FeatureTestRunnerTests public static TheoryData Intrinsics => new() { - { HwIntrinsics.DisableAES | HwIntrinsics.AllowAll, new[] { "EnableAES", "AllowAll" } }, - { HwIntrinsics.DisableHWIntrinsic, new[] { "EnableHWIntrinsic" } }, - { HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableAVX, new[] { "EnableSSE42", "EnableAVX" } } + { HwIntrinsics.DisableAES | HwIntrinsics.AllowAll, ["EnableAES", "AllowAll"] }, + { HwIntrinsics.DisableHWIntrinsic, ["EnableHWIntrinsic"] }, + { HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableAVX, ["EnableSSE42", "EnableAVX"] } }; [Theory] diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs index 4329a6be3..a145e7365 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs @@ -22,20 +22,20 @@ public class ReferenceDecoderBenchmarks public const int DefaultExecutionCount = 50; public static readonly string[] PngBenchmarkFiles = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Kaboom, TestImages.Png.Bike, TestImages.Png.Splash, TestImages.Png.SplashInterlaced - }; + ]; public static readonly string[] BmpBenchmarkFiles = - { - TestImages.Bmp.NegHeight, + [ + TestImages.Bmp.NegHeight, TestImages.Bmp.Car, TestImages.Bmp.V5Header - }; + ]; public ReferenceDecoderBenchmarks(ITestOutputHelper output) { From 37adbd3dd07c81fbe7af508dfd6a5899203d3223 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Thu, 10 Jul 2025 16:21:54 +0200 Subject: [PATCH 021/112] update shared infra --- shared-infrastructure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-infrastructure b/shared-infrastructure index 132a8232b..d0f141bad 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 132a8232bd61471e9e9df727fb7a112800030327 +Subproject commit d0f141bad2baf7e256aa38ef18129c31cfb857a5 From dd06da4c3764a7dc1dd58f8bade4b6b550d9c405 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 5 Aug 2025 12:34:32 +1000 Subject: [PATCH 022/112] Fix #2974 --- src/ImageSharp/Formats/Png/PngMetadata.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index a7b730ec9..8768d8946 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -230,7 +230,24 @@ public class PngMetadata : IFormatMetadata /// public void AfterImageApply(Image destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel - => this.ColorTable = null; + { + this.ColorTable = null; + + // If the color type is RGB and we have a transparent color, we need to switch to RGBA + // so that we do not incorrectly preserve the obsolete tRNS chunk. + if (this.ColorType == PngColorType.Rgb && this.TransparentColor.HasValue) + { + this.ColorType = PngColorType.RgbWithAlpha; + this.TransparentColor = null; + } + + // The same applies for Grayscale. + if (this.ColorType == PngColorType.Grayscale && this.TransparentColor.HasValue) + { + this.ColorType = PngColorType.GrayscaleWithAlpha; + this.TransparentColor = null; + } + } /// IDeepCloneable IDeepCloneable.DeepClone() => this.DeepClone(); From 20975bcd8b7dd3e6e0634b79256ddf2587e071c6 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 5 Aug 2025 12:36:52 +1000 Subject: [PATCH 023/112] Update src/ImageSharp/Formats/Png/PngMetadata.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ImageSharp/Formats/Png/PngMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index 8768d8946..cecdf88c9 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -234,7 +234,7 @@ public class PngMetadata : IFormatMetadata this.ColorTable = null; // If the color type is RGB and we have a transparent color, we need to switch to RGBA - // so that we do not incorrectly preserve the obsolete tRNS chunk. + // so that we do not incorrectly preserve the obsolete tRNS chunk. if (this.ColorType == PngColorType.Rgb && this.TransparentColor.HasValue) { this.ColorType = PngColorType.RgbWithAlpha; From 063952605b4822c5b8ee5c1721514a36c01f142f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 11 Aug 2025 13:05:30 +1000 Subject: [PATCH 024/112] Handle hex parsing in Color with format support (#2964) * Handle hex parsing in Color with format support * Rewrite to remove allocations * Fix formatting * Create zero-allocation version * Use primed OS independent LFS caching * Use a normalized cache key so Windows uses it. * Fix LFS caching * Remove bad task * Try to get Windows to use the cache * Try again. --- .github/workflows/build-and-test.yml | 65 ++- .github/workflows/code-coverage.yml | 25 +- src/ImageSharp/Color/Color.cs | 369 ++++++++++++++++-- src/ImageSharp/Color/ColorHexFormat.cs | 40 ++ .../PixelImplementations/Rgba32.cs | 96 ----- tests/ImageSharp.Tests/Color/ColorTests.cs | 110 +++++- .../PixelFormats/Rgba32Tests.cs | 38 +- .../PixelFormats/UnPackedPixelTests.cs | 2 +- 8 files changed, 546 insertions(+), 199 deletions(-) create mode 100644 src/ImageSharp/Color/ColorHexFormat.cs diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index cb90793e0..e00757cb7 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -12,8 +12,54 @@ on: - main - release/* types: [ labeled, opened, synchronize, reopened ] + jobs: + # Prime a single LFS cache and expose the exact key for the matrix + WarmLFS: + runs-on: ubuntu-latest + outputs: + lfs_key: ${{ steps.expose-key.outputs.lfs_key }} + steps: + - name: Git Config + shell: bash + run: | + git config --global core.autocrlf false + git config --global core.longpaths true + + - name: Git Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + # Deterministic list of LFS object IDs, then compute a portable key: + # - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256 + # - `awk '{print $1}'` extracts just the SHA field + # - `sort` sorts in byte order (hex hashes sort the same everywhere) + # This ensures the file content is identical regardless of OS or locale + - name: Git Create LFS id list + shell: bash + run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id + + - name: Git Expose LFS cache key + id: expose-key + shell: bash + env: + LFS_KEY: lfs-${{ hashFiles('.lfs-assets-id') }}-v1 + run: echo "lfs_key=$LFS_KEY" >> "$GITHUB_OUTPUT" + + - name: Git Setup LFS Cache + uses: actions/cache@v4 + with: + path: .git/lfs + key: ${{ steps.expose-key.outputs.lfs_key }} + + - name: Git Pull LFS + shell: bash + run: git lfs pull + Build: + needs: WarmLFS strategy: matrix: isARM: @@ -69,14 +115,14 @@ jobs: options: os: buildjet-4vcpu-ubuntu-2204-arm - runs-on: ${{matrix.options.os}} + runs-on: ${{ matrix.options.os }} steps: - name: Install libgdi+, which is required for tests running on ubuntu if: ${{ contains(matrix.options.os, 'ubuntu') }} run: | - sudo apt-get update - sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev + sudo apt-get update + sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev - name: Git Config shell: bash @@ -90,18 +136,15 @@ jobs: fetch-depth: 0 submodules: recursive - # See https://github.com/actions/checkout/issues/165#issuecomment-657673315 - - name: Git Create LFS FileList - run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id - + # Use the warmed key from WarmLFS. Do not recompute or recreate .lfs-assets-id here. - name: Git Setup LFS Cache uses: actions/cache@v4 - id: lfs-cache with: path: .git/lfs - key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 + key: ${{ needs.WarmLFS.outputs.lfs_key }} - name: Git Pull LFS + shell: bash run: git lfs pull - name: NuGet Install @@ -168,11 +211,8 @@ jobs: Publish: needs: [Build] - runs-on: ubuntu-latest - if: (github.event_name == 'push') - steps: - name: Git Config shell: bash @@ -213,4 +253,3 @@ jobs: run: | dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate - diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index b4965795c..a7278a817 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -4,6 +4,7 @@ on: schedule: # 2AM every Tuesday/Thursday - cron: "0 2 * * 2,4" + jobs: Build: strategy: @@ -14,15 +15,14 @@ jobs: runtime: -x64 codecov: true - runs-on: ${{matrix.options.os}} + runs-on: ${{ matrix.options.os }} steps: - - name: Install libgdi+, which is required for tests running on ubuntu if: ${{ contains(matrix.options.os, 'ubuntu') }} run: | - sudo apt-get update - sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev + sudo apt-get update + sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev - name: Git Config shell: bash @@ -36,16 +36,21 @@ jobs: fetch-depth: 0 submodules: recursive - # See https://github.com/actions/checkout/issues/165#issuecomment-657673315 - - name: Git Create LFS FileList - run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id + # Deterministic list of LFS object IDs, then compute a portable key: + # - `git lfs ls-files -l` lists all tracked LFS objects with their SHA-256 + # - `awk '{print $1}'` extracts just the SHA field + # - `sort` sorts in byte order (hex hashes sort the same everywhere) + # This ensures the file content is identical regardless of OS or locale + - name: Git Create LFS id list + shell: bash + run: git lfs ls-files -l | awk '{print $1}' | sort > .lfs-assets-id - name: Git Setup LFS Cache uses: actions/cache@v4 id: lfs-cache with: path: .git/lfs - key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 + key: lfs-${{ hashFiles('.lfs-assets-id') }}-v1 - name: Git Pull LFS run: git lfs pull @@ -69,13 +74,13 @@ jobs: - name: DotNet Build shell: pwsh - run: ./ci-build.ps1 "${{matrix.options.framework}}" + run: ./ci-build.ps1 "${{ matrix.options.framework }}" env: SIXLABORS_TESTING: True - name: DotNet Test shell: pwsh - run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}" + run: ./ci-test.ps1 "${{ matrix.options.os }}" "${{ matrix.options.framework }}" "${{ matrix.options.runtime }}" "${{ matrix.options.codecov }}" env: SIXLABORS_TESTING: True XUNIT_PATH: .\tests\ImageSharp.Tests # Required for xunit diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 1dfbf0a24..bb78dcbbc 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Globalization; using System.Numerics; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.PixelFormats; @@ -126,66 +127,91 @@ public readonly partial struct Color : IEquatable } /// - /// Creates a new instance of the struct - /// from the given hexadecimal string. + /// Gets a from the given hexadecimal string. /// /// - /// The hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. + /// The hexadecimal representation of the combined color components. + /// + /// + /// The format of the hexadecimal string to parse, if applicable. Defaults to . /// /// - /// The . + /// The equivalent of the hexadecimal input. /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color ParseHex(string hex) + /// + /// Thrown when the is not in the correct format. + /// + public static Color ParseHex(string hex, ColorHexFormat format = ColorHexFormat.Rgba) { - Rgba32 rgba = Rgba32.ParseHex(hex); - return FromPixel(rgba); + Guard.NotNull(hex, nameof(hex)); + + if (!TryParseHex(hex, out Color color, format)) + { + throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); + } + + return color; } /// - /// Attempts to creates a new instance of the struct - /// from the given hexadecimal string. + /// Gets a from the given hexadecimal string. /// /// - /// The hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. + /// The hexadecimal representation of the combined color components. + /// + /// + /// When this method returns, contains the equivalent of the hexadecimal input. + /// + /// + /// The format of the hexadecimal string to parse, if applicable. Defaults to . /// - /// When this method returns, contains the equivalent of the hexadecimal input. /// - /// The . + /// if the parsing was successful; otherwise, . /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool TryParseHex(string hex, out Color result) + public static bool TryParseHex(string hex, out Color result, ColorHexFormat format = ColorHexFormat.Rgba) { result = default; - if (Rgba32.TryParseHex(hex, out Rgba32 rgba)) + if (format == ColorHexFormat.Argb) { - result = FromPixel(rgba); - return true; + if (TryParseArgbHex(hex, out Argb32 argb)) + { + result = FromPixel(argb); + return true; + } + } + else if (format == ColorHexFormat.Rgba) + { + if (TryParseRgbaHex(hex, out Rgba32 rgba)) + { + result = FromPixel(rgba); + return true; + } } return false; } /// - /// Creates a new instance of the struct - /// from the given input string. + /// Gets a from the given input string. /// /// - /// The name of the color or the hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. + /// The name of the color or the hexadecimal representation of the combined color components. + /// + /// + /// The format of the hexadecimal string to parse, if applicable. Defaults to . /// /// - /// The . + /// The equivalent of the input string. /// - /// Input string is not in the correct format. - public static Color Parse(string input) + /// + /// Thrown when the is not in the correct format. + /// + public static Color Parse(string input, ColorHexFormat format = ColorHexFormat.Rgba) { Guard.NotNull(input, nameof(input)); - if (!TryParse(input, out Color color)) + if (!TryParse(input, out Color color, format)) { throw new ArgumentException("Input string is not in the correct format.", nameof(input)); } @@ -194,18 +220,21 @@ public readonly partial struct Color : IEquatable } /// - /// Attempts to creates a new instance of the struct - /// from the given input string. + /// Tries to create a new instance of the struct from the given input string. /// /// - /// The name of the color or the hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. + /// The name of the color or the hexadecimal representation of the combined color components. + /// + /// + /// When this method returns, contains the equivalent of the input string. + /// + /// + /// The format of the hexadecimal string to parse, if applicable. Defaults to . /// - /// When this method returns, contains the equivalent of the hexadecimal input. /// - /// The . + /// if the parsing was successful; otherwise, . /// - public static bool TryParse(string input, out Color result) + public static bool TryParse(string input, out Color result, ColorHexFormat format = ColorHexFormat.Rgba) { result = default; @@ -219,7 +248,13 @@ public readonly partial struct Color : IEquatable return true; } - return TryParseHex(input, out result); + result = default; + if (string.IsNullOrWhiteSpace(input)) + { + return false; + } + + return TryParseHex(input, out result, format); } /// @@ -227,6 +262,7 @@ public readonly partial struct Color : IEquatable /// /// The new value of alpha [0..1]. /// The color having it's alpha channel altered. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public Color WithAlpha(float alpha) { Vector4 v = this.ToScaledVector4(); @@ -235,22 +271,32 @@ public readonly partial struct Color : IEquatable } /// - /// Gets the hexadecimal representation of the color instance in rrggbbaa form. + /// Gets the hexadecimal string representation of the color instance. /// + /// + /// The format of the hexadecimal string to return. Defaults to . + /// /// A hexadecimal string representation of the value. + /// Thrown when the is not supported. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public string ToHex() + public string ToHex(ColorHexFormat format = ColorHexFormat.Rgba) { - if (this.boxedHighPrecisionPixel is not null) + Rgba32 rgba = (this.boxedHighPrecisionPixel is not null) + ? this.boxedHighPrecisionPixel.ToRgba32() + : Rgba32.FromScaledVector4(this.data); + + uint hexOrder = format switch { - return this.boxedHighPrecisionPixel.ToRgba32().ToHex(); - } + ColorHexFormat.Argb => (uint)((rgba.B << 0) | (rgba.G << 8) | (rgba.R << 16) | (rgba.A << 24)), + ColorHexFormat.Rgba => (uint)((rgba.A << 0) | (rgba.B << 8) | (rgba.G << 16) | (rgba.R << 24)), + _ => throw new ArgumentOutOfRangeException(nameof(format), format, "Unsupported color hex format.") + }; - return Rgba32.FromScaledVector4(this.data).ToHex(); + return hexOrder.ToString("X8", CultureInfo.InvariantCulture); } /// - public override string ToString() => this.ToHex(); + public override string ToString() => this.ToHex(ColorHexFormat.Rgba); /// /// Converts the color instance to a specified type. @@ -336,4 +382,241 @@ public readonly partial struct Color : IEquatable return this.boxedHighPrecisionPixel.GetHashCode(); } + + /// + /// Gets the hexadecimal string representation of the color instance in the format RRGGBBAA. + /// + /// + /// The hexadecimal representation of the combined color components. + /// + /// + /// When this method returns, contains the equivalent of the hexadecimal input. + /// + /// + /// if the parsing was successful; otherwise, . + /// + private static bool TryParseRgbaHex(string? hex, out Rgba32 result) + { + result = default; + + if (!TryConvertToRgbaUInt32(hex, out uint packedValue)) + { + return false; + } + + result = Unsafe.As(ref packedValue); + return true; + } + + /// + /// Gets the hexadecimal string representation of the color instance in the format AARRGGBB. + /// + /// + /// The hexadecimal representation of the combined color components. + /// + /// + /// When this method returns, contains the equivalent of the hexadecimal input. + /// + /// + /// if the parsing was successful; otherwise, . + /// + private static bool TryParseArgbHex(string? hex, out Argb32 result) + { + result = default; + + if (!TryConvertToArgbUInt32(hex, out uint packedValue)) + { + return false; + } + + result = Unsafe.As(ref packedValue); + return true; + } + + private static bool TryConvertToRgbaUInt32(string? value, out uint result) + { + result = default; + + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + ReadOnlySpan hex = value.AsSpan(); + + if (hex[0] == '#') + { + hex = hex[1..]; + } + + byte a = 255, r, g, b; + + switch (hex.Length) + { + case 8: + if (!TryParseByte(hex[0], hex[1], out r) || + !TryParseByte(hex[2], hex[3], out g) || + !TryParseByte(hex[4], hex[5], out b) || + !TryParseByte(hex[6], hex[7], out a)) + { + return false; + } + + break; + + case 6: + if (!TryParseByte(hex[0], hex[1], out r) || + !TryParseByte(hex[2], hex[3], out g) || + !TryParseByte(hex[4], hex[5], out b)) + { + return false; + } + + break; + + case 4: + if (!TryExpand(hex[0], out r) || + !TryExpand(hex[1], out g) || + !TryExpand(hex[2], out b) || + !TryExpand(hex[3], out a)) + { + return false; + } + + break; + + case 3: + if (!TryExpand(hex[0], out r) || + !TryExpand(hex[1], out g) || + !TryExpand(hex[2], out b)) + { + return false; + } + + break; + + default: + return false; + } + + result = (uint)(r | (g << 8) | (b << 16) | (a << 24)); // RGBA layout + return true; + } + + private static bool TryConvertToArgbUInt32(string? value, out uint result) + { + result = default; + + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + ReadOnlySpan hex = value.AsSpan(); + + if (hex[0] == '#') + { + hex = hex[1..]; + } + + byte a = 255, r, g, b; + + switch (hex.Length) + { + case 8: + if (!TryParseByte(hex[0], hex[1], out a) || + !TryParseByte(hex[2], hex[3], out r) || + !TryParseByte(hex[4], hex[5], out g) || + !TryParseByte(hex[6], hex[7], out b)) + { + return false; + } + + break; + + case 6: + if (!TryParseByte(hex[0], hex[1], out r) || + !TryParseByte(hex[2], hex[3], out g) || + !TryParseByte(hex[4], hex[5], out b)) + { + return false; + } + + break; + + case 4: + if (!TryExpand(hex[0], out a) || + !TryExpand(hex[1], out r) || + !TryExpand(hex[2], out g) || + !TryExpand(hex[3], out b)) + { + return false; + } + + break; + + case 3: + if (!TryExpand(hex[0], out r) || + !TryExpand(hex[1], out g) || + !TryExpand(hex[2], out b)) + { + return false; + } + + break; + + default: + return false; + } + + result = (uint)((b << 24) | (g << 16) | (r << 8) | a); + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool TryParseByte(char hi, char lo, out byte value) + { + if (TryConvertHexCharToByte(hi, out byte high) && TryConvertHexCharToByte(lo, out byte low)) + { + value = (byte)((high << 4) | low); + return true; + } + + value = 0; + return false; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool TryExpand(char c, out byte value) + { + if (TryConvertHexCharToByte(c, out byte nibble)) + { + value = (byte)((nibble << 4) | nibble); + return true; + } + + value = 0; + return false; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool TryConvertHexCharToByte(char c, out byte value) + { + if ((uint)(c - '0') <= 9) + { + value = (byte)(c - '0'); + return true; + } + + char lower = (char)(c | 0x20); // Normalize to lowercase + + if ((uint)(lower - 'a') <= 5) + { + value = (byte)(lower - 'a' + 10); + return true; + } + + value = 0; + return false; + } } diff --git a/src/ImageSharp/Color/ColorHexFormat.cs b/src/ImageSharp/Color/ColorHexFormat.cs new file mode 100644 index 000000000..e1cd898c7 --- /dev/null +++ b/src/ImageSharp/Color/ColorHexFormat.cs @@ -0,0 +1,40 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +namespace SixLabors.ImageSharp; + +/// +/// Specifies the channel order when formatting or parsing a color as a hexadecimal string. +/// +public enum ColorHexFormat +{ + /// + /// Uses RRGGBBAA channel order where the red, green, and blue components come first, + /// followed by the alpha component. This matches the CSS Color Module Level 4 and common web standards. + /// + /// When parsing, supports the following formats: + /// + /// #RGB expands to RRGGBBFF (fully opaque) + /// #RGBA expands to RRGGBBAA + /// #RRGGBB expands to RRGGBBFF (fully opaque) + /// #RRGGBBAA used as-is + /// + /// + /// When formatting, outputs an 8-digit hex string in RRGGBBAA order. + /// + Rgba, + + /// + /// Uses AARRGGBB channel order where the alpha component comes first, + /// followed by the red, green, and blue components. This matches the Microsoft/XAML convention. + /// + /// When parsing, supports the following formats: + /// + /// #ARGB expands to AARRGGBB + /// #AARRGGBB used as-is + /// + /// + /// When formatting, outputs an 8-digit hex string in AARRGGBB order. + /// + Argb +} diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 8980700c9..199754c69 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Buffers.Binary; using System.Globalization; using System.Numerics; using System.Runtime.CompilerServices; @@ -211,64 +210,6 @@ public partial struct Rgba32 : IPixel, IPackedVector [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Rgba32 left, Rgba32 right) => !left.Equals(right); - /// - /// Creates a new instance of the struct - /// from the given hexadecimal string. - /// - /// - /// The hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. - /// - /// - /// The . - /// - /// Hexadecimal string is not in the correct format. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rgba32 ParseHex(string hex) - { - Guard.NotNull(hex, nameof(hex)); - - if (!TryParseHex(hex, out Rgba32 rgba)) - { - throw new ArgumentException("Hexadecimal string is not in the correct format.", nameof(hex)); - } - - return rgba; - } - - /// - /// Attempts to creates a new instance of the struct - /// from the given hexadecimal string. - /// - /// - /// The hexadecimal representation of the combined color components arranged - /// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax. - /// - /// When this method returns, contains the equivalent of the hexadecimal input. - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool TryParseHex(string? hex, out Rgba32 result) - { - result = default; - if (string.IsNullOrWhiteSpace(hex)) - { - return false; - } - - hex = ToRgbaHex(hex); - - if (hex is null || !uint.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint packedValue)) - { - return false; - } - - packedValue = BinaryPrimitives.ReverseEndianness(packedValue); - result = Unsafe.As(ref packedValue); - return true; - } - /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly Rgba32 ToRgba32() => this; @@ -409,41 +350,4 @@ public partial struct Rgba32 : IPixel, IPackedVector Vector128 result = Vector128.ConvertToInt32(vector.AsVector128()).AsByte(); return new Rgba32(result.GetElement(0), result.GetElement(4), result.GetElement(8), result.GetElement(12)); } - - /// - /// Converts the specified hex value to an rrggbbaa hex value. - /// - /// The hex value to convert. - /// - /// A rrggbbaa hex value. - /// - private static string? ToRgbaHex(string hex) - { - if (hex[0] == '#') - { - hex = hex[1..]; - } - - if (hex.Length == 8) - { - return hex; - } - - if (hex.Length == 6) - { - return hex + "FF"; - } - - if (hex.Length is < 3 or > 4) - { - return null; - } - - char a = hex.Length == 3 ? 'F' : hex[3]; - char b = hex[2]; - char g = hex[1]; - char r = hex[0]; - - return new string(new[] { r, r, g, g, b, b, a, a }); - } } diff --git a/tests/ImageSharp.Tests/Color/ColorTests.cs b/tests/ImageSharp.Tests/Color/ColorTests.cs index d430df5b4..c482fc998 100644 --- a/tests/ImageSharp.Tests/Color/ColorTests.cs +++ b/tests/ImageSharp.Tests/Color/ColorTests.cs @@ -67,9 +67,9 @@ public partial class ColorTests [Theory] [InlineData(false)] [InlineData(true)] - public void ToHex(bool highPrecision) + public void ToHexRgba(bool highPrecision) { - string expected = "ABCD1234"; + const string expected = "AABBCCDD"; Color color = Color.ParseHex(expected); if (highPrecision) @@ -81,10 +81,27 @@ public partial class ColorTests Assert.Equal(expected, actual); } + [Theory] + [InlineData(false)] + [InlineData(true)] + public void ToHexArgb(bool highPrecision) + { + const string expected = "AABBCCDD"; + Color color = Color.ParseHex(expected, ColorHexFormat.Argb); + + if (highPrecision) + { + color = Color.FromPixel(color.ToPixel()); + } + + string actual = color.ToHex(ColorHexFormat.Argb); + Assert.Equal(expected, actual); + } + [Fact] public void WebSafePalette_IsCorrect() { - Rgba32[] actualPalette = Color.WebSafePalette.ToArray().Select(c => c.ToPixel()).ToArray(); + Rgba32[] actualPalette = [.. Color.WebSafePalette.ToArray().Select(c => c.ToPixel())]; for (int i = 0; i < ReferencePalette.WebSafeColors.Length; i++) { @@ -95,7 +112,7 @@ public partial class ColorTests [Fact] public void WernerPalette_IsCorrect() { - Rgba32[] actualPalette = Color.WernerPalette.ToArray().Select(c => c.ToPixel()).ToArray(); + Rgba32[] actualPalette = [.. Color.WernerPalette.ToArray().Select(c => c.ToPixel())]; for (int i = 0; i < ReferencePalette.WernerColors.Length; i++) { @@ -103,7 +120,7 @@ public partial class ColorTests } } - public class FromHex + public class FromHexRgba { [Fact] public void ShortHex() @@ -126,6 +143,23 @@ public partial class ColorTests Assert.Equal(new Rgba32(0, 0, 0, 255), actual.ToPixel()); } + [Fact] + public void LongHex() + { + Assert.Equal(new Rgba32(255, 255, 255, 0), Color.ParseHex("#FFFFFF00").ToPixel()); + Assert.Equal(new Rgba32(255, 255, 255, 128), Color.ParseHex("#FFFFFF80").ToPixel()); + } + + [Fact] + public void TryLongHex() + { + Assert.True(Color.TryParseHex("#FFFFFF00", out Color actual)); + Assert.Equal(new Rgba32(255, 255, 255, 0), actual.ToPixel()); + + Assert.True(Color.TryParseHex("#FFFFFF80", out actual)); + Assert.Equal(new Rgba32(255, 255, 255, 128), actual.ToPixel()); + } + [Fact] public void LeadingPoundIsOptional() { @@ -152,6 +186,72 @@ public partial class ColorTests public void FalseOnNull() => Assert.False(Color.TryParseHex(null, out Color _)); } + public class FromHexArgb + { + [Fact] + public void ShortHex() + { + Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("#fff", ColorHexFormat.Argb).ToPixel()); + Assert.Equal(new Rgb24(255, 255, 255), Color.ParseHex("fff", ColorHexFormat.Argb).ToPixel()); + Assert.Equal(new Argb32(0, 0, 255, 0), Color.ParseHex("000f", ColorHexFormat.Argb).ToPixel()); + } + + [Fact] + public void TryShortHex() + { + Assert.True(Color.TryParseHex("#fff", out Color actual, ColorHexFormat.Argb)); + Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + + Assert.True(Color.TryParseHex("fff", out actual, ColorHexFormat.Argb)); + Assert.Equal(new Rgb24(255, 255, 255), actual.ToPixel()); + + Assert.True(Color.TryParseHex("000f", out actual, ColorHexFormat.Argb)); + Assert.Equal(new Argb32(0, 0, 255, 0), actual.ToPixel()); + } + + [Fact] + public void LongHex() + { + Assert.Equal(new Argb32(255, 255, 255, 0), Color.ParseHex("#00FFFFFF", ColorHexFormat.Argb).ToPixel()); + Assert.Equal(new Argb32(255, 255, 255, 128), Color.ParseHex("#80FFFFFF", ColorHexFormat.Argb).ToPixel()); + } + + [Fact] + public void TryLongHex() + { + Assert.True(Color.TryParseHex("#00FFFFFF", out Color actual, ColorHexFormat.Argb)); + Assert.Equal(new Argb32(255, 255, 255, 0), actual.ToPixel()); + + Assert.True(Color.TryParseHex("#80FFFFFF", out actual, ColorHexFormat.Argb)); + Assert.Equal(new Argb32(255, 255, 255, 128), actual.ToPixel()); + } + + [Fact] + public void LeadingPoundIsOptional() + { + Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("#008080", ColorHexFormat.Argb).ToPixel()); + Assert.Equal(new Rgb24(0, 128, 128), Color.ParseHex("008080", ColorHexFormat.Argb).ToPixel()); + } + + [Fact] + public void ThrowsOnEmpty() => Assert.Throws(() => Color.ParseHex(string.Empty, ColorHexFormat.Argb)); + + [Fact] + public void ThrowsOnInvalid() => Assert.Throws(() => Color.ParseHex("!", ColorHexFormat.Argb)); + + [Fact] + public void ThrowsOnNull() => Assert.Throws(() => Color.ParseHex(null, ColorHexFormat.Argb)); + + [Fact] + public void FalseOnEmpty() => Assert.False(Color.TryParseHex(string.Empty, out Color _, ColorHexFormat.Argb)); + + [Fact] + public void FalseOnInvalid() => Assert.False(Color.TryParseHex("!", out Color _, ColorHexFormat.Argb)); + + [Fact] + public void FalseOnNull() => Assert.False(Color.TryParseHex(null, out Color _, ColorHexFormat.Argb)); + } + public class FromString { [Fact] diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs index 6d56185ec..3bb1fead1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs @@ -21,10 +21,10 @@ public class Rgba32Tests { Rgba32 color1 = new(0, 0, 0); Rgba32 color2 = new(0, 0, 0, 1F); - Rgba32 color3 = Rgba32.ParseHex("#000"); - Rgba32 color4 = Rgba32.ParseHex("#000F"); - Rgba32 color5 = Rgba32.ParseHex("#000000"); - Rgba32 color6 = Rgba32.ParseHex("#000000FF"); + Rgba32 color3 = Color.ParseHex("#000").ToPixel(); + Rgba32 color4 = Color.ParseHex("#000F").ToPixel(); + Rgba32 color5 = Color.ParseHex("#000000").ToPixel(); + Rgba32 color6 = Color.ParseHex("#000000FF").ToPixel(); Assert.Equal(color1, color2); Assert.Equal(color1, color3); @@ -41,9 +41,9 @@ public class Rgba32Tests { Rgba32 color1 = new(255, 0, 0, 255); Rgba32 color2 = new(0, 0, 0, 255); - Rgba32 color3 = Rgba32.ParseHex("#000"); - Rgba32 color4 = Rgba32.ParseHex("#000000"); - Rgba32 color5 = Rgba32.ParseHex("#FF000000"); + Rgba32 color3 = Color.ParseHex("#000").ToPixel(); + Rgba32 color4 = Color.ParseHex("#000000").ToPixel(); + Rgba32 color5 = Color.ParseHex("#FF000000").ToPixel(); Assert.NotEqual(color1, color2); Assert.NotEqual(color1, color3); @@ -82,30 +82,6 @@ public class Rgba32Tests Assert.Equal(Math.Round(.5f * 255), color5.A); } - /// - /// Tests whether FromHex and ToHex work correctly. - /// - [Fact] - public void FromAndToHex() - { - // 8 digit hex matches css4 spec. RRGGBBAA - Rgba32 color = Rgba32.ParseHex("#AABBCCDD"); // 170, 187, 204, 221 - Assert.Equal(170, color.R); - Assert.Equal(187, color.G); - Assert.Equal(204, color.B); - Assert.Equal(221, color.A); - - Assert.Equal("AABBCCDD", color.ToHex()); - - color.R = 0; - - Assert.Equal("00BBCCDD", color.ToHex()); - - color.A = 255; - - Assert.Equal("00BBCCFF", color.ToHex()); - } - /// /// Tests that the individual byte elements are laid out in RGBA order. /// diff --git a/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs index 651f6fe7f..eb93ba230 100644 --- a/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/UnPackedPixelTests.cs @@ -60,7 +60,7 @@ public class UnPackedPixelTests [Fact] public void Color_Types_From_Hex_Produce_Equal_Scaled_Component_OutPut() { - Rgba32 color = Rgba32.ParseHex("183060C0"); + Rgba32 color = Color.ParseHex("183060C0").ToPixel(); RgbaVector colorVector = RgbaVector.FromHex("183060C0"); Assert.Equal(color.R, (byte)(colorVector.R * 255)); From eac1b9087f121012c55471761c310c00a97975a4 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 4 Sep 2025 20:13:46 +1000 Subject: [PATCH 025/112] Update to license enforcing submodule --- .editorconfig | 2 -- shared-infrastructure | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index d6bd9e592..f579ff5d3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -181,8 +181,6 @@ csharp_style_prefer_primary_constructors = false:none dotnet_style_prefer_collection_expression = true:error resharper_use_collection_expression_highlighting =true:error - - ########################################## # Unnecessary Code Rules # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules diff --git a/shared-infrastructure b/shared-infrastructure index d0f141bad..57699ffb7 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit d0f141bad2baf7e256aa38ef18129c31cfb857a5 +Subproject commit 57699ffb797bc2389c5d6cbb3b1800f2eb5fb947 From cb05fc7b793b87614075c40b229625d2e6be5f86 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 10 Sep 2025 19:17:27 +1000 Subject: [PATCH 026/112] Fix #2980 --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 74 ++++++++++------ src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 86 ++++++++++--------- .../Formats/Gif/GifDecoderTests.cs | 10 +++ .../Quantization/QuantizedImageTests.cs | 2 - tests/ImageSharp.Tests/TestImages.cs | 1 + .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../04.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../04.png | 4 +- .../05.png | 4 +- .../06.png | 4 +- .../07.png | 4 +- .../08.png | 4 +- .../09.png | 4 +- .../10.png | 4 +- .../11.png | 4 +- .../12.png | 4 +- .../13.png | 4 +- .../14.png | 4 +- .../15.png | 4 +- .../16.png | 4 +- .../17.png | 4 +- .../18.png | 4 +- .../19.png | 4 +- .../20.png | 4 +- .../21.png | 4 +- .../22.png | 4 +- .../23.png | 4 +- .../24.png | 4 +- .../25.png | 4 +- .../26.png | 4 +- ...NotBoundToSinglePixelType_Argb32_trans.png | 4 +- ...NotBoundToSinglePixelType_Rgba32_trans.png | 4 +- ...oundToSinglePixelType_RgbaVector_trans.png | 4 +- ...2012BadMinCode_Rgba32_issue2012_drona1.png | 4 +- .../00.png | 4 +- .../01.png | 4 +- .../00.png | 2 +- .../01.png | 2 +- .../Issue2980_Rgba32_issue_2980.gif/00.png | 3 + .../Issue2980_Rgba32_issue_2980.gif/01.png | 3 + .../Issue2980_Rgba32_issue_2980.gif/02.png | 3 + .../Issue2980_Rgba32_issue_2980.gif/03.png | 3 + .../00.png | 4 +- .../01.png | 4 +- .../02.png | 4 +- .../03.png | 4 +- .../04.png | 4 +- .../05.png | 4 +- .../06.png | 4 +- .../07.png | 4 +- tests/Images/Input/Gif/issues/issue_2980.gif | 3 + 74 files changed, 246 insertions(+), 194 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/00.png create mode 100644 tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/01.png create mode 100644 tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/02.png create mode 100644 tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/03.png create mode 100644 tests/Images/Input/Gif/issues/issue_2980.gif diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index ca28bc771..2bb81b172 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -489,6 +489,12 @@ internal sealed class GifDecoderCore : ImageDecoderCore backgroundColor = Color.Transparent; } + // We zero the alpha only when this frame declares transparency so that + // frames with a transparent index coalesce over a transparent canvas rather than + // baking the LSD background as a matte. When the flag is not set, this frame will + // write an opaque color for every addressed pixel; keeping the LSD background + // opaque here allows ReadFrameColors to show that background in uncovered areas + // for non-transparent GIFs that rely on it. We still do not prefill the canvas here. if (this.graphicsControlExtension.TransparencyFlag) { backgroundColor = backgroundColor.WithAlpha(0); @@ -498,24 +504,18 @@ internal sealed class GifDecoderCore : ImageDecoderCore this.ReadFrameColors(stream, ref image, ref previousFrame, ref previousDisposalMode, colorTable, backgroundColor.ToPixel()); // Update from newly decoded frame. - if (this.graphicsControlExtension.DisposalMethod != FrameDisposalMode.RestoreToPrevious) + FrameDisposalMode disposalMethod = this.graphicsControlExtension.DisposalMethod; + if (disposalMethod != FrameDisposalMode.RestoreToPrevious) { - if (this.backgroundColorIndex < colorTable.Length) - { - backgroundColor = Color.FromPixel(colorTable[this.backgroundColorIndex]); - } - else - { - backgroundColor = Color.Transparent; - } - - // TODO: I don't understand why this is always set to alpha of zero. - // This should be dependent on the transparency flag of the graphics - // control extension. ImageMagick does the same. - // if (this.graphicsControlExtension.TransparencyFlag) - { - backgroundColor = backgroundColor.WithAlpha(0); - } + // Do not key this on the transparency flag. Disposal handling is determined by + // the previous frame's disposal, not by whether the current frame declares a transparent + // index. For editing we carry a transparent background so that RestoreToBackground clears + // remove pixels to transparent rather than painting an opaque matte. The LSD background + // color is display advice and should be used only when explicitly flattening or when + // rendering with an option to honor it. + backgroundColor = (this.backgroundColorIndex < colorTable.Length) + ? Color.FromPixel(colorTable[this.backgroundColorIndex]).WithAlpha(0) + : Color.Transparent; } // Skip any remaining blocks @@ -546,30 +546,45 @@ internal sealed class GifDecoderCore : ImageDecoderCore GifImageDescriptor descriptor = this.imageDescriptor; int imageWidth = this.logicalScreenDescriptor.Width; int imageHeight = this.logicalScreenDescriptor.Height; - bool transFlag = this.graphicsControlExtension.TransparencyFlag; + bool useTransparency = this.graphicsControlExtension.TransparencyFlag; + bool useBackground; FrameDisposalMode disposalMethod = this.graphicsControlExtension.DisposalMethod; ImageFrame currentFrame; ImageFrame? restoreFrame = null; if (previousFrame is null && previousDisposalMode is null) { - image = transFlag - ? new Image(this.configuration, imageWidth, imageHeight, this.metadata) - : new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata); + // First frame: prefill with LSD background iff a GCT exists (policy: HonorBackgroundColor). + useBackground = + this.logicalScreenDescriptor.GlobalColorTableFlag + && disposalMethod == FrameDisposalMode.RestoreToBackground; + + image = useBackground + ? new Image(this.configuration, imageWidth, imageHeight, backgroundPixel, this.metadata) + : new Image(this.configuration, imageWidth, imageHeight, this.metadata); this.SetFrameMetadata(image.Frames.RootFrame.Metadata); currentFrame = image.Frames.RootFrame; } else { + // Subsequent frames: use LSD background iff previous disposal was RestoreToBackground and a GCT exists. + useBackground = + this.logicalScreenDescriptor.GlobalColorTableFlag + && previousDisposalMode == FrameDisposalMode.RestoreToBackground; + if (previousFrame != null) { currentFrame = image!.Frames.AddFrame(previousFrame); } - else + else if (useBackground) { currentFrame = image!.Frames.CreateFrame(backgroundPixel); } + else + { + currentFrame = image!.Frames.CreateFrame(); + } this.SetFrameMetadata(currentFrame.Metadata); @@ -580,7 +595,7 @@ internal sealed class GifDecoderCore : ImageDecoderCore if (previousDisposalMode == FrameDisposalMode.RestoreToBackground) { - this.RestoreToBackground(currentFrame, backgroundPixel, transFlag); + this.RestoreToBackground(currentFrame, backgroundPixel, !useBackground); } } @@ -670,22 +685,31 @@ internal sealed class GifDecoderCore : ImageDecoderCore // Take the descriptorLeft..maxX slice of the row, so the loop can be simplified. row = row[descriptorLeft..maxX]; - if (!transFlag) + if (!useTransparency) { for (int x = 0; x < row.Length; x++) { int index = indicesRow[x]; - index = Numerics.Clamp(index, 0, colorTableMaxIdx); + + // Treat any out of bounds values as background. + if (index > colorTableMaxIdx) + { + index = Numerics.Clamp(index, 0, colorTableMaxIdx); + } + row[x] = TPixel.FromRgb24(colorTable[index]); } } else { + TPixel transparentPixel = Color.Transparent.ToPixel(); for (int x = 0; x < row.Length; x++) { int index = indicesRow[x]; // Treat any out of bounds values as transparent. + // We explicitly set the pixel to transparent rather than alter the inbound + // color palette. if (index > colorTableMaxIdx || index == transIndex) { continue; diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index ffe318063..07c73dcf2 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -120,11 +120,15 @@ internal sealed class GifEncoderCore // Is this a gif with color information. If so use that, otherwise use octree. if (gifMetadata.ColorTableMode == FrameColorTableMode.Global && gifMetadata.GlobalColorTable?.Length > 0) { - int transparencyIndex = GetTransparentIndex(quantized, frameMetadata); - if (transparencyIndex >= 0 || gifMetadata.GlobalColorTable.Value.Length < 256) + int ti = GetTransparentIndex(quantized, frameMetadata); + if (ti >= 0 || gifMetadata.GlobalColorTable.Value.Length < 256) { // We avoid dithering by default to preserve the original colors. - globalQuantizer = new PaletteQuantizer(gifMetadata.GlobalColorTable.Value, options.DeepClone(o => o.Dither = null)); + globalQuantizer = new PaletteQuantizer( + gifMetadata.GlobalColorTable.Value, + options.DeepClone(o => o.Dither = null), + ti, + Color.Transparent); } else { @@ -173,20 +177,14 @@ internal sealed class GifEncoderCore WriteHeader(stream); // Write the LSD. - int derivedTransparencyIndex = GetTransparentIndex(quantized, null); - if (derivedTransparencyIndex >= 0) + int transparencyIndex = GetTransparentIndex(quantized, null); + if (transparencyIndex >= 0) { frameMetadata.HasTransparency = true; - frameMetadata.TransparencyIndex = ClampIndex(derivedTransparencyIndex); + frameMetadata.TransparencyIndex = ClampIndex(transparencyIndex); } - // TODO: We should be checking the metadata here also I think? - if (!TryGetBackgroundIndex(quantized, this.backgroundColor, out byte backgroundIndex)) - { - backgroundIndex = derivedTransparencyIndex >= 0 - ? frameMetadata.TransparencyIndex - : gifMetadata.BackgroundColorIndex; - } + byte backgroundIndex = GetBackgroundIndex(quantized, gifMetadata, this.backgroundColor); // Get the number of bits. int bitDepth = ColorNumerics.GetBitsNeededForColorDepth(quantized.Palette.Length); @@ -224,7 +222,7 @@ internal sealed class GifEncoderCore image, globalQuantizer, globalFrameQuantizer, - derivedTransparencyIndex, + transparencyIndex, frameMetadata.DisposalMode, cancellationToken); } @@ -334,15 +332,23 @@ internal sealed class GifEncoderCore { // Capture any explicit transparency index from the metadata. // We use it to determine the value to use to replace duplicate pixels. - int transparencyIndex = metadata.HasTransparency ? metadata.TransparencyIndex : -1; + bool useTransparency = metadata.HasTransparency; + int transparencyIndex = useTransparency ? metadata.TransparencyIndex : -1; ImageFrame? previous = previousDisposalMode == FrameDisposalMode.RestoreToBackground ? null : previousFrame; - Color background = metadata.DisposalMode == FrameDisposalMode.RestoreToBackground - ? this.backgroundColor ?? Color.Transparent - : Color.Transparent; + // If the previous frame has a value we need to check the disposal mode of that frame + // to determine if we should use the background color to fill the encoding frame + // when de-duplicating. + FrameDisposalMode disposalMode = previous is null ? + metadata.DisposalMode : + previous.Metadata.GetGifMetadata().DisposalMode; + + Color background = !useTransparency && disposalMode == FrameDisposalMode.RestoreToBackground + ? this.backgroundColor ?? Color.Transparent + : Color.Transparent; // Deduplicate and quantize the frame capturing only required parts. (bool difference, Rectangle bounds) = @@ -491,6 +497,7 @@ internal sealed class GifEncoderCore return quantized; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static byte ClampIndex(int value) => (byte)Numerics.Clamp(value, byte.MinValue, byte.MaxValue); /// @@ -531,41 +538,38 @@ internal sealed class GifEncoderCore /// Returns the index of the background color in the palette. /// /// The current quantized frame. + /// The gif metadata /// The background color to match. - /// The index in the palette of the background color. /// The pixel format. - /// The . - private static bool TryGetBackgroundIndex( - IndexedImageFrame? quantized, - Color? background, - out byte index) + /// The index of the background color. + private static byte GetBackgroundIndex(IndexedImageFrame? quantized, GifMetadata metadata, Color? background) where TPixel : unmanaged, IPixel { int match = -1; - if (quantized != null && background.HasValue) + if (quantized != null) { - TPixel backgroundPixel = background.Value.ToPixel(); - ReadOnlySpan palette = quantized.Palette.Span; - for (int i = 0; i < palette.Length; i++) + if (background.HasValue) { - if (!backgroundPixel.Equals(palette[i])) + TPixel backgroundPixel = background.Value.ToPixel(); + ReadOnlySpan palette = quantized.Palette.Span; + for (int i = 0; i < palette.Length; i++) { - continue; - } + if (!backgroundPixel.Equals(palette[i])) + { + continue; + } - match = i; - break; + match = i; + break; + } + } + else if (metadata.BackgroundColorIndex < quantized.Palette.Length) + { + match = metadata.BackgroundColorIndex; } } - if (match >= 0) - { - index = (byte)Numerics.Clamp(match, 0, 255); - return true; - } - - index = 0; - return false; + return ClampIndex(match); } /// diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index 7bb711f3f..febc65da3 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -398,4 +398,14 @@ public class GifDecoderTests Assert.Throws(() => Image.Identify(options, testFile.FullPath)); Assert.Throws(() => Image.Load(options, testFile.FullPath)); } + + [Theory] + [WithFile(TestImages.Gif.Issues.Issue2980, PixelTypes.Rgba32)] + public void Issue2980(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + image.DebugSaveMultiFrame(provider); + image.CompareToReferenceOutputMultiFrame(provider, ImageComparer.Exact); + } } diff --git a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs index 75c096b1f..d832136a9 100644 --- a/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs +++ b/tests/ImageSharp.Tests/Quantization/QuantizedImageTests.cs @@ -53,7 +53,6 @@ public class QuantizedImageTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Assert.True(image[0, 0].Equals(default)); QuantizerOptions options = new(); if (!dither) @@ -79,7 +78,6 @@ public class QuantizedImageTests where TPixel : unmanaged, IPixel { using Image image = provider.GetImage(); - Assert.True(image[0, 0].Equals(default)); QuantizerOptions options = new(); if (!dither) diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 4ea77b41a..9a5cfc706 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -582,6 +582,7 @@ public static class TestImages public const string Issue2859_A = "Gif/issues/issue_2859_A.gif"; public const string Issue2859_B = "Gif/issues/issue_2859_B.gif"; public const string Issue2953 = "Gif/issues/issue_2953.gif"; + public const string Issue2980 = "Gif/issues/issue_2980.gif"; } public static readonly string[] Animated = diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/00.png index 193cde24d..f9d43792c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18b60d2066cb53d41988da37b8c521ddcb5355b995320a8413b95522a0492140 -size 687 +oid sha256:07b63781e5481a46955fc26e9023b243aeada231c4957332c80241e1ad119733 +size 273 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/01.png index 4d2d25510..da7411347 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:30ff7708250c5f02dc02d74238d398b319d8fc6c071178f32f82a17e3b637afd -size 542 +oid sha256:6bd0b25eafd2fb3f55f593a5243fa1e3b6a7ec43a70b8d0c3a6eddd56fe65ae6 +size 114 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/02.png index 0654e49d4..5d2c89228 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d21f4576486692122b6ee719d75883849f65ddb07f632ea1c62b42651c289688 -size 591 +oid sha256:e2f7bb0aed90e52d7905014d790f0bcb5df3f05e5cb82b51dda88ac13dc5afcf +size 115 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/03.png index 0c1090f66..a9db965de 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_firstframerestoreprev_loop.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88db68f2d59301b8ff9326143455a03c94cb616220f6e8e3832f13effe0c09bc -size 545 +oid sha256:b10d33fd285b8a200090bccc35541a608ed062edf1a055357c895935265d216b +size 116 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/00.png index 193cde24d..f9d43792c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18b60d2066cb53d41988da37b8c521ddcb5355b995320a8413b95522a0492140 -size 687 +oid sha256:07b63781e5481a46955fc26e9023b243aeada231c4957332c80241e1ad119733 +size 273 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/01.png index f289fdca3..0d6140760 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:034b0b6b94c13fbef8c44d650daa07362f113aae6600d63230a3f96e29b16dec -size 790 +oid sha256:9296af767fc47ee67249de4f473633f308a323e9e82676dc00952e05cc23f761 +size 341 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/02.png index 07537b9df..e4bfadab5 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4b3684db6e3df52a9eb520d562b51b54632e897e9e39bff5ce904ae00799f2f -size 924 +oid sha256:b2926b6f27314950ff21f1357636f933694f8424e391a10d980a1492ef7b3f07 +size 421 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/03.png index e376be689..a2df6ead1 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_norestore_loop.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e33c564f55b653a693105612949401002014821abaecaf654c96d0f2b5d59b4 -size 962 +oid sha256:350624a4f22cbc47b07e5c8ffe0ea2e0f03687d53b77896c7701b04d7c93089d +size 431 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/00.png index 193cde24d..f9d43792c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18b60d2066cb53d41988da37b8c521ddcb5355b995320a8413b95522a0492140 -size 687 +oid sha256:07b63781e5481a46955fc26e9023b243aeada231c4957332c80241e1ad119733 +size 273 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/01.png index f289fdca3..0d6140760 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:034b0b6b94c13fbef8c44d650daa07362f113aae6600d63230a3f96e29b16dec -size 790 +oid sha256:9296af767fc47ee67249de4f473633f308a323e9e82676dc00952e05cc23f761 +size 341 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/02.png index 27f29acbb..2153fa5cf 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4f4eb12da36cd43c620aa5ad1c793bb6eb8431c61d2cc1b77c1118f35a741cc -size 876 +oid sha256:726aff614b67ea2ee9ffd53fff8e304130019de99d3ae641bef97e0a24f756be +size 343 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/03.png index 684c2fa38..369f668fc 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_frame_restoreprev_loop.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:15bf02e06c6819d74a0a79cbfc5c86913c248a8812ff0ec613c0e747a000241b -size 789 +oid sha256:a645f615d592a1c24b94ad3a4fc63503cb8b0504c9464ee5089d9831b23c28e1 +size 336 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/00.png index 193cde24d..f9d43792c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18b60d2066cb53d41988da37b8c521ddcb5355b995320a8413b95522a0492140 -size 687 +oid sha256:07b63781e5481a46955fc26e9023b243aeada231c4957332c80241e1ad119733 +size 273 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/01.png index 7818cf380..4fa343103 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:01f389a2e93023f3132927a9565c04c8c1f827e36111ebe682177adecc3a27ee -size 774 +oid sha256:1e90013c0ea6e60ef68143914fdf4b14f83e869cf90aff42d837b1340d867f77 +size 276 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/02.png index 18bc40863..cdd623a6a 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:00ef57db2fef89112ac7d1808afb6803612c6a20fc589166be6d6b7007c46400 -size 946 +oid sha256:69c0e3fb7365e09f6acd26e334f3cb65ba8657b2de7b1022256f5aac91f257ac +size 296 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/03.png index bd2ea67ae..36f963ccc 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_Animated_WithTransparency_Rgba32_animated_transparent_loop.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:deafa4d4f8fd84489c061ca1042c2ad9e655fff3b6419248cfb35fa4ea40d9e6 -size 1000 +oid sha256:2be415d41972782f91ad513428796588b0040c4125d604f72d1288c5b3e3742f +size 282 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/00.png index c8b4db92c..06a7b52d6 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f2cc0d653e6f3e06b1d8828ff5794fd5f81526a9e411137a2d1a78f9d8894100 -size 7168 +oid sha256:f212a6b0f4e2ce7d38a489dfe0e050adf807a33f8305367ce377f45a6d7c4619 +size 15016 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/01.png index afeab25c3..ae776f82f 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a7f721df04021f246e9df9f6b91c3654e8b40ded575473c05d646f7bc632b958 -size 7558 +oid sha256:8612f3caef51ce4f0daf2d37f3bf959382a63770391f2ec242c2af46eab2b3b5 +size 15748 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/02.png index a03761d56..82ba6c23d 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a40b7f8d2779e6fdf26e2720fdf24f8da03e9ef9d8b1ff68e9bb68f001814b79 -size 6956 +oid sha256:717938369a68299af27a2b42d58c97ddd5fcd2d8a93418af8f92b3d1c2e93064 +size 14485 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/03.png index 848c6be81..f83ea81d9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fc7fdca7cfec1ae6d119dbccdc7ea78c19584076a197c54e494645b2c84e45e -size 7131 +oid sha256:6a0545794d1384f46acb32bbc4369a226d002eb8ae286e064855d55afd72f4c6 +size 15040 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/04.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/04.png index 11b93c1aa..20ff589c9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/04.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_giphy.gif/04.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4b59fa394cc6205e00440428e9a141a627b88b5e2562ec6b1dd0d48651da77f -size 7104 +oid sha256:853a4f2749ff5ca67bd7c49c2e2f0323772a828a215fac0fd02e9b7eb9d63051 +size 15291 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/00.png index 9236bef85..7acd64ad9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ac324bd9199113897bd986cffe8e7f3770fb2e68e6792d631071ff1db40075f -size 29351 +oid sha256:c41341baee0a461d811cbb8c6cd64d3276d7d4520e95732c5dd12f3834e0a6f3 +size 47309 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/01.png index 91b3c95dc..5822b7e96 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f9ec5a3228c71b54a2bccd8aaf929e11436d45cb56f43cd507cfd4e7bb288fb7 -size 30538 +oid sha256:7a0d6d652a7fc1bdf84bd5e1a785d97e1da08ba3397c3644973f221f3a75b59e +size 48583 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/02.png index d9c98dace..e4536355c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa0c9f304a6afc62aba3b6567905160f7728f43e3b5ba3dc79bf743c9a5f49ab -size 30754 +oid sha256:2f8ed2197b5a9b9749c572096714251bf23be463b3bbd01329d47296078c5f23 +size 48824 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/03.png index 5573c1519..ca8f63548 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7e61d8611c06c4f82c0000ebac4a1b3a53d1342e23f9efb10406ae06a510580c -size 31260 +oid sha256:6c75f616b6460d832ba7b6a0e0551f07d55c2cb0533e95ce16b9a1b9073f75f9 +size 49783 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/04.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/04.png index a595bb707..87d44ffc6 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/04.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/04.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:168bcccba4dffeaec2f2e3978405f802451089790b6377d8c653cfaed7bae833 -size 31741 +oid sha256:0bb07ef91e0f8a82d457ad2ebfed9ca6940d228a4e9954e75c3c1826d4ac5f53 +size 50381 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/05.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/05.png index 29537a2f5..a7b15ecf9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/05.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/05.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1c6675dcca4418fdc529e4de1bc0014a2463d6c6b197dd701b84044a00b31016 -size 30061 +oid sha256:7d80517e1d79f85a5a725d8678011ec5c05748ccc2eb7567573380b610183ea5 +size 47731 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/06.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/06.png index 380b5aad3..86299abfa 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/06.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/06.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7d01cfb14c66662f8972f48d62a7cbb70c2ffa174d74a5533be61a2565d923a0 -size 31139 +oid sha256:07a406840c321421e6aa07ad69d14d96e2bb728364c8fabb98151c5693efa2fa +size 49847 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/07.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/07.png index 9c815c41b..bfd4828ad 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/07.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/07.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6918449a54dea19a15f3f4ef9f5d0e890f7dc97e651d4c77bd60dfaa4f49d646 -size 31304 +oid sha256:72678c10f8cd852f87c19ec1c2a7acfb326291e1ae0f48588d5d7d999592bb32 +size 49850 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/08.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/08.png index 09521859c..c7c53dadb 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/08.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/08.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8927c2e34c9ab90c1fbc3d4f8be289f4a47fee5cfe9c4d72bc39eb78c94a3bf -size 32500 +oid sha256:7c9a61f0639bda2fd8690544ad41df7179ea29987b8827b4cae2e959998d27cf +size 51612 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/09.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/09.png index e38de41ab..accff0f9d 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/09.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/09.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2ffb21368cf6c3e4d567ca19cc40187bee254ea6ebea83c6d6f9c2df02b56eb -size 32374 +oid sha256:ef326f40bdc7f0a43ad1edb51b000388f4f5ca1b7c24633447c03d999bd088c6 +size 51724 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/10.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/10.png index 4d104e273..71c5577c3 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/10.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b903f04b431ed0d9474ef89cb48d2b7b7fa8c124b5fb1f2562d826eaa2cd3ba -size 32692 +oid sha256:a4e8f6a96ce47d36c778d7fa243d723bca725438fe9d9174b61afb638c1cd815 +size 52070 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/11.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/11.png index 141d2df42..58daa5067 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/11.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/11.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:898566396d44cb9c495ed6c40c56928fe642434ed4888331bb92b17fb0cd4847 -size 33243 +oid sha256:b1f96f15c1a46db19726b6ce0d5a78800b1a430c4323a60e628e7e08aa795189 +size 52829 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/12.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/12.png index 590132fca..164a07efb 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/12.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/12.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18a1888eb6d79f857f8336e76e50b5402127036418183e03869e58021b8f9c47 -size 32797 +oid sha256:d98e70649b2a1971f62eb41d53e064f898b45da47f05e000e4dd80464f5ac290 +size 52329 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/13.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/13.png index 9ab3afd9e..1c1de607e 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/13.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8384afabdc9133435c61c0cec97fe599719f7cc601fc1444b1b182383dfcbd40 -size 31306 +oid sha256:54ae733a92eb63174fa02708aee26d28cf0d1069ae4514ff244ebea333d87af8 +size 49767 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/14.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/14.png index 33bdd55d4..061dda667 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/14.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/14.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ea0c2d692d1a5b645af16726b54cc54a0d0166292cc3b3619a96f062996f13f -size 30782 +oid sha256:6a3bc3c870891b220efd95d6da83a166595564e0610766f105496bc77b090e9c +size 48893 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/15.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/15.png index 1ca1ab28e..2958cfc36 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/15.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/15.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4bb35f4484cb66bf63d46f4311617dc7e675ead33b8f978f564045491eea5bc -size 31875 +oid sha256:e9afd78075471066aa12aeaf33ddda780571faa14a61b842963c53b688432569 +size 50818 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/16.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/16.png index 9dced1b13..27964b46f 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/16.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/16.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21aa4d98c2870022104e44de7c63e16d4a8f7ae139c7a996c862b1cbd55bc3d7 -size 32317 +oid sha256:0caefffa407c227ca906cc21e959d3480a0a35a5a1720a00076a8d2c7ca1afb4 +size 51462 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/17.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/17.png index 110ce0967..8664f2ed2 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/17.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/17.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f7550515971c3af24efb51b4a81c21e3e3a642c53b654512bc6c6ad67d049748 -size 33265 +oid sha256:27e0c6a2204395b0da83c8fed89cf72168641b9318815db2e1d7a169317739d2 +size 52691 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/18.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/18.png index 68406f480..0c61aa82a 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/18.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/18.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:161d80a458dc2418eea4ab8caa851c0632eadd64538843a2c2a5cdd0a54ff66b -size 32545 +oid sha256:ff6af0ab7aabc30f57b1801045f27fcc327103db8f910dcd031cb68bd3e13df9 +size 51515 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/19.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/19.png index b0c387fb8..66a5f9c15 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/19.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/19.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8342d403ab99e900932b52b55f6c6583aac0567c4215c4e187eccf264f4e2c2c -size 32210 +oid sha256:eff399d98ab583c5c8dd26e78bc8920b43e5ee1c142fb9553080850e0506817d +size 51044 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/20.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/20.png index 7178b780d..6c18956a6 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/20.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/20.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8a29b4ca76d42a067b3e4f27521e5a0b05c85668002e92a30d12f1a3784062ec -size 31574 +oid sha256:0bbd6daf4825780010d0da77e05ff505e594acef2588a804a4c98501501c8728 +size 50347 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/21.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/21.png index ffb8ced6e..f4f27b24c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/21.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/21.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:be2601503fadee016c5f88b137091b50c6a7451e577f253f166b212ee937b35a -size 31384 +oid sha256:e48f2f7c177ea47fa096d1fa37ef22c4cc818d43b18cdf64c26ed96c79f00b48 +size 49743 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/22.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/22.png index 1b0034ab5..8706c7cf0 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/22.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/22.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2800403642452bff9858db473777b93030dde29c04b0280665a36aa9b57fcb18 -size 31855 +oid sha256:40cbbf0c4d939b696e01302614aab6affe22775783bf1902a33644fbb6ec5bdc +size 50602 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/23.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/23.png index ddf9fbf7a..ed2a543c8 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/23.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/23.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f0225e8395085728e2988ec148e33dc9df009746d5fe0860b12539776337372a -size 32035 +oid sha256:7e7901c37835974abd5163eede0a3049db5e936358089b3de67e99699019582e +size 50810 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/24.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/24.png index 302c97696..4ab5d089f 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/24.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/24.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f348830b798dff6f62a5c279105181efb4e692fe83f3e42cd3cae9b5ca0af7ce -size 32097 +oid sha256:80f0028de9c58117e8a4179ffa890ba0771f7135016fc018a2157bb2cabaa920 +size 50971 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/25.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/25.png index 3c3e74adb..6ac020e21 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/25.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/25.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd5fb5b83f44bbbc1b32690f54f995eb1709937de780ca35e31598c399c7d8ef -size 31750 +oid sha256:a01abb68b8be21b7531455dbd94b256cd826a52c170a62f88955e2b7a55376e0 +size 50531 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/26.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/26.png index 1b77c89bc..2119d2420 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/26.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Decode_VerifyAllFrames_Rgba32_kumin.gif/26.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a02cb3c82c90b05381126ff3f696e562200442aca34ba54830878701c51d932 -size 31647 +oid sha256:922fa84cc14f0795c8cb7459b6269dc5789018d1f0591560fba0a3c3e80b00b2 +size 50484 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Argb32_trans.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Argb32_trans.png index 1cfc3adb8..08b9fb724 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Argb32_trans.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Argb32_trans.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa4c441acc8fe614c9b375e8e609e735e1c767918ecc1f8f2f028665fdcfcf34 -size 12441 +oid sha256:49eeef6073a5ef2494ecfb138071c22157870e11c903ca81b837b32a813732ac +size 20256 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Rgba32_trans.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Rgba32_trans.png index 1cfc3adb8..08b9fb724 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Rgba32_trans.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_Rgba32_trans.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa4c441acc8fe614c9b375e8e609e735e1c767918ecc1f8f2f028665fdcfcf34 -size 12441 +oid sha256:49eeef6073a5ef2494ecfb138071c22157870e11c903ca81b837b32a813732ac +size 20256 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_RgbaVector_trans.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_RgbaVector_trans.png index 1cfc3adb8..08b9fb724 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_RgbaVector_trans.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/GifDecoder_IsNotBoundToSinglePixelType_RgbaVector_trans.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa4c441acc8fe614c9b375e8e609e735e1c767918ecc1f8f2f028665fdcfcf34 -size 12441 +oid sha256:49eeef6073a5ef2494ecfb138071c22157870e11c903ca81b837b32a813732ac +size 20256 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2012BadMinCode_Rgba32_issue2012_drona1.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2012BadMinCode_Rgba32_issue2012_drona1.png index 5d443b52a..bad4e3803 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2012BadMinCode_Rgba32_issue2012_drona1.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2012BadMinCode_Rgba32_issue2012_drona1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a0e1677baade797de1eaec390f2e475865d24de8bd344edddbb3fce200d6bcb0 -size 135418 +oid sha256:05c72bee64dbf29fe16349d8dfdfbee565779241dbfa860f62a53b649be000e3 +size 1884 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/00.png index f63cc98ad..75ffac608 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f39b23217f1d095eeb8eed5ccea36be813c307a60ef4b1942e9f74028451c38 -size 81944 +oid sha256:bc99ff5deb71c9caff1a645b4175b720edff792982d7c0d4189c769405386a90 +size 9474 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/01.png index f63cc98ad..75ffac608 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2758_BadDescriptorDimensions_Rgba32_issue_2758.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4f39b23217f1d095eeb8eed5ccea36be813c307a60ef4b1942e9f74028451c38 -size 81944 +oid sha256:bc99ff5deb71c9caff1a645b4175b720edff792982d7c0d4189c769405386a90 +size 9474 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/00.png index 36c368318..05e989247 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:731299281f942f277ce6803e0adda3b5dd0395eb79cae26cabc9d56905fae0fd +oid sha256:7d41ed74bdeaf5fb851935411dbe95e83c9ccbb8d5bad2d73c43fc5de4c5d798 size 1833 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/01.png index c03e5817f..9ac022ef4 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2859_LZWPixelStackOverflow_Rgba32_issue_2859_B.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:50ccac7739142578d99a76b6d39ba377099d4a7ac30cbb0a5aee44ef1e7c9c8c +oid sha256:052fc0cb71e18e6eb599f58bff8f4bfa822f536122f5dad77e6b8fa2c61bb207 size 1271 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/00.png new file mode 100644 index 000000000..7afb1c85b --- /dev/null +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/00.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f47b8bdb0159b3e9c6f3ba81a977fe198dec6cb0c47f33e8ba84203ef40dac9b +size 131 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/01.png new file mode 100644 index 000000000..d892d615a --- /dev/null +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/01.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e3c543efd04b63ee11d0e771f6b2dd2cba244f9b4a63f78a5555adfef13d60c +size 171 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/02.png new file mode 100644 index 000000000..cd8df1479 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/02.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ccae6eb76a1c3a8c7d75c78b7153964cbedc9223297bf67323dd2ec808ca96a +size 159 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/03.png new file mode 100644 index 000000000..5a42c4c6f --- /dev/null +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2980_Rgba32_issue_2980.gif/03.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6df2819dfd822558f734b70adbcb8edd4afb63072610d5cb79579ca84958c324 +size 151 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/00.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/00.png index 52f14e0f7..46f520cb0 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/00.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/00.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:473c5629d7a9f8b3d6c809e8ede40f8fd38e90beddf71851b352c726fc0570d6 -size 534 +oid sha256:4abf8935cd9ed76e3e2fe92d106928ecb7ede58498a550e52d52f0f7d6561c8e +size 466 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/01.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/01.png index b47f34ba0..d4a1f1d91 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/01.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/01.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b9b9f856c0347b460f824d6b027b343c65c67a29360793181c9a29a76f9002b -size 538 +oid sha256:a5028c4c0250855b9f0f4ec81cb376d5ab6acd73c385c5fe5e6df6537aa95d32 +size 462 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/02.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/02.png index 64869ca3c..c9f0f00c9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/02.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/02.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74b8015c60d215808b1d663ae4af956d1454414206ba21326ad35b8952b0cab6 -size 534 +oid sha256:92e36c91cae2dbef6570792d25b9eb08080efc6be3f2e887c2da6d87411f784d +size 471 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/03.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/03.png index ab52225f8..e44b6db71 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/03.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/03.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8dacb6a468d3cdc94613d56264ddf34d3649846edf33619fc13b9522fcf982d6 -size 539 +oid sha256:e9f6c6bee409938823b9a8ca106301142c44ec7479a72c3f6b3ea821ade30b72 +size 466 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/04.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/04.png index 78988aa60..bdc59e93c 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/04.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/04.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8af74db6e01928ad54444fa122e4b87929741052c85abe9c0ffc998adffcbdfc -size 542 +oid sha256:c7c3b861dca59f386fdc88acd8849f71c68ff0af45b2dfa712a55d2d865605d7 +size 462 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/05.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/05.png index ab52225f8..e44b6db71 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/05.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/05.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8dacb6a468d3cdc94613d56264ddf34d3649846edf33619fc13b9522fcf982d6 -size 539 +oid sha256:e9f6c6bee409938823b9a8ca106301142c44ec7479a72c3f6b3ea821ade30b72 +size 466 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/06.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/06.png index 64869ca3c..c9f0f00c9 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/06.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/06.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74b8015c60d215808b1d663ae4af956d1454414206ba21326ad35b8952b0cab6 -size 534 +oid sha256:92e36c91cae2dbef6570792d25b9eb08080efc6be3f2e887c2da6d87411f784d +size 471 diff --git a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/07.png b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/07.png index 97610dbc0..fd9984855 100644 --- a/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/07.png +++ b/tests/Images/External/ReferenceOutput/GifDecoderTests/IssueTooLargeLzwBits_Rgba32_issue_2743.gif/07.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c816ca1e58d14361b84ba47454e4cbf4d3e4d29dfb7827756eb52ef2604f297c -size 161 +oid sha256:ed091484d552b8c234ab75921e423e6d01172df61124b9b03dcdf2dadab34b85 +size 96 diff --git a/tests/Images/Input/Gif/issues/issue_2980.gif b/tests/Images/Input/Gif/issues/issue_2980.gif new file mode 100644 index 000000000..9c41a0f0b --- /dev/null +++ b/tests/Images/Input/Gif/issues/issue_2980.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3737a411dde845e20fc151e610434b96fb0a47297341db6f435e1ea64ae789b +size 507 From 82f20726993eaef66432c207af6e1cb0f09ff9df Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 10 Sep 2025 19:26:27 +1000 Subject: [PATCH 027/112] Remove unused value. --- src/ImageSharp/Formats/Gif/GifDecoderCore.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 2bb81b172..78ceb0b23 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -702,7 +702,6 @@ internal sealed class GifDecoderCore : ImageDecoderCore } else { - TPixel transparentPixel = Color.Transparent.ToPixel(); for (int x = 0; x < row.Length; x++) { int index = indicesRow[x]; From f78f2344142baf8159f800f5e8b54d6db0007563 Mon Sep 17 00:00:00 2001 From: Brian Berns Date: Tue, 16 Sep 2025 23:48:08 -0400 Subject: [PATCH 028/112] Fixed check for buffer overflow. --- .../Formats/Tiff/Compression/Decompressors/LzwString.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index e6895d67c..c56b2a683 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -77,9 +77,9 @@ public class LzwString LzwString e = this; int endIdx = this.Length - 1; - if (endIdx >= buffer.Length) + if (offset + endIdx >= buffer.Length) { - TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is to small or code length is invalid!"); + TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is too small or code length is invalid!"); } for (int i = endIdx; i >= 0; i--) From 385a9404c059e98cc0fedb5051245dae3767b20f Mon Sep 17 00:00:00 2001 From: Brian Berns Date: Wed, 17 Sep 2025 00:34:00 -0400 Subject: [PATCH 029/112] If string is too long, skip bytes at the end instead of throwing an exception. --- .../Compression/Decompressors/LzwString.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index c56b2a683..e8a62e754 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -69,25 +69,33 @@ public class LzwString return 0; } - if (this.Length == 1) + int available = buffer.Length - offset; + if (available <= 0) { - buffer[offset] = this.value; - return 1; + return 0; + } + + int numToWrite = this.Length; + if (numToWrite > available) + { + numToWrite = available; } LzwString e = this; - int endIdx = this.Length - 1; - if (offset + endIdx >= buffer.Length) + + // if string is too long, skip bytes at the end + int toSkip = this.Length - numToWrite; + for (int i = 0; i < toSkip; i++) { - TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is too small or code length is invalid!"); + e = e.previous; } - for (int i = endIdx; i >= 0; i--) + for (int i = numToWrite - 1; i >= 0; i--) { buffer[offset + i] = e.value; e = e.previous; } - return this.Length; + return numToWrite; } } From efc4cf55ab700a2ac9d27ad422c5b558f8f3350c Mon Sep 17 00:00:00 2001 From: Wacton Date: Thu, 18 Sep 2025 12:40:55 +0100 Subject: [PATCH 030/112] Enforce ICC D50 PCS illuminant --- .../ColorProfiles/ColorProfileConverterExtensionsIcc.cs | 8 ++++---- src/ImageSharp/ColorProfiles/KnownIlluminants.cs | 8 +++++++- .../ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs index c33f40001..3ddbf93b5 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs @@ -60,8 +60,8 @@ internal static class ColorProfileConverterExtensionsIcc ColorProfileConverter pcsConverter = new(new ColorConversionOptions { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = KnownIlluminants.D50Icc, + TargetWhitePoint = KnownIlluminants.D50Icc }); // Normalize the source, then convert to the PCS space. @@ -104,8 +104,8 @@ internal static class ColorProfileConverterExtensionsIcc ColorProfileConverter pcsConverter = new(new ColorConversionOptions { MemoryAllocator = converter.Options.MemoryAllocator, - SourceWhitePoint = new CieXyz(converter.Options.SourceIccProfile.Header.PcsIlluminant), - TargetWhitePoint = new CieXyz(converter.Options.TargetIccProfile.Header.PcsIlluminant), + SourceWhitePoint = KnownIlluminants.D50Icc, + TargetWhitePoint = KnownIlluminants.D50Icc }); using IMemoryOwner pcsBuffer = converter.Options.MemoryAllocator.Allocate(source.Length); diff --git a/src/ImageSharp/ColorProfiles/KnownIlluminants.cs b/src/ImageSharp/ColorProfiles/KnownIlluminants.cs index b9236497f..20ba445ec 100644 --- a/src/ImageSharp/ColorProfiles/KnownIlluminants.cs +++ b/src/ImageSharp/ColorProfiles/KnownIlluminants.cs @@ -9,6 +9,7 @@ namespace SixLabors.ImageSharp.ColorProfiles; /// /// /// Coefficients taken from: http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html +/// and https://color.org/specification/ICC.1-2022-05.pdf ///
/// Descriptions taken from: http://en.wikipedia.org/wiki/Standard_illuminant ///
@@ -30,10 +31,15 @@ public static class KnownIlluminants public static CieXyz C { get; } = new(0.98074F, 1F, 1.18232F); /// - /// Gets the Horizon Light. ICC profile PCS illuminant. + /// Gets the Horizon Light. /// public static CieXyz D50 { get; } = new(0.96422F, 1F, 0.82521F); + /// + /// Gets the D50 illuminant used in the ICC profile specification. + /// + public static CieXyz D50Icc { get; } = new(0.9642F, 1F, 0.8249F); + /// /// Gets the Mid-morning / Mid-afternoon Daylight illuminant. /// diff --git a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs index 6c56dc682..cb349af96 100644 --- a/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs +++ b/tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs @@ -42,7 +42,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) [InlineData(TestIccProfiles.RommRgb, TestIccProfiles.StandardRgbV4)] // CMYK -> LAB -> CMYK (different bit depth v2 LUTs, 16-bit vs 8-bit) [InlineData(TestIccProfiles.Fogra39, TestIccProfiles.StandardRgbV2, 0.0005)] // CMYK -> LAB -> XYZ -> RGB (different LUT tags, A2B vs TRC) --- tolerance slightly higher due to difference in inverse curve implementation [InlineData(TestIccProfiles.StandardRgbV2, TestIccProfiles.Fogra39)] // RGB -> XYZ -> LAB -> CMYK (different LUT tags, TRC vs A2B) - public void CanConvertIccProfiles(string sourceProfile, string targetProfile, double tolerance = 0.00005) + public void CanConvertIccProfiles(string sourceProfile, string targetProfile, double tolerance = 0.000005) { List actual = Inputs.ConvertAll(input => GetActualTargetValues(input, sourceProfile, targetProfile)); AssertConversion(sourceProfile, targetProfile, actual, tolerance, testOutputHelper); @@ -63,7 +63,7 @@ public class ColorProfileConverterTests(ITestOutputHelper testOutputHelper) [InlineData(TestIccProfiles.Fogra39, TestIccProfiles.StandardRgbV2, 0.0005)] // CMYK -> LAB -> XYZ -> RGB (different LUT tags, A2B vs TRC) --- tolerance slightly higher due to difference in inverse curve implementation [InlineData(TestIccProfiles.StandardRgbV2, TestIccProfiles.Fogra39)] // RGB -> XYZ -> LAB -> CMYK (different LUT tags, TRC vs A2B) [InlineData(TestIccProfiles.Issue129, TestIccProfiles.StandardRgbV4)] // CMYK -> LAB -> -> XYZ -> RGB - public void CanBulkConvertIccProfiles(string sourceProfile, string targetProfile, double tolerance = 0.00005) + public void CanBulkConvertIccProfiles(string sourceProfile, string targetProfile, double tolerance = 0.000005) { List actual = GetBulkActualTargetValues(Inputs, sourceProfile, targetProfile); AssertConversion(sourceProfile, targetProfile, actual, tolerance, testOutputHelper); From 5eaeafc9547883a9e9948131b26996e3b365380c Mon Sep 17 00:00:00 2001 From: Brian Berns Date: Sun, 28 Sep 2025 13:02:17 -0400 Subject: [PATCH 031/112] Added test case for issue #2983. --- tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs | 5 +++++ tests/ImageSharp.Tests/TestImages.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 5dd1f7884..26dc4f587 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -833,4 +833,9 @@ public class TiffDecoderTests : TiffDecoderBaseTester [WithFile(ExtraSamplesUnspecified, PixelTypes.Rgba32)] public void TiffDecoder_CanDecode_ExtraSamplesUnspecified(TestImageProvider provider) where TPixel : unmanaged, IPixel => TestTiffDecoder(provider); + + [Theory] + [WithFile(Issue2983, PixelTypes.Rgba32)] + public void TiffDecoder_CanDecode_Issue2983(TestImageProvider provider) + where TPixel : unmanaged, IPixel => TestTiffDecoder(provider); } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 9a5cfc706..3e5b3b712 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1164,6 +1164,7 @@ public static class TestImages public const string IptcData = "Tiff/iptc.tiff"; public const string Issue2909 = "Tiff/Issues/Issue2909.tiff"; + public const string Issue2983 = "Tiff/Issues/Issue2983.tiff"; public static readonly string[] Multiframes = [MultiframeDeflateWithPreview, MultiframeLzwPredictor /*, MultiFrameDifferentSize, MultiframeDifferentSizeTiled, MultiFrameDifferentVariants,*/ ]; From 336b6a22f6fce033328838f0895848c109b17e3b Mon Sep 17 00:00:00 2001 From: Brian Berns Date: Mon, 29 Sep 2025 01:29:09 -0400 Subject: [PATCH 032/112] Added TIFF image for unit test. --- tests/Images/Input/Tiff/Issues/Issue2983.tiff | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/Images/Input/Tiff/Issues/Issue2983.tiff diff --git a/tests/Images/Input/Tiff/Issues/Issue2983.tiff b/tests/Images/Input/Tiff/Issues/Issue2983.tiff new file mode 100644 index 000000000..7332ca42a --- /dev/null +++ b/tests/Images/Input/Tiff/Issues/Issue2983.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7bfe1d8660d11111cdf2674aedc43c1362dc8c2ecfab9b74b43a06c7c195863e +size 13311100 From 60149fc64fb994d9089c7fad0c19e205efc38d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=88=E7=BA=BE?= Date: Sat, 11 Oct 2025 10:57:38 +0800 Subject: [PATCH 033/112] Enhance DrawImage functionality by adding repeatCount parameter for animation control in DrawImageExtensions and DrawImageProcessor classes. --- .../Extensions/Drawing/DrawImageExtensions.cs | 80 +++++++++++-------- .../Processors/Drawing/DrawImageProcessor.cs | 19 ++++- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 20 ++++- 3 files changed, 81 insertions(+), 38 deletions(-) diff --git a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs index 25e504831..a6a02e133 100644 --- a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs @@ -21,10 +21,11 @@ public static class DrawImageExtensions public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, - float opacity) + float opacity, + int repeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); } /// @@ -39,10 +40,11 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, Rectangle foregroundRectangle, - float opacity) + float opacity, + int repeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); } /// @@ -57,8 +59,9 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, PixelColorBlendingMode colorBlending, - float opacity) - => DrawImage(source, foreground, Point.Empty, colorBlending, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, colorBlending, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -74,8 +77,9 @@ public static class DrawImageExtensions Image foreground, Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, - float opacity) - => DrawImage(source, foreground, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -91,8 +95,9 @@ public static class DrawImageExtensions Image foreground, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, - float opacity) - => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -110,8 +115,9 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, - float opacity) - => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -123,8 +129,9 @@ public static class DrawImageExtensions public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, - GraphicsOptions options) - => DrawImage(source, foreground, Point.Empty, options); + GraphicsOptions options, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, options, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -138,8 +145,9 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, Rectangle foregroundRectangle, - GraphicsOptions options) - => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options); + GraphicsOptions options, + int repeatCount) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -153,10 +161,11 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, Point backgroundLocation, - float opacity) + float opacity, + int repeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); } /// @@ -173,10 +182,11 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, Rectangle foregroundRectangle, - float opacity) + float opacity, + int repeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity); + return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); } /// @@ -193,8 +203,9 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, PixelColorBlendingMode colorBlending, - float opacity) - => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -212,8 +223,9 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, - float opacity) - => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity); + float opacity, + int repeatCount) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -227,8 +239,9 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, Point backgroundLocation, - GraphicsOptions options) - => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); + GraphicsOptions options, + int repeatCount) + => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -244,8 +257,9 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, Rectangle foregroundRectangle, - GraphicsOptions options) - => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage); + GraphicsOptions options, + int repeatCount) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, repeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -263,8 +277,9 @@ public static class DrawImageExtensions Point backgroundLocation, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, - float opacity) - => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity)); + float opacity, + int repeatCount) + => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity, repeatCount)); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -284,8 +299,9 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, - float opacity) => + float opacity, + int repeatCount) => source.ApplyProcessor( - new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity), + new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, repeatCount), foregroundRectangle); } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs index 6ecf16fc6..3e17dae51 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -19,13 +19,15 @@ public class DrawImageProcessor : IImageProcessor /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. + /// The loop count. The number of times to loop the animation. 0 means infinitely. public DrawImageProcessor( Image foreground, Point backgroundLocation, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, - float opacity) - : this(foreground, backgroundLocation, foreground.Bounds, colorBlendingMode, alphaCompositionMode, opacity) + float opacity, + int repeatCount) + : this(foreground, backgroundLocation, foreground.Bounds, colorBlendingMode, alphaCompositionMode, opacity, repeatCount) { } @@ -38,13 +40,15 @@ public class DrawImageProcessor : IImageProcessor /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. + /// The loop count. The number of times to loop the animation. 0 means infinitely. public DrawImageProcessor( Image foreground, Point backgroundLocation, Rectangle foregroundRectangle, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, - float opacity) + float opacity, + int repeatCount) { this.ForeGround = foreground; this.BackgroundLocation = backgroundLocation; @@ -52,6 +56,7 @@ public class DrawImageProcessor : IImageProcessor this.ColorBlendingMode = colorBlendingMode; this.AlphaCompositionMode = alphaCompositionMode; this.Opacity = opacity; + this.RepeatCount = repeatCount; } /// @@ -84,6 +89,11 @@ public class DrawImageProcessor : IImageProcessor /// public float Opacity { get; } + /// + /// Gets the loop count. The number of times to loop the animation. 0 means infinitely. + /// + public int RepeatCount { get; } + /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) where TPixelBg : unmanaged, IPixel @@ -122,6 +132,7 @@ public class DrawImageProcessor : IImageProcessor this.definition.ForegroundRectangle, this.definition.ColorBlendingMode, this.definition.AlphaCompositionMode, - this.definition.Opacity); + this.definition.Opacity, + this.definition.RepeatCount); } } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index d2a99ce92..c72a10d8a 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -17,6 +17,8 @@ internal class DrawImageProcessor : ImageProcessor where TPixelBg : unmanaged, IPixel where TPixelFg : unmanaged, IPixel { + private int currentFrameLoop; + /// /// Initializes a new instance of the class. /// @@ -28,6 +30,7 @@ internal class DrawImageProcessor : ImageProcessor /// The blending mode to use when drawing the image. /// The alpha blending mode to use when drawing the image. /// The opacity of the image to blend. Must be between 0 and 1. + /// The loop count. The number of times to loop the animation. 0 means infinitely. public DrawImageProcessor( Configuration configuration, Image foregroundImage, @@ -36,9 +39,11 @@ internal class DrawImageProcessor : ImageProcessor Rectangle foregroundRectangle, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, - float opacity) + float opacity, + int repeatCount) : base(configuration, backgroundImage, backgroundImage.Bounds) { + Guard.MustBeGreaterThanOrEqualTo(repeatCount, 0, nameof(repeatCount)); Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.ForegroundImage = foregroundImage; @@ -73,6 +78,11 @@ internal class DrawImageProcessor : ImageProcessor /// public Point BackgroundLocation { get; } + /// + /// Gets the loop count. The number of times to loop the animation. 0 means infinitely. + /// + public int RepeatCount { get; } + /// protected override void OnFrameApply(ImageFrame source) { @@ -114,12 +124,13 @@ internal class DrawImageProcessor : ImageProcessor // Sanitize the dimensions so that we don't try and sample outside the image. Rectangle backgroundRectangle = Rectangle.Intersect(new Rectangle(left, top, width, height), this.SourceRectangle); Configuration configuration = this.Configuration; + int currentFrameIndex = this.currentFrameLoop % this.ForegroundImage.Frames.Count; DrawImageProcessor.RowOperation operation = new( configuration, source.PixelBuffer, - this.ForegroundImage.Frames.RootFrame.PixelBuffer, + this.ForegroundImage.Frames[currentFrameIndex].PixelBuffer, backgroundRectangle, foregroundRectangle, this.Blender, @@ -129,6 +140,11 @@ internal class DrawImageProcessor : ImageProcessor configuration, new Rectangle(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); + + if (this.RepeatCount is 0 || this.currentFrameLoop / this.ForegroundImage.Frames.Count <= this.RepeatCount) + { + this.currentFrameLoop++; + } } /// From e749f3fa835de6d2543c60023e49386c2a45bcc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=88=E7=BA=BE?= Date: Sat, 11 Oct 2025 11:17:26 +0800 Subject: [PATCH 034/112] Fix condition for frame loop increment in DrawImageProcessor to ensure correct repeat count handling. --- .../Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index c72a10d8a..001888865 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -141,7 +141,7 @@ internal class DrawImageProcessor : ImageProcessor new Rectangle(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); - if (this.RepeatCount is 0 || this.currentFrameLoop / this.ForegroundImage.Frames.Count <= this.RepeatCount) + if (this.RepeatCount is 0 || this.currentFrameLoop / this.ForegroundImage.Frames.Count < this.RepeatCount) { this.currentFrameLoop++; } From 338fd4ce7913c43d69a5727759e34641a2b9e7a7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 23 Oct 2025 23:17:58 +1000 Subject: [PATCH 035/112] Fix #2992 --- .../Formats/Webp/WebpAnimationDecoder.cs | 112 +++++++++++++++++- .../Formats/Webp/WebpChunkParsingUtils.cs | 50 +++++++- .../Formats/Webp/WebpDecoderCore.cs | 50 +++++++- src/ImageSharp/Formats/Webp/WebpImageInfo.cs | 5 + .../Formats/WebP/WebpDecoderTests.cs | 30 +++++ 5 files changed, 234 insertions(+), 13 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 173d9436d..86489cd36 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -32,6 +32,11 @@ internal class WebpAnimationDecoder : IDisposable /// private readonly uint maxFrames; + /// + /// Whether to skip metadata. + /// + private readonly bool skipMetadata; + /// /// The area to restore. /// @@ -57,19 +62,97 @@ internal class WebpAnimationDecoder : IDisposable /// private readonly BackgroundColorHandling backgroundColorHandling; + /// + /// How to handle validation of errors in different segments of encoded image files. + /// + private readonly SegmentIntegrityHandling segmentIntegrityHandling; + /// /// Initializes a new instance of the class. /// /// The memory allocator. /// The global configuration. /// The maximum number of frames to decode. Inclusive. + /// Whether to skip metadata. /// The flag to decide how to handle the background color in the Animation Chunk. - public WebpAnimationDecoder(MemoryAllocator memoryAllocator, Configuration configuration, uint maxFrames, BackgroundColorHandling backgroundColorHandling) + /// How to handle validation of errors in different segments of encoded image files. + public WebpAnimationDecoder( + MemoryAllocator memoryAllocator, + Configuration configuration, + uint maxFrames, + bool skipMetadata, + BackgroundColorHandling backgroundColorHandling, + SegmentIntegrityHandling segmentIntegrityHandling) { this.memoryAllocator = memoryAllocator; this.configuration = configuration; this.maxFrames = maxFrames; + this.skipMetadata = skipMetadata; this.backgroundColorHandling = backgroundColorHandling; + this.segmentIntegrityHandling = segmentIntegrityHandling; + } + + /// + /// Reads the animated webp image information from the specified stream. + /// + /// The stream, where the image should be decoded from. Cannot be null. + /// The webp features. + /// The width of the image. + /// The height of the image. + /// The size of the image data in bytes. + public ImageInfo Identify( + BufferedReadStream stream, + WebpFeatures features, + uint width, + uint height, + uint completeDataSize) + { + List framesMetadata = []; + this.metadata = new ImageMetadata(); + this.webpMetadata = this.metadata.GetWebpMetadata(); + this.webpMetadata.RepeatCount = features.AnimationLoopCount; + + Color backgroundColor = this.backgroundColorHandling == BackgroundColorHandling.Ignore + ? Color.Transparent + : features.AnimationBackgroundColor!.Value; + + this.webpMetadata.BackgroundColor = backgroundColor; + + Span buffer = stackalloc byte[4]; + uint frameCount = 0; + int remainingBytes = (int)completeDataSize; + while (remainingBytes > 0) + { + WebpChunkType chunkType = WebpChunkParsingUtils.ReadChunkType(stream, buffer); + remainingBytes -= 4; + switch (chunkType) + { + case WebpChunkType.FrameData: + + ImageFrameMetadata frameMetadata = new(); + uint dataSize = ReadFrameInfo(stream, ref frameMetadata); + framesMetadata.Add(frameMetadata); + + remainingBytes -= (int)dataSize; + break; + case WebpChunkType.Xmp: + case WebpChunkType.Exif: + WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, this.metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer); + break; + default: + + // Specification explicitly states to ignore unknown chunks. + // We do not support writing these chunks at present. + break; + } + + if (stream.Position == stream.Length || ++frameCount == this.maxFrames) + { + break; + } + } + + return new ImageInfo(new Size((int)width, (int)height), this.metadata, framesMetadata); } /// @@ -128,10 +211,12 @@ internal class WebpAnimationDecoder : IDisposable break; case WebpChunkType.Xmp: case WebpChunkType.Exif: - WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, false, buffer); + WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer); break; default: - WebpThrowHelper.ThrowImageFormatException("Read unexpected webp chunk data"); + + // Specification explicitly states to ignore unknown chunks. + // We do not support writing these chunks at present. break; } @@ -144,6 +229,26 @@ internal class WebpAnimationDecoder : IDisposable return image!; } + /// + /// Reads frame information from the specified stream and updates the provided frame metadata. + /// + /// The stream from which to read the frame information. Must support reading and seeking. + /// A reference to the structure that will be updated with the parsed frame metadata. + /// The number of bytes read from the stream while parsing the frame information. + private static uint ReadFrameInfo(BufferedReadStream stream, ref ImageFrameMetadata frameMetadata) + { + WebpFrameData frameData = WebpFrameData.Parse(stream); + SetFrameMetadata(frameMetadata, frameData); + + // Size of the frame header chunk. + const int chunkHeaderSize = 16; + + uint remaining = frameData.DataSize - chunkHeaderSize; + stream.Skip((int)remaining); + + return remaining; + } + /// /// Reads an individual webp frame. /// @@ -155,6 +260,7 @@ internal class WebpAnimationDecoder : IDisposable /// The width of the image. /// The height of the image. /// The default background color of the canvas in. + /// The number of bytes read from the stream while parsing the frame information. private uint ReadFrame( BufferedReadStream stream, ref Image? image, diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 8df159dbf..4ce64629f 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers.Binary; +using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Formats.Webp.BitReader; using SixLabors.ImageSharp.Formats.Webp.Lossy; using SixLabors.ImageSharp.IO; @@ -120,6 +121,7 @@ internal static class WebpChunkParsingUtils return new WebpImageInfo { + DataSize = dataSize, Width = width, Height = height, XScale = xScale, @@ -178,6 +180,7 @@ internal static class WebpChunkParsingUtils return new WebpImageInfo { + DataSize = imageDataSize, Width = width, Height = height, BitsPerPixel = features.Alpha ? WebpBitsPerPixel.Bit32 : WebpBitsPerPixel.Bit24, @@ -333,7 +336,13 @@ internal static class WebpChunkParsingUtils /// If there are more such chunks, readers MAY ignore all except the first one. /// Also, a file may possibly contain both 'EXIF' and 'XMP ' chunks. /// - public static void ParseOptionalChunks(BufferedReadStream stream, WebpChunkType chunkType, ImageMetadata metadata, bool ignoreMetaData, Span buffer) + public static void ParseOptionalChunks( + BufferedReadStream stream, + WebpChunkType chunkType, + ImageMetadata metadata, + bool ignoreMetaData, + SegmentIntegrityHandling segmentIntegrityHandling, + Span buffer) { long streamLength = stream.Length; while (stream.Position < streamLength) @@ -353,12 +362,30 @@ internal static class WebpChunkParsingUtils bytesRead = stream.Read(exifData, 0, (int)chunkLength); if (bytesRead != chunkLength) { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); + if (segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); + } + + return; } if (metadata.ExifProfile != null) { - metadata.ExifProfile = new ExifProfile(exifData); + ExifProfile exifProfile = new(exifData); + + // Set the resolution from the metadata. + double horizontalValue = GetExifResolutionValue(exifProfile, ExifTag.XResolution); + double verticalValue = GetExifResolutionValue(exifProfile, ExifTag.YResolution); + + if (horizontalValue > 0 && verticalValue > 0) + { + metadata.HorizontalResolution = horizontalValue; + metadata.VerticalResolution = verticalValue; + metadata.ResolutionUnits = UnitConverter.ExifProfileToResolutionUnit(exifProfile); + } + + metadata.ExifProfile = exifProfile; } break; @@ -367,7 +394,12 @@ internal static class WebpChunkParsingUtils bytesRead = stream.Read(xmpData, 0, (int)chunkLength); if (bytesRead != chunkLength) { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); + if (segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); + } + + return; } if (metadata.XmpProfile != null) @@ -383,6 +415,16 @@ internal static class WebpChunkParsingUtils } } + private static double GetExifResolutionValue(ExifProfile exifProfile, ExifTag tag) + { + if (exifProfile.TryGetValue(tag, out IExifValue? resolution)) + { + return resolution.Value.ToDouble(); + } + + return 0; + } + /// /// Determines if the chunk type is an optional VP8X chunk. /// diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 51379a32a..0e9888adb 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -56,6 +56,8 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// private readonly BackgroundColorHandling backgroundColorHandling; + private readonly SegmentIntegrityHandling segmentIntegrityHandling; + /// /// Initializes a new instance of the class. /// @@ -64,6 +66,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable : base(options.GeneralOptions) { this.backgroundColorHandling = options.BackgroundColorHandling; + this.segmentIntegrityHandling = options.GeneralOptions.SegmentIntegrityHandling; this.configuration = options.GeneralOptions.Configuration; this.skipMetadata = options.GeneralOptions.SkipMetadata; this.maxFrames = options.GeneralOptions.MaxFrames; @@ -89,7 +92,10 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable this.memoryAllocator, this.configuration, this.maxFrames, - this.backgroundColorHandling); + this.skipMetadata, + this.backgroundColorHandling, + this.segmentIntegrityHandling); + return animationDecoder.Decode(stream, this.webImageInfo.Features, this.webImageInfo.Width, this.webImageInfo.Height, fileSize); } @@ -101,6 +107,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable this.webImageInfo.Vp8LBitReader, this.memoryAllocator, this.configuration); + losslessDecoder.Decode(pixels, image.Width, image.Height); } else @@ -109,6 +116,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable this.webImageInfo.Vp8BitReader, this.memoryAllocator, this.configuration); + lossyDecoder.Decode(pixels, image.Width, image.Height, this.webImageInfo, this.alphaData); } @@ -131,11 +139,29 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { - ReadImageHeader(stream, stackalloc byte[4]); - + uint fileSize = ReadImageHeader(stream, stackalloc byte[4]); ImageMetadata metadata = new(); + using (this.webImageInfo = this.ReadVp8Info(stream, metadata, true)) { + if (this.webImageInfo.Features is { Animation: true }) + { + using WebpAnimationDecoder animationDecoder = new( + this.memoryAllocator, + this.configuration, + this.maxFrames, + this.skipMetadata, + this.backgroundColorHandling, + this.segmentIntegrityHandling); + + return animationDecoder.Identify( + stream, + this.webImageInfo.Features, + this.webImageInfo.Width, + this.webImageInfo.Height, + fileSize); + } + return new ImageInfo( new Size((int)this.webImageInfo.Width, (int)this.webImageInfo.Height), metadata); @@ -211,6 +237,8 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable } else if (WebpChunkParsingUtils.IsOptionalVp8XChunk(chunkType)) { + // ANIM chunks appear before EXIF and XMP chunks. + // Return after parsing an ANIM chunk - The animated decoder will handle the rest. bool isAnimationChunk = this.ParseOptionalExtendedChunks(stream, metadata, chunkType, features, ignoreAlpha, buffer); if (isAnimationChunk) { @@ -273,7 +301,9 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable this.ReadAlphaData(stream, features, ignoreAlpha, buffer); break; default: - WebpThrowHelper.ThrowImageFormatException("Unexpected chunk followed VP8X header"); + + // Specification explicitly states to ignore unknown chunks. + // We do not support writing these chunks at present. break; } @@ -335,7 +365,11 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable int bytesRead = stream.Read(exifData, 0, (int)exifChunkSize); if (bytesRead != exifChunkSize) { - // Ignore invalid chunk. + if (this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); + } + return; } @@ -385,7 +419,11 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable int bytesRead = stream.Read(xmpData, 0, (int)xmpChunkSize); if (bytesRead != xmpChunkSize) { - // Ignore invalid chunk. + if (this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); + } + return; } diff --git a/src/ImageSharp/Formats/Webp/WebpImageInfo.cs b/src/ImageSharp/Formats/Webp/WebpImageInfo.cs index 3428ce199..e0993145f 100644 --- a/src/ImageSharp/Formats/Webp/WebpImageInfo.cs +++ b/src/ImageSharp/Formats/Webp/WebpImageInfo.cs @@ -8,6 +8,11 @@ namespace SixLabors.ImageSharp.Formats.Webp; internal class WebpImageInfo : IDisposable { + /// + /// Gets or sets the size of the encoded image data in bytes. + /// + public uint DataSize { get; set; } + /// /// Gets or sets the bitmap width in pixels. /// diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 111544f7f..c0abed214 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -314,6 +314,21 @@ public class WebpDecoderTests Assert.Equal(12, image.Frames.Count); } + [Theory] + [InlineData(Lossless.Animated)] + public void Info_AnimatedLossless_VerifyAllFrames(string imagePath) + { + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); + ImageInfo image = WebpDecoder.Instance.Identify(DecoderOptions.Default, stream); + WebpMetadata webpMetaData = image.Metadata.GetWebpMetadata(); + WebpFrameMetadata frameMetaData = image.FrameMetadataCollection[0].GetWebpMetadata(); + + Assert.Equal(0, webpMetaData.RepeatCount); + Assert.Equal(150U, frameMetaData.FrameDelay); + Assert.Equal(12, image.FrameCount); + } + [Theory] [WithFile(Lossy.Animated, PixelTypes.Rgba32)] public void Decode_AnimatedLossy_VerifyAllFrames(TestImageProvider provider) @@ -331,6 +346,21 @@ public class WebpDecoderTests Assert.Equal(12, image.Frames.Count); } + [Theory] + [InlineData(Lossy.Animated)] + public void Info_AnimatedLossy_VerifyAllFrames(string imagePath) + { + TestFile testFile = TestFile.Create(imagePath); + using MemoryStream stream = new(testFile.Bytes, false); + ImageInfo image = WebpDecoder.Instance.Identify(DecoderOptions.Default, stream); + WebpMetadata webpMetaData = image.Metadata.GetWebpMetadata(); + WebpFrameMetadata frameMetaData = image.FrameMetadataCollection[0].GetWebpMetadata(); + + Assert.Equal(0, webpMetaData.RepeatCount); + Assert.Equal(150U, frameMetaData.FrameDelay); + Assert.Equal(12, image.FrameCount); + } + [Theory] [WithFile(Lossless.Animated, PixelTypes.Rgba32)] public void Decode_AnimatedLossless_WithFrameDecodingModeFirst_OnlyDecodesOneFrame(TestImageProvider provider) From 370655ba9ffa6c27435c7a1a5d743f074e36cace Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 23 Oct 2025 23:20:52 +1000 Subject: [PATCH 036/112] Fix #2988 --- src/ImageSharp/Formats/Png/PngFrameMetadata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs index 701b9af05..7e0b56beb 100644 --- a/src/ImageSharp/Formats/Png/PngFrameMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngFrameMetadata.cs @@ -32,7 +32,7 @@ public class PngFrameMetadata : IFormatFrameMetadata /// /// Gets or sets the frame delay for animated images. - /// If not 0, when utilized in Png animation, this field specifies the number of hundredths (1/100) of a second to + /// If not 0, when utilized in Png animation, this field specifies the number of seconds to /// wait before continuing with the processing of the Data Stream. /// The clock starts ticking immediately after the graphic is rendered. /// From 302a2800cc8d8a72956a5ea1493ccc219307e097 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 23 Oct 2025 23:34:27 +1000 Subject: [PATCH 037/112] Update WebpChunkParsingUtils.cs --- src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 4ce64629f..dc95ca044 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -370,7 +370,7 @@ internal static class WebpChunkParsingUtils return; } - if (metadata.ExifProfile != null) + if (metadata.ExifProfile == null) { ExifProfile exifProfile = new(exifData); @@ -402,10 +402,7 @@ internal static class WebpChunkParsingUtils return; } - if (metadata.XmpProfile != null) - { - metadata.XmpProfile = new XmpProfile(xmpData); - } + metadata.XmpProfile ??= new XmpProfile(xmpData); break; default: From c3e990fcfc3c50a0d0c85ce62f70bc2c7515b4e7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Oct 2025 13:47:34 +1000 Subject: [PATCH 038/112] Fix #2959 --- .../Tiff/Compression/TiffBaseDecompressor.cs | 16 ++-- .../Formats/Tiff/TiffDecoderCore.cs | 95 +++++++++++++++++-- 2 files changed, 93 insertions(+), 18 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseDecompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseDecompressor.cs index 03cd639ad..86b5c19d2 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/TiffBaseDecompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/TiffBaseDecompressor.cs @@ -28,20 +28,20 @@ internal abstract class TiffBaseDecompressor : TiffBaseCompression /// Decompresses image data into the supplied buffer. /// /// The to read image data from. - /// The strip offset of stream. - /// The number of bytes to read from the input stream. + /// The data offset within the stream. + /// The number of bytes to read from the input stream. /// The height of the strip. /// The output buffer for uncompressed data. /// The token to monitor cancellation. - public void Decompress(BufferedReadStream stream, ulong stripOffset, ulong stripByteCount, int stripHeight, Span buffer, CancellationToken cancellationToken) + public void Decompress(BufferedReadStream stream, ulong offset, ulong count, int stripHeight, Span buffer, CancellationToken cancellationToken) { - DebugGuard.MustBeLessThanOrEqualTo(stripOffset, (ulong)long.MaxValue, nameof(stripOffset)); - DebugGuard.MustBeLessThanOrEqualTo(stripByteCount, (ulong)long.MaxValue, nameof(stripByteCount)); + DebugGuard.MustBeLessThanOrEqualTo(offset, (ulong)long.MaxValue, nameof(offset)); + DebugGuard.MustBeLessThanOrEqualTo(count, (ulong)int.MaxValue, nameof(count)); - stream.Seek((long)stripOffset, SeekOrigin.Begin); - this.Decompress(stream, (int)stripByteCount, stripHeight, buffer, cancellationToken); + stream.Seek((long)offset, SeekOrigin.Begin); + this.Decompress(stream, (int)count, stripHeight, buffer, cancellationToken); - if ((long)stripOffset + (long)stripByteCount < stream.Position) + if ((long)offset + (long)count < stream.Position) { TiffThrowHelper.ThrowImageFormatException("Out of range when reading a strip."); } diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index fbff35297..1dab2547b 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -5,6 +5,7 @@ using System.Buffers; using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Formats.Tiff.Compression; +using SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors; using SixLabors.ImageSharp.Formats.Tiff.Constants; using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; using SixLabors.ImageSharp.IO; @@ -441,8 +442,14 @@ internal class TiffDecoderCore : ImageDecoderCore { for (int stripIndex = 0; stripIndex < stripBuffers.Length; stripIndex++) { - int uncompressedStripSize = this.CalculateStripBufferSize(width, rowsPerStrip, stripIndex); - stripBuffers[stripIndex] = this.memoryAllocator.Allocate(uncompressedStripSize); + ulong uncompressedStripSize = this.CalculateStripBufferSize(width, rowsPerStrip, stripIndex); + + if (uncompressedStripSize > int.MaxValue) + { + TiffThrowHelper.ThrowNotSupported("Strips larger than Int32.MaxValue bytes are not supported for compressed images."); + } + + stripBuffers[stripIndex] = this.memoryAllocator.Allocate((int)uncompressedStripSize); } using TiffBaseDecompressor decompressor = this.CreateDecompressor(width, bitsPerPixel, frame.Metadata); @@ -507,15 +514,83 @@ internal class TiffDecoderCore : ImageDecoderCore rowsPerStrip = height; } - int uncompressedStripSize = this.CalculateStripBufferSize(width, rowsPerStrip); + ulong uncompressedStripSize = this.CalculateStripBufferSize(width, rowsPerStrip); int bitsPerPixel = this.BitsPerPixel; - using IMemoryOwner stripBuffer = this.memoryAllocator.Allocate(uncompressedStripSize, AllocationOptions.Clean); - Span stripBufferSpan = stripBuffer.GetSpan(); - Buffer2D pixels = frame.PixelBuffer; - using TiffBaseDecompressor decompressor = this.CreateDecompressor(width, bitsPerPixel, frame.Metadata); TiffBaseColorDecoder colorDecoder = this.CreateChunkyColorDecoder(); + Buffer2D pixels = frame.PixelBuffer; + + // There exists in this world TIFF files with uncompressed strips larger than Int32.MaxValue. + // We can read them, but we cannot allocate a buffer that large to hold the uncompressed data. + // In this scenario we fall back to reading and decoding one row at a time. + // + // The NoneTiffCompression decompressor can be used to read individual rows since we have + // a guarantee that each row required the same number of bytes. + if (decompressor is NoneTiffCompression none && uncompressedStripSize > int.MaxValue) + { + ulong bytesPerRowU = this.CalculateStripBufferSize(width, 1); + + // This should never happen, but we check just to be sure. + if (bytesPerRowU > int.MaxValue) + { + TiffThrowHelper.ThrowNotSupported("Strips larger than Int32.MaxValue bytes are not supported for compressed images."); + } + + int bytesPerRow = (int)bytesPerRowU; + using IMemoryOwner rowBufferOwner = this.memoryAllocator.Allocate(bytesPerRow, AllocationOptions.Clean); + Span rowBuffer = rowBufferOwner.GetSpan(); + for (int stripIndex = 0; stripIndex < stripOffsets.Length; stripIndex++) + { + cancellationToken.ThrowIfCancellationRequested(); + + int stripHeight = stripIndex < stripOffsets.Length - 1 || height % rowsPerStrip == 0 + ? rowsPerStrip + : height % rowsPerStrip; + + int top = rowsPerStrip * stripIndex; + if (top + stripHeight > height) + { + break; + } + + ulong baseOffset = stripOffsets[stripIndex]; + ulong available = stripByteCounts[stripIndex]; + ulong required = (ulong)bytesPerRow * (ulong)stripHeight; + if (available < required) + { + TiffThrowHelper.ThrowImageFormatException("StripByteCounts is smaller than required for uncompressed data."); + } + + for (int r = 0; r < stripHeight; r++) + { + cancellationToken.ThrowIfCancellationRequested(); + + ulong rowOffset = baseOffset + ((ulong)r * (ulong)bytesPerRow); + + // Use the NoneTiffCompression decompressor to read exactly one row. + none.Decompress( + this.inputStream, + rowOffset, + (ulong)bytesPerRow, + 1, + rowBuffer, + cancellationToken); + + colorDecoder.Decode(rowBuffer, pixels, 0, top + r, width, 1); + } + } + + return; + } + + if (uncompressedStripSize > int.MaxValue) + { + TiffThrowHelper.ThrowNotSupported("Strips larger than Int32.MaxValue bytes are not supported for compressed images."); + } + + using IMemoryOwner stripBuffer = this.memoryAllocator.Allocate((int)uncompressedStripSize, AllocationOptions.Clean); + Span stripBufferSpan = stripBuffer.GetSpan(); for (int stripIndex = 0; stripIndex < stripOffsets.Length; stripIndex++) { @@ -808,7 +883,7 @@ internal class TiffDecoderCore : ImageDecoderCore /// The height for the desired pixel buffer. /// The index of the plane for planar image configuration (or zero for chunky). /// The size (in bytes) of the required pixel buffer. - private int CalculateStripBufferSize(int width, int height, int plane = -1) + private ulong CalculateStripBufferSize(int width, int height, int plane = -1) { DebugGuard.MustBeLessThanOrEqualTo(plane, 3, nameof(plane)); @@ -841,8 +916,8 @@ internal class TiffDecoderCore : ImageDecoderCore } } - int bytesPerRow = ((width * bitsPerPixel) + 7) / 8; - return bytesPerRow * height; + ulong bytesPerRow = (((ulong)width * (ulong)bitsPerPixel) + 7) / 8; + return bytesPerRow * (ulong)height; } [MethodImpl(MethodImplOptions.AggressiveInlining)] From 5a9f42d1ddd5567d531766e926d5ad122790225d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Oct 2025 14:14:13 +1000 Subject: [PATCH 039/112] Break, don't throw --- src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 1dab2547b..8a4a27946 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -559,7 +559,7 @@ internal class TiffDecoderCore : ImageDecoderCore ulong required = (ulong)bytesPerRow * (ulong)stripHeight; if (available < required) { - TiffThrowHelper.ThrowImageFormatException("StripByteCounts is smaller than required for uncompressed data."); + break; } for (int r = 0; r < stripHeight; r++) From 2f9cd4fe2b120df978d66ed00e2395b2f8ddec26 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 29 Oct 2025 22:14:03 +1000 Subject: [PATCH 040/112] Fix detection of canonical sRGB profiles --- src/ImageSharp/Formats/DecoderOptions.cs | 4 +- .../Metadata/Profiles/ICC/IccProfile.SRGB.cs | 346 ++++++++++++++++++ .../Metadata/Profiles/ICC/IccProfile.cs | 2 +- .../Metadata/Profiles/ICC/IccProfileHeader.cs | 38 -- .../Formats/Jpg/JpegDecoderTests.cs | 3 + tests/ImageSharp.Tests/TestImages.cs | 3 + ...B_ICC_Jpeg_Rgba32_Perceptual-cLUT-only.png | 3 + .../Decode_RGB_ICC_Jpeg_Rgba32_Perceptual.png | 3 + .../Decode_RGB_ICC_Jpeg_Rgba32_sRGB_Gray.png | 3 + .../Jpg/icc-profiles/Perceptual-cLUT-only.jpg | 3 + .../Input/Jpg/icc-profiles/Perceptual.jpg | 3 + .../Input/Jpg/icc-profiles/sRGB_Gray.jpg | 3 + 12 files changed, 373 insertions(+), 41 deletions(-) create mode 100644 src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs create mode 100644 tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual-cLUT-only.png create mode 100644 tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual.png create mode 100644 tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_sRGB_Gray.png create mode 100644 tests/Images/Input/Jpg/icc-profiles/Perceptual-cLUT-only.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/Perceptual.jpg create mode 100644 tests/Images/Input/Jpg/icc-profiles/sRGB_Gray.jpg diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index 2511cffdb..bb6c2a282 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -78,7 +78,7 @@ public sealed class DecoderOptions return false; } - if (IccProfileHeader.IsLikelySrgb(profile.Header)) + if (profile.IsCanonicalSrgbMatrixTrc()) { return false; } @@ -99,7 +99,7 @@ public sealed class DecoderOptions return false; } - if (this.ColorProfileHandling == ColorProfileHandling.Compact && IccProfileHeader.IsLikelySrgb(profile.Header)) + if (this.ColorProfileHandling == ColorProfileHandling.Compact && profile.IsCanonicalSrgbMatrixTrc()) { return true; } diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs new file mode 100644 index 000000000..bfa4ab9bd --- /dev/null +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.SRGB.cs @@ -0,0 +1,346 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Numerics; +using SixLabors.ImageSharp.ColorProfiles; + +namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; + +/// +/// Provides logic for identifying canonical IEC 61966-2-1 (sRGB) matrix-TRC ICC profiles, +/// distinguishing them from appearance or device-specific variants. +/// +public sealed partial class IccProfile +{ + // sRGB v2 Preference + private static readonly IccProfileId StandardRgbV2 = new(0x3D0EB2DE, 0xAE9397BE, 0x9B6726CE, 0x8C0A43CE); + + // sRGB v4 Preference + private static readonly IccProfileId StandardRgbV4 = new(0x34562ABF, 0x994CCD06, 0x6D2C5721, 0xD0D68C5D); + + /// + /// Detects canonical sRGB matrix+TRC profiles quickly and safely. + /// Rules: + /// 1) Accept known IEC sRGB v2 and v4 by profile ID. + /// 2) Require RGB, PCS=XYZ, ICC v2 or v4, and no A2B*/B2A* LUTs. + /// 3) Require rTRC, gTRC, bTRC to exist and be identical by parameters or sampled shape. + /// 4) Accept if rXYZ/gXYZ/bXYZ already match the D50-adapted sRGB colorants within tolerance. + /// 5) If white point ≈ D65, adapt only the colorant columns to D50 using Bradford + /// via and then compare. + /// This rejects channel-swapped and appearance profiles while allowing real sRGB. + /// + /// + /// Reference D50-adapted sRGB colorants from Bruce Lindbloom: + /// + /// R=(0.4360747, 0.2225045, 0.0139322) + /// G=(0.3850649, 0.7168786, 0.0971045) + /// B=(0.1430804, 0.0606169, 0.7141733) + /// + internal bool IsCanonicalSrgbMatrixTrc() + { + IccProfileHeader h = this.Header; + + // Fast path for known IEC sRGB profile IDs + if (h.Id == StandardRgbV2 || h.Id == StandardRgbV4) + { + return true; + } + + // Header gating to avoid parsing work for obvious non-matches + if (h.FileSignature != "acsp") + { + return false; + } + + if (h.DataColorSpace != IccColorSpaceType.Rgb) + { + return false; + } + + if (h.ProfileConnectionSpace != IccColorSpaceType.CieXyz) + { + return false; + } + + if (h.Version.Major is not 2 and not 4) + { + return false; + } + + this.InitializeEntries(); + IccTagDataEntry[] entries = this.entries; + + // Reject device/display LUT profiles. We only accept matrix+TRC encodings. + if (Has(entries, IccProfileTag.AToB0) || Has(entries, IccProfileTag.AToB1) || Has(entries, IccProfileTag.AToB2) || + Has(entries, IccProfileTag.BToA0) || Has(entries, IccProfileTag.BToA1) || Has(entries, IccProfileTag.BToA2)) + { + return false; + } + + // Required matrix+TRC tags + if (!TryGetXyz(entries, IccProfileTag.MediaWhitePoint, out Vector3 wtpt)) + { + return false; + } + + if (!TryGetXyz(entries, IccProfileTag.RedMatrixColumn, out Vector3 rXYZ)) + { + return false; + } + + if (!TryGetXyz(entries, IccProfileTag.GreenMatrixColumn, out Vector3 gXYZ)) + { + return false; + } + + if (!TryGetXyz(entries, IccProfileTag.BlueMatrixColumn, out Vector3 bXYZ)) + { + return false; + } + + // TRCs must exist and be identical across channels. This filters many trick profiles. + if (!TryGetTrc(entries, IccProfileTag.RedTrc, out Trc tR)) + { + return false; + } + + if (!TryGetTrc(entries, IccProfileTag.GreenTrc, out Trc tG)) + { + return false; + } + + if (!TryGetTrc(entries, IccProfileTag.BlueTrc, out Trc tB)) + { + return false; + } + + if (!tR.Equals(tG) || !tR.Equals(tB)) + { + return false; + } + + // D50-adapted sRGB colorants (compare as columns: r,g,b), tight epsilon + const float eps = 2e-3F; + Vector3 rRef = new(0.4360747F, 0.2225045F, 0.0139322F); + Vector3 gRef = new(0.3850649F, 0.7168786F, 0.0971045F); + Vector3 bRef = new(0.1430804F, 0.0606169F, 0.7141733F); + + // First, accept if the stored colorants are already the D50 sRGB primaries. + // Many v2 sRGB profiles store D50-adapted colorants while declaring wtpt≈D65. + if (Near(rXYZ, rRef, eps) && Near(gXYZ, gRef, eps) && Near(bXYZ, bRef, eps)) + { + return true; + } + + // If the profile declares a D65 white, adapt the colorant columns to D50 and compare again. + // We never adapt when they already match, to avoid compounding rounding. + if (Near(wtpt, KnownIlluminants.D65.AsVector3Unsafe(), 2e-3F)) + { + CieXyz fromWp = new(wtpt); // Declared white + CieXyz toWp = KnownIlluminants.D50; // PCS white + Matrix4x4 matrix = KnownChromaticAdaptationMatrices.Bradford; + + rXYZ = VonKriesChromaticAdaptation.Transform(new CieXyz(rXYZ), (fromWp, toWp), matrix).AsVector3Unsafe(); + gXYZ = VonKriesChromaticAdaptation.Transform(new CieXyz(gXYZ), (fromWp, toWp), matrix).AsVector3Unsafe(); + bXYZ = VonKriesChromaticAdaptation.Transform(new CieXyz(bXYZ), (fromWp, toWp), matrix).AsVector3Unsafe(); + } + + // Require identity mapping of primaries, no permutation + if (!Near(rXYZ, rRef, eps) || !Near(gXYZ, gRef, eps) || !Near(bXYZ, bRef, eps)) + { + return false; + } + + return true; + + static bool Has(ReadOnlySpan span, IccProfileTag tag) + { + for (int i = 0; i < span.Length; i++) + { + if (span[i].TagSignature == tag) + { + return true; + } + } + + return false; + } + + static bool TryGetXyz(ReadOnlySpan span, IccProfileTag tag, out Vector3 xyz) + { + for (int i = 0; i < span.Length; i++) + { + IccTagDataEntry e = span[i]; + if (e.TagSignature != tag) + { + continue; + } + + if (e is IccXyzTagDataEntry x && x.Data is { Length: >= 1 }) + { + xyz = x.Data[0]; + return true; + } + + break; + } + + xyz = default; + return false; + } + + static bool TryGetTrc(ReadOnlySpan span, IccProfileTag tag, out Trc trc) + { + for (int i = 0; i < span.Length; i++) + { + IccTagDataEntry e = span[i]; + if (e.TagSignature != tag) + { + continue; + } + + if (e is IccParametricCurveTagDataEntry p) + { + trc = Trc.FromParametric(p.Curve); + return true; + } + + if (e is IccCurveTagDataEntry c) + { + trc = Trc.FromCurveLut(c.CurveData); + return true; + } + + break; + } + + trc = default; + return false; + } + + static bool Near(in Vector3 a, in Vector3 b, float tol) + => MathF.Abs(a.X - b.X) <= tol && + MathF.Abs(a.Y - b.Y) <= tol && + MathF.Abs(a.Z - b.Z) <= tol; + } + + /// + /// Compact, allocation-free descriptor of a TRC for equality and optional sRGB check. + /// + private readonly struct Trc : IEquatable + { + private readonly byte kind; // 0 = none, 1 = parametric, 2 = sampled + private readonly float g; // parametric payload or downsampled hash + private readonly float a; + private readonly float b; + private readonly float c; + private readonly float d; + private readonly float e; + private readonly float f; + private readonly int n; // for sampled, length or a small signature + + private Trc(byte kind, float g, float a, float b, float c, float d, float e, float f, int n) + { + this.kind = kind; + this.g = g; + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + this.n = n; + } + + public static Trc FromParametric(IccParametricCurve c) + + // Normalize by curve type to a stable tuple + // The types map to piecewise forms, but equality across channels is the key requirement here + => new(1, c.G, c.A, c.B, c.C, c.D, c.E, c.F, (int)c.Type); + + public static Trc FromCurveLut(float[] data) + { + // Exact sequence equality is enforced by the calling code using the same Trc construction + // Record a short signature to compare cheaply, avoid copying + if (data == null) + { + return default; + } + + int n = data.Length; + if (n == 0) + { + return default; + } + + // Downsample a few points to a robust fingerprint + // Use fixed indices to avoid allocations + float s0 = data[0]; + float s1 = data[n >> 2]; + float s2 = data[n >> 1]; + float s3 = data[(n * 3) >> 2]; + float s4 = data[n - 1]; + + return new Trc( + 2, + s0, + s1, + s2, + s3, + s4, + 0F, + 0F, + n); + } + + public override bool Equals(object? obj) => obj is Trc trc && this.Equals(trc); + + public bool Equals(Trc other) + { + if (this.kind != other.kind) + { + return false; + } + + if (this.kind == 0) + { + return false; + } + + if (this.kind == 1) + { + // parametric: exact parameter match and type match + return this.n == other.n && + this.g == other.g && this.a == other.a && + this.b == other.b && this.c == other.c && + this.d == other.d && this.e == other.e && this.f == other.f; + } + + // sampled: same length and same 5-point fingerprint + return this.n == other.n && + this.g == other.g && this.a == other.a && + this.b == other.b && this.c == other.c && this.d == other.d; + } + + // Optional stricter sRGB check if you need it later + public bool IsSrgbLike() + { + if (this.kind == 1) + { + // Accept common sRGB parametric encodings where type and parameters match + // IEC 61966-2-1 maps to Type4 or Type5 forms in practice + // Tighten only if you must exclude gamma~2.2 profiles that share primaries + return true; + } + + return true; + } + + public override int GetHashCode() + { + int a = HashCode.Combine(this.kind, this.g, this.a, this.b, this.c, this.d, this.e); + int b = HashCode.Combine(this.f, this.n); + return HashCode.Combine(a, b); + } + } +} diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs index 392ccb306..05be3eb5d 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs @@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// /// Represents an ICC profile /// -public sealed class IccProfile : IDeepCloneable +public sealed partial class IccProfile : IDeepCloneable { /// /// The byte array to read the ICC profile from diff --git a/src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs b/src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs index b50885d02..959668aaf 100644 --- a/src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs +++ b/src/ImageSharp/Metadata/Profiles/ICC/IccProfileHeader.cs @@ -11,17 +11,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Icc; /// public sealed class IccProfileHeader { - private static readonly Vector3 TruncatedD50 = new(0.9642029F, 1F, 0.8249054F); - - // sRGB v2 Preference - private static readonly IccProfileId StandardRgbV2 = new(0x3D0EB2DE, 0xAE9397BE, 0x9B6726CE, 0x8C0A43CE); - - // sRGB v4 Preference - private static readonly IccProfileId StandardRgbV4 = new(0x34562ABF, 0x994CCD06, 0x6D2C5721, 0xD0D68C5D); - - // sRGB v4 Appearance - private static readonly IccProfileId StandardRgbV4A = new(0xDF1132A1, 0x746E97B0, 0xAD85719, 0xBE711E08); - /// /// Gets or sets the profile size in bytes (will be ignored when writing a profile). /// @@ -108,31 +97,4 @@ public sealed class IccProfileHeader /// Gets or sets the profile ID (hash). /// public IccProfileId Id { get; set; } - - internal static bool IsLikelySrgb(IccProfileHeader header) - { - // Reject known perceptual-appearance profile - // This profile employs perceptual rendering intents to maintain color appearance across different - // devices and media, which can lead to variations from standard sRGB representations. - if (header.Id == StandardRgbV4A) - { - return false; - } - - // Accept known sRGB profile IDs - if (header.Id == StandardRgbV2 || header.Id == StandardRgbV4) - { - return true; - } - - // Fallback: best-guess heuristic - return - header.FileSignature == "acsp" && - header.DataColorSpace == IccColorSpaceType.Rgb && - (header.ProfileConnectionSpace == IccColorSpaceType.CieXyz || header.ProfileConnectionSpace == IccColorSpaceType.CieLab) && - (header.Class == IccProfileClass.DisplayDevice || header.Class == IccProfileClass.ColorSpace) && - header.PcsIlluminant == TruncatedD50 && - (header.Version.Major == 2 || header.Version.Major == 4) && - !string.Equals(header.CmmType, "ADBE", StringComparison.Ordinal); - } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 2856abe5c..71753bf9c 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -402,6 +402,9 @@ public partial class JpegDecoderTests [WithFile(TestImages.Jpeg.ICC.ProPhoto, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.ICC.WideRGB, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.ICC.AppleRGB, PixelTypes.Rgba32)] + [WithFile(TestImages.Jpeg.ICC.SRgbGray, PixelTypes.Rgba32)] + [WithFile(TestImages.Jpeg.ICC.Perceptual, PixelTypes.Rgba32)] + [WithFile(TestImages.Jpeg.ICC.PerceptualcLUTOnly, PixelTypes.Rgba32)] public void Decode_RGB_ICC_Jpeg(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 3e5b3b712..af6148c87 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -216,6 +216,9 @@ public static class TestImages public const string AppleRGB = "Jpg/icc-profiles/Momiji-AppleRGB-yes.jpg"; public const string CMYK = "Jpg/icc-profiles/issue-129.jpg"; public const string YCCK = "Jpg/icc-profiles/issue_2723.jpg"; + public const string SRgbGray = "Jpg/icc-profiles/sRGB_Gray.jpg"; + public const string Perceptual = "Jpg/icc-profiles/Perceptual.jpg"; + public const string PerceptualcLUTOnly = "Jpg/icc-profiles/Perceptual-cLUT-only.jpg"; } public static class Progressive diff --git a/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual-cLUT-only.png b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual-cLUT-only.png new file mode 100644 index 000000000..a0b73d299 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual-cLUT-only.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe06798b92c9b476c167407e752b4379d50f1b1ad6329eceb368c8c36097b401 +size 95103 diff --git a/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual.png b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual.png new file mode 100644 index 000000000..99ae53f93 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_Perceptual.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21f8d54d4b789b783f3020402d4c1b91bb541de6565e2960976b569f60694631 +size 99385 diff --git a/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_sRGB_Gray.png b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_sRGB_Gray.png new file mode 100644 index 000000000..759b26a60 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Rgba32_sRGB_Gray.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18ad361f79b4ab26d452d5cc7ada4c121dfbf45d20da7c23a58f71a9497d17a2 +size 5341 diff --git a/tests/Images/Input/Jpg/icc-profiles/Perceptual-cLUT-only.jpg b/tests/Images/Input/Jpg/icc-profiles/Perceptual-cLUT-only.jpg new file mode 100644 index 000000000..7b2e57f65 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Perceptual-cLUT-only.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04e552f0bd68bddb40f35c456034b1bf1e590f37e990a28b2fe2e94753bbe685 +size 276191 diff --git a/tests/Images/Input/Jpg/icc-profiles/Perceptual.jpg b/tests/Images/Input/Jpg/icc-profiles/Perceptual.jpg new file mode 100644 index 000000000..879fd05ad --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/Perceptual.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74a0931e320ca938d7dc94c4ab7b27a15880732fc139718629a7234f34bdafba +size 297456 diff --git a/tests/Images/Input/Jpg/icc-profiles/sRGB_Gray.jpg b/tests/Images/Input/Jpg/icc-profiles/sRGB_Gray.jpg new file mode 100644 index 000000000..2abd97686 --- /dev/null +++ b/tests/Images/Input/Jpg/icc-profiles/sRGB_Gray.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22892d1b7965d973c7d8925ad7d749988c6a36b333b264a55d389f1e4faa0245 +size 36854 From 399a43d4bb15d3e64b6372e8834968ca39bc08af Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 30 Oct 2025 11:11:12 +1000 Subject: [PATCH 041/112] Make conversion methods public. --- ...rProfileConverterExtensionsCieLabCieLab.cs | 32 ++++++++++++++++++- ...rProfileConverterExtensionsCieLabCieXyz.cs | 32 ++++++++++++++++++- ...olorProfileConverterExtensionsCieLabRgb.cs | 32 ++++++++++++++++++- ...rProfileConverterExtensionsCieXyzCieLab.cs | 32 ++++++++++++++++++- ...rProfileConverterExtensionsCieXyzCieXyz.cs | 32 ++++++++++++++++++- ...olorProfileConverterExtensionsCieXyzRgb.cs | 32 ++++++++++++++++++- ...olorProfileConverterExtensionsRgbCieLab.cs | 32 ++++++++++++++++++- ...olorProfileConverterExtensionsRgbCieXyz.cs | 32 ++++++++++++++++++- .../ColorProfileConverterExtensionsRgbRgb.cs | 32 ++++++++++++++++++- 9 files changed, 279 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieLab.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieLab.cs index a2dd5d9ce..4d94f583a 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieLab.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieLab.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieLabCieLab +/// +/// Allows conversion between two color profiles based on the CIE Lab color space. +/// +public static class ColorProfileConverterExtensionsCieLabCieLab { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -34,6 +50,20 @@ internal static class ColorProfileConverterExtensionsCieLabCieLab return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieXyz.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieXyz.cs index 096622564..1de4510bc 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieXyz.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabCieXyz.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieLabCieXyz +/// +/// Allows conversion between two color profiles based on the CIE Lab and CIE XYZ color spaces. +/// +public static class ColorProfileConverterExtensionsCieLabCieXyz { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -33,6 +49,20 @@ internal static class ColorProfileConverterExtensionsCieLabCieXyz return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabRgb.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabRgb.cs index 51be13799..4f0d47080 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabRgb.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieLabRgb.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieLabRgb +/// +/// Allows conversion between two color profiles based on the CIE Lab and RGB color spaces. +/// +public static class ColorProfileConverterExtensionsCieLabRgb { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -34,6 +50,20 @@ internal static class ColorProfileConverterExtensionsCieLabRgb return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieLab.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieLab.cs index 3bab4e7b1..3bb1b2d4f 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieLab.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieLab.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieXyzCieLab +/// +/// Allows conversion between two color profiles based on the CIE XYZ and CIE Lab color spaces. +/// +public static class ColorProfileConverterExtensionsCieXyzCieLab { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -33,6 +49,20 @@ internal static class ColorProfileConverterExtensionsCieXyzCieLab return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieXyz.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieXyz.cs index 518851147..dabca4579 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieXyz.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzCieXyz.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieXyzCieXyz +/// +/// Allows conversion between two color profiles based on the CIE XYZ color space. +/// +public static class ColorProfileConverterExtensionsCieXyzCieXyz { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -30,6 +46,20 @@ internal static class ColorProfileConverterExtensionsCieXyzCieXyz return TTo.FromProfileConnectingSpace(options, in pcsFrom); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzRgb.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzRgb.cs index c56bf214b..1803c0839 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzRgb.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsCieXyzRgb.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsCieXyzRgb +/// +/// Allows conversion between two color profiles based on the CIE XYZ and RGB color spaces. +/// +public static class ColorProfileConverterExtensionsCieXyzRgb { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -33,6 +49,20 @@ internal static class ColorProfileConverterExtensionsCieXyzRgb return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieLab.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieLab.cs index badbcc683..c2ed9a591 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieLab.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieLab.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsRgbCieLab +/// +/// Allows conversion between two color profiles based on the RGB and CIE Lab color spaces. +/// +public static class ColorProfileConverterExtensionsRgbCieLab { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -34,6 +50,20 @@ internal static class ColorProfileConverterExtensionsRgbCieLab return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieXyz.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieXyz.cs index cd7d5e4d6..9cf7ec70d 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieXyz.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbCieXyz.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsRgbCieXyz +/// +/// Allows conversion between two color profiles based on the RGB and CIE XYZ color spaces. +/// +public static class ColorProfileConverterExtensionsRgbCieXyz { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -33,6 +49,20 @@ internal static class ColorProfileConverterExtensionsRgbCieXyz return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbRgb.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbRgb.cs index 2a4b64b1c..34f3f7f19 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbRgb.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsRgbRgb.cs @@ -6,8 +6,24 @@ using SixLabors.ImageSharp.Memory; namespace SixLabors.ImageSharp.ColorProfiles; -internal static class ColorProfileConverterExtensionsRgbRgb +/// +/// Allows conversion between two color profiles based on the RGB color space. +/// +public static class ColorProfileConverterExtensionsRgbRgb { + /// + /// Converts a color value from one color profile to another using the specified color profile converter. + /// + /// + /// The conversion process may use ICC profiles if available; otherwise, it performs a manual + /// conversion through the profile connection space (PCS) with chromatic adaptation as needed. The method requires + /// both source and target types to be value types implementing the appropriate color profile interface. + /// + /// The source color profile type. Must implement . + /// The target color profile type. Must implement . + /// The color profile converter to use for the conversion. + /// The source color value to convert. + /// A value of type representing the converted color in the target color profile. public static TTo Convert(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -34,6 +50,20 @@ internal static class ColorProfileConverterExtensionsRgbRgb return TTo.FromProfileConnectingSpace(options, in pcsTo); } + /// + /// Converts a span of color values from one color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion between two color profiles, handling necessary + /// transformations such as profile connection space conversion and chromatic adaptation. If ICC profiles are + /// available and applicable, the conversion uses them for improved accuracy. The method does not allocate memory + /// for the destination; the caller is responsible for providing a suitably sized span. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter to use for the conversion operation. + /// A read-only span containing the source color values to convert. + /// A span that receives the converted color values. Must be at least as long as the source span. public static void Convert(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile From 25770464298414fc7839385c8001a0f2ab42fb81 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 13 Nov 2025 18:03:13 +1000 Subject: [PATCH 042/112] Fix #3000 --- .../Metadata/Profiles/Exif/ExifProfile.cs | 12 +- src/ImageSharp/Primitives/Point.cs | 12 +- src/ImageSharp/Primitives/PointF.cs | 12 +- src/ImageSharp/Primitives/SizeF.cs | 12 +- .../Processing/AffineTransformBuilder.cs | 41 +- .../Transforms/TransformExtensions.cs | 8 +- .../AffineTransformProcessor{TPixel}.cs | 4 +- .../ProjectiveTransformProcessor{TPixel}.cs | 4 +- .../Transforms/Linear/RotateProcessor.cs | 4 +- .../Transforms/Linear/SkewProcessor.cs | 4 +- .../Processors/Transforms/TransformUtils.cs | 374 ++++++++++-------- .../Processing/ProjectiveTransformBuilder.cs | 56 +-- src/ImageSharp/Processing/TransformSpace.cs | 26 -- .../Transforms/AffineTransformTests.cs | 40 +- .../Transforms/ProjectiveTransformTests.cs | 8 +- .../Processors/Transforms/ResizeTests.cs | 2 +- .../Processors/Transforms/RotateTests.cs | 8 +- .../Transforms/TransformBuilderTestBase.cs | 4 +- tests/ImageSharp.Tests/TestImages.cs | 3 + .../Issue3000_Rgba32_Issue_3000_p-3-3.png | 3 + .../Issue3000_Rgba32_Issue_3000_p-4-4.png | 3 + ...urceRectangle1_Rgba32_TestPattern96x48.png | 4 +- ...gle1_Rgba32_TestPattern96x48__original.png | 3 + ...urceRectangle2_Rgba32_TestPattern96x48.png | 4 +- ...2_TestPattern100x50_R(0)_S(1,2)_T(0,0).png | 4 +- ...2_TestPattern100x50_R(0)_S(2,1)_T(0,0).png | 4 +- ...tPattern100x50_R(50)_S(1,1)_T(-20,-10).png | 4 +- ..._TestPattern100x50_R(50)_S(1,1)_T(0,0).png | 4 +- ...estPattern100x50_R(50)_S(1,1)_T(20,10).png | 4 +- ...ttern100x50_R(50)_S(1.1,1.3)_T(30,-20).png | 4 +- ...tPattern100x50_R(50)_S(1.5,1.5)_T(0,0).png | 4 +- ...d_Rgba32_TestPattern96x96_R(50)_S(0.8).png | 4 +- ...pler_Rgba32_TestPattern150x150_Bicubic.png | 4 +- ...hSampler_Rgba32_TestPattern150x150_Box.png | 4 +- ...r_Rgba32_TestPattern150x150_CatmullRom.png | 4 +- ...pler_Rgba32_TestPattern150x150_Hermite.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos2.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos3.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos5.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos8.png | 4 +- ...2_TestPattern150x150_MitchellNetravali.png | 4 +- ...a32_TestPattern150x150_NearestNeighbor.png | 4 +- ...ler_Rgba32_TestPattern150x150_Robidoux.png | 4 +- ...gba32_TestPattern150x150_RobidouxSharp.png | 4 +- ...mpler_Rgba32_TestPattern150x150_Spline.png | 4 +- ...ler_Rgba32_TestPattern150x150_Triangle.png | 4 +- ...ampler_Rgba32_TestPattern150x150_Welch.png | 4 +- ...sions_Rgba32_TestPattern100x100_0.0001.png | 4 +- ...imensions_Rgba32_TestPattern100x100_57.png | 4 +- .../DrawImageTests/DrawTransformed.png | 4 +- ...X=200, Y=200 ]-PointF [ X=-50, Y=200 ].png | 4 +- ...[ X=150, Y=150 ]-PointF [ X=0, Y=150 ].png | 4 +- ...ntF [ X=0, Y=150 ]-PointF [ X=0, Y=0 ].png | 4 +- ... X=140, Y=210 ]-PointF [ X=15, Y=125 ].png | 4 +- ...pler_Rgba32_TestPattern150x150_Bicubic.png | 4 +- ...hSampler_Rgba32_TestPattern150x150_Box.png | 4 +- ...r_Rgba32_TestPattern150x150_CatmullRom.png | 4 +- ...pler_Rgba32_TestPattern150x150_Hermite.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos2.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos3.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos5.png | 4 +- ...ler_Rgba32_TestPattern150x150_Lanczos8.png | 4 +- ...2_TestPattern150x150_MitchellNetravali.png | 4 +- ...a32_TestPattern150x150_NearestNeighbor.png | 4 +- ...ler_Rgba32_TestPattern150x150_Robidoux.png | 4 +- ...gba32_TestPattern150x150_RobidouxSharp.png | 4 +- ...mpler_Rgba32_TestPattern150x150_Spline.png | 4 +- ...ler_Rgba32_TestPattern150x150_Triangle.png | 4 +- ...ampler_Rgba32_TestPattern150x150_Welch.png | 4 +- ...2_Solid30x30_(255,0,0,255)_Bottom-Both.png | 4 +- ...id30x30_(255,0,0,255)_Bottom-LeftOrTop.png | 4 +- ...x30_(255,0,0,255)_Bottom-RightOrBottom.png | 4 +- ...a32_Solid30x30_(255,0,0,255)_Left-Both.png | 4 +- ...olid30x30_(255,0,0,255)_Left-LeftOrTop.png | 4 +- ...30x30_(255,0,0,255)_Left-RightOrBottom.png | 4 +- ...32_Solid30x30_(255,0,0,255)_Right-Both.png | 4 +- ...lid30x30_(255,0,0,255)_Right-LeftOrTop.png | 4 +- ...0x30_(255,0,0,255)_Right-RightOrBottom.png | 4 +- ...ba32_Solid30x30_(255,0,0,255)_Top-Both.png | 4 +- ...Solid30x30_(255,0,0,255)_Top-LeftOrTop.png | 4 +- ...d30x30_(255,0,0,255)_Top-RightOrBottom.png | 4 +- ...imensions_Rgba32_TestPattern100x100_57.png | 4 +- ...otate_WithAngle_TestPattern100x50_-170.png | 4 +- ...Rotate_WithAngle_TestPattern100x50_-50.png | 4 +- ...Rotate_WithAngle_TestPattern100x50_170.png | 4 +- .../Rotate_WithAngle_TestPattern100x50_50.png | 4 +- ...otate_WithAngle_TestPattern50x100_-170.png | 4 +- ...Rotate_WithAngle_TestPattern50x100_-50.png | 4 +- ...Rotate_WithAngle_TestPattern50x100_170.png | 4 +- .../Rotate_WithAngle_TestPattern50x100_50.png | 4 +- ...lType_Bgra32_TestPattern100x50_-20_-10.png | 4 +- ...xelType_Bgra32_TestPattern100x50_20_10.png | 4 +- ...elType_Rgb24_TestPattern100x50_-20_-10.png | 4 +- ...ixelType_Rgb24_TestPattern100x50_20_10.png | 4 +- ...w_WorksWithAllResamplers_ducky_Bicubic.png | 4 +- .../Skew_WorksWithAllResamplers_ducky_Box.png | 4 +- ...orksWithAllResamplers_ducky_CatmullRom.png | 4 +- ...w_WorksWithAllResamplers_ducky_Hermite.png | 4 +- ..._WorksWithAllResamplers_ducky_Lanczos2.png | 4 +- ..._WorksWithAllResamplers_ducky_Lanczos3.png | 4 +- ..._WorksWithAllResamplers_ducky_Lanczos5.png | 4 +- ..._WorksWithAllResamplers_ducky_Lanczos8.png | 4 +- ...hAllResamplers_ducky_MitchellNetravali.png | 4 +- ...ithAllResamplers_ducky_NearestNeighbor.png | 4 +- ..._WorksWithAllResamplers_ducky_Robidoux.png | 4 +- ...sWithAllResamplers_ducky_RobidouxSharp.png | 4 +- ...ew_WorksWithAllResamplers_ducky_Spline.png | 4 +- ..._WorksWithAllResamplers_ducky_Triangle.png | 4 +- ...kew_WorksWithAllResamplers_ducky_Welch.png | 4 +- tests/Images/Input/Png/issues/issue_3000.png | 3 + 110 files changed, 537 insertions(+), 457 deletions(-) delete mode 100644 src/ImageSharp/Processing/TransformSpace.cs create mode 100644 tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png create mode 100644 tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png create mode 100644 tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48__original.png create mode 100644 tests/Images/Input/Png/issues/issue_3000.png diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index d7932f90b..de4a89813 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -340,18 +340,18 @@ public sealed class ExifProfile : IDeepCloneable if (area.Value?.Length == 4) { RectangleF rectangle = new(area.Value[0], area.Value[1], area.Value[2], area.Value[3]); - if (!TransformUtils.TryGetTransformedRectangle(rectangle, matrix, out Rectangle bounds)) + if (!TransformUtils.TryGetTransformedRectangle(rectangle, matrix, out RectangleF bounds)) { return; } // Ensure the bounds are within the image dimensions. - bounds = Rectangle.Intersect(bounds, new Rectangle(0, 0, width, height)); + bounds = RectangleF.Intersect(bounds, new Rectangle(0, 0, width, height)); - area.Value[0] = (ushort)bounds.X; - area.Value[1] = (ushort)bounds.Y; - area.Value[2] = (ushort)bounds.Width; - area.Value[3] = (ushort)bounds.Height; + area.Value[0] = (ushort)MathF.Floor(bounds.X); + area.Value[1] = (ushort)MathF.Floor(bounds.Y); + area.Value[2] = (ushort)MathF.Ceiling(bounds.Width); + area.Value[3] = (ushort)MathF.Ceiling(bounds.Height); this.SetValue(ExifTag.SubjectArea, area.Value); } else diff --git a/src/ImageSharp/Primitives/Point.cs b/src/ImageSharp/Primitives/Point.cs index 8ace7ffac..8627fe980 100644 --- a/src/ImageSharp/Primitives/Point.cs +++ b/src/ImageSharp/Primitives/Point.cs @@ -69,7 +69,7 @@ public struct Point : IEquatable /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); + public readonly bool IsEmpty => this.Equals(Empty); /// /// Creates a with the coordinates of the specified . @@ -239,7 +239,7 @@ public struct Point : IEquatable /// /// The out value for X. /// The out value for Y. - public void Deconstruct(out int x, out int y) + public readonly void Deconstruct(out int x, out int y) { x = this.X; y = this.Y; @@ -268,17 +268,17 @@ public struct Point : IEquatable public void Offset(Point point) => this.Offset(point.X, point.Y); /// - public override int GetHashCode() => HashCode.Combine(this.X, this.Y); + public override readonly int GetHashCode() => HashCode.Combine(this.X, this.Y); /// - public override string ToString() => $"Point [ X={this.X}, Y={this.Y} ]"; + public override readonly string ToString() => $"Point [ X={this.X}, Y={this.Y} ]"; /// - public override bool Equals(object? obj) => obj is Point other && this.Equals(other); + public override readonly bool Equals(object? obj) => obj is Point other && this.Equals(other); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(Point other) => this.X.Equals(other.X) && this.Y.Equals(other.Y); + public readonly bool Equals(Point other) => this.X.Equals(other.X) && this.Y.Equals(other.Y); private static short HighInt16(int n) => unchecked((short)((n >> 16) & 0xffff)); diff --git a/src/ImageSharp/Primitives/PointF.cs b/src/ImageSharp/Primitives/PointF.cs index de363e2bd..35a506bb4 100644 --- a/src/ImageSharp/Primitives/PointF.cs +++ b/src/ImageSharp/Primitives/PointF.cs @@ -58,7 +58,7 @@ public struct PointF : IEquatable /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); + public readonly bool IsEmpty => this.Equals(Empty); /// /// Creates a with the coordinates of the specified . @@ -251,7 +251,7 @@ public struct PointF : IEquatable /// /// The out value for X. /// The out value for Y. - public void Deconstruct(out float x, out float y) + public readonly void Deconstruct(out float x, out float y) { x = this.X; y = this.Y; @@ -277,15 +277,15 @@ public struct PointF : IEquatable public void Offset(PointF point) => this.Offset(point.X, point.Y); /// - public override int GetHashCode() => HashCode.Combine(this.X, this.Y); + public override readonly int GetHashCode() => HashCode.Combine(this.X, this.Y); /// - public override string ToString() => $"PointF [ X={this.X}, Y={this.Y} ]"; + public override readonly string ToString() => $"PointF [ X={this.X}, Y={this.Y} ]"; /// - public override bool Equals(object? obj) => obj is PointF pointF && this.Equals(pointF); + public override readonly bool Equals(object? obj) => obj is PointF pointF && this.Equals(pointF); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(PointF other) => this.X.Equals(other.X) && this.Y.Equals(other.Y); + public readonly bool Equals(PointF other) => this.X.Equals(other.X) && this.Y.Equals(other.Y); } diff --git a/src/ImageSharp/Primitives/SizeF.cs b/src/ImageSharp/Primitives/SizeF.cs index 81c749875..108ea1eed 100644 --- a/src/ImageSharp/Primitives/SizeF.cs +++ b/src/ImageSharp/Primitives/SizeF.cs @@ -67,7 +67,7 @@ public struct SizeF : IEquatable /// Gets a value indicating whether this is empty. /// [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); + public readonly bool IsEmpty => this.Equals(Empty); /// /// Creates a with the coordinates of the specified . @@ -201,24 +201,24 @@ public struct SizeF : IEquatable /// /// The out value for the width. /// The out value for the height. - public void Deconstruct(out float width, out float height) + public readonly void Deconstruct(out float width, out float height) { width = this.Width; height = this.Height; } /// - public override int GetHashCode() => HashCode.Combine(this.Width, this.Height); + public override readonly int GetHashCode() => HashCode.Combine(this.Width, this.Height); /// - public override string ToString() => $"SizeF [ Width={this.Width}, Height={this.Height} ]"; + public override readonly string ToString() => $"SizeF [ Width={this.Width}, Height={this.Height} ]"; /// - public override bool Equals(object? obj) => obj is SizeF && this.Equals((SizeF)obj); + public override readonly bool Equals(object? obj) => obj is SizeF sizeF && this.Equals(sizeF); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(SizeF other) => this.Width.Equals(other.Width) && this.Height.Equals(other.Height); + public readonly bool Equals(SizeF other) => this.Width.Equals(other.Width) && this.Height.Equals(other.Height); /// /// Multiplies by a producing . diff --git a/src/ImageSharp/Processing/AffineTransformBuilder.cs b/src/ImageSharp/Processing/AffineTransformBuilder.cs index 6d1e8aaa5..e330c6c26 100644 --- a/src/ImageSharp/Processing/AffineTransformBuilder.cs +++ b/src/ImageSharp/Processing/AffineTransformBuilder.cs @@ -17,24 +17,9 @@ public class AffineTransformBuilder /// Initializes a new instance of the class. /// public AffineTransformBuilder() - : this(TransformSpace.Pixel) { } - /// - /// Initializes a new instance of the class. - /// - /// - /// The to use when applying the affine transform. - /// - public AffineTransformBuilder(TransformSpace transformSpace) - => this.TransformSpace = transformSpace; - - /// - /// Gets the to use when applying the affine transform. - /// - public TransformSpace TransformSpace { get; } - /// /// Prepends a rotation matrix using the given rotation angle in degrees /// and the image center point as rotation center. @@ -52,7 +37,7 @@ public class AffineTransformBuilder /// The . public AffineTransformBuilder PrependRotationRadians(float radians) => this.Prepend( - size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace)); + size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size)); /// /// Prepends a rotation matrix using the given rotation in degrees at the given origin. @@ -88,7 +73,7 @@ public class AffineTransformBuilder /// The amount of rotation, in radians. /// The . public AffineTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace)); + => this.Append(size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size)); /// /// Appends a rotation matrix using the given rotation in degrees at the given origin. @@ -172,7 +157,7 @@ public class AffineTransformBuilder /// The Y angle, in radians. /// The . public AffineTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace)); + => this.Prepend(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -210,7 +195,7 @@ public class AffineTransformBuilder /// The Y angle, in radians. /// The . public AffineTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace)); + => this.Append(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -344,12 +329,26 @@ public class AffineTransformBuilder /// for linear transforms. /// /// The . - public Size GetTransformedSize(Rectangle sourceRectangle) + public SizeF GetTransformedSize(Rectangle sourceRectangle) { Matrix3x2 matrix = this.BuildMatrix(sourceRectangle); - return TransformUtils.GetTransformedSize(matrix, sourceRectangle.Size, this.TransformSpace); + return GetTransformedSize(sourceRectangle, matrix); } + /// + /// Returns the size of a rectangle large enough to contain the transformed source rectangle. + /// + /// The rectangle in the source image. + /// The transformation matrix. + /// + /// The resultant matrix is degenerate containing one or more values equivalent + /// to or a zero determinant and therefore cannot be used + /// for linear transforms. + /// + /// The . + internal static SizeF GetTransformedSize(Rectangle sourceRectangle, Matrix3x2 matrix) + => TransformUtils.GetRawTransformedSize(matrix, sourceRectangle.Size); + private static void CheckDegenerate(Matrix3x2 matrix) { if (TransformUtils.IsDegenerate(matrix)) diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index 60f90b10f..5857cb435 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -7,8 +7,8 @@ using SixLabors.ImageSharp.Processing.Processors.Transforms; namespace SixLabors.ImageSharp.Processing; /// -/// Defines extensions that allow the application of composable transform operations on an -/// using Mutate/Clone. +/// Defines extensions that allow the application of composable transform operations +/// on an using Mutate/Clone. /// public static class TransformExtensions { @@ -51,7 +51,7 @@ public static class TransformExtensions IResampler sampler) { Matrix3x2 transform = builder.BuildMatrix(sourceRectangle); - Size targetDimensions = builder.GetTransformedSize(sourceRectangle); + Size targetDimensions = TransformUtils.GetTransformedCanvasSize(transform, sourceRectangle.Size); return source.Transform(sourceRectangle, transform, targetDimensions, sampler); } @@ -113,7 +113,7 @@ public static class TransformExtensions IResampler sampler) { Matrix4x4 transform = builder.BuildMatrix(sourceRectangle); - Size targetDimensions = builder.GetTransformedSize(sourceRectangle); + Size targetDimensions = TransformUtils.GetTransformedCanvasSize(transform, sourceRectangle.Size); return source.Transform(sourceRectangle, transform, targetDimensions, sampler); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index 59f5773cf..de9daa2fc 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -77,7 +77,9 @@ internal class AffineTransformProcessor : TransformProcessor, IR return; } - // Convert from screen to world space. + // All matrices are defined in normalized coordinate space so we need to convert to pixel space. + // After normalization we need to invert the matrix for correct sampling. + matrix = TransformUtils.NormalizeToPixel(matrix); Matrix3x2.Invert(matrix, out matrix); if (sampler is NearestNeighborResampler) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs index 1c30fd114..7af627a26 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs @@ -75,7 +75,9 @@ internal class ProjectiveTransformProcessor : TransformProcessor return; } - // Convert from screen to world space. + // All matrices are defined in normalized coordinate space so we need to convert to pixel space. + // After normalization we need to invert the matrix for correct sampling. + matrix = TransformUtils.NormalizeToPixel(matrix); Matrix4x4.Invert(matrix, out matrix); if (sampler is NearestNeighborResampler) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs index 0af2b268a..c745c480d 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs @@ -28,14 +28,14 @@ public sealed class RotateProcessor : AffineTransformProcessor /// The source image size public RotateProcessor(float degrees, IResampler sampler, Size sourceSize) : this( - TransformUtils.CreateRotationTransformMatrixDegrees(degrees, sourceSize, TransformSpace.Pixel), + TransformUtils.CreateRotationTransformMatrixDegrees(degrees, sourceSize), sampler, sourceSize) => this.Degrees = degrees; // Helper constructor private RotateProcessor(Matrix3x2 rotationMatrix, IResampler sampler, Size sourceSize) - : base(rotationMatrix, sampler, TransformUtils.GetTransformedSize(rotationMatrix, sourceSize, TransformSpace.Pixel)) + : base(rotationMatrix, sampler, TransformUtils.GetTransformedCanvasSize(rotationMatrix, sourceSize)) { } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs index 0bbc8e0f6..a5621bc4c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs @@ -30,7 +30,7 @@ public sealed class SkewProcessor : AffineTransformProcessor /// The source image size public SkewProcessor(float degreesX, float degreesY, IResampler sampler, Size sourceSize) : this( - TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, sourceSize, TransformSpace.Pixel), + TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, sourceSize), sampler, sourceSize) { @@ -40,7 +40,7 @@ public sealed class SkewProcessor : AffineTransformProcessor // Helper constructor: private SkewProcessor(Matrix3x2 skewMatrix, IResampler sampler, Size sourceSize) - : base(skewMatrix, sampler, TransformUtils.GetTransformedSize(skewMatrix, sourceSize, TransformSpace.Pixel)) + : base(skewMatrix, sampler, TransformUtils.GetTransformedCanvasSize(skewMatrix, sourceSize)) { } diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs index d25d4f474..6badd949a 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs @@ -80,79 +80,69 @@ internal static class TransformUtils } /// - /// Creates a centered rotation transform matrix using the given rotation in degrees and the source size. + /// Creates a centered rotation transform matrix using the given rotation in degrees and The original source size. /// /// The amount of rotation, in degrees. /// The source image size. - /// The to use when creating the centered matrix. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateRotationTransformMatrixDegrees(float degrees, Size size, TransformSpace transformSpace) - => CreateRotationTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degrees), size, transformSpace); + public static Matrix3x2 CreateRotationTransformMatrixDegrees(float degrees, Size size) + => CreateRotationTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degrees), size); /// - /// Creates a centered rotation transform matrix using the given rotation in radians and the source size. + /// Creates a centered rotation transform matrix using the given rotation in radians and The original source size. /// /// The amount of rotation, in radians. /// The source image size. - /// The to use when creating the centered matrix. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateRotationTransformMatrixRadians(float radians, Size size, TransformSpace transformSpace) - => CreateCenteredTransformMatrix(Matrix3x2Extensions.CreateRotation(radians, PointF.Empty), size, transformSpace); + public static Matrix3x2 CreateRotationTransformMatrixRadians(float radians, Size size) + => CreateCenteredTransformMatrix(Matrix3x2Extensions.CreateRotation(radians, PointF.Empty), size); /// - /// Creates a centered skew transform matrix from the give angles in degrees and the source size. + /// Creates a centered skew transform matrix from the give angles in degrees and The original source size. /// /// The X angle, in degrees. /// The Y angle, in degrees. /// The source image size. - /// The to use when creating the centered matrix. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateSkewTransformMatrixDegrees(float degreesX, float degreesY, Size size, TransformSpace transformSpace) - => CreateSkewTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), size, transformSpace); + public static Matrix3x2 CreateSkewTransformMatrixDegrees(float degreesX, float degreesY, Size size) + => CreateSkewTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), size); /// - /// Creates a centered skew transform matrix from the give angles in radians and the source size. + /// Creates a centered skew transform matrix from the give angles in radians and The original source size. /// /// The X angle, in radians. /// The Y angle, in radians. /// The source image size. - /// The to use when creating the centered matrix. /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateSkewTransformMatrixRadians(float radiansX, float radiansY, Size size, TransformSpace transformSpace) - => CreateCenteredTransformMatrix(Matrix3x2Extensions.CreateSkew(radiansX, radiansY, PointF.Empty), size, transformSpace); + public static Matrix3x2 CreateSkewTransformMatrixRadians(float radiansX, float radiansY, Size size) + => CreateCenteredTransformMatrix(Matrix3x2Extensions.CreateSkew(radiansX, radiansY, PointF.Empty), size); /// /// Gets the centered transform matrix based upon the source rectangle. /// /// The transformation matrix. /// The source image size. - /// - /// The to use when creating the centered matrix. - /// /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateCenteredTransformMatrix(Matrix3x2 matrix, Size size, TransformSpace transformSpace) + public static Matrix3x2 CreateCenteredTransformMatrix(Matrix3x2 matrix, Size size) { - Size transformSize = GetUnboundedTransformedSize(matrix, size, transformSpace); - - // We invert the matrix to handle the transformation from screen to world space. - // This ensures scaling matrices are correct. - Matrix3x2.Invert(matrix, out Matrix3x2 inverted); + // 1) Unbounded size. + SizeF ts = GetRawTransformedSize(matrix, size); - // The source size is provided using the coordinate space of the source image. - // however the transform should always be applied in the pixel space. - // To account for this we offset by the size - 1 to translate to the pixel space. - float offset = transformSpace == TransformSpace.Pixel ? 1F : 0F; + // 2) Invert the content transform for screen->world. + Matrix3x2.Invert(matrix, out Matrix3x2 inv); - Matrix3x2 translationToTargetCenter = Matrix3x2.CreateTranslation(new Vector2(-(transformSize.Width - offset), -(transformSize.Height - offset)) * .5F); - Matrix3x2 translateToSourceCenter = Matrix3x2.CreateTranslation(new Vector2(size.Width - offset, size.Height - offset) * .5F); + // 3) Translate target (canvas) so its center is at the origin, + // translate source so its center is at the origin, then undo the content transform. + Matrix3x2 toTarget = Matrix3x2.CreateTranslation(new Vector2(-ts.Width, -ts.Height) * 0.5f); + Matrix3x2 toSource = Matrix3x2.CreateTranslation(new Vector2(size.Width, size.Height) * 0.5f); - // Translate back to world space. - Matrix3x2.Invert(translationToTargetCenter * inverted * translateToSourceCenter, out Matrix3x2 centered); + // 4) World->screen. + Matrix3x2.Invert(toTarget * inv * toSource, out Matrix3x2 centered); return centered; } @@ -287,7 +277,6 @@ internal static class TransformUtils /// The top-right point of the distorted quad. /// The bottom-right point of the distorted quad. /// The bottom-left point of the distorted quad. - /// The to use when creating the matrix. /// The computed projection matrix for the quad distortion. /// /// This method is based on the algorithm described in the following article: @@ -298,8 +287,7 @@ internal static class TransformUtils PointF topLeft, PointF topRight, PointF bottomRight, - PointF bottomLeft, - TransformSpace transformSpace) + PointF bottomLeft) { PointF p1 = new(rectangle.X, rectangle.Y); PointF p2 = new(rectangle.X + rectangle.Width, rectangle.Y); @@ -345,46 +333,94 @@ internal static class TransformUtils (float)b[2], (float)b[5], 0, 1); #pragma warning restore SA1117 - // Check if the matrix involves only affine transformations by inspecting the relevant components. - // We want to use pixel space for calculations only if the transformation is purely 2D and does not include - // any perspective effects, non-standard scaling, or unusual translations that could distort the image. - if (transformSpace == TransformSpace.Pixel && IsAffineRotationOrSkew(projectionMatrix)) - { - if (projectionMatrix.M41 != 0) - { - projectionMatrix.M41--; - } - - if (projectionMatrix.M42 != 0) - { - projectionMatrix.M42--; - } - } - return projectionMatrix; } /// - /// Returns the size relative to the source for the given transformation matrix. + /// Calculates the size of a destination canvas large enough to contain + /// the fully transformed source content, including any translation offsets. /// /// The transformation matrix. - /// The source size. - /// The to use when calculating the size. - /// The . - public static Size GetTransformedSize(Matrix3x2 matrix, Size size, TransformSpace transformSpace) - => GetTransformedSize(matrix, size, transformSpace, true); + /// The original source size. + /// + /// A representing the dimensions of the destination + /// canvas required to fully contain the transformed source, including + /// any positive or negative translation offsets. + /// + /// + /// + /// This method ensures that the transformed content remains fully visible + /// on the destination canvas by expanding its size to include translations + /// in all directions. + /// + /// + /// It behaves identically to calling + /// with + /// preserveCanvas set to . + /// + /// + /// The resulting canvas size represents the total area required to display + /// the transformed image without clipping, not merely the geometric bounds + /// of the transformed source. + /// + /// + public static Size GetTransformedCanvasSize(Matrix3x2 matrix, Size size) + => Size.Ceiling(GetTransformedSize(matrix, size, true)); /// - /// Returns the size relative to the source for the given transformation matrix. + /// Calculates the size of a destination canvas large enough to contain + /// the fully transformed source content, including any translation offsets. /// /// The transformation matrix. - /// The source size. - /// The used when generating the matrix. + /// The original source size. /// - /// The . + /// A representing the dimensions of the destination + /// canvas required to fully contain the transformed source, including + /// any positive or negative translation offsets. /// + /// + /// + /// This method ensures that the transformed content remains fully visible + /// on the destination canvas by expanding its size to include translations + /// in all directions. + /// + /// + /// It behaves identically to calling + /// with + /// preserveCanvas set to . + /// + /// + /// The resulting canvas size represents the total area required to display + /// the transformed image without clipping, not merely the geometric bounds + /// of the transformed source. + /// + /// + public static Size GetTransformedCanvasSize(Matrix4x4 matrix, Size size) + => Size.Ceiling(GetTransformedSize(matrix, size, true)); + + /// + /// Returns the size relative to the source for the given transformation matrix. + /// + /// The transformation matrix. + /// The original source size. + /// The . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static SizeF GetRawTransformedSize(Matrix4x4 matrix, Size size) + => GetTransformedSize(matrix, size, false); + + /// + /// Returns the size of the transformed source. When is true, + /// the size is expanded to include translation so the full moved content remains visible. + /// + /// The transformation matrix. + /// The original source size. + /// + /// If , expand the size to account for translation (left/up as well as right/down). + /// If , return only the transformed span without translation expansion. + /// + /// The . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size GetTransformedSize(Matrix4x4 matrix, Size size, TransformSpace transformSpace) + private static SizeF GetTransformedSize(Matrix4x4 matrix, Size size, bool preserveCanvas) { Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!"); @@ -393,27 +429,9 @@ internal static class TransformUtils return size; } - // Check if the matrix involves only affine transformations by inspecting the relevant components. - // We want to use pixel space for calculations only if the transformation is purely 2D and does not include - // any perspective effects, non-standard scaling, or unusual translations that could distort the image. - bool usePixelSpace = transformSpace == TransformSpace.Pixel && IsAffineRotationOrSkew(matrix); - - // Define an offset size to translate between pixel space and coordinate space. - // When using pixel space, apply a scaling sensitive offset to translate to discrete pixel coordinates. - // When not using pixel space, use SizeF.Empty as the offset. - - // Compute scaling factors from the matrix - float scaleX = 1F / new Vector2(matrix.M11, matrix.M21).Length(); // sqrt(M11^2 + M21^2) - float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) - - // Apply the offset relative to the scale - SizeF offsetSize = usePixelSpace ? new SizeF(scaleX, scaleY) : SizeF.Empty; - - // Subtract the offset size to translate to the appropriate space (pixel or coordinate). - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size), matrix, out RectangleF bounds)) { - // Add the offset size back to translate the transformed bounds to the correct space. - return Size.Ceiling(ConstrainSize(bounds) + offsetSize); + return preserveCanvas ? GetPreserveCanvasSize(bounds) : bounds.Size; } return size; @@ -438,30 +456,31 @@ internal static class TransformUtils swizzler.Transform(new Point(sourceRectangle.Left, sourceRectangle.Top)), swizzler.Transform(new Point(sourceRectangle.Right, sourceRectangle.Top)), swizzler.Transform(new Point(sourceRectangle.Right, sourceRectangle.Bottom)), - swizzler.Transform(new Point(sourceRectangle.Left, sourceRectangle.Bottom)), - TransformSpace.Pixel); + swizzler.Transform(new Point(sourceRectangle.Left, sourceRectangle.Bottom))); /// /// Returns the size relative to the source for the given transformation matrix. /// /// The transformation matrix. - /// The source size. - /// The to use when calculating the size. + /// The original source size. /// The . - private static Size GetUnboundedTransformedSize(Matrix3x2 matrix, Size size, TransformSpace transformSpace) - => GetTransformedSize(matrix, size, transformSpace, false); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static SizeF GetRawTransformedSize(Matrix3x2 matrix, Size size) + => GetTransformedSize(matrix, size, false); /// - /// Returns the size relative to the source for the given transformation matrix. + /// Returns the size of the transformed source. When is true, + /// the size is expanded to include translation so the full moved content remains visible. /// /// The transformation matrix. - /// The source size. - /// The to use when calculating the size. - /// Whether to constrain the size to ensure that the dimensions are positive. - /// - /// The . - /// - private static Size GetTransformedSize(Matrix3x2 matrix, Size size, TransformSpace transformSpace, bool constrain) + /// The original source size. + /// + /// If , expand the size to account for translation (left/up as well as right/down). + /// If , return only the transformed span without translation expansion. + /// + /// The . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static SizeF GetTransformedSize(Matrix3x2 matrix, Size size, bool preserveCanvas) { Guard.IsTrue(size.Width > 0 && size.Height > 0, nameof(size), "Source size dimensions cannot be 0!"); @@ -470,21 +489,9 @@ internal static class TransformUtils return size; } - // Define an offset size to translate between coordinate space and pixel space. - // Compute scaling factors from the matrix - SizeF offsetSize = SizeF.Empty; - if (transformSpace == TransformSpace.Pixel) - { - float scaleX = 1F / new Vector2(matrix.M11, matrix.M21).Length(); // sqrt(M11^2 + M21^2) - float scaleY = 1F / new Vector2(matrix.M12, matrix.M22).Length(); // sqrt(M12^2 + M22^2) - offsetSize = new SizeF(scaleX, scaleY); - } - - // Subtract the offset size to translate to the pixel space. - if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size - offsetSize), matrix, out Rectangle bounds)) + if (TryGetTransformedRectangle(new RectangleF(Point.Empty, size), matrix, out RectangleF bounds)) { - // Add the offset size back to translate the transformed bounds to the coordinate space. - return Size.Ceiling((constrain ? ConstrainSize(bounds) : bounds.Size) + offsetSize); + return preserveCanvas ? GetPreserveCanvasSize(bounds) : bounds.Size; } return size; @@ -499,7 +506,8 @@ internal static class TransformUtils /// /// if the transformation was successful; otherwise, . /// - private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 matrix, out Rectangle bounds) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix3x2 matrix, out RectangleF bounds) { if (matrix.IsIdentity || rectangle.Equals(default)) { @@ -526,7 +534,7 @@ internal static class TransformUtils /// if the transformation was successful; otherwise, . /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out Rectangle bounds) + internal static bool TryGetTransformedRectangle(RectangleF rectangle, Matrix4x4 matrix, out RectangleF bounds) { if (matrix.IsIdentity || rectangle.Equals(default)) { @@ -543,15 +551,61 @@ internal static class TransformUtils return true; } + /// + /// Calculates the size of a destination canvas large enough to contain the full + /// transformed content of a source rectangle while preserving any translation offsets. + /// + /// + /// The representing the transformed bounds of the source content + /// in destination (output) space. + /// + /// + /// A that describes the canvas dimensions required to fully + /// contain the transformed content while accounting for any positive or negative translation. + /// + /// + /// + /// This method expands the output canvas to ensure that translated content remains visible. + /// + /// + /// If the transformation produces a positive translation, the method extends the canvas + /// on the positive side (right or bottom). + /// If the transformation produces a negative translation (the content moves left or up), + /// the method extends the canvas on the negative side to include that offset. + /// + /// + /// The result is equivalent to taking the union of: + /// + /// + /// The original, untransformed rectangle at the origin [0..Width] × [0..Height]. + /// + /// + /// The translated rectangle defined by . + /// + /// + /// This ensures the entire translated image fits within the resulting canvas, + /// without trimming any portion caused by translation. + /// + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Size ConstrainSize(Rectangle rectangle) + private static SizeF GetPreserveCanvasSize(RectangleF rectangle) { - // We want to resize the canvas here taking into account any translations. - int height = rectangle.Top < 0 ? rectangle.Bottom : Math.Max(rectangle.Height, rectangle.Bottom); - int width = rectangle.Left < 0 ? rectangle.Right : Math.Max(rectangle.Width, rectangle.Right); - - // If location in either direction is translated to a negative value equal to or exceeding the - // dimensions in either direction we need to reassign the dimension. + // Compute the required height. + // If the top is negative, expand upward by that amount (rectangle.Bottom already includes height). + // Otherwise, take the larger of the transformed height or the bottom offset. + float height = rectangle.Top < 0 + ? rectangle.Bottom + : MathF.Max(rectangle.Height, rectangle.Bottom); + + // Compute the required width. + // If the left is negative, expand leftward by that amount (rectangle.Right already includes width). + // Otherwise, take the larger of the transformed width or the right offset. + float width = rectangle.Left < 0 + ? rectangle.Right + : MathF.Max(rectangle.Width, rectangle.Right); + + // Guard: if translation exceeds or cancels dimensions, + // ensure non-zero positive size using the base rectangle dimensions. if (height <= 0) { height = rectangle.Height; @@ -562,63 +616,63 @@ internal static class TransformUtils width = rectangle.Width; } - return new Size(width, height); + // Return the final size that preserves the full visible region of the transformed content. + return new SizeF(width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Rectangle GetBoundingRectangle(Vector2 tl, Vector2 tr, Vector2 bl, Vector2 br) + private static RectangleF GetBoundingRectangle(Vector2 tl, Vector2 tr, Vector2 bl, Vector2 br) { - // Find the minimum and maximum "corners" based on the given vectors float left = MathF.Min(tl.X, MathF.Min(tr.X, MathF.Min(bl.X, br.X))); float top = MathF.Min(tl.Y, MathF.Min(tr.Y, MathF.Min(bl.Y, br.Y))); float right = MathF.Max(tl.X, MathF.Max(tr.X, MathF.Max(bl.X, br.X))); float bottom = MathF.Max(tl.Y, MathF.Max(tr.Y, MathF.Max(bl.Y, br.Y))); - // Clamp the values to the nearest whole pixel. - return Rectangle.FromLTRB( - (int)Math.Floor(left), - (int)Math.Floor(top), - (int)Math.Ceiling(right), - (int)Math.Ceiling(bottom)); + return RectangleF.FromLTRB(left, top, right, bottom); } - private static bool IsAffineRotationOrSkew(Matrix4x4 matrix) + /// + /// Normalizes an affine 2D matrix so that it operates in pixel space. + /// Applies the row-vector conjugation T(+0.5,+0.5) * M * T(-0.5,-0.5) + /// to align the transform with pixel centers. + /// + /// The affine matrix. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Matrix3x2 NormalizeToPixel(Matrix3x2 matrix) { - const float epsilon = 1e-6f; + const float dx = 0.5f, dy = 0.5f; - // Check if the matrix is affine (last column should be [0, 0, 0, 1]) - if (Math.Abs(matrix.M14) > epsilon || - Math.Abs(matrix.M24) > epsilon || - Math.Abs(matrix.M34) > epsilon || - Math.Abs(matrix.M44 - 1f) > epsilon) - { - return false; - } - - // Translation component (M41, m42) are allowed, others are not. - if (Math.Abs(matrix.M43) > epsilon) - { - return false; - } - - // Extract the linear (rotation and skew) part of the matrix - // Upper-left 3x3 matrix - float m11 = matrix.M11, m12 = matrix.M12, m13 = matrix.M13; - float m21 = matrix.M21, m22 = matrix.M22, m23 = matrix.M23; - float m31 = matrix.M31, m32 = matrix.M32, m33 = matrix.M33; + matrix.M31 += (-dx) + ((dx * matrix.M11) + (dy * matrix.M21)); + matrix.M32 += (-dy) + ((dx * matrix.M12) + (dy * matrix.M22)); + return matrix; + } - // Compute the determinant of the linear part - float determinant = (m11 * ((m22 * m33) - (m23 * m32))) - - (m12 * ((m21 * m33) - (m23 * m31))) + - (m13 * ((m21 * m32) - (m22 * m31))); + /// + /// Normalizes a projective 4×4 matrix so that it operates in pixel space. + /// Applies the row-vector conjugation T(+0.5,+0.5,0) * M * T(-0.5,-0.5,0) + /// to align the transform with pixel centers. + /// + /// The projective matrix. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Matrix4x4 NormalizeToPixel(Matrix4x4 matrix) + { + const float dx = 0.5f, dy = 0.5f; - // Check if the determinant is approximately ±1 (no scaling) - if (Math.Abs(Math.Abs(determinant) - 1f) > epsilon) + // Fast path: affine (no perspective) + if (matrix.M14 == 0f && matrix.M24 == 0f && matrix.M34 == 0f && matrix.M44 == 1f) { - return false; + // t' = t + (-d + d·L) + matrix.M41 += (-dx) + ((dx * matrix.M11) + (dy * matrix.M21)); + matrix.M42 += (-dy) + ((dx * matrix.M12) + (dy * matrix.M22)); + return matrix; } - // All checks passed; the matrix represents rotation and/or skew (with possible translation) - return true; + Matrix4x4 tPos = Matrix4x4.Identity; + tPos.M41 = dx; + tPos.M42 = dy; + Matrix4x4 tNeg = Matrix4x4.Identity; + tNeg.M41 = -dx; + tNeg.M42 = -dy; + return tPos * matrix * tNeg; } } diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index 82b897ea5..dc049ef0e 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -17,24 +17,9 @@ public class ProjectiveTransformBuilder /// Initializes a new instance of the class. /// public ProjectiveTransformBuilder() - : this(TransformSpace.Pixel) { } - /// - /// Initializes a new instance of the class. - /// - /// - /// The to use when applying the projective transform. - /// - public ProjectiveTransformBuilder(TransformSpace transformSpace) - => this.TransformSpace = transformSpace; - - /// - /// Gets the to use when applying the projective transform. - /// - public TransformSpace TransformSpace { get; } - /// /// Prepends a matrix that performs a tapering projective transform. /// @@ -69,7 +54,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -87,7 +72,8 @@ public class ProjectiveTransformBuilder /// The rotation origin point. /// The . internal ProjectiveTransformBuilder PrependRotationRadians(float radians, Vector2 origin) - => this.PrependMatrix(Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); + => this.PrependMatrix( + Matrix4x4.CreateRotationZ(radians, new Vector3(origin, 0))); /// /// Appends a centered rotation matrix using the given rotation in degrees. @@ -103,7 +89,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size, this.TransformSpace))); + => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -187,7 +173,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -225,7 +211,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size, this.TransformSpace))); + => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -289,7 +275,11 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder PrependQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Prepend(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new Rectangle(Point.Empty, size), + topLeft, + topRight, + bottomRight, + bottomLeft)); /// /// Appends a quad distortion matrix using the specified corner points. @@ -301,7 +291,11 @@ public class ProjectiveTransformBuilder /// The . public ProjectiveTransformBuilder AppendQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) => this.Append(size => TransformUtils.CreateQuadDistortionMatrix( - new Rectangle(Point.Empty, size), topLeft, topRight, bottomRight, bottomLeft, this.TransformSpace)); + new Rectangle(Point.Empty, size), + topLeft, + topRight, + bottomRight, + bottomLeft)); /// /// Prepends a raw matrix. @@ -383,12 +377,26 @@ public class ProjectiveTransformBuilder /// for linear transforms. /// /// The . - public Size GetTransformedSize(Rectangle sourceRectangle) + public SizeF GetTransformedSize(Rectangle sourceRectangle) { Matrix4x4 matrix = this.BuildMatrix(sourceRectangle); - return TransformUtils.GetTransformedSize(matrix, sourceRectangle.Size, this.TransformSpace); + return GetTransformedSize(sourceRectangle, matrix); } + /// + /// Returns the size of a rectangle large enough to contain the transformed source rectangle. + /// + /// The rectangle in the source image. + /// The transformation matrix. + /// + /// The resultant matrix is degenerate containing one or more values equivalent + /// to or a zero determinant and therefore cannot be used + /// for linear transforms. + /// + /// The . + internal static SizeF GetTransformedSize(Rectangle sourceRectangle, Matrix4x4 matrix) + => TransformUtils.GetRawTransformedSize(matrix, sourceRectangle.Size); + private static void CheckDegenerate(Matrix4x4 matrix) { if (TransformUtils.IsDegenerate(matrix)) diff --git a/src/ImageSharp/Processing/TransformSpace.cs b/src/ImageSharp/Processing/TransformSpace.cs deleted file mode 100644 index bca676bd8..000000000 --- a/src/ImageSharp/Processing/TransformSpace.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -namespace SixLabors.ImageSharp.Processing; - -/// -/// Represents the different spaces used in transformation operations. -/// -public enum TransformSpace -{ - /// - /// Coordinate space is a continuous, mathematical grid where objects and positions - /// are defined with precise, often fractional values. This space allows for fine-grained - /// transformations like scaling, rotation, and translation with high precision. - /// In coordinate space, an image can span from (0,0) to (4,4) for a 4x4 image, including the boundaries. - /// - Coordinate, - - /// - /// Pixel space is a discrete grid where each position corresponds to a specific pixel on the screen. - /// In this space, positions are defined by whole numbers, with no fractional values. - /// A 4x4 image in pixel space covers exactly 4 pixels wide and 4 pixels tall, ranging from (0,0) to (3,3). - /// Pixel space is used when rendering images to ensure that everything aligns with the actual pixels on the screen. - /// - Pixel -} diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs index a7855e23a..941d78c43 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs @@ -234,7 +234,23 @@ public class AffineTransformTests image.DebugSave(provider); Assert.Equal(4, image.Width); - Assert.Equal(8, image.Height); + Assert.Equal(7, image.Height); + } + + [Theory] + [WithFile(TestImages.Png.Issue3000, PixelTypes.Rgba32, 3, 3)] + [WithFile(TestImages.Png.Issue3000, PixelTypes.Rgba32, 4, 4)] + public void Issue3000(TestImageProvider provider, float x, float y) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + image.Mutate(c => c + .Transform(new AffineTransformBuilder().AppendRotationDegrees(90, new Vector2(x, y)))); + + string details = $"p-{x}-{y}"; + image.DebugSave(provider, testOutputDetails: details); + image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: details); } [Theory] @@ -267,31 +283,41 @@ public class AffineTransformTests image.CompareToReferenceOutput(ValidatorComparer, provider, testOutputDetails: radians); } - [Fact] - public void TransformRotationDoesNotOffset() + [Theory] + [WithSolidFilledImages(100, 100, "DimGray", PixelTypes.Rgba32)] + public void TransformRotationDoesNotOffset(TestImageProvider provider) + where TPixel : unmanaged, IPixel { Rgba32 background = Color.DimGray.ToPixel(); - Rgba32 marker = Color.Aqua.ToPixel(); + TPixel marker = Color.Aqua.ToPixel(); + + using Image canvas = provider.GetImage(); - using Image img = new(100, 100, background); + using Image img = canvas.Clone(); img[0, 0] = marker; img.Mutate(c => c.Rotate(180)); Assert.Equal(marker, img[99, 99]); - using Image img2 = new(100, 100, background); + img.DebugSave(provider, "Rotate180"); + + using Image img2 = canvas.Clone(); img2[0, 0] = marker; img2.Mutate( c => c.Transform(new AffineTransformBuilder().AppendRotationDegrees(180), KnownResamplers.NearestNeighbor)); - using Image img3 = new(100, 100, background); + img.DebugSave(provider, "AffineRotate180NN"); + + using Image img3 = canvas.Clone(); img3[0, 0] = marker; img3.Mutate(c => c.Transform(new AffineTransformBuilder().AppendRotationDegrees(180))); + img3.DebugSave(provider, "AffineRotate180Bicubic"); + ImageComparer.Exact.VerifySimilarity(img, img2); ImageComparer.Exact.VerifySimilarity(img, img3); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs index 2e580ea9f..c65f136d6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs @@ -249,17 +249,17 @@ public class ProjectiveTransformTests image.Mutate(ctx => ctx.Transform(builder)); // A 180-degree rotation inverts both axes around the image center. - // The subject location (5, 15) becomes (imageWidth - 5 - 1, imageHeight - 15 - 1) = (94, 84) + // The subject location (5, 15) becomes (imageWidth - 5, imageHeight - 15) = (95, 85) Assert.Equal( - [94, 84], + [95, 85], image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); // The subject area is also mirrored around the center. // New X = imageWidth - originalX - width // New Y = imageHeight - originalY - height - // (5, 15, 50, 50) becomes (44, 34, 50, 50) + // (5, 15, 50, 50) becomes (45, 35, 50, 50) Assert.Equal( - [44, 34, 50, 50], + [45, 35, 50, 50], image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs index 1e0e66965..023d47886 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs @@ -652,7 +652,7 @@ public class ResizeTests image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); Assert.Equal( - [2, 7, 11, 11], + [2, 7, 10, 10], image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } } diff --git a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs index dfa263fec..5eee7313d 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs @@ -55,17 +55,17 @@ public class RotateTests image.Mutate(ctx => ctx.Rotate(180)); // A 180-degree rotation inverts both axes around the image center. - // The subject location (5, 15) becomes (imageWidth - 5 - 1, imageHeight - 15 - 1) = (94, 84) + // The subject location (5, 15) becomes (imageWidth - 5, imageHeight - 15) = (95, 85) Assert.Equal( - [94, 84], + [95, 85], image.Metadata.ExifProfile.GetValue(ExifTag.SubjectLocation).Value); // The subject area is also mirrored around the center. // New X = imageWidth - originalX - width // New Y = imageHeight - originalY - height - // (5, 15, 50, 50) becomes (44, 34, 50, 50) + // (5, 15, 50, 50) becomes (45, 35, 50, 50) Assert.Equal( - [44, 34, 50, 50], + [45, 35, 50, 50], image.Metadata.ExifProfile.GetValue(ExifTag.SubjectArea).Value); } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index 5caf071ac..f5aa1715f 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -98,7 +98,7 @@ public abstract class TransformBuilderTestBase this.AppendRotationDegrees(builder, degrees); // TODO: We should also test CreateRotationMatrixDegrees() (and all TransformUtils stuff!) for correctness - Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size, TransformSpace.Pixel); + Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size); Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); @@ -152,7 +152,7 @@ public abstract class TransformBuilderTestBase this.AppendSkewDegrees(builder, degreesX, degreesY); - Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size, TransformSpace.Pixel); + Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size); Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index af6148c87..157cb379c 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -163,6 +163,9 @@ public static class TestImages // Issue 2924: https://github.com/SixLabors/ImageSharp/issues/2924 public const string Issue2924 = "Png/issues/Issue_2924.png"; + // Issue 3000: htps://github.com/SixLabors/ImageSharp/issues/3000 + public const string Issue3000 = "Png/issues/Issue_3000.png"; + public static class Bad { public const string MissingDataChunk = "Png/xdtn0g01.png"; diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png new file mode 100644 index 000000000..385ac042c --- /dev/null +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d75205909d532dc98da52389c804ff99cb3b796b5657afb521659fe221c2b8f0 +size 122 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png new file mode 100644 index 000000000..ef4aa03b9 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a75beaec77378de4abb09317afa56b8e99ecba0d1c8571cad31aa790afb1a687 +size 123 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48.png index 53ac0ff89..7fad1fcba 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbe1ffaf7b801fd92724438cc810fd0c5506e0a907b970c4f0bf5bec3627ca2a -size 551 +oid sha256:60b050406fda4ff347660e71cb28a9dfceb4b39532f62ee96cb61d2671d3cf00 +size 340 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48__original.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48__original.png new file mode 100644 index 000000000..0d610ae03 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle1_Rgba32_TestPattern96x48__original.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74bf3b8655c7548f28c25b1e467992f691dc429f4b06e85cfd04a3b541825811 +size 478 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle2_Rgba32_TestPattern96x48.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle2_Rgba32_TestPattern96x48.png index 2480164d6..b22cbb019 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle2_Rgba32_TestPattern96x48.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_FromSourceRectangle2_Rgba32_TestPattern96x48.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b45933471a1af1b6d4112240e1bc6b6187065a872043ddbf917200ce9e8cc84b -size 371 +oid sha256:fbfb3143d96070c58c949e8d1e8d9ddbcf1e7863514489ea2defc65863c84e73 +size 276 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(1,2)_T(0,0).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(1,2)_T(0,0).png index da8e446c0..df64eea18 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(1,2)_T(0,0).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(1,2)_T(0,0).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b66a5f9d8a7f3f2a78b868bec6c7d1deea927b82d81aa6d1677e0461a3920dc9 -size 3800 +oid sha256:120b661bef4adac64d362d8c987b3427cd8140ccac7404d09a16765ba1199434 +size 5191 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(2,1)_T(0,0).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(2,1)_T(0,0).png index 4c45ba8c6..b1e8764c1 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(2,1)_T(0,0).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(0)_S(2,1)_T(0,0).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5fdc46ee866e088e0ec3221145a3d2d954a0bcb6d25cbb4d538978272f34949 -size 4871 +oid sha256:0d668ebe5f8857fd21d7eb9ae86860751a6f3061f6c9f76705ff49216dc07870 +size 6215 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(-20,-10).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(-20,-10).png index 480c07da4..6067f0ccc 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(-20,-10).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(-20,-10).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ae57ca0658b1ffa7aca9031f4ec065ab5a9813fb8a9c5acd221526df6a4f729 -size 9747 +oid sha256:2fb676b3af585e7cbe2efdb893157d5f4e152cf810d0693cafb81596e941e121 +size 9697 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(0,0).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(0,0).png index d1ea99cf9..69f862a5a 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(0,0).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(0,0).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0fced9def2b41cbbf215a49ea6ef6baf4c3c041fd180671eb209db5c6e7177e5 -size 10470 +oid sha256:afe7ddbff155b918a4eff91af31e01100355c146cb9c8a12ab2496da8b22821d +size 10446 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(20,10).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(20,10).png index 227f54651..5b88ba508 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(20,10).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1,1)_T(20,10).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e4cc16c2f1b439f8780dead04db01fed95f8e20b68270ae8e7a988af999e3db -size 10561 +oid sha256:ad76301984e5b54eae374adfe130693667053fbed181847b4c68688fb74c9818 +size 10518 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.1,1.3)_T(30,-20).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.1,1.3)_T(30,-20).png index b93742a85..7f08d0dfd 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.1,1.3)_T(30,-20).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.1,1.3)_T(30,-20).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06e3966550f1c3ae72796e5522f7829cf1f86daca469c479acf49e6fae72e3d0 -size 13227 +oid sha256:fbd57af1fa982f9090f57d820a9b927f894914e5f54774e9cd6fdcfe14e5f761 +size 13139 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.5,1.5)_T(0,0).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.5,1.5)_T(0,0).png index 57c3b02ba..2d4ad649f 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.5,1.5)_T(0,0).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScaleTranslate_Rgba32_TestPattern100x50_R(50)_S(1.5,1.5)_T(0,0).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ce5fefe04cc2a036fddcfcf038901a7a09b4ea5d0621a1e0d3abc8430953ae3 -size 20778 +oid sha256:c4bbc28c203550baf885cefba95c48a3f91dfb5242c09acbf3a8509b7258048e +size 20768 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScale_ManuallyCentered_Rgba32_TestPattern96x96_R(50)_S(0.8).png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScale_ManuallyCentered_Rgba32_TestPattern96x96_R(50)_S(0.8).png index b3bfc7ee5..08182dcfb 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScale_ManuallyCentered_Rgba32_TestPattern96x96_R(50)_S(0.8).png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_RotateScale_ManuallyCentered_Rgba32_TestPattern96x96_R(50)_S(0.8).png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b653c0fe761d351cb15b09f35da578a954d103dea7507e2c1d7c4ebf3bdac49a -size 10943 +oid sha256:566e85b1a527f48c953bcc7bc6c58ebd1fe0b14972c38edd596b025e0dd48624 +size 10940 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png index a295c016d..392d3462f 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a17bb1653cc6d6ecc292ce0670c651bfea032f61c6a0e84636205bde53a86f8 -size 13536 +oid sha256:aa5b0d5de93f26c0a7a03b57a00d4a49cda62f4a4b98b6d374261467c03a8357 +size 13500 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png index 63214687d..56f2a3127 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8970378312c0d479d618e4d5b8da54175c127db517fbe54f9057188d02cc735 -size 4165 +oid sha256:62267d8d56af3e1452f0e25144f2cfe352b88def98af28e819a3a6982040a4ca +size 4102 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png index a295c016d..5919cce39 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a17bb1653cc6d6ecc292ce0670c651bfea032f61c6a0e84636205bde53a86f8 -size 13536 +oid sha256:878d5c53b84af4d133825206a327fd4cd02a43831ecabf5c61c5d89181c5a107 +size 13499 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png index ef37b3e2d..fa01f13cc 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9bbf7ef00f98b410f309b3bf70ce87d3c6455666a26e89cd004744145a10408a -size 12559 +oid sha256:f0aa3c19852632e603ec425aeecc5243d4c6c24a1ac6e3906d29913bf7ead2df +size 12535 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png index 93a0ce6c5..98ad27d78 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f9ab86abad276d58bb029bd8e2c2aaffac5618322788cb3619577c7643e10d2 -size 14223 +oid sha256:ec648c2e8006d478ace4a78d2434a4ef7f10d4a3502468cd8b9e2b1f154620b6 +size 14278 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png index c2ca6bf57..feb217ee9 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:05c4dc9af1fef422fd5ada2fa1459c26253e0fb5e5a13226fa2e7445ece32272 -size 17927 +oid sha256:6cb06152d5a0765ad86e8005d6ddac469914ccced89d5ee37d77e7d030b97c9e +size 17281 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png index ade9a1ccd..fd1cf7e77 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:82b47e1cad2eea417b99a2e4b68a5ba1a6cd6703f360e8402f3dca8b92373ecc -size 18945 +oid sha256:38ea8596a682be0075bb31ed176b1fe04b518eb887235d551a574e338d45880b +size 18869 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png index cf04e2036..619483421 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b15ce5a201ee6b946de485a58d3d8e779b6841457e096b2bd7a92968a122f9af -size 20844 +oid sha256:965f42f021c63a0f2ccc691723c4ad7f92119294aec407c7ffd46a6238c8f268 +size 20792 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png index 6be0fc0ff..7201a5f15 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1622a48b3f4790d66b229ed29acd18504cedf68d0a548832665c28d47ea663b -size 13857 +oid sha256:86f1b9e8f1e38070ce862d87c927313904ceaa9e6080f5acead90e82d164738c +size 13879 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png index 0064e973f..77c61443b 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74df7b82e2148cfc8dae7e05c96009c0d70c09bf39cdc5ef9d727063d2a8cb3f -size 4154 +oid sha256:270f9c2bf5d15fcb21796b3b9eb393e0cc00d9c337036637295ad1efb56781b1 +size 4114 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png index 5dd0c5225..22dc949c3 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cc740ccd76910e384ad84a780591652ac7ee0ea30abf7fd7f5b146f8ff380f07 -size 13991 +oid sha256:d413162a83c223124a2f29f8154e4bdc08d94bd3e15569ec6cffaa13bdda72c8 +size 13953 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png index a6e120e90..3d86b73ab 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ccdc54e814604d4d339f6083091abf852aae65052ceb731af998208faddb5b0b -size 13744 +oid sha256:941ea7b4d1f2c187f58920546e2f19fc275505929439cc389edcc59e652e8787 +size 13777 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png index d32c11d44..060fdc809 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd24e0a52c7743ab7d3ed255e3757c2d5495b3f56198556a157df589b1fb67ca -size 14889 +oid sha256:cc5e6a607ef2343cb74c5227dbc7861840db956951f1fc4703fe53dbccda0974 +size 14808 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png index 72782b0b9..524072160 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:878f1aab39b0b2405498c24146b8f81248b37b974e5ea7882e96174a034b645f -size 12374 +oid sha256:2ac06a9ba2b2c8bef7e0117ac52fbb790101c0f89313dc49feb1f5a1d929ab02 +size 12381 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png index 6cedab729..669aeba9a 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dcc2bf4f7e0ab3d56ee71ac1e1855dababeb2e4ec167fd5dc264efdc9e727328 -size 17027 +oid sha256:ad0f483fa7fda620860858c4f330ba914480fba15d70b408fb1aa3fed52dbfc1 +size 16839 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_0.0001.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_0.0001.png index 7368a3b00..438450e53 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_0.0001.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_0.0001.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c733878f4c0cc6075a01fbe7cb471f8b3e91c2c5eaf89309ea3c073d9cc4921 -size 854 +oid sha256:ba501a7fc32a68f8989965aa6457b3860ec42947e2bcd4526c7570ff743f38fc +size 841 diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png index da66b2676..f7f2101d7 100644 --- a/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png +++ b/tests/Images/External/ReferenceOutput/AffineTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:af872886136893938aee82b1ac73e7a1820666a9a5f4bbf34159c09b3283169a -size 5520 +oid sha256:8265c5b2e8edd5eaf0aeeccf86cac486e7beec581e696d3b4f4cfee8f4be9b2b +size 5554 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawTransformed.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawTransformed.png index 7e693a583..3692f1a1e 100644 --- a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawTransformed.png +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawTransformed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ba180567e820b145a13c9b26db9c777e95126adfe8e8cacec0ffe1060dcfe8d -size 184124 +oid sha256:7f8a4db4facce1d68b363a3b59ea40c9da9fa3c989c736d97a703c84d8230660 +size 184595 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=-50, Y=-50 ]-PointF [ X=200, Y=-50 ]-PointF [ X=200, Y=200 ]-PointF [ X=-50, Y=200 ].png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=-50, Y=-50 ]-PointF [ X=200, Y=-50 ]-PointF [ X=200, Y=200 ]-PointF [ X=-50, Y=200 ].png index 38c603855..fc2f4b0c6 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=-50, Y=-50 ]-PointF [ X=200, Y=-50 ]-PointF [ X=200, Y=200 ]-PointF [ X=-50, Y=200 ].png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=-50, Y=-50 ]-PointF [ X=200, Y=-50 ]-PointF [ X=200, Y=200 ]-PointF [ X=-50, Y=200 ].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:abce6af307a81a8ebac8e502142b00b2615403b5570c8dbe7b6895cfdd1a6d60 -size 66879 +oid sha256:ac986987f25d25ab964a5bef710fe81166cb643d85511906218b4f0e72e9e840 +size 30532 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=0, Y=0 ]-PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ].png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=0, Y=0 ]-PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ].png index f7ea0d006..e0357c3f1 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=0, Y=0 ]-PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ].png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=0, Y=0 ]-PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d4cda265a50aa26711efafdbcd947c9a01eff872611df5298920583f9a3d4224 -size 26458 +oid sha256:e0ada2a4d32a3a757b803dbf08148f113f5d358b31af79a77e97c660ce96c302 +size 1608 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ]-PointF [ X=0, Y=0 ].png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ]-PointF [ X=0, Y=0 ].png index 78c37cc44..18d91fe29 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ]-PointF [ X=0, Y=0 ].png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=150, Y=0 ]-PointF [ X=150, Y=150 ]-PointF [ X=0, Y=150 ]-PointF [ X=0, Y=0 ].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:278a488a858b8eda141493fe00c617eb1f664196853da8341d7e5b7f231ddce4 -size 24645 +oid sha256:ffc30373989ec6857797b460931f011b30baaec633b095b6fc3d8fd5d43c77ec +size 2467 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=25, Y=50 ]-PointF [ X=210, Y=25 ]-PointF [ X=140, Y=210 ]-PointF [ X=15, Y=125 ].png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=25, Y=50 ]-PointF [ X=210, Y=25 ]-PointF [ X=140, Y=210 ]-PointF [ X=15, Y=125 ].png index b4740828d..c1b6694f5 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=25, Y=50 ]-PointF [ X=210, Y=25 ]-PointF [ X=140, Y=210 ]-PointF [ X=15, Y=125 ].png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithQuadDistortion_Rgba32_TestPattern150x150_PointF [ X=25, Y=50 ]-PointF [ X=210, Y=25 ]-PointF [ X=140, Y=210 ]-PointF [ X=15, Y=125 ].png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e03e79e6fab3a9e43041e54640a04c7cc3677709e7d879f9f410cf8afc7547a7 -size 42691 +oid sha256:9828ef0faf1a6709673cfe39028ed4202920d346bcc172bda6683bb3d1d0a7a3 +size 36577 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png index 3826753d5..a515475c9 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Bicubic.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:543dbf5376386bf518830850645d69934e2ca17ab208ce3fd5274a6a172f5206 -size 10951 +oid sha256:6bff913e6e67129325203fae91278ca17407b10d99c4e4f571e6cfe3b5b7f93c +size 10889 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png index f9aa1ffe0..779e437ff 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Box.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d0cf291ebf5d8cebab1cd76e2830e5e2d2e0d9a050f7187da72680ead39110c -size 2757 +oid sha256:54b761b76d03216e7aa6238eee92755c03f7b016bffd1400be66ecf136b29c26 +size 2747 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png index 3826753d5..e165b5f3c 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_CatmullRom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:543dbf5376386bf518830850645d69934e2ca17ab208ce3fd5274a6a172f5206 -size 10951 +oid sha256:16da371a29269dade522b3d602beee8f769723c5712a348d960805b75619376d +size 10889 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png index 2f9109ba3..7d420da8c 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Hermite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:57698b6666029a55edf8bd35a7ba96f68d224988cf01308a3af1c6606ae9d0b1 -size 10174 +oid sha256:b25b190603828131be8d82a27e019353c9bf80dcb38536e325abc5aa065762ed +size 10230 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png index 7dfec7898..96e71e12e 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc7c9da04142a679887c714c43f1838eba0092a869140d234fce3412673207c6 -size 13575 +oid sha256:0cc07a20532c52151388c42d7add4f9749913c4dd7629253400a51d40760df23 +size 13566 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png index 6e3b97f2d..5e04f3fe3 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8b973f41f8afa39b94c71b307b7eb393953e2d083d56e1f0e8f43d6ab1f342a -size 16821 +oid sha256:64aae32ec91233b6a139d2f515db4a3e609fa3ab6c660cb53b05d672e7f70e6f +size 16795 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png index 6986c0391..8206fbdbe 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:122c1501e09516244f0db36e1cca373ff68514a18e84f57ed3072d52d6112e36 -size 17022 +oid sha256:c6167a1fb585b49167f4c8fa1f19111f10c825ea7d41ae4e266680d22b2bb28e +size 17094 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png index 76b53fabf..76aaf324a 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Lanczos8.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12181516bce69c9302f15bba928fd530796449599cb9744a2411cc796788ee3b -size 18066 +oid sha256:131e831cc2e2d8eb4f5860d0e685b31006ab846433e38440b6a85a445aed1a12 +size 17890 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png index ae4242a42..10301fd32 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_MitchellNetravali.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1eb5accc5ada5b963ecef6ac15bfb1845f481e51aef63e06a522ea73bbeab945 -size 11194 +oid sha256:aedcc9342e0b37d60759330f62db446646c31da172e21d931ee8e8451ee720ae +size 11193 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png index efb6a2dee..1f736d040 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_NearestNeighbor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0418f0ea38ec19b407f2b5046d7ff0ed207189ad71db1e50e82c419d83620543 -size 2759 +oid sha256:34f21056cac1ec3f1bd37a6c50466210e7ca7d8263963d2c503535b40e5b31d8 +size 2752 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png index 976be43a3..b5269595c 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Robidoux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1233a9ab2c4b0b17b0248c3d40050c466330c22095287dfbdb8bf7dfbda4ff1f -size 11212 +oid sha256:b4e0cbe71672de45880111fb45c7b544203f67154060fa0707ba9216dfd6d883 +size 11217 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png index 04fb2e87e..81a20c24a 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_RobidouxSharp.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e2912d4e42c7b76d9ff48a49921d6472e351662597d69b88bc3708683c7933e3 -size 11221 +oid sha256:e8208cf34114bc87c6244f83a73e7c9dd4455da2fb6d25c34e32ed2fef3cfc9a +size 11214 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png index b35d68aaf..4edc410d9 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Spline.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51b05c38647e0c1d88cc722e4109a882305073a065d2a27ccd3bee82f727127d -size 11775 +oid sha256:c4ee4328adcc71b1d9b3786ab2c03906aa725fefadd1d521206d5a04af421d8d +size 11711 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png index 64b9c6aba..f5877639e 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Triangle.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b260e816b23a43d7efb7507897ba2f5dbb6a596dd67a5abd4c9a0c005e926ee0 -size 9748 +oid sha256:fbc694ac18a702c127c588bb9184bcc39a01c1b8be5ceecadeaab4477260afec +size 9984 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png index 29b95bf52..49633ed22 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithSampler_Rgba32_TestPattern150x150_Welch.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:50b03d627bb53048f5e56380500f116da4c503f5bb6a1b1d3c0d67ee4256d8f6 -size 15977 +oid sha256:8e85f331d7c4304fcd8ea8788da04982d9a5e43951be642bd7dbacd8907c3151 +size 15784 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-Both.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-Both.png index 54dca2639..65e75b83e 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-Both.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-Both.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96454548849147d7c7f0ca507c8521a7d5eaa7771f9f383cc836858870b52c57 -size 280 +oid sha256:92153056f19a20cc1d6ff65dd36ffd215eb50509cc3544e338e76c8d5665fb27 +size 278 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-LeftOrTop.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-LeftOrTop.png index 41f94c9c7..7a9f2794c 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-LeftOrTop.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-LeftOrTop.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e94d224fdb284b6f1ba21b8caa66174edd7e6a3027f9dd03f4757e08296e6508 -size 212 +oid sha256:0db75a869ae36fbca7f57daa4495f2c16050b226474d203aba98cb8e0766d3fb +size 249 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-RightOrBottom.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-RightOrBottom.png index 49cd1c837..4f01d8c13 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-RightOrBottom.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Bottom-RightOrBottom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d1162be9fa1f31bee8d3cba05c1422a1945621a412be11cce13d376efd5c679c -size 173 +oid sha256:09a80b11d888da121313d5f00ab0ec79ccf7bc49800135aa5eb411bd15fc6b86 +size 204 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-Both.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-Both.png index 59f928178..8985e6476 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-Both.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-Both.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ed262e9b885af773a4a40a4506e678630670e208bf7f9ec10307e943b166bed -size 258 +oid sha256:1ff446c4bb62d4492fc561a9dd48c4c0d95d8f4bcd9bbadf1675b2621baf9fa1 +size 212 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-LeftOrTop.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-LeftOrTop.png index 57ee3dc2f..1f9f0557b 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-LeftOrTop.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-LeftOrTop.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a24f2cfc225d01294b8bbc5ca7d7f1738fb0b79217046eb9edf04e4c4c01851 -size 201 +oid sha256:2d76e8055ddbdaaa8f21117ab5e06d3e7d0f5da9d21dd2a992d82e284f028606 +size 235 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-RightOrBottom.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-RightOrBottom.png index 7e47f43ff..c8c5696b1 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-RightOrBottom.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Left-RightOrBottom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:938186fb3d0f468176988a9530efd22e66241a1361fff027005ec8a8ae323ff3 -size 197 +oid sha256:c7e594fd12ea7863d297d66852d3f80d5d3645636cdd39611c7b6fae068a6dc9 +size 230 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-Both.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-Both.png index 0f756e781..434457ffc 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-Both.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-Both.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4bc4b8ea7e7f10676d8de612fe6bc5144e100b95ff3fe7a1e3d4066a7684ce4d -size 239 +oid sha256:50f7f407d040b1071f7f6fbad96d6cfb2907d87060c671e74f6122ac5d381c30 +size 208 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-LeftOrTop.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-LeftOrTop.png index b2d420886..d3810b9d6 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-LeftOrTop.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-LeftOrTop.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:345337f7dffa48d95251503ee2ae8e91db98b5cbe06b579d73c38a018c781544 -size 182 +oid sha256:f305e35f0f4fac1c099b5d9f0b2775c1bb17f382aba13a068dedff45eda4632d +size 215 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-RightOrBottom.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-RightOrBottom.png index 4f0ad9d04..74d204d7c 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-RightOrBottom.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Right-RightOrBottom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de4e2b71dade9dfb750a2c614a684963d6962958db79145c87fd23d9f0f8c005 -size 180 +oid sha256:c41784431d5a50746f66b3c34e966cb21fa8a088de797825633349cb077b4f97 +size 212 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-Both.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-Both.png index 78bdb8bbb..308fe3454 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-Both.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-Both.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d8b651663366e7543211635f337c229e2f88f1142886ea3a9b69587daaada97 -size 288 +oid sha256:7a6b2c8e072993c00a96692f10c7ebe6fcc6f4cfdcb9dff2d0aa6c65db54e1c4 +size 267 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-LeftOrTop.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-LeftOrTop.png index 7015a0557..6111bcae1 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-LeftOrTop.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-LeftOrTop.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ab8df31f1716c05bb8687f79c7d1154f6cc6f65e3917abe60ecc42d0df173dc -size 215 +oid sha256:018fe6af5dd7ed2edd163bf3da5e22f8333d3e3287629a2065ebfd15b7a2a8b3 +size 256 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-RightOrBottom.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-RightOrBottom.png index 67a765e8d..a0935a1ce 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-RightOrBottom.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_WithTaperMatrix_Rgba32_Solid30x30_(255,0,0,255)_Top-RightOrBottom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a1671da9ea7702a37a866fabfb3ca0d746233ee108594198f23cb563af43ae6 -size 180 +oid sha256:530501bed8301799b68ba3dc8d50c877ed3f58073ab1a8a283e8f776e761cd28 +size 200 diff --git a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png index 4b2bb99d9..81863d3ef 100644 --- a/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png +++ b/tests/Images/External/ReferenceOutput/ProjectiveTransformTests/Transform_With_Custom_Dimensions_Rgba32_TestPattern100x100_57.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e7dedec16ccd66543a1d44052a104957ba62099ba2f2ccc72285c233c2ae3fa -size 4411 +oid sha256:73a18d217d0db5e6ed55cbf52801b7f083e083ca2f0a6ac20d320fd29961e6e0 +size 4399 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-170.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-170.png index 65bb77977..c8b2ee0ce 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-170.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-170.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3594547265b23603b1a76ff6bc6f0eab4af55d6e0070e53356123dfc7ae256f8 -size 9034 +oid sha256:881daeef5b8db99af8b89e7d4e968fb4c43e13c904e936aefa1d0156b767803e +size 9051 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-50.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-50.png index 7c54b1b07..ccd3d8fa5 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-50.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ae9ef073f3338b71d2a40fcf2e89d9b6ab62204d6de9b6a1f75f4705ee197f0 -size 10704 +oid sha256:86032d5b7e49574655c1cd54886ac57d6385714481ba6bd72176d858f884cd1a +size 10720 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_170.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_170.png index b6e930224..30a81a5b9 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_170.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_170.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:994dda7da034595aa77d107652bea06c86077d24ef8a6883b18f1f509bb19928 -size 8906 +oid sha256:cb823498eacf5bab12f7607d230523a3488e26fcc10fe1b3ab51de900a9dff97 +size 8835 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_50.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_50.png index d1ea99cf9..69f862a5a 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_50.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern100x50_50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0fced9def2b41cbbf215a49ea6ef6baf4c3c041fd180671eb209db5c6e7177e5 -size 10470 +oid sha256:afe7ddbff155b918a4eff91af31e01100355c146cb9c8a12ab2496da8b22821d +size 10446 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-170.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-170.png index 2f3f0f17f..b2f18f855 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-170.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-170.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:29c5f48f1ece0b12854b4c44fba84fdfc9ac5751cdf564a32478dcdaed43b2a4 -size 9798 +oid sha256:be885eca2d9771be335a29d3da533a17376efa4c563996ac4cb37138fd1899eb +size 9826 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-50.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-50.png index 5242a9d98..39c4304be 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-50.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7de58474c3f386c4ec31a9088d561a513f82c08d1157132d735169b847b9680 -size 11579 +oid sha256:afea3d7ec03c945d695b3cd85e9ea1d79cb35745256efe1e32273eb08789e5ce +size 11476 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_170.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_170.png index 2af9d2fc2..e98d3115f 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_170.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_170.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ef9b7051d7a5733dfe2534fddefdc28dfbc49d087355f46c4d945b04f0e3936 -size 9672 +oid sha256:096eba716663179933fe6eb526822ac9dedf83c3633d43df328ed33fb16900f6 +size 9687 diff --git a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_50.png b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_50.png index 83c02764f..380b4b7d5 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_50.png +++ b/tests/Images/External/ReferenceOutput/Transforms/RotateTests/Rotate_WithAngle_TestPattern50x100_50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:825770c9b2e9f265d834eab6b40604df5508bf9bc5b4f82f5d3effd6d5a26935 -size 11434 +oid sha256:c7367063704e10827bb81f46ebb56b6fe87a816eb8ec258ca95d8e26d9276f0f +size 11408 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_-20_-10.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_-20_-10.png index d6dba3f88..e8822425d 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_-20_-10.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_-20_-10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e283463b0f450dd72cf303acccf3dd1ff7a31fe401ff0f288d67c4baefca240 -size 8742 +oid sha256:37acdbbcebe56ab98e17b025312e5860c471d807603c2ce6f4a50fd5f219c0f7 +size 8732 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_20_10.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_20_10.png index 76bb244d5..0a798ce06 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_20_10.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Bgra32_TestPattern100x50_20_10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:485d9d9ef955a04af43d17e6bc3952e9bf65a9752b6cf8ba9cbbe8f772f05a18 -size 8995 +oid sha256:722d191e930331e296a548641a80ac163430bdb4017e3d68e4638fbb1d6ed45c +size 9021 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_-20_-10.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_-20_-10.png index c1c1d814f..8d4d2fd9b 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_-20_-10.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_-20_-10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d3d749ac365764051ea16bc39d1aff84c06faf282359805b58bb97c9eed7f0bb -size 6400 +oid sha256:ce2bbe927b718a1b4de05b2baad7016b69490d1b5dfb085420192b7ac6c0ec5d +size 6367 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_20_10.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_20_10.png index 27608881e..2d5fd9e9f 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_20_10.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_IsNotBoundToSinglePixelType_Rgb24_TestPattern100x50_20_10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d82f2a15502b0a29aa4df1077ec90c88f9211f283fdc0edd7b059ed9b387441 -size 6334 +oid sha256:d79a7044e95a1ca032124366e4705bd93a866609547ebb489ff7d2228547cea5 +size 6330 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Bicubic.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Bicubic.png index 340455428..a9de3011d 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Bicubic.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Bicubic.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8e8afa56c5abb0e4b5895f35415db1178d041120d9f8306902f554cfaaada88d -size 26540 +oid sha256:677e4419a1cac8692da2d852f6e169c4a66ef8f164fffa65550fccb71bb54563 +size 26606 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Box.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Box.png index 9ef786692..2ae230ac5 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Box.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Box.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2c174ef54b68f025352e25800f655fe3b94a0d3f75cb48bd2ac0e8d6931faf8 -size 24827 +oid sha256:0f700e854d2d4ee9c12150ef300e0041fa4706ae595eeea6869894a1e2947eaf +size 24963 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_CatmullRom.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_CatmullRom.png index 14f774853..63f5f9959 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_CatmullRom.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_CatmullRom.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b56ceae2f350a1402beecc5b5e2930be1011a95fbf224cccf73b96f3931b646 -size 26531 +oid sha256:965248b773ea4b3f8e870ff598ccf88784dd700d9aa063b70b0146a00fc806bc +size 26613 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Hermite.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Hermite.png index c8204eacf..bf1e06332 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Hermite.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Hermite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:049ee7fc2bb758609a64149c338bfae2eab44755f53e6b7c25a5e8b8725ed8ac -size 24416 +oid sha256:cd8e29141de12f1c1a2b3fb057a58b5a017b6db3498023a8f77dc8ac02d7845c +size 24396 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos2.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos2.png index 2bc57092a..c903716e7 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos2.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:72c487a2fa3d608021b26a4d6b4517f8548fdcfc62fbafdd8649015dbec8ff87 -size 26504 +oid sha256:a28ac3e9bd2edc2aa7163275006f701672cd7f0b92454a0453a6e73387c70138 +size 26611 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos3.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos3.png index fee364e21..5749ec1ac 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos3.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:099733c9d4490c86cfbb10a016e2dd073539a95f9d5ff9018cf9b5be5404fa13 -size 33435 +oid sha256:2a57780c4145cf1eef6028d7e58ef94ab6d47f80a024f43fe98297f2d398a7fc +size 33409 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos5.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos5.png index 30325ccc6..5f98b4184 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos5.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:27f2a2b21f8ae878e15120ea5a4a983bde7984b3468dc8426055885efc278fe6 -size 35547 +oid sha256:129f1770502c71fcbe67da35a6966a4c72e4d17ee70a8e951a5229db99d03089 +size 35607 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos8.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos8.png index ff81256a7..979b0366a 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos8.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Lanczos8.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b5cbe60e26e123e5a5cdf5a4e88305340f76d32a9c64a220c1fa7512f84e786 -size 39442 +oid sha256:0b7a58c5219ce2b6c91f98b7a75a9c89292e69d816451425b9b829d6a2b1711c +size 39420 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_MitchellNetravali.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_MitchellNetravali.png index 263dd7426..6cfbcee61 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_MitchellNetravali.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_MitchellNetravali.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:102cceb79acb1dfd7ec8887b4906e33456c774d48320d1624b3c73975d26f145 -size 25981 +oid sha256:b80944705b204ab37b1a1a0b7d0705fba4f4eae4ea9453ae8ed0e39104765ee9 +size 25836 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_NearestNeighbor.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_NearestNeighbor.png index 9ef786692..2ae230ac5 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_NearestNeighbor.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_NearestNeighbor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2c174ef54b68f025352e25800f655fe3b94a0d3f75cb48bd2ac0e8d6931faf8 -size 24827 +oid sha256:0f700e854d2d4ee9c12150ef300e0041fa4706ae595eeea6869894a1e2947eaf +size 24963 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Robidoux.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Robidoux.png index 85bbd5ec3..8aeed9c8d 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Robidoux.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Robidoux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e61629aeefac7e0a1a6b46b44ad86ed4a5ba0908bb3febc18bb5f9f3ded1c08d -size 25751 +oid sha256:314e15b8d690b17aa67ee856bcaf55afc62ce86c1b1d86b0f17dffe8739a2d17 +size 25739 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_RobidouxSharp.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_RobidouxSharp.png index f200a5f95..e7e2c554b 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_RobidouxSharp.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_RobidouxSharp.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:45b1b48e1df393f4c435189c71a6bd3bccfe7a055d76d414a8d0c009b59fa0a0 -size 26145 +oid sha256:abf063ddd974a8eef6b24da9e58a10143d9fefa29369b11f7b27685312a0c74b +size 26084 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Spline.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Spline.png index 434bb32a8..0d11b5565 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Spline.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Spline.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d6d186f9e547f658b719bc033e3b110d64cf2a02caecc510d4e2f88359e69746 -size 24176 +oid sha256:f417e1771b2a367f857888ae90bd75f9922d9e5fc8826009ded592d9da010a44 +size 24155 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Triangle.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Triangle.png index e3be1ffe5..0f305ddd3 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Triangle.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Triangle.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:339b3299984f1450f1a8200e487964c0338b511b82e459d67a3583d0bd46b805 -size 24013 +oid sha256:6aebe33dad1ea3a709f54f234cb779956f5b561a9a5ecf23a95e7ec42d91c535 +size 23905 diff --git a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Welch.png b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Welch.png index 7dbeeaf35..835d72907 100644 --- a/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Welch.png +++ b/tests/Images/External/ReferenceOutput/Transforms/SkewTests/Skew_WorksWithAllResamplers_ducky_Welch.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5335c6184829fdc405475bd34d2fae60cf6d5ae050b4d671ac5dd25242ff1368 -size 31888 +oid sha256:bb7684478edd471057076a408c6b32102838db466476929ee58e248f5c20a2b2 +size 31872 diff --git a/tests/Images/Input/Png/issues/issue_3000.png b/tests/Images/Input/Png/issues/issue_3000.png new file mode 100644 index 000000000..d7d7ad4c6 --- /dev/null +++ b/tests/Images/Input/Png/issues/issue_3000.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f33e2f343140b01d9c5c913f4ea695748e3a93df145bc0bf2f73763f2d24cadc +size 385 From 24a1972c4d3c1a5f939da5c5d6e7cfbb8251ee8e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 13 Nov 2025 18:22:19 +1000 Subject: [PATCH 043/112] Fix casing --- tests/ImageSharp.Tests/TestImages.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 157cb379c..76475031c 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -164,7 +164,7 @@ public static class TestImages public const string Issue2924 = "Png/issues/Issue_2924.png"; // Issue 3000: htps://github.com/SixLabors/ImageSharp/issues/3000 - public const string Issue3000 = "Png/issues/Issue_3000.png"; + public const string Issue3000 = "Png/issues/issue_3000.png"; public static class Bad { From d8bf8ee810a15f058396026369645c9a6c0b1566 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 13 Nov 2025 18:38:26 +1000 Subject: [PATCH 044/112] Rename files to fix casing --- ...Issue_3000_p-3-3.png => issue3000_Rgba32_issue_3000_p-3-3.png} | 0 ...Issue_3000_p-4-4.png => issue3000_Rgba32_issue_3000_p-4-4.png} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/Images/External/ReferenceOutput/AffineTransformTests/{Issue3000_Rgba32_Issue_3000_p-3-3.png => issue3000_Rgba32_issue_3000_p-3-3.png} (100%) rename tests/Images/External/ReferenceOutput/AffineTransformTests/{Issue3000_Rgba32_Issue_3000_p-4-4.png => issue3000_Rgba32_issue_3000_p-4-4.png} (100%) diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-3-3.png similarity index 100% rename from tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-3-3.png rename to tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-3-3.png diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-4-4.png similarity index 100% rename from tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_Issue_3000_p-4-4.png rename to tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-4-4.png From 6dea233103c50fd6d4464fcfb8b0945dbabdf068 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 13 Nov 2025 18:48:35 +1000 Subject: [PATCH 045/112] Fix the correct pathname part --- ...issue_3000_p-3-3.png => Issue3000_Rgba32_issue_3000_p-3-3.png} | 0 ...issue_3000_p-4-4.png => Issue3000_Rgba32_issue_3000_p-4-4.png} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/Images/External/ReferenceOutput/AffineTransformTests/{issue3000_Rgba32_issue_3000_p-3-3.png => Issue3000_Rgba32_issue_3000_p-3-3.png} (100%) rename tests/Images/External/ReferenceOutput/AffineTransformTests/{issue3000_Rgba32_issue_3000_p-4-4.png => Issue3000_Rgba32_issue_3000_p-4-4.png} (100%) diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-3-3.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_issue_3000_p-3-3.png similarity index 100% rename from tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-3-3.png rename to tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_issue_3000_p-3-3.png diff --git a/tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-4-4.png b/tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_issue_3000_p-4-4.png similarity index 100% rename from tests/Images/External/ReferenceOutput/AffineTransformTests/issue3000_Rgba32_issue_3000_p-4-4.png rename to tests/Images/External/ReferenceOutput/AffineTransformTests/Issue3000_Rgba32_issue_3000_p-4-4.png From e8eb6ba391fa554d21cda809872561a733ca7f3f Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 14 Nov 2025 16:55:43 +0100 Subject: [PATCH 046/112] Add .NET10.0 as TFM --- .github/workflows/build-and-test.yml | 29 +++++++++++++++++-- src/ImageSharp/ImageSharp.csproj | 2 +- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e00757cb7..7737b8daa 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -65,6 +65,31 @@ jobs: isARM: - ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }} options: + - os: ubuntu-latest + framework: net10.0 + sdk: 10.0.x + sdk-preview: true + runtime: -x64 + codecov: false + - os: macos-13 # macos-latest runs on arm64 runners where libgdiplus is unavailable + framework: net10.0 + sdk: 10.0.x + sdk-preview: true + runtime: -x64 + codecov: false + - os: windows-latest + framework: net10.0 + sdk: 10.0.x + sdk-preview: true + runtime: -x64 + codecov: false + - os: buildjet-4vcpu-ubuntu-2204-arm + framework: net10.0 + sdk: 10.0.x + sdk-preview: true + runtime: -x64 + codecov: false + - os: ubuntu-latest framework: net9.0 sdk: 9.0.x @@ -163,14 +188,14 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x + ${{matrix.options.sdk}} - name: DotNet Setup Preview if: ${{ matrix.options.sdk-preview == true }} uses: actions/setup-dotnet@v4 with: dotnet-version: | - 9.0.x + ${{matrix.options.sdk}} - name: DotNet Build if: ${{ matrix.options.sdk-preview != true }} diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index b7629044a..a9a7df50d 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -30,7 +30,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index ce391fad2..627ebea0f 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -12,7 +12,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 From 053aca4eff88a434b48d4be78437832d851f15ae Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 14 Nov 2025 17:13:51 +0100 Subject: [PATCH 047/112] Use 10.0 in build --- .github/workflows/build-and-test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7737b8daa..e5522ee1d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -188,15 +188,16 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - ${{matrix.options.sdk}} + 8.0.x - name: DotNet Setup Preview if: ${{ matrix.options.sdk-preview == true }} uses: actions/setup-dotnet@v4 with: dotnet-version: | - ${{matrix.options.sdk}} - + 9.0.x + 10.0.x + - name: DotNet Build if: ${{ matrix.options.sdk-preview != true }} shell: pwsh From 8bd918aa9632c157e40295f26330e69a342cd4a4 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 14 Nov 2025 17:23:40 +0100 Subject: [PATCH 048/112] Add .NET10.0 in all projects --- tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj | 4 ++-- .../ImageSharp.Tests.ProfilingSandbox.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index c92bb6a6b..004065ee2 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -19,7 +19,7 @@ BenchmarkDotNet requires a certain structure to the code, as such, some of these rules cannot be implemented. --> - + @@ -39,7 +39,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj index 832f3d171..d3187694d 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj +++ b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj @@ -19,7 +19,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 From 6db71cdf4124156ea80fa98fa9e751c6bcdc4995 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 14 Nov 2025 17:31:41 +0100 Subject: [PATCH 049/112] Enable C#14 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 755cbe3b3..c2b11624c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -22,7 +22,7 @@ - 12.0 + 14.0 - + + 12.0 + + + 14.0 From b6937708e5c49aa8f9ac0e5bcac10d1ae54c622b Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 14 Nov 2025 23:47:27 +0100 Subject: [PATCH 051/112] Try fix build error Can not reproduce it locally.. --- .../Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs index 0a9b888ed..c8f46d3aa 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/ICC/DataWriter/IccDataWriterPrimitivesTests.cs @@ -42,7 +42,7 @@ public class IccDataWriterPrimitivesTests byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal([], output); + Assert.Equal(Array.Empty(), output); } [Fact] @@ -62,7 +62,7 @@ public class IccDataWriterPrimitivesTests byte[] output = writer.GetData(); Assert.Equal(0, count); - Assert.Equal([], output); + Assert.Equal(Array.Empty(), output); } [Theory] From c560e321dec10522e2adb81c7f583e03febdcca3 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 15 Nov 2025 10:08:16 +0100 Subject: [PATCH 052/112] Drop .NET9 --- .github/workflows/build-and-test.yml | 28 +------------------ src/ImageSharp/ImageSharp.csproj | 2 +- .../ImageSharp.Benchmarks.csproj | 2 +- .../ImageSharp.Tests.ProfilingSandbox.csproj | 2 +- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 2 +- 5 files changed, 5 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e5522ee1d..818c4566c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -90,31 +90,6 @@ jobs: runtime: -x64 codecov: false - - os: ubuntu-latest - framework: net9.0 - sdk: 9.0.x - sdk-preview: true - runtime: -x64 - codecov: false - - os: macos-13 # macos-latest runs on arm64 runners where libgdiplus is unavailable - framework: net9.0 - sdk: 9.0.x - sdk-preview: true - runtime: -x64 - codecov: false - - os: windows-latest - framework: net9.0 - sdk: 9.0.x - sdk-preview: true - runtime: -x64 - codecov: false - - os: buildjet-4vcpu-ubuntu-2204-arm - framework: net9.0 - sdk: 9.0.x - sdk-preview: true - runtime: -x64 - codecov: false - - os: ubuntu-latest framework: net8.0 sdk: 8.0.x @@ -195,9 +170,8 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 9.0.x 10.0.x - + - name: DotNet Build if: ${{ matrix.options.sdk-preview != true }} shell: pwsh diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index a9a7df50d..2c7172387 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -30,7 +30,7 @@ - net8.0;net9.0;net10.0 + net8.0;net10.0 diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 004065ee2..2628623b4 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -39,7 +39,7 @@ - net8.0;net9.0;net10.0 + net8.0;net10.0 diff --git a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj index d3187694d..bc52610d2 100644 --- a/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj +++ b/tests/ImageSharp.Tests.ProfilingSandbox/ImageSharp.Tests.ProfilingSandbox.csproj @@ -19,7 +19,7 @@ - net8.0;net9.0;net10.0 + net8.0;net10.0 diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 627ebea0f..a1d5b0ee2 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -12,7 +12,7 @@ - net8.0;net9.0;net10.0 + net8.0;net10.0 From 54d2dc2b889678951ffc9f9e329c380a06ecba45 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sat, 15 Nov 2025 10:36:36 +0100 Subject: [PATCH 053/112] Update remoteexecutor --- tests/Directory.Build.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index e20717cdd..8c88ff647 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -25,7 +25,7 @@ See https://github.com/ImageMagick/ImageMagick/commit/27a0a9c37f18af9c8d823a3ea076f600843b553c --> - + From ad4b3e90b24c084a841835dbfefc22353e05fade Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 21:36:15 +0100 Subject: [PATCH 054/112] Update ISA Groups https://github.com/dotnet/runtime/issues/121685#issuecomment-3539194032 --- .../Common/SimdUtilsTests.Shuffle.cs | 10 +-- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 4 +- .../Formats/Jpg/Block8x8FTests.cs | 4 +- .../ImageSharp.Tests/Formats/Jpg/DCTTests.cs | 4 +- .../Formats/Jpg/JpegColorConverterTests.cs | 12 ++-- .../Formats/Png/PngDecoderFilterTests.cs | 2 +- .../Formats/Png/PngEncoderFilterTests.cs | 2 +- .../Formats/Png/PngEncoderTests.cs | 2 +- .../WebP/ColorSpaceTransformUtilsTests.cs | 4 +- .../Formats/WebP/LosslessUtilsTests.cs | 14 ++-- .../Formats/WebP/PredictorEncoderTests.cs | 4 +- .../Formats/WebP/QuantEncTests.cs | 2 +- .../Formats/WebP/Vp8ResidualTests.cs | 2 +- .../Formats/WebP/WebpCommonUtilsTests.cs | 4 +- .../Formats/WebP/YuvConversionTests.cs | 2 +- .../Processors/Convolution/BokehBlurTest.cs | 2 +- .../Processing/Transforms/ResizeTests.cs | 2 +- .../FeatureTesting/FeatureTestRunner.cs | 65 ++++++++--------- .../Tests/FeatureTestRunnerTests.cs | 69 +++---------------- 19 files changed, 80 insertions(+), 130 deletions(-) diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs index ba37ee166..2a7616570 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs @@ -292,7 +292,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); } [Theory] @@ -352,7 +352,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Theory] @@ -394,7 +394,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Theory] @@ -436,7 +436,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Theory] @@ -478,7 +478,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); } private static void TestShuffleFloat4Channel( diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 36b301264..eeaf93645 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -133,7 +133,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE41); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Theory] @@ -171,7 +171,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512BW | HwIntrinsics.DisableAVX2); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index ab205c8a3..e1d4feaa7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -267,7 +267,7 @@ public partial class Block8x8FTests : JpegFixture RunTest, srcSeed, qtSeed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); } [Fact] @@ -462,7 +462,7 @@ public partial class Block8x8FTests : JpegFixture // 3. DisableAvx2 - call fallback code of float implementation FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 062a8a5ee..7d7b05a28 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -152,7 +152,7 @@ public static class DCTTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, seed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableFMA | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -360,7 +360,7 @@ public static class DCTTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, seed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableFMA | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index d58ff9823..5ea9e4d78 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -19,7 +19,7 @@ public class JpegColorConverterTests private const int TestBufferLength = 40; - private const HwIntrinsics IntrinsicsConfig = HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2; + private const HwIntrinsics IntrinsicsConfig = HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2; private static readonly ApproximateColorProfileComparer ColorSpaceComparer = new(epsilon: Precision); @@ -73,7 +73,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -106,7 +106,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -139,7 +139,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -172,7 +172,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -205,7 +205,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512F | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs index 00db13d4b..99406be2f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs @@ -171,7 +171,7 @@ public class PngDecoderFilterTests public void PaethFilter_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.AllowAll); [Fact] - public void PaethFilter_WithoutSsse3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableSSSE3); + public void PaethFilter_WithoutSsse3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableSSE42); [Fact] public void PaethFilter_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableHWIntrinsic); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index a930426b6..736c8b4c0 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -51,7 +51,7 @@ public class PngEncoderFilterTests : MeasureFixture FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSSE3); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index 0d666d8c8..ca01655a0 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -618,7 +618,7 @@ public partial class PngEncoderTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.DisableSSSE3, + HwIntrinsics.DisableSSE42, provider); } diff --git a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs index 66f320143..06249090d 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs @@ -71,7 +71,7 @@ public class ColorSpaceTransformUtilsTests public void CollectColorBlueTransforms_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.AllowAll); [Fact] - public void CollectColorBlueTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableSSE41); + public void CollectColorBlueTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableSSE42); [Fact] public void CollectColorBlueTransforms_WithoutVector256_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableAVX2); @@ -80,7 +80,7 @@ public class ColorSpaceTransformUtilsTests public void CollectColorRedTransforms_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.AllowAll); [Fact] - public void CollectColorRedTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableSSE41); + public void CollectColorRedTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableSSE42); [Fact] public void CollectColorRedTransforms_WithoutVector256_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index 982f0a5d5..d2429e71f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -304,19 +304,19 @@ public class LosslessUtilsTests public void Predictor11_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor11_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.DisableSSE2); + public void Predictor11_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.DisableSSE42); [Fact] public void Predictor12_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor12_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.DisableSSE2); + public void Predictor12_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.DisableSSE42); [Fact] public void Predictor13_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor13_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.DisableSSE2); + public void Predictor13_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.DisableSSE42); [Fact] public void SubtractGreen_Works() => RunSubtractGreenTest(); @@ -331,7 +331,7 @@ public class LosslessUtilsTests public void SubtractGreen_Scalar_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableHWIntrinsic); [Fact] - public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSSE3); + public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); [Fact] public void AddGreenToBlueAndRed_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.AllowAll); @@ -340,13 +340,13 @@ public class LosslessUtilsTests public void AddGreenToBlueAndRed_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2); [Fact] - public void AddGreenToBlueAndRed_WithoutAVX2OrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableSSSE3); + public void AddGreenToBlueAndRed_WithoutAVX2OrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); [Fact] public void TransformColor_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.AllowAll); [Fact] - public void TransformColor_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableSSE2); + public void TransformColor_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableSSE42); [Fact] public void TransformColor_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableAVX2); @@ -355,7 +355,7 @@ public class LosslessUtilsTests public void TransformColorInverse_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.AllowAll); [Fact] - public void TransformColorInverse_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableSSE2); + public void TransformColorInverse_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableSSE42); [Fact] public void TransformColorInverse_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index 23ef8e7b1..4ab1d019b 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -24,7 +24,7 @@ public class PredictorEncoderTests [Fact] public void ColorSpaceTransform_WithPeakImage_WithoutSSE41_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableSSE41); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableSSE42); [Fact] public void ColorSpaceTransform_WithBikeImage_WithHardwareIntrinsics_Works() @@ -32,7 +32,7 @@ public class PredictorEncoderTests [Fact] public void ColorSpaceTransform_WithBikeImage_WithoutSSE41_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableSSE41); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableSSE42); [Fact] public void ColorSpaceTransform_WithBikeImage_WithoutAvx2_Works() diff --git a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs index fc7da8cf6..54a80c29f 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs @@ -45,7 +45,7 @@ public class QuantEncTests public void QuantizeBlock_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.AllowAll); [Fact] - public void QuantizeBlock_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableSSE2); + public void QuantizeBlock_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableSSE42); [Fact] public void QuantizeBlock_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index 62c67c2e0..c00460471 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -252,5 +252,5 @@ public class Vp8ResidualTests public void SetCoeffsTest_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.AllowAll); [Fact] - public void SetCoeffsTest_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.DisableSSE2); + public void SetCoeffsTest_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.DisableSSE42); } diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs index ca1859e54..13a204bce 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs @@ -23,7 +23,7 @@ public class WebpCommonUtilsTests [Fact] public void CheckNonOpaque_WithOpaquePixels_WithoutSse2_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithOpaquePixelsTest, HwIntrinsics.DisableSSE2); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithOpaquePixelsTest, HwIntrinsics.DisableSSE42); [Fact] public void CheckNonOpaque_WithOpaquePixels_WithoutAvx2_Works() @@ -35,7 +35,7 @@ public class WebpCommonUtilsTests [Fact] public void CheckNonOpaque_WithNoneOpaquePixels_WithoutSse2_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.DisableSSE2); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.DisableSSE42); [Fact] public void CheckNonOpaque_WithNoneOpaquePixels_WithoutAvx2_Works() diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index e86642fea..5e34f1221 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -32,7 +32,7 @@ public class YuvConversionTests public void UpSampleYuvToRgb_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.AllowAll); [Fact] - public void UpSampleYuvToRgb_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.DisableSSE2); + public void UpSampleYuvToRgb_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.DisableSSE42); [Theory] [WithFile(TestImages.Webp.Yuv, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index f045c981e..bed2cdbd6 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -148,7 +148,7 @@ public class BokehBlurTest [Theory] [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.AllowAll)] - [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.DisableSSE41)] + [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.DisableSSE42)] public void BokehBlurFilterProcessor_Bounded(TestImageProvider provider, BokehBlurInfo value, HwIntrinsics intrinsicsFilter) { static void RunTest(string arg1, string arg2) diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index 1d445b980..3f2d8e059 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -102,6 +102,6 @@ public class ResizeTests : BaseImageOperationsExtensionTest FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableFMA); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs index 63126dcbc..d3671abd4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs +++ b/tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs @@ -436,37 +436,38 @@ public enum HwIntrinsics : long // Use flags so we can pass multiple values without using params. // Don't base on 0 or use inverse for All as that doesn't translate to string values. DisableHWIntrinsic = 1L << 0, - DisableSSE = 1L << 1, - DisableSSE2 = 1L << 2, - DisableAES = 1L << 3, - DisablePCLMULQDQ = 1L << 4, - DisableSSE3 = 1L << 5, - DisableSSSE3 = 1L << 6, - DisableSSE41 = 1L << 7, - DisableSSE42 = 1L << 8, - DisablePOPCNT = 1L << 9, - DisableAVX = 1L << 10, - DisableFMA = 1L << 11, - DisableAVX2 = 1L << 12, + DisableSSE42 = 1L << 1, + DisableAVX = 1L << 2, + DisableAVX2 = 1L << 3, + DisableAVX512 = 1L << 4, + DisableAVX512v2 = 1L << 5, + DisableAVX512v3 = 1L << 6, + DisableAVX10v1 = 1L << 7, + DisableAVX10v2 = 1L << 8, + DisableAPX = 1L << 9, + DisableAES = 1L << 10, + DisableAVX512VP2INTERSECT = 1L << 11, + DisableAVXIFMA = 1L << 12, DisableAVXVNNI = 1L << 13, - DisableAVX512BW = 1L << 14, - DisableAVX512BW_VL = 1L << 15, - DisableAVX512CD = 1L << 16, - DisableAVX512CD_VL = 1L << 17, - DisableAVX512DQ = 1L << 18, - DisableAVX512DQ_VL = 1L << 19, - DisableAVX512F = 1L << 20, - DisableAVX512F_VL = 1L << 21, - DisableAVX512VBMI = 1L << 22, - DisableAVX512VBMI_VL = 1L << 23, - DisableBMI1 = 1L << 24, - DisableBMI2 = 1L << 25, - DisableLZCNT = 1L << 26, - DisableArm64AdvSimd = 1L << 27, - DisableArm64Crc32 = 1L << 28, - DisableArm64Dp = 1L << 29, - DisableArm64Aes = 1L << 30, - DisableArm64Sha1 = 1L << 31, - DisableArm64Sha256 = 1L << 32, - AllowAll = 1L << 33 + DisableAVXVNNIINT = 1L << 14, + DisableGFNI = 1L << 15, + DisableSHA = 1L << 16, + DisableVAES = 1L << 17, + DisableWAITPKG = 1L << 18, + DisableX86Serialize = 1 << 19, + // Arm64 + DisableArm64Aes = 1L << 20, + DisableArm64Atomics = 1L << 21, + DisableArm64Crc32 = 1L << 22, + DisableArm64Dczva = 1L << 23, + DisableArm64Dp = 1L << 24, + DisableArm64Rdm = 1L << 25, + DisableArm64Sha1 = 1L << 26, + DisableArm64Sha256 = 1L << 27, + DisableArm64Sve = 1L << 28, + DisableArm64Sve2 = 1L << 29, + // RISC-V64 + DisableRiscV64Zba = 1L << 30, + DisableRiscV64Zbb = 1L << 31, + AllowAll = 1L << 32, } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 82b247d9d..363428d04 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -110,54 +110,29 @@ public class FeatureTestRunnerTests Assert.False(Sha1.IsSupported); Assert.False(Sha256.IsSupported); break; - case HwIntrinsics.DisableSSE: - Assert.False(Sse.IsSupported); - break; - case HwIntrinsics.DisableSSE2: - Assert.False(Sse2.IsSupported); - break; case HwIntrinsics.DisableAES: Assert.False(Aes.IsSupported); - break; - case HwIntrinsics.DisablePCLMULQDQ: Assert.False(Pclmulqdq.IsSupported); break; - case HwIntrinsics.DisableSSE3: + case HwIntrinsics.DisableSSE42: + Assert.False(Sse.IsSupported); + Assert.False(Sse2.IsSupported); Assert.False(Sse3.IsSupported); - break; - case HwIntrinsics.DisableSSSE3: Assert.False(Ssse3.IsSupported); - break; - case HwIntrinsics.DisableSSE41: Assert.False(Sse41.IsSupported); - break; - case HwIntrinsics.DisableSSE42: Assert.False(Sse42.IsSupported); - break; - case HwIntrinsics.DisablePOPCNT: Assert.False(Popcnt.IsSupported); break; case HwIntrinsics.DisableAVX: Assert.False(Avx.IsSupported); break; - case HwIntrinsics.DisableFMA: - Assert.False(Fma.IsSupported); - break; case HwIntrinsics.DisableAVX2: Assert.False(Avx2.IsSupported); - break; - case HwIntrinsics.DisableBMI1: + Assert.False(Fma.IsSupported); Assert.False(Bmi1.IsSupported); - break; - case HwIntrinsics.DisableBMI2: Assert.False(Bmi2.IsSupported); - break; - case HwIntrinsics.DisableLZCNT: Assert.False(Lzcnt.IsSupported); break; - case HwIntrinsics.DisableArm64AdvSimd: - Assert.False(AdvSimd.IsSupported); - break; case HwIntrinsics.DisableArm64Aes: Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); break; @@ -194,7 +169,7 @@ public class FeatureTestRunnerTests FeatureTestRunner.RunWithHwIntrinsicsFeature( AssertHwIntrinsicsFeatureDisabled, - HwIntrinsics.DisableSSE, + HwIntrinsics.DisableSSE42, new FakeSerializable()); } @@ -231,54 +206,28 @@ public class FeatureTestRunnerTests Assert.False(Sha1.IsSupported); Assert.False(Sha256.IsSupported); break; - case HwIntrinsics.DisableSSE: - Assert.False(Sse.IsSupported); - break; - case HwIntrinsics.DisableSSE2: - Assert.False(Sse2.IsSupported); - break; case HwIntrinsics.DisableAES: Assert.False(Aes.IsSupported); - break; - case HwIntrinsics.DisablePCLMULQDQ: Assert.False(Pclmulqdq.IsSupported); break; - case HwIntrinsics.DisableSSE3: - Assert.False(Sse3.IsSupported); - break; - case HwIntrinsics.DisableSSSE3: + case HwIntrinsics.DisableSSE42: + Assert.False(Sse.IsSupported); + Assert.False(Sse2.IsSupported); Assert.False(Ssse3.IsSupported); - break; - case HwIntrinsics.DisableSSE41: Assert.False(Sse41.IsSupported); - break; - case HwIntrinsics.DisableSSE42: Assert.False(Sse42.IsSupported); - break; - case HwIntrinsics.DisablePOPCNT: Assert.False(Popcnt.IsSupported); break; case HwIntrinsics.DisableAVX: Assert.False(Avx.IsSupported); break; - case HwIntrinsics.DisableFMA: - Assert.False(Fma.IsSupported); - break; case HwIntrinsics.DisableAVX2: Assert.False(Avx2.IsSupported); - break; - case HwIntrinsics.DisableBMI1: + Assert.False(Fma.IsSupported); Assert.False(Bmi1.IsSupported); - break; - case HwIntrinsics.DisableBMI2: Assert.False(Bmi2.IsSupported); - break; - case HwIntrinsics.DisableLZCNT: Assert.False(Lzcnt.IsSupported); break; - case HwIntrinsics.DisableArm64AdvSimd: - Assert.False(AdvSimd.IsSupported); - break; case HwIntrinsics.DisableArm64Aes: Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); break; From 1d1aa0ae4f1d5a775ab1b49b8ea9f1f0c209f9e8 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 21:48:06 +0100 Subject: [PATCH 055/112] Add usermessages to asserts --- .../TestUtilities/Tests/FeatureTestRunnerTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 363428d04..c6539bbdf 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -115,13 +115,13 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: - Assert.False(Sse.IsSupported); - Assert.False(Sse2.IsSupported); - Assert.False(Sse3.IsSupported); - Assert.False(Ssse3.IsSupported); - Assert.False(Sse41.IsSupported); - Assert.False(Sse42.IsSupported); - Assert.False(Popcnt.IsSupported); + Assert.False(Sse.IsSupported, "Sse should be disabled."); + Assert.False(Sse2.IsSupported, "Sse2 should be disabled."); + Assert.False(Sse3.IsSupported, "Sse3 should be disabled."); + Assert.False(Ssse3.IsSupported, "Ssse3 should be disabled."); + Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); + Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); + Assert.False(Popcnt.IsSupported, "Popcnt should be disabled."); break; case HwIntrinsics.DisableAVX: Assert.False(Avx.IsSupported); From 994c37b35341b2e5c84c0c12f3492e979bf6db5d Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 21:56:25 +0100 Subject: [PATCH 056/112] SSE is not disabled by SSE42 --- .../TestUtilities/Tests/FeatureTestRunnerTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index c6539bbdf..faf723040 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -115,7 +115,6 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: - Assert.False(Sse.IsSupported, "Sse should be disabled."); Assert.False(Sse2.IsSupported, "Sse2 should be disabled."); Assert.False(Sse3.IsSupported, "Sse3 should be disabled."); Assert.False(Ssse3.IsSupported, "Ssse3 should be disabled."); @@ -211,7 +210,6 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: - Assert.False(Sse.IsSupported); Assert.False(Sse2.IsSupported); Assert.False(Ssse3.IsSupported); Assert.False(Sse41.IsSupported); From 330ca36b39d1be162e260ec00be9c255c468f321 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 22:03:46 +0100 Subject: [PATCH 057/112] SSE2 ist not disabled by SSE42 --- .../TestUtilities/Tests/FeatureTestRunnerTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index faf723040..566099664 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -115,7 +115,6 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: - Assert.False(Sse2.IsSupported, "Sse2 should be disabled."); Assert.False(Sse3.IsSupported, "Sse3 should be disabled."); Assert.False(Ssse3.IsSupported, "Ssse3 should be disabled."); Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); @@ -210,7 +209,6 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: - Assert.False(Sse2.IsSupported); Assert.False(Ssse3.IsSupported); Assert.False(Sse41.IsSupported); Assert.False(Sse42.IsSupported); From 6aad0e733eee9403804b5850759318ffa9457246 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 22:14:27 +0100 Subject: [PATCH 058/112] In .net8 there is no grouping --- .../Tests/FeatureTestRunnerTests.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 566099664..1b220ce1b 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -115,21 +115,26 @@ public class FeatureTestRunnerTests Assert.False(Pclmulqdq.IsSupported); break; case HwIntrinsics.DisableSSE42: +#if NET10_0_OR_GREATER Assert.False(Sse3.IsSupported, "Sse3 should be disabled."); Assert.False(Ssse3.IsSupported, "Ssse3 should be disabled."); Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); - Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); Assert.False(Popcnt.IsSupported, "Popcnt should be disabled."); +#else + Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); +#endif break; case HwIntrinsics.DisableAVX: Assert.False(Avx.IsSupported); break; case HwIntrinsics.DisableAVX2: Assert.False(Avx2.IsSupported); +#if NET10_0_OR_GREATER Assert.False(Fma.IsSupported); Assert.False(Bmi1.IsSupported); Assert.False(Bmi2.IsSupported); Assert.False(Lzcnt.IsSupported); +#endif break; case HwIntrinsics.DisableArm64Aes: Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); @@ -206,23 +211,30 @@ public class FeatureTestRunnerTests break; case HwIntrinsics.DisableAES: Assert.False(Aes.IsSupported); +#if NET10_0_OR_GREATER Assert.False(Pclmulqdq.IsSupported); +#endif break; case HwIntrinsics.DisableSSE42: - Assert.False(Ssse3.IsSupported); - Assert.False(Sse41.IsSupported); - Assert.False(Sse42.IsSupported); - Assert.False(Popcnt.IsSupported); +#if NET10_0_OR_GREATER + Assert.False(Sse3.IsSupported, "Sse3 should be disabled."); + Assert.False(Ssse3.IsSupported, "Ssse3 should be disabled."); + Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); + Assert.False(Popcnt.IsSupported, "Popcnt should be disabled."); +#endif + Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); break; case HwIntrinsics.DisableAVX: Assert.False(Avx.IsSupported); break; case HwIntrinsics.DisableAVX2: Assert.False(Avx2.IsSupported); +#if NET10_0_OR_GREATER Assert.False(Fma.IsSupported); Assert.False(Bmi1.IsSupported); Assert.False(Bmi2.IsSupported); Assert.False(Lzcnt.IsSupported); +#endif break; case HwIntrinsics.DisableArm64Aes: Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); From eca4734ad173ee0beb7338257b5c424e2cbaa2f8 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 22:34:45 +0100 Subject: [PATCH 059/112] Add more usermessages --- .../Tests/FeatureTestRunnerTests.cs | 176 +++++++++--------- 1 file changed, 89 insertions(+), 87 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index 1b220ce1b..c9ea4cf39 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -47,7 +47,7 @@ public class FeatureTestRunnerTests } FeatureTestRunner.RunWithHwIntrinsicsFeature( - () => Assert.True(Vector.IsHardwareAccelerated), + () => Assert.True(Vector.IsHardwareAccelerated, "Vector hardware acceleration should be enabled when AllowAll is specified."), HwIntrinsics.AllowAll); } @@ -56,21 +56,21 @@ public class FeatureTestRunnerTests { static void AssertDisabled() { - Assert.False(Sse.IsSupported); - Assert.False(Sse2.IsSupported); - Assert.False(Aes.IsSupported); - Assert.False(Pclmulqdq.IsSupported); - Assert.False(Sse3.IsSupported); - Assert.False(Ssse3.IsSupported); - Assert.False(Sse41.IsSupported); - Assert.False(Sse42.IsSupported); - Assert.False(Popcnt.IsSupported); - Assert.False(Avx.IsSupported); - Assert.False(Fma.IsSupported); - Assert.False(Avx2.IsSupported); - Assert.False(Bmi1.IsSupported); - Assert.False(Bmi2.IsSupported); - Assert.False(Lzcnt.IsSupported); + Assert.False(Sse.IsSupported, "SSE should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse2.IsSupported, "SSE2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Aes.IsSupported, "AES (x86) should be disabled when DisableHWIntrinsic is set."); + Assert.False(Pclmulqdq.IsSupported, "PCLMULQDQ should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse3.IsSupported, "SSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Ssse3.IsSupported, "SSSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse41.IsSupported, "SSE4.1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse42.IsSupported, "SSE4.2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Popcnt.IsSupported, "POPCNT should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx.IsSupported, "AVX should be disabled when DisableHWIntrinsic is set."); + Assert.False(Fma.IsSupported, "FMA should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx2.IsSupported, "AVX2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi1.IsSupported, "BMI1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi2.IsSupported, "BMI2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Lzcnt.IsSupported, "LZCNT should be disabled when DisableHWIntrinsic is set."); } FeatureTestRunner.RunWithHwIntrinsicsFeature( @@ -88,31 +88,33 @@ public class FeatureTestRunnerTests switch (Enum.Parse(intrinsic)) { case HwIntrinsics.DisableHWIntrinsic: - Assert.False(Sse.IsSupported); - Assert.False(Sse2.IsSupported); - Assert.False(Aes.IsSupported); - Assert.False(Pclmulqdq.IsSupported); - Assert.False(Sse3.IsSupported); - Assert.False(Ssse3.IsSupported); - Assert.False(Sse41.IsSupported); - Assert.False(Sse42.IsSupported); - Assert.False(Popcnt.IsSupported); - Assert.False(Avx.IsSupported); - Assert.False(Fma.IsSupported); - Assert.False(Avx2.IsSupported); - Assert.False(Bmi1.IsSupported); - Assert.False(Bmi2.IsSupported); - Assert.False(Lzcnt.IsSupported); - Assert.False(AdvSimd.IsSupported); - Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); - Assert.False(Crc32.IsSupported); - Assert.False(Dp.IsSupported); - Assert.False(Sha1.IsSupported); - Assert.False(Sha256.IsSupported); + Assert.False(Sse.IsSupported, "SSE should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse2.IsSupported, "SSE2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Aes.IsSupported, "AES (x86) should be disabled when DisableHWIntrinsic is set."); + Assert.False(Pclmulqdq.IsSupported, "PCLMULQDQ should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse3.IsSupported, "SSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Ssse3.IsSupported, "SSSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse41.IsSupported, "SSE4.1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse42.IsSupported, "SSE4.2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Popcnt.IsSupported, "POPCNT should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx.IsSupported, "AVX should be disabled when DisableHWIntrinsic is set."); + Assert.False(Fma.IsSupported, "FMA should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx2.IsSupported, "AVX2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi1.IsSupported, "BMI1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi2.IsSupported, "BMI2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Lzcnt.IsSupported, "LZCNT should be disabled when DisableHWIntrinsic is set."); + Assert.False(AdvSimd.IsSupported, "Arm64 AdvSimd should be disabled when DisableHWIntrinsic is set."); + Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported, "Arm64 AES should be disabled when DisableHWIntrinsic is set."); + Assert.False(Crc32.IsSupported, "Arm64 CRC32 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Dp.IsSupported, "Arm64 DotProd (DP) should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sha1.IsSupported, "Arm64 SHA1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sha256.IsSupported, "Arm64 SHA256 should be disabled when DisableHWIntrinsic is set."); break; case HwIntrinsics.DisableAES: - Assert.False(Aes.IsSupported); - Assert.False(Pclmulqdq.IsSupported); + Assert.False(Aes.IsSupported, "AES (x86) should be disabled when DisableAES is set."); +#if NET10_0_OR_GREATER + Assert.False(Pclmulqdq.IsSupported, "PCLMULQDQ should be disabled when DisableAES is set (paired disable)."); +#endif break; case HwIntrinsics.DisableSSE42: #if NET10_0_OR_GREATER @@ -121,35 +123,35 @@ public class FeatureTestRunnerTests Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); Assert.False(Popcnt.IsSupported, "Popcnt should be disabled."); #else - Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); + Assert.False(Sse42.IsSupported, "Sse42 should be disabled when DisableSSE42 is set."); #endif break; case HwIntrinsics.DisableAVX: - Assert.False(Avx.IsSupported); + Assert.False(Avx.IsSupported, "AVX should be disabled when DisableAVX is set."); break; case HwIntrinsics.DisableAVX2: - Assert.False(Avx2.IsSupported); + Assert.False(Avx2.IsSupported, "AVX2 should be disabled when DisableAVX2 is set."); #if NET10_0_OR_GREATER - Assert.False(Fma.IsSupported); - Assert.False(Bmi1.IsSupported); - Assert.False(Bmi2.IsSupported); - Assert.False(Lzcnt.IsSupported); + Assert.False(Fma.IsSupported, "FMA should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Bmi1.IsSupported, "BMI1 should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Bmi2.IsSupported, "BMI2 should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Lzcnt.IsSupported, "LZCNT should be disabled when DisableAVX2 is set (paired disable)."); #endif break; case HwIntrinsics.DisableArm64Aes: - Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); + Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported, "Arm64 AES should be disabled when DisableArm64Aes is set."); break; case HwIntrinsics.DisableArm64Crc32: - Assert.False(Crc32.IsSupported); + Assert.False(Crc32.IsSupported, "Arm64 CRC32 should be disabled when DisableArm64Crc32 is set."); break; case HwIntrinsics.DisableArm64Dp: - Assert.False(Dp.IsSupported); + Assert.False(Dp.IsSupported, "Arm64 DotProd (DP) should be disabled when DisableArm64Dp is set."); break; case HwIntrinsics.DisableArm64Sha1: - Assert.False(Sha1.IsSupported); + Assert.False(Sha1.IsSupported, "Arm64 SHA1 should be disabled when DisableArm64Sha1 is set."); break; case HwIntrinsics.DisableArm64Sha256: - Assert.False(Sha256.IsSupported); + Assert.False(Sha256.IsSupported, "Arm64 SHA256 should be disabled when DisableArm64Sha256 is set."); break; } } @@ -167,7 +169,7 @@ public class FeatureTestRunnerTests { Assert.NotNull(serializable); Assert.NotNull(FeatureTestRunner.DeserializeForXunit(serializable)); - Assert.False(Sse.IsSupported); + Assert.False(Sse.IsSupported, "SSE should be disabled when DisableSSE42 is set (sanity check using serializable param overload)."); } FeatureTestRunner.RunWithHwIntrinsicsFeature( @@ -187,32 +189,32 @@ public class FeatureTestRunnerTests switch (Enum.Parse(intrinsic)) { case HwIntrinsics.DisableHWIntrinsic: - Assert.False(Sse.IsSupported); - Assert.False(Sse2.IsSupported); - Assert.False(Aes.IsSupported); - Assert.False(Pclmulqdq.IsSupported); - Assert.False(Sse3.IsSupported); - Assert.False(Ssse3.IsSupported); - Assert.False(Sse41.IsSupported); - Assert.False(Sse42.IsSupported); - Assert.False(Popcnt.IsSupported); - Assert.False(Avx.IsSupported); - Assert.False(Fma.IsSupported); - Assert.False(Avx2.IsSupported); - Assert.False(Bmi1.IsSupported); - Assert.False(Bmi2.IsSupported); - Assert.False(Lzcnt.IsSupported); - Assert.False(AdvSimd.IsSupported); - Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); - Assert.False(Crc32.IsSupported); - Assert.False(Dp.IsSupported); - Assert.False(Sha1.IsSupported); - Assert.False(Sha256.IsSupported); + Assert.False(Sse.IsSupported, "SSE should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse2.IsSupported, "SSE2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Aes.IsSupported, "AES (x86) should be disabled when DisableHWIntrinsic is set."); + Assert.False(Pclmulqdq.IsSupported, "PCLMULQDQ should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse3.IsSupported, "SSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Ssse3.IsSupported, "SSSE3 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse41.IsSupported, "SSE4.1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sse42.IsSupported, "SSE4.2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Popcnt.IsSupported, "POPCNT should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx.IsSupported, "AVX should be disabled when DisableHWIntrinsic is set."); + Assert.False(Fma.IsSupported, "FMA should be disabled when DisableHWIntrinsic is set."); + Assert.False(Avx2.IsSupported, "AVX2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi1.IsSupported, "BMI1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Bmi2.IsSupported, "BMI2 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Lzcnt.IsSupported, "LZCNT should be disabled when DisableHWIntrinsic is set."); + Assert.False(AdvSimd.IsSupported, "Arm64 AdvSimd should be disabled when DisableHWIntrinsic is set."); + Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported, "Arm64 AES should be disabled when DisableHWIntrinsic is set."); + Assert.False(Crc32.IsSupported, "Arm64 CRC32 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Dp.IsSupported, "Arm64 DotProd (DP) should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sha1.IsSupported, "Arm64 SHA1 should be disabled when DisableHWIntrinsic is set."); + Assert.False(Sha256.IsSupported, "Arm64 SHA256 should be disabled when DisableHWIntrinsic is set."); break; case HwIntrinsics.DisableAES: - Assert.False(Aes.IsSupported); + Assert.False(Aes.IsSupported, "AES (x86) should be disabled when DisableAES is set."); #if NET10_0_OR_GREATER - Assert.False(Pclmulqdq.IsSupported); + Assert.False(Pclmulqdq.IsSupported, "PCLMULQDQ should be disabled when DisableAES is set (paired disable)."); #endif break; case HwIntrinsics.DisableSSE42: @@ -222,34 +224,34 @@ public class FeatureTestRunnerTests Assert.False(Sse41.IsSupported, "Sse41 should be disabled."); Assert.False(Popcnt.IsSupported, "Popcnt should be disabled."); #endif - Assert.False(Sse42.IsSupported, "Sse42 should be disabled."); + Assert.False(Sse42.IsSupported, "Sse42 should be disabled when DisableSSE42 is set."); break; case HwIntrinsics.DisableAVX: - Assert.False(Avx.IsSupported); + Assert.False(Avx.IsSupported, "AVX should be disabled when DisableAVX is set."); break; case HwIntrinsics.DisableAVX2: - Assert.False(Avx2.IsSupported); + Assert.False(Avx2.IsSupported, "AVX2 should be disabled when DisableAVX2 is set."); #if NET10_0_OR_GREATER - Assert.False(Fma.IsSupported); - Assert.False(Bmi1.IsSupported); - Assert.False(Bmi2.IsSupported); - Assert.False(Lzcnt.IsSupported); + Assert.False(Fma.IsSupported, "FMA should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Bmi1.IsSupported, "BMI1 should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Bmi2.IsSupported, "BMI2 should be disabled when DisableAVX2 is set (paired disable)."); + Assert.False(Lzcnt.IsSupported, "LZCNT should be disabled when DisableAVX2 is set (paired disable)."); #endif break; case HwIntrinsics.DisableArm64Aes: - Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported); + Assert.False(System.Runtime.Intrinsics.Arm.Aes.IsSupported, "Arm64 AES should be disabled when DisableArm64Aes is set."); break; case HwIntrinsics.DisableArm64Crc32: - Assert.False(Crc32.IsSupported); + Assert.False(Crc32.IsSupported, "Arm64 CRC32 should be disabled when DisableArm64Crc32 is set."); break; case HwIntrinsics.DisableArm64Dp: - Assert.False(Dp.IsSupported); + Assert.False(Dp.IsSupported, "Arm64 DotProd (DP) should be disabled when DisableArm64Dp is set."); break; case HwIntrinsics.DisableArm64Sha1: - Assert.False(Sha1.IsSupported); + Assert.False(Sha1.IsSupported, "Arm64 SHA1 should be disabled when DisableArm64Sha1 is set."); break; case HwIntrinsics.DisableArm64Sha256: - Assert.False(Sha256.IsSupported); + Assert.False(Sha256.IsSupported, "Arm64 SHA256 should be disabled when DisableArm64Sha256 is set."); break; } } From fd04531820748ac9d024d2004743a45ac3579f2c Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 22:43:35 +0100 Subject: [PATCH 060/112] Check for SSE42 not SSE --- .../TestUtilities/Tests/FeatureTestRunnerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs index c9ea4cf39..ee3d02670 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs @@ -169,7 +169,7 @@ public class FeatureTestRunnerTests { Assert.NotNull(serializable); Assert.NotNull(FeatureTestRunner.DeserializeForXunit(serializable)); - Assert.False(Sse.IsSupported, "SSE should be disabled when DisableSSE42 is set (sanity check using serializable param overload)."); + Assert.False(Sse42.IsSupported, "SSE42 should be disabled when DisableSSE42 is set (sanity check using serializable param overload)."); } FeatureTestRunner.RunWithHwIntrinsicsFeature( From 726794a98f4dac354706d2b3b1dcb24670f31c0e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 17 Nov 2025 11:06:22 +1000 Subject: [PATCH 061/112] Rename helper, fix docs. --- .../Metadata/Profiles/Exif/ExifProfile.cs | 4 ++-- .../Processing/AffineTransformBuilder.cs | 12 +++++------ .../Transforms/TransformExtensions.cs | 4 ++-- .../Linear/AffineTransformProcessor.cs | 2 +- .../AffineTransformProcessor{TPixel}.cs | 2 +- .../Linear/ProjectiveTransformProcessor.cs | 2 +- .../ProjectiveTransformProcessor{TPixel}.cs | 6 +++--- .../Transforms/Linear/RotateProcessor.cs | 4 ++-- .../Transforms/Linear/SkewProcessor.cs | 4 ++-- .../SwizzleProcessor{TSwizzler,TPixel}.cs | 2 +- ...ransformUtils.cs => TransformUtilities.cs} | 10 +++++----- .../Processing/ProjectiveTransformBuilder.cs | 20 +++++++++---------- .../Transforms/TransformBuilderTestBase.cs | 4 ++-- tests/ImageSharp.Tests/TestImages.cs | 2 +- 14 files changed, 39 insertions(+), 39 deletions(-) rename src/ImageSharp/Processing/Processors/Transforms/{TransformUtils.cs => TransformUtilities.cs} (99%) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs index de4a89813..aa2eb29e7 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs @@ -318,7 +318,7 @@ public sealed class ExifProfile : IDeepCloneable { if (location.Value?.Length == 2) { - Vector2 point = TransformUtils.ProjectiveTransform2D(location.Value[0], location.Value[1], matrix); + Vector2 point = TransformUtilities.ProjectiveTransform2D(location.Value[0], location.Value[1], matrix); // Ensure the point is within the image dimensions. point = Vector2.Clamp(point, Vector2.Zero, new Vector2(width - 1, height - 1)); @@ -340,7 +340,7 @@ public sealed class ExifProfile : IDeepCloneable if (area.Value?.Length == 4) { RectangleF rectangle = new(area.Value[0], area.Value[1], area.Value[2], area.Value[3]); - if (!TransformUtils.TryGetTransformedRectangle(rectangle, matrix, out RectangleF bounds)) + if (!TransformUtilities.TryGetTransformedRectangle(rectangle, matrix, out RectangleF bounds)) { return; } diff --git a/src/ImageSharp/Processing/AffineTransformBuilder.cs b/src/ImageSharp/Processing/AffineTransformBuilder.cs index e330c6c26..c1e11a1d4 100644 --- a/src/ImageSharp/Processing/AffineTransformBuilder.cs +++ b/src/ImageSharp/Processing/AffineTransformBuilder.cs @@ -37,7 +37,7 @@ public class AffineTransformBuilder /// The . public AffineTransformBuilder PrependRotationRadians(float radians) => this.Prepend( - size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size)); + size => TransformUtilities.CreateRotationTransformMatrixRadians(radians, size)); /// /// Prepends a rotation matrix using the given rotation in degrees at the given origin. @@ -73,7 +73,7 @@ public class AffineTransformBuilder /// The amount of rotation, in radians. /// The . public AffineTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => TransformUtils.CreateRotationTransformMatrixRadians(radians, size)); + => this.Append(size => TransformUtilities.CreateRotationTransformMatrixRadians(radians, size)); /// /// Appends a rotation matrix using the given rotation in degrees at the given origin. @@ -157,7 +157,7 @@ public class AffineTransformBuilder /// The Y angle, in radians. /// The . public AffineTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); + => this.Prepend(size => TransformUtilities.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -195,7 +195,7 @@ public class AffineTransformBuilder /// The Y angle, in radians. /// The . public AffineTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); + => this.Append(size => TransformUtilities.CreateSkewTransformMatrixRadians(radiansX, radiansY, size)); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -347,11 +347,11 @@ public class AffineTransformBuilder /// /// The . internal static SizeF GetTransformedSize(Rectangle sourceRectangle, Matrix3x2 matrix) - => TransformUtils.GetRawTransformedSize(matrix, sourceRectangle.Size); + => TransformUtilities.GetRawTransformedSize(matrix, sourceRectangle.Size); private static void CheckDegenerate(Matrix3x2 matrix) { - if (TransformUtils.IsDegenerate(matrix)) + if (TransformUtilities.IsDegenerate(matrix)) { throw new DegenerateTransformException("Matrix is degenerate. Check input values."); } diff --git a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs index 5857cb435..dd200013a 100644 --- a/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Transforms/TransformExtensions.cs @@ -51,7 +51,7 @@ public static class TransformExtensions IResampler sampler) { Matrix3x2 transform = builder.BuildMatrix(sourceRectangle); - Size targetDimensions = TransformUtils.GetTransformedCanvasSize(transform, sourceRectangle.Size); + Size targetDimensions = TransformUtilities.GetTransformedCanvasSize(transform, sourceRectangle.Size); return source.Transform(sourceRectangle, transform, targetDimensions, sampler); } @@ -113,7 +113,7 @@ public static class TransformExtensions IResampler sampler) { Matrix4x4 transform = builder.BuildMatrix(sourceRectangle); - Size targetDimensions = TransformUtils.GetTransformedCanvasSize(transform, sourceRectangle.Size); + Size targetDimensions = TransformUtilities.GetTransformedCanvasSize(transform, sourceRectangle.Size); return source.Transform(sourceRectangle, transform, targetDimensions, sampler); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs index 30c279e59..afd1b70b7 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor.cs @@ -21,7 +21,7 @@ public class AffineTransformProcessor : CloningImageProcessor Guard.NotNull(sampler, nameof(sampler)); Guard.MustBeValueType(sampler); - if (TransformUtils.IsDegenerate(matrix)) + if (TransformUtilities.IsDegenerate(matrix)) { throw new DegenerateTransformException("Matrix is degenerate. Check input values."); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs index de9daa2fc..260a366b9 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/AffineTransformProcessor{TPixel}.cs @@ -79,7 +79,7 @@ internal class AffineTransformProcessor : TransformProcessor, IR // All matrices are defined in normalized coordinate space so we need to convert to pixel space. // After normalization we need to invert the matrix for correct sampling. - matrix = TransformUtils.NormalizeToPixel(matrix); + matrix = TransformUtilities.NormalizeToPixel(matrix); Matrix3x2.Invert(matrix, out matrix); if (sampler is NearestNeighborResampler) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs index 9e9507b73..1c457e84c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor.cs @@ -21,7 +21,7 @@ public sealed class ProjectiveTransformProcessor : CloningImageProcessor Guard.NotNull(sampler, nameof(sampler)); Guard.MustBeValueType(sampler); - if (TransformUtils.IsDegenerate(matrix)) + if (TransformUtilities.IsDegenerate(matrix)) { throw new DegenerateTransformException("Matrix is degenerate. Check input values."); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs index 7af627a26..ecf587684 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/ProjectiveTransformProcessor{TPixel}.cs @@ -77,7 +77,7 @@ internal class ProjectiveTransformProcessor : TransformProcessor // All matrices are defined in normalized coordinate space so we need to convert to pixel space. // After normalization we need to invert the matrix for correct sampling. - matrix = TransformUtils.NormalizeToPixel(matrix); + matrix = TransformUtilities.NormalizeToPixel(matrix); Matrix4x4.Invert(matrix, out matrix); if (sampler is NearestNeighborResampler) @@ -137,7 +137,7 @@ internal class ProjectiveTransformProcessor : TransformProcessor for (int x = 0; x < destinationRowSpan.Length; x++) { - Vector2 point = TransformUtils.ProjectiveTransform2D(x, y, this.matrix); + Vector2 point = TransformUtilities.ProjectiveTransform2D(x, y, this.matrix); int px = (int)MathF.Round(point.X); int py = (int)MathF.Round(point.Y); @@ -209,7 +209,7 @@ internal class ProjectiveTransformProcessor : TransformProcessor for (int x = 0; x < span.Length; x++) { - Vector2 point = TransformUtils.ProjectiveTransform2D(x, y, matrix); + Vector2 point = TransformUtilities.ProjectiveTransform2D(x, y, matrix); float pY = point.Y; float pX = point.X; diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs index c745c480d..ea0f1c113 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/RotateProcessor.cs @@ -28,14 +28,14 @@ public sealed class RotateProcessor : AffineTransformProcessor /// The source image size public RotateProcessor(float degrees, IResampler sampler, Size sourceSize) : this( - TransformUtils.CreateRotationTransformMatrixDegrees(degrees, sourceSize), + TransformUtilities.CreateRotationTransformMatrixDegrees(degrees, sourceSize), sampler, sourceSize) => this.Degrees = degrees; // Helper constructor private RotateProcessor(Matrix3x2 rotationMatrix, IResampler sampler, Size sourceSize) - : base(rotationMatrix, sampler, TransformUtils.GetTransformedCanvasSize(rotationMatrix, sourceSize)) + : base(rotationMatrix, sampler, TransformUtilities.GetTransformedCanvasSize(rotationMatrix, sourceSize)) { } diff --git a/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs index a5621bc4c..9c23a9532 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Linear/SkewProcessor.cs @@ -30,7 +30,7 @@ public sealed class SkewProcessor : AffineTransformProcessor /// The source image size public SkewProcessor(float degreesX, float degreesY, IResampler sampler, Size sourceSize) : this( - TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, sourceSize), + TransformUtilities.CreateSkewTransformMatrixDegrees(degreesX, degreesY, sourceSize), sampler, sourceSize) { @@ -40,7 +40,7 @@ public sealed class SkewProcessor : AffineTransformProcessor // Helper constructor: private SkewProcessor(Matrix3x2 skewMatrix, IResampler sampler, Size sourceSize) - : base(skewMatrix, sampler, TransformUtils.GetTransformedCanvasSize(skewMatrix, sourceSize)) + : base(skewMatrix, sampler, TransformUtilities.GetTransformedCanvasSize(skewMatrix, sourceSize)) { } diff --git a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs index 3bec82cce..9acf18730 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SwizzleProcessor{TSwizzler,TPixel}.cs @@ -24,7 +24,7 @@ internal class SwizzleProcessor : TransformProcessor // Calculate the transform matrix from the swizzle operation to allow us // to update any metadata that represents pixel coordinates in the source image. this.transformMatrix = new ProjectiveTransformBuilder() - .AppendMatrix(TransformUtils.GetSwizzlerMatrix(swizzler, sourceRectangle)) + .AppendMatrix(TransformUtilities.GetSwizzlerMatrix(swizzler, sourceRectangle)) .BuildMatrix(sourceRectangle); } diff --git a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs b/src/ImageSharp/Processing/Processors/Transforms/TransformUtilities.cs similarity index 99% rename from src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs rename to src/ImageSharp/Processing/Processors/Transforms/TransformUtilities.cs index 6badd949a..17bdeadde 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/TransformUtils.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/TransformUtilities.cs @@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms; /// /// Contains utility methods for working with transforms. /// -internal static class TransformUtils +internal static class TransformUtilities { /// /// Returns a value that indicates whether the specified matrix is degenerate @@ -80,7 +80,7 @@ internal static class TransformUtils } /// - /// Creates a centered rotation transform matrix using the given rotation in degrees and The original source size. + /// Creates a centered rotation transform matrix using the given rotation in degrees and the original source size. /// /// The amount of rotation, in degrees. /// The source image size. @@ -90,7 +90,7 @@ internal static class TransformUtils => CreateRotationTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degrees), size); /// - /// Creates a centered rotation transform matrix using the given rotation in radians and The original source size. + /// Creates a centered rotation transform matrix using the given rotation in radians and the original source size. /// /// The amount of rotation, in radians. /// The source image size. @@ -100,7 +100,7 @@ internal static class TransformUtils => CreateCenteredTransformMatrix(Matrix3x2Extensions.CreateRotation(radians, PointF.Empty), size); /// - /// Creates a centered skew transform matrix from the give angles in degrees and The original source size. + /// Creates a centered skew transform matrix from the give angles in degrees and the original source size. /// /// The X angle, in degrees. /// The Y angle, in degrees. @@ -111,7 +111,7 @@ internal static class TransformUtils => CreateSkewTransformMatrixRadians(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), size); /// - /// Creates a centered skew transform matrix from the give angles in radians and The original source size. + /// Creates a centered skew transform matrix from the give angles in radians and the original source size. /// /// The X angle, in radians. /// The Y angle, in radians. diff --git a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs index dc049ef0e..e40a307a3 100644 --- a/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs +++ b/src/ImageSharp/Processing/ProjectiveTransformBuilder.cs @@ -28,7 +28,7 @@ public class ProjectiveTransformBuilder /// The amount to taper. /// The . public ProjectiveTransformBuilder PrependTaper(TaperSide side, TaperCorner corner, float fraction) - => this.Prepend(size => TransformUtils.CreateTaperMatrix(size, side, corner, fraction)); + => this.Prepend(size => TransformUtilities.CreateTaperMatrix(size, side, corner, fraction)); /// /// Appends a matrix that performs a tapering projective transform. @@ -38,7 +38,7 @@ public class ProjectiveTransformBuilder /// The amount to taper. /// The . public ProjectiveTransformBuilder AppendTaper(TaperSide side, TaperCorner corner, float fraction) - => this.Append(size => TransformUtils.CreateTaperMatrix(size, side, corner, fraction)); + => this.Append(size => TransformUtilities.CreateTaperMatrix(size, side, corner, fraction)); /// /// Prepends a centered rotation matrix using the given rotation in degrees. @@ -54,7 +54,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder PrependRotationRadians(float radians) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size))); + => this.Prepend(size => new Matrix4x4(TransformUtilities.CreateRotationTransformMatrixRadians(radians, size))); /// /// Prepends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -89,7 +89,7 @@ public class ProjectiveTransformBuilder /// The amount of rotation, in radians. /// The . public ProjectiveTransformBuilder AppendRotationRadians(float radians) - => this.Append(size => new Matrix4x4(TransformUtils.CreateRotationTransformMatrixRadians(radians, size))); + => this.Append(size => new Matrix4x4(TransformUtilities.CreateRotationTransformMatrixRadians(radians, size))); /// /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. @@ -173,7 +173,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder PrependSkewRadians(float radiansX, float radiansY) - => this.Prepend(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); + => this.Prepend(size => new Matrix4x4(TransformUtilities.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); /// /// Prepends a skew matrix using the given angles in degrees at the given origin. @@ -211,7 +211,7 @@ public class ProjectiveTransformBuilder /// The Y angle, in radians. /// The . public ProjectiveTransformBuilder AppendSkewRadians(float radiansX, float radiansY) - => this.Append(size => new Matrix4x4(TransformUtils.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); + => this.Append(size => new Matrix4x4(TransformUtilities.CreateSkewTransformMatrixRadians(radiansX, radiansY, size))); /// /// Appends a skew matrix using the given angles in degrees at the given origin. @@ -274,7 +274,7 @@ public class ProjectiveTransformBuilder /// The bottom-left corner point of the distorted quad. /// The . public ProjectiveTransformBuilder PrependQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) - => this.Prepend(size => TransformUtils.CreateQuadDistortionMatrix( + => this.Prepend(size => TransformUtilities.CreateQuadDistortionMatrix( new Rectangle(Point.Empty, size), topLeft, topRight, @@ -290,7 +290,7 @@ public class ProjectiveTransformBuilder /// The bottom-left corner point of the distorted quad. /// The . public ProjectiveTransformBuilder AppendQuadDistortion(PointF topLeft, PointF topRight, PointF bottomRight, PointF bottomLeft) - => this.Append(size => TransformUtils.CreateQuadDistortionMatrix( + => this.Append(size => TransformUtilities.CreateQuadDistortionMatrix( new Rectangle(Point.Empty, size), topLeft, topRight, @@ -395,11 +395,11 @@ public class ProjectiveTransformBuilder /// /// The . internal static SizeF GetTransformedSize(Rectangle sourceRectangle, Matrix4x4 matrix) - => TransformUtils.GetRawTransformedSize(matrix, sourceRectangle.Size); + => TransformUtilities.GetRawTransformedSize(matrix, sourceRectangle.Size); private static void CheckDegenerate(Matrix4x4 matrix) { - if (TransformUtils.IsDegenerate(matrix)) + if (TransformUtilities.IsDegenerate(matrix)) { throw new DegenerateTransformException("Matrix is degenerate. Check input values."); } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs index f5aa1715f..73215b1c6 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/TransformBuilderTestBase.cs @@ -98,7 +98,7 @@ public abstract class TransformBuilderTestBase this.AppendRotationDegrees(builder, degrees); // TODO: We should also test CreateRotationMatrixDegrees() (and all TransformUtils stuff!) for correctness - Matrix3x2 matrix = TransformUtils.CreateRotationTransformMatrixDegrees(degrees, size); + Matrix3x2 matrix = TransformUtilities.CreateRotationTransformMatrixDegrees(degrees, size); Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); @@ -152,7 +152,7 @@ public abstract class TransformBuilderTestBase this.AppendSkewDegrees(builder, degreesX, degreesY); - Matrix3x2 matrix = TransformUtils.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size); + Matrix3x2 matrix = TransformUtilities.CreateSkewTransformMatrixDegrees(degreesX, degreesY, size); Vector2 position = new(x, y); Vector2 expected = Vector2.Transform(position, matrix); diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 76475031c..94dcd2b7b 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -163,7 +163,7 @@ public static class TestImages // Issue 2924: https://github.com/SixLabors/ImageSharp/issues/2924 public const string Issue2924 = "Png/issues/Issue_2924.png"; - // Issue 3000: htps://github.com/SixLabors/ImageSharp/issues/3000 + // Issue 3000: https://github.com/SixLabors/ImageSharp/issues/3000 public const string Issue3000 = "Png/issues/issue_3000.png"; public static class Bad From 7b4615f70c25dbd831f9d5ec675d5a88b45e28a9 Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Sun, 16 Nov 2025 09:11:25 +0100 Subject: [PATCH 062/112] Add ARM hosted runners Added macos-26 and ubuntu-2204 github runners which run on arm Use Tolerant ImageComparer We now use the tolerant Image Comparer for now. Disable Tests which need libgdiplus This disables all tests which need libgdiplus for macs with arm. The hosted runners do not have libgdiplus installed Install libgdiplus on mac Enable disabled tests on arm Try to create symlink Try without fallback path Skip on linux This was removed by mistake Remove whitespace --- .github/workflows/build-and-test.yml | 27 +++++++++++++++++-- .../Formats/Tiff/TiffDecoderTests.cs | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e00757cb7..3e3d6d0e2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -77,13 +77,19 @@ jobs: sdk-preview: true runtime: -x64 codecov: false + - os: macos-26 + framework: net9.0 + sdk: 9.0.x + sdk-preview: true + runtime: -x64 + codecov: false - os: windows-latest framework: net9.0 sdk: 9.0.x sdk-preview: true runtime: -x64 codecov: false - - os: buildjet-4vcpu-ubuntu-2204-arm + - os: ubuntu-22.04-arm framework: net9.0 sdk: 9.0.x sdk-preview: true @@ -100,12 +106,17 @@ jobs: sdk: 8.0.x runtime: -x64 codecov: false + - os: macos-26 + framework: net8.0 + sdk: 8.0.x + runtime: -x64 + codecov: false - os: windows-latest framework: net8.0 sdk: 8.0.x runtime: -x64 codecov: false - - os: buildjet-4vcpu-ubuntu-2204-arm + - os: ubuntu-22.04-arm framework: net8.0 sdk: 8.0.x runtime: -x64 @@ -124,6 +135,18 @@ jobs: sudo apt-get update sudo apt-get -y install libgdiplus libgif-dev libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev + - name: Install libgdi+, which is required for tests running on macos + if: ${{ contains(matrix.options.os, 'macos-26') }} + run: | + brew update + brew install mono-libgdiplus + # Create symlinks to make libgdiplus discoverable + sudo mkdir -p /usr/local/lib + sudo ln -sf $(brew --prefix)/lib/libgdiplus.dylib /usr/local/lib/libgdiplus.dylib + # Verify installation + ls -la $(brew --prefix)/lib/libgdiplus* || echo "libgdiplus not found in brew prefix" + ls -la /usr/local/lib/libgdiplus* || echo "libgdiplus not found in /usr/local/lib" + - name: Git Config shell: bash run: | diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 26dc4f587..5df730cb1 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -360,7 +360,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester { using Image image = provider.GetImage(TiffDecoder.Instance); image.DebugSave(provider); - image.CompareToReferenceOutput(ImageComparer.Exact, provider); + image.CompareToReferenceOutput(ImageComparer.Tolerant(), provider); } [Theory] From 04f170b3678e068f2ff4c32695512d9fb3b192eb Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 21 Nov 2025 10:48:51 +1000 Subject: [PATCH 063/112] Fix #3009 --- src/ImageSharp/Image.FromBytes.cs | 28 ++++++++++++++++++- src/ImageSharp/Image.LoadPixelData.cs | 5 ++++ .../Image/ImageTests.DetectFormat.cs | 4 +++ .../Image/ImageTests.Identify.cs | 4 +++ ...s.Load_FromBytes_PassLocalConfiguration.cs | 11 ++++++++ ...s.Load_FromBytes_UseGlobalConfiguration.cs | 4 +++ ...ts.Load_FromStream_ThrowsRightException.cs | 13 ++++++++- 7 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 96ef84510..d48065d01 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -34,7 +34,12 @@ public abstract partial class Image /// The encoded image format is unknown. public static unsafe IImageFormat DetectFormat(DecoderOptions options, ReadOnlySpan buffer) { - Guard.NotNull(options, nameof(options.Configuration)); + Guard.NotNull(options, nameof(options)); + + if (buffer.IsEmpty) + { + throw new UnknownImageFormatException("Cannot detect image format from empty data."); + } fixed (byte* ptr = buffer) { @@ -66,6 +71,13 @@ public abstract partial class Image /// The encoded image format is unknown. public static unsafe ImageInfo Identify(DecoderOptions options, ReadOnlySpan buffer) { + Guard.NotNull(options, nameof(options)); + + if (buffer.IsEmpty) + { + throw new UnknownImageFormatException("Cannot identify image format from empty data."); + } + fixed (byte* ptr = buffer) { using UnmanagedMemoryStream stream = new(ptr, buffer.Length); @@ -99,6 +111,13 @@ public abstract partial class Image /// The encoded image format is unknown. public static unsafe Image Load(DecoderOptions options, ReadOnlySpan buffer) { + Guard.NotNull(options, nameof(options)); + + if (buffer.IsEmpty) + { + throw new UnknownImageFormatException("Cannot load image from empty data."); + } + fixed (byte* ptr = buffer) { using UnmanagedMemoryStream stream = new(ptr, buffer.Length); @@ -133,6 +152,13 @@ public abstract partial class Image public static unsafe Image Load(DecoderOptions options, ReadOnlySpan data) where TPixel : unmanaged, IPixel { + Guard.NotNull(options, nameof(options)); + + if (data.IsEmpty) + { + throw new UnknownImageFormatException("Cannot load image from empty data."); + } + fixed (byte* ptr = data) { using UnmanagedMemoryStream stream = new(ptr, data.Length); diff --git a/src/ImageSharp/Image.LoadPixelData.cs b/src/ImageSharp/Image.LoadPixelData.cs index 53b672b7d..efe1b6e2f 100644 --- a/src/ImageSharp/Image.LoadPixelData.cs +++ b/src/ImageSharp/Image.LoadPixelData.cs @@ -69,6 +69,11 @@ public abstract partial class Image { Guard.NotNull(configuration, nameof(configuration)); + if (data.IsEmpty) + { + throw new ArgumentException("Pixel data cannot be empty.", nameof(data)); + } + int count = width * height; Guard.MustBeGreaterThanOrEqualTo(data.Length, count, nameof(data)); diff --git a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs index a1966e2bb..178f5375f 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.DetectFormat.cs @@ -50,6 +50,10 @@ public partial class ImageTests Assert.Equal(this.LocalImageFormat, format); } + [Fact] + public void FromBytes_EmptySpan_Throws() + => Assert.Throws(() => Image.DetectFormat([])); + [Fact] public void FromFileSystemPath_GlobalConfiguration() { diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs index 490fa3b0b..433a1e101 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Identify.cs @@ -38,6 +38,10 @@ public partial class ImageTests Assert.Equal(ExpectedGlobalFormat, info.Metadata.DecodedImageFormat); } + [Fact] + public void FromBytes_EmptySpan_Throws() + => Assert.Throws(() => Image.Identify([])); + [Fact] public void FromBytes_CustomConfiguration() { diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs index 3a47a0ea7..600bed010 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs @@ -79,5 +79,16 @@ public partial class ImageTests this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration); } + + [Fact] + public void FromBytes_EmptySpan_Throws() + { + DecoderOptions options = new() + { + Configuration = this.TopLevelConfiguration + }; + + Assert.Throws(() => Image.Load(options, [])); + } } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs index 00ec985ac..a0ce1e5d8 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs @@ -45,5 +45,9 @@ public partial class ImageTests VerifyDecodedImage(img); Assert.IsType(img.Metadata.DecodedImageFormat); } + + [Fact] + public void FromBytes_EmptySpan_Throws() + => Assert.ThrowsAny(() => Image.Load([])); } } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs index a064b6472..c2609545d 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_ThrowsRightException.cs @@ -32,6 +32,17 @@ public partial class ImageTests } }); - public void Dispose() => this.Stream?.Dispose(); + [Fact] + public void FromStream_Empty_Throws() + { + using MemoryStream ms = new(); + Assert.Throws(() => Image.Load(DecoderOptions.Default, ms)); + } + + public void Dispose() + { + this.Stream?.Dispose(); + GC.SuppressFinalize(this); + } } } From 47ac160a454fe96180de0134924c5e6c8a7cf328 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 21 Nov 2025 11:38:15 +1000 Subject: [PATCH 064/112] Normalize WebP Chunk parsing. Fixes #3010 --- .../Formats/Webp/WebpChunkParsingUtils.cs | 41 ++++++++--- .../Formats/Webp/WebpDecoderCore.cs | 70 +++++-------------- 2 files changed, 46 insertions(+), 65 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index dc95ca044..0f97c404b 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -258,6 +258,9 @@ internal static class WebpChunkParsingUtils /// The stream to read from. /// The buffer to store the read data into. /// A unsigned 24 bit integer. + /// + /// Thrown if the input stream is not valid. + /// public static uint ReadUInt24LittleEndian(Stream stream, Span buffer) { if (stream.Read(buffer, 0, 3) == 3) @@ -274,6 +277,9 @@ internal static class WebpChunkParsingUtils /// /// The stream to read from. /// The uint24 data to write. + /// + /// Thrown if the data is not a valid unsigned 24 bit integer. + /// public static unsafe void WriteUInt24LittleEndian(Stream stream, uint data) { if (data >= 1 << 24) @@ -296,18 +302,24 @@ internal static class WebpChunkParsingUtils /// /// The stream to read the data from. /// Buffer to store the data read from the stream. + /// If true, the chunk size is required to be read, otherwise it can be skipped. /// The chunk size in bytes. - public static uint ReadChunkSize(Stream stream, Span buffer) + /// Thrown if the input stream is not valid. + public static uint ReadChunkSize(Stream stream, Span buffer, bool required = true) { - DebugGuard.IsTrue(buffer.Length is 4, "buffer has wrong length"); - if (stream.Read(buffer) is 4) { uint chunkSize = BinaryPrimitives.ReadUInt32LittleEndian(buffer); return chunkSize % 2 is 0 ? chunkSize : chunkSize + 1; } - throw new ImageFormatException("Invalid Webp data, could not read chunk size."); + if (required) + { + throw new ImageFormatException("Invalid Webp data, could not read chunk size."); + } + + // Return the size of the remaining data in the stream. + return (uint)(stream.Length - stream.Position); } /// @@ -320,14 +332,12 @@ internal static class WebpChunkParsingUtils /// public static WebpChunkType ReadChunkType(BufferedReadStream stream, Span buffer) { - DebugGuard.IsTrue(buffer.Length == 4, "buffer has wrong length"); - if (stream.Read(buffer) == 4) { - WebpChunkType chunkType = (WebpChunkType)BinaryPrimitives.ReadUInt32BigEndian(buffer); - return chunkType; + return (WebpChunkType)BinaryPrimitives.ReadUInt32BigEndian(buffer); } + // We should ignore unknown chunks but still be able to read the type. throw new ImageFormatException("Invalid Webp data, could not read chunk type."); } @@ -336,6 +346,12 @@ internal static class WebpChunkParsingUtils /// If there are more such chunks, readers MAY ignore all except the first one. /// Also, a file may possibly contain both 'EXIF' and 'XMP ' chunks. /// + /// The stream to read the data from. + /// The chunk type to parse. + /// The image metadata to write to. + /// If true, metadata will be ignored. + /// Indicates how to handle segment integrity issues. + /// Buffer to store the data read from the stream. public static void ParseOptionalChunks( BufferedReadStream stream, WebpChunkType chunkType, @@ -344,10 +360,13 @@ internal static class WebpChunkParsingUtils SegmentIntegrityHandling segmentIntegrityHandling, Span buffer) { + bool ignoreNone = segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone; long streamLength = stream.Length; while (stream.Position < streamLength) { - uint chunkLength = ReadChunkSize(stream, buffer); + // Ignore unknown chunk types or when metadata is to be ignored. + // If handling should ignore none, we still need to validate the chunk length. + uint chunkLength = ReadChunkSize(stream, buffer, ignoreNone && (chunkType is WebpChunkType.Exif or WebpChunkType.Xmp) && !ignoreMetaData); if (ignoreMetaData) { @@ -362,7 +381,7 @@ internal static class WebpChunkParsingUtils bytesRead = stream.Read(exifData, 0, (int)chunkLength); if (bytesRead != chunkLength) { - if (segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + if (ignoreNone) { WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); } @@ -394,7 +413,7 @@ internal static class WebpChunkParsingUtils bytesRead = stream.Read(xmpData, 0, (int)chunkLength); if (bytesRead != chunkLength) { - if (segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + if (ignoreNone) { WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); } diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 0e9888adb..2d06d0e49 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -248,7 +248,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable else { // Ignore unknown chunks. - uint chunkSize = ReadChunkSize(stream, buffer, false); + uint chunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, false); stream.Skip((int)chunkSize); } } @@ -328,7 +328,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable while (stream.Position < streamLength) { // Read chunk header. - WebpChunkType chunkType = ReadChunkType(stream, buffer); + WebpChunkType chunkType = WebpChunkParsingUtils.ReadChunkType(stream, buffer); if (chunkType == WebpChunkType.Exif && metadata.ExifProfile == null) { this.ReadExifProfile(stream, metadata, buffer); @@ -340,7 +340,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable else { // Skip duplicate XMP or EXIF chunk. - uint chunkLength = ReadChunkSize(stream, buffer); + uint chunkLength = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, false); stream.Skip((int)chunkLength); } } @@ -354,8 +354,11 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// Temporary buffer. private void ReadExifProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) { - uint exifChunkSize = ReadChunkSize(stream, buffer); - if (this.skipMetadata) + bool ignoreMetadata = this.skipMetadata; + bool ignoreNone = this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone && !ignoreMetadata; + + uint exifChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, ignoreNone); + if (ignoreMetadata) { stream.Skip((int)exifChunkSize); } @@ -365,7 +368,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable int bytesRead = stream.Read(exifData, 0, (int)exifChunkSize); if (bytesRead != exifChunkSize) { - if (this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + if (ignoreNone) { WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); } @@ -408,8 +411,11 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// Temporary buffer. private void ReadXmpProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) { - uint xmpChunkSize = ReadChunkSize(stream, buffer); - if (this.skipMetadata) + bool ignoreMetadata = this.skipMetadata; + bool ignoreNone = this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone && !ignoreMetadata; + + uint xmpChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, ignoreNone); + if (ignoreMetadata) { stream.Skip((int)xmpChunkSize); } @@ -419,7 +425,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable int bytesRead = stream.Read(xmpData, 0, (int)xmpChunkSize); if (bytesRead != xmpChunkSize) { - if (this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone) + if (ignoreNone) { WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); } @@ -439,7 +445,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// Temporary buffer. private void ReadIccProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) { - uint iccpChunkSize = ReadChunkSize(stream, buffer); + uint iccpChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer); if (this.skipMetadata) { stream.Skip((int)iccpChunkSize); @@ -512,50 +518,6 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable } } - /// - /// Identifies the chunk type from the chunk. - /// - /// The stream to decode from. - /// Temporary buffer. - /// - /// Thrown if the input stream is not valid. - /// - private static WebpChunkType ReadChunkType(BufferedReadStream stream, Span buffer) - { - if (stream.Read(buffer, 0, 4) == 4) - { - return (WebpChunkType)BinaryPrimitives.ReadUInt32BigEndian(buffer); - } - - throw new ImageFormatException("Invalid Webp data."); - } - - /// - /// Reads the chunk size. If Chunk Size is odd, a single padding byte will be added to the payload, - /// so the chunk size will be increased by 1 in those cases. - /// - /// The stream to decode from. - /// Temporary buffer. - /// If true, the chunk size is required to be read, otherwise it can be skipped. - /// The chunk size in bytes. - /// Invalid data. - private static uint ReadChunkSize(BufferedReadStream stream, Span buffer, bool required = true) - { - if (stream.Read(buffer, 0, 4) == 4) - { - uint chunkSize = BinaryPrimitives.ReadUInt32LittleEndian(buffer); - return (chunkSize % 2 == 0) ? chunkSize : chunkSize + 1; - } - - if (required) - { - throw new ImageFormatException("Invalid Webp data."); - } - - // Return the size of the remaining data in the stream. - return (uint)(stream.Length - stream.Position); - } - /// public void Dispose() => this.alphaData?.Dispose(); } From 4979e995faf05831e8b7d3d24936174fbc8d08cf Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 21 Nov 2025 13:11:44 +1000 Subject: [PATCH 065/112] Normalize EXIF XMP and ICC reading. --- .../Formats/Webp/WebpAnimationDecoder.cs | 21 +- .../Formats/Webp/WebpChunkParsingUtils.cs | 211 +++++++++++++----- .../Formats/Webp/WebpDecoderCore.cs | 143 +----------- 3 files changed, 180 insertions(+), 195 deletions(-) diff --git a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs index 86489cd36..a23705413 100644 --- a/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs +++ b/src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs @@ -112,12 +112,12 @@ internal class WebpAnimationDecoder : IDisposable this.webpMetadata = this.metadata.GetWebpMetadata(); this.webpMetadata.RepeatCount = features.AnimationLoopCount; - Color backgroundColor = this.backgroundColorHandling == BackgroundColorHandling.Ignore + this.webpMetadata.BackgroundColor = this.backgroundColorHandling == BackgroundColorHandling.Ignore ? Color.Transparent : features.AnimationBackgroundColor!.Value; - this.webpMetadata.BackgroundColor = backgroundColor; - + bool ignoreMetadata = this.skipMetadata; + SegmentIntegrityHandling segmentIntegrityHandling = this.segmentIntegrityHandling; Span buffer = stackalloc byte[4]; uint frameCount = 0; int remainingBytes = (int)completeDataSize; @@ -135,9 +135,16 @@ internal class WebpAnimationDecoder : IDisposable remainingBytes -= (int)dataSize; break; + case WebpChunkType.Iccp: case WebpChunkType.Xmp: case WebpChunkType.Exif: - WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, this.metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer); + WebpChunkParsingUtils.ParseOptionalChunks( + stream, + chunkType, + this.metadata, + ignoreMetadata, + segmentIntegrityHandling, + buffer); break; default: @@ -187,9 +194,12 @@ internal class WebpAnimationDecoder : IDisposable this.webpMetadata.BackgroundColor = backgroundColor; TPixel backgroundPixel = backgroundColor.ToPixel(); + bool ignoreMetadata = this.skipMetadata; + SegmentIntegrityHandling segmentIntegrityHandling = this.segmentIntegrityHandling; Span buffer = stackalloc byte[4]; uint frameCount = 0; int remainingBytes = (int)completeDataSize; + while (remainingBytes > 0) { WebpChunkType chunkType = WebpChunkParsingUtils.ReadChunkType(stream, buffer); @@ -209,9 +219,10 @@ internal class WebpAnimationDecoder : IDisposable remainingBytes -= (int)dataSize; break; + case WebpChunkType.Iccp: case WebpChunkType.Xmp: case WebpChunkType.Exif: - WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, this.skipMetadata, this.segmentIntegrityHandling, buffer); + WebpChunkParsingUtils.ParseOptionalChunks(stream, chunkType, image!.Metadata, ignoreMetadata, segmentIntegrityHandling, buffer); break; default: diff --git a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs index 0f97c404b..26ae28fd4 100644 --- a/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs +++ b/src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs @@ -9,6 +9,7 @@ using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; namespace SixLabors.ImageSharp.Formats.Webp; @@ -275,7 +276,7 @@ internal static class WebpChunkParsingUtils /// /// Writes a unsigned 24 bit integer. /// - /// The stream to read from. + /// The stream to write to. /// The uint24 data to write. /// /// Thrown if the data is not a valid unsigned 24 bit integer. @@ -337,7 +338,8 @@ internal static class WebpChunkParsingUtils return (WebpChunkType)BinaryPrimitives.ReadUInt32BigEndian(buffer); } - // We should ignore unknown chunks but still be able to read the type. + // While we ignore unknown chunks we still need a to be a ble to read a chunk type + // known or otherwise from the stream. throw new ImageFormatException("Invalid Webp data, could not read chunk type."); } @@ -349,88 +351,179 @@ internal static class WebpChunkParsingUtils /// The stream to read the data from. /// The chunk type to parse. /// The image metadata to write to. - /// If true, metadata will be ignored. + /// If true, metadata will be ignored. /// Indicates how to handle segment integrity issues. /// Buffer to store the data read from the stream. public static void ParseOptionalChunks( BufferedReadStream stream, WebpChunkType chunkType, ImageMetadata metadata, - bool ignoreMetaData, + bool ignoreMetadata, SegmentIntegrityHandling segmentIntegrityHandling, Span buffer) { - bool ignoreNone = segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone; long streamLength = stream.Length; while (stream.Position < streamLength) { - // Ignore unknown chunk types or when metadata is to be ignored. - // If handling should ignore none, we still need to validate the chunk length. - uint chunkLength = ReadChunkSize(stream, buffer, ignoreNone && (chunkType is WebpChunkType.Exif or WebpChunkType.Xmp) && !ignoreMetaData); - - if (ignoreMetaData) - { - stream.Skip((int)chunkLength); - } - - int bytesRead; switch (chunkType) { - case WebpChunkType.Exif: - byte[] exifData = new byte[chunkLength]; - bytesRead = stream.Read(exifData, 0, (int)chunkLength); - if (bytesRead != chunkLength) - { - if (ignoreNone) - { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); - } - - return; - } - - if (metadata.ExifProfile == null) - { - ExifProfile exifProfile = new(exifData); - - // Set the resolution from the metadata. - double horizontalValue = GetExifResolutionValue(exifProfile, ExifTag.XResolution); - double verticalValue = GetExifResolutionValue(exifProfile, ExifTag.YResolution); - - if (horizontalValue > 0 && verticalValue > 0) - { - metadata.HorizontalResolution = horizontalValue; - metadata.VerticalResolution = verticalValue; - metadata.ResolutionUnits = UnitConverter.ExifProfileToResolutionUnit(exifProfile); - } - - metadata.ExifProfile = exifProfile; - } + case WebpChunkType.Iccp: + ReadIccProfile(stream, metadata, ignoreMetadata, segmentIntegrityHandling, buffer); + break; + case WebpChunkType.Exif: + ReadExifProfile(stream, metadata, ignoreMetadata, segmentIntegrityHandling, buffer); break; case WebpChunkType.Xmp: - byte[] xmpData = new byte[chunkLength]; - bytesRead = stream.Read(xmpData, 0, (int)chunkLength); - if (bytesRead != chunkLength) - { - if (ignoreNone) - { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); - } - - return; - } - - metadata.XmpProfile ??= new XmpProfile(xmpData); - + ReadXmpProfile(stream, metadata, ignoreMetadata, segmentIntegrityHandling, buffer); break; default: + + // Ignore unknown chunks. + // These must always fall after the image data so we are safe to always skip them. + uint chunkLength = ReadChunkSize(stream, buffer, false); stream.Skip((int)chunkLength); break; } } } + /// + /// Reads the ICCP chunk from the stream. + /// + /// The stream to decode from. + /// The image metadata. + /// If true, metadata will be ignored. + /// Indicates how to handle segment integrity issues. + /// Temporary buffer. + public static void ReadIccProfile( + BufferedReadStream stream, + ImageMetadata metadata, + bool ignoreMetadata, + SegmentIntegrityHandling segmentIntegrityHandling, + Span buffer) + { + // While ICC profiles are optional, an invalid ICC profile cannot be ignored as it must precede the image data + // and since we canot determine its size to allow skipping without reading the chunk size, we have to throw if it's invalid. + // Hence we do not consider segment integrity handling here. + uint iccpChunkSize = ReadChunkSize(stream, buffer); + if (ignoreMetadata || metadata.IccProfile != null) + { + stream.Skip((int)iccpChunkSize); + } + else + { + bool ignoreNone = segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone; + byte[] iccpData = new byte[iccpChunkSize]; + int bytesRead = stream.Read(iccpData, 0, (int)iccpChunkSize); + + // We have the size but the profile is invalid if we cannot read enough data. + // Use the segment integrity handling to determine if we throw. + if (bytesRead != iccpChunkSize && ignoreNone) + { + WebpThrowHelper.ThrowInvalidImageContentException("Not enough data to read the iccp chunk"); + } + + IccProfile profile = new(iccpData); + if (profile.CheckIsValid()) + { + metadata.IccProfile = profile; + } + } + } + + /// + /// Reads the EXIF profile from the stream. + /// + /// The stream to decode from. + /// The image metadata. + /// If true, metadata will be ignored. + /// Indicates how to handle segment integrity issues. + /// Temporary buffer. + public static void ReadExifProfile( + BufferedReadStream stream, + ImageMetadata metadata, + bool ignoreMetadata, + SegmentIntegrityHandling segmentIntegrityHandling, + Span buffer) + { + bool ignoreNone = segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone; + uint exifChunkSize = ReadChunkSize(stream, buffer, ignoreNone); + if (ignoreMetadata || metadata.ExifProfile != null) + { + stream.Skip((int)exifChunkSize); + } + else + { + byte[] exifData = new byte[exifChunkSize]; + int bytesRead = stream.Read(exifData, 0, (int)exifChunkSize); + if (bytesRead != exifChunkSize) + { + if (ignoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); + } + + return; + } + + ExifProfile exifProfile = new(exifData); + + // Set the resolution from the metadata. + double horizontalValue = GetExifResolutionValue(exifProfile, ExifTag.XResolution); + double verticalValue = GetExifResolutionValue(exifProfile, ExifTag.YResolution); + + if (horizontalValue > 0 && verticalValue > 0) + { + metadata.HorizontalResolution = horizontalValue; + metadata.VerticalResolution = verticalValue; + metadata.ResolutionUnits = UnitConverter.ExifProfileToResolutionUnit(exifProfile); + } + + metadata.ExifProfile = exifProfile; + } + } + + /// + /// Reads the XMP profile the stream. + /// + /// The stream to decode from. + /// The image metadata. + /// If true, metadata will be ignored. + /// Indicates how to handle segment integrity issues. + /// Temporary buffer. + public static void ReadXmpProfile( + BufferedReadStream stream, + ImageMetadata metadata, + bool ignoreMetadata, + SegmentIntegrityHandling segmentIntegrityHandling, + Span buffer) + { + bool ignoreNone = segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone; + + uint xmpChunkSize = ReadChunkSize(stream, buffer, ignoreNone); + if (ignoreMetadata || metadata.XmpProfile != null) + { + stream.Skip((int)xmpChunkSize); + } + else + { + byte[] xmpData = new byte[xmpChunkSize]; + int bytesRead = stream.Read(xmpData, 0, (int)xmpChunkSize); + if (bytesRead != xmpChunkSize) + { + if (ignoreNone) + { + WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); + } + + return; + } + + metadata.XmpProfile = new XmpProfile(xmpData); + } + } + private static double GetExifResolutionValue(ExifProfile exifProfile, ExifTag tag) { if (exifProfile.TryGetValue(tag, out IExifValue? resolution)) diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index 2d06d0e49..fd31a7fad 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -3,15 +3,11 @@ using System.Buffers; using System.Buffers.Binary; -using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Formats.Webp.Lossless; using SixLabors.ImageSharp.Formats.Webp.Lossy; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Metadata; -using SixLabors.ImageSharp.Metadata.Profiles.Exif; -using SixLabors.ImageSharp.Metadata.Profiles.Icc; -using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Webp; @@ -248,6 +244,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable else { // Ignore unknown chunks. + // These must always fall after the image data so we are safe to always skip them. uint chunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, false); stream.Skip((int)chunkSize); } @@ -279,18 +276,20 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable bool ignoreAlpha, Span buffer) { + bool ignoreMetadata = this.skipMetadata; + SegmentIntegrityHandling integrityHandling = this.segmentIntegrityHandling; switch (chunkType) { case WebpChunkType.Iccp: - this.ReadIccProfile(stream, metadata, buffer); + WebpChunkParsingUtils.ReadIccProfile(stream, metadata, ignoreMetadata, integrityHandling, buffer); break; case WebpChunkType.Exif: - this.ReadExifProfile(stream, metadata, buffer); + WebpChunkParsingUtils.ReadExifProfile(stream, metadata, ignoreMetadata, integrityHandling, buffer); break; case WebpChunkType.Xmp: - this.ReadXmpProfile(stream, metadata, buffer); + WebpChunkParsingUtils.ReadXmpProfile(stream, metadata, ignoreMetadata, integrityHandling, buffer); break; case WebpChunkType.AnimationParameter: @@ -319,7 +318,10 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable /// Temporary buffer. private void ParseOptionalChunks(BufferedReadStream stream, ImageMetadata metadata, WebpFeatures features, Span buffer) { - if (this.skipMetadata || (!features.ExifProfile && !features.XmpMetaData)) + bool ignoreMetadata = this.skipMetadata; + SegmentIntegrityHandling integrityHandling = this.segmentIntegrityHandling; + + if (ignoreMetadata || (!features.ExifProfile && !features.XmpMetaData)) { return; } @@ -331,11 +333,11 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable WebpChunkType chunkType = WebpChunkParsingUtils.ReadChunkType(stream, buffer); if (chunkType == WebpChunkType.Exif && metadata.ExifProfile == null) { - this.ReadExifProfile(stream, metadata, buffer); + WebpChunkParsingUtils.ReadExifProfile(stream, metadata, ignoreMetadata, integrityHandling, buffer); } else if (chunkType == WebpChunkType.Xmp && metadata.XmpProfile == null) { - this.ReadXmpProfile(stream, metadata, buffer); + WebpChunkParsingUtils.ReadXmpProfile(stream, metadata, ignoreMetadata, integrityHandling, buffer); } else { @@ -346,127 +348,6 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable } } - /// - /// Reads the EXIF profile from the stream. - /// - /// The stream to decode from. - /// The image metadata. - /// Temporary buffer. - private void ReadExifProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) - { - bool ignoreMetadata = this.skipMetadata; - bool ignoreNone = this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone && !ignoreMetadata; - - uint exifChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, ignoreNone); - if (ignoreMetadata) - { - stream.Skip((int)exifChunkSize); - } - else - { - byte[] exifData = new byte[exifChunkSize]; - int bytesRead = stream.Read(exifData, 0, (int)exifChunkSize); - if (bytesRead != exifChunkSize) - { - if (ignoreNone) - { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the EXIF profile"); - } - - return; - } - - ExifProfile exifProfile = new(exifData); - - // Set the resolution from the metadata. - double horizontalValue = GetExifResolutionValue(exifProfile, ExifTag.XResolution); - double verticalValue = GetExifResolutionValue(exifProfile, ExifTag.YResolution); - - if (horizontalValue > 0 && verticalValue > 0) - { - metadata.HorizontalResolution = horizontalValue; - metadata.VerticalResolution = verticalValue; - metadata.ResolutionUnits = UnitConverter.ExifProfileToResolutionUnit(exifProfile); - } - - metadata.ExifProfile = exifProfile; - } - } - - private static double GetExifResolutionValue(ExifProfile exifProfile, ExifTag tag) - { - if (exifProfile.TryGetValue(tag, out IExifValue? resolution)) - { - return resolution.Value.ToDouble(); - } - - return 0; - } - - /// - /// Reads the XMP profile the stream. - /// - /// The stream to decode from. - /// The image metadata. - /// Temporary buffer. - private void ReadXmpProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) - { - bool ignoreMetadata = this.skipMetadata; - bool ignoreNone = this.segmentIntegrityHandling == SegmentIntegrityHandling.IgnoreNone && !ignoreMetadata; - - uint xmpChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer, ignoreNone); - if (ignoreMetadata) - { - stream.Skip((int)xmpChunkSize); - } - else - { - byte[] xmpData = new byte[xmpChunkSize]; - int bytesRead = stream.Read(xmpData, 0, (int)xmpChunkSize); - if (bytesRead != xmpChunkSize) - { - if (ignoreNone) - { - WebpThrowHelper.ThrowImageFormatException("Could not read enough data for the XMP profile"); - } - - return; - } - - metadata.XmpProfile = new XmpProfile(xmpData); - } - } - - /// - /// Reads the ICCP chunk from the stream. - /// - /// The stream to decode from. - /// The image metadata. - /// Temporary buffer. - private void ReadIccProfile(BufferedReadStream stream, ImageMetadata metadata, Span buffer) - { - uint iccpChunkSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer); - if (this.skipMetadata) - { - stream.Skip((int)iccpChunkSize); - } - else - { - byte[] iccpData = new byte[iccpChunkSize]; - int bytesRead = stream.Read(iccpData, 0, (int)iccpChunkSize); - if (bytesRead != iccpChunkSize) - { - WebpThrowHelper.ThrowInvalidImageContentException("Not enough data to read the iccp chunk"); - } - - IccProfile profile = new(iccpData); - if (profile.CheckIsValid()) - { - metadata.IccProfile = profile; - } - } - } - /// /// Reads the animation parameters chunk from the stream. /// From 958aea050d747f1b6d5235e80eaabc425f49521c Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 21 Nov 2025 07:21:56 +0100 Subject: [PATCH 066/112] Use a more tolerant comparer --- tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 5df730cb1..13e739e4f 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -360,7 +360,9 @@ public class TiffDecoderTests : TiffDecoderBaseTester { using Image image = provider.GetImage(TiffDecoder.Instance); image.DebugSave(provider); - image.CompareToReferenceOutput(ImageComparer.Tolerant(), provider); + + // ARM reports a 0.0000% difference, so we use a tolerant comparer here. + image.CompareToReferenceOutput(ImageComparer.TolerantPercentage(0.0001F), provider); } [Theory] From c82b1f7908889195f616e118a732be66600c8d5e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 21 Nov 2025 16:45:01 +1000 Subject: [PATCH 067/112] Explicitly handle missing SOS marker. Fix #2948 --- .../Formats/Jpeg/JpegDecoderCore.cs | 19 ++++++++++++++++++ .../Formats/Jpg/JpegDecoderTests.cs | 20 +++++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + .../Input/Jpg/issues/issue-2948-sos.jpg | 3 +++ 4 files changed, 43 insertions(+) create mode 100644 tests/Images/Input/Jpg/issues/issue-2948-sos.jpg diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 0ad78b903..7825955e7 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -71,6 +71,11 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData /// private bool hasAdobeMarker; + /// + /// Whether the image has a SOS marker. + /// + private bool hasSOSMarker; + /// /// Contains information about the JFIF marker. /// @@ -197,6 +202,12 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData { using SpectralConverter spectralConverter = new(this.configuration, this.resizeMode == JpegDecoderResizeMode.ScaleOnly ? null : this.Options.TargetSize); this.ParseStream(stream, spectralConverter, cancellationToken); + + if (!this.hasSOSMarker) + { + JpegThrowHelper.ThrowInvalidImageContentException("Missing SOS marker."); + } + this.InitExifProfile(); this.InitIccProfile(); this.InitIptcProfile(); @@ -215,6 +226,12 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) { this.ParseStream(stream, spectralConverter: null, cancellationToken); + + if (!this.hasSOSMarker) + { + JpegThrowHelper.ThrowInvalidImageContentException("Missing SOS marker."); + } + this.InitExifProfile(); this.InitIccProfile(); this.InitIptcProfile(); @@ -403,6 +420,8 @@ internal sealed class JpegDecoderCore : ImageDecoderCore, IRawJpegData break; case JpegConstants.Markers.SOS: + + this.hasSOSMarker = true; if (!metadataOnly) { this.ProcessStartOfScanMarker(stream, markerContentByteSize); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 71753bf9c..6dd26cdcb 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -417,4 +417,24 @@ public partial class JpegDecoderTests image.DebugSave(provider); image.CompareToReferenceOutput(provider); } + + // https://github.com/SixLabors/ImageSharp/issues/2948 + [Theory] + [WithFile(TestImages.Jpeg.Issues.Issue2948, PixelTypes.Rgb24)] + public void Issue2948_No_SOS_Decode_Throws_InvalidImageContentException(TestImageProvider provider) + where TPixel : unmanaged, IPixel + => Assert.Throws(() => + { + using Image image = provider.GetImage(JpegDecoder.Instance); + }); + + // https://github.com/SixLabors/ImageSharp/issues/2948 + [Theory] + [InlineData(TestImages.Jpeg.Issues.Issue2948)] + public void Issue2948_No_SOS_Identify_Throws_InvalidImageContentException(string imagePath) + => Assert.Throws(() => + { + TestFile testFile = TestFile.Create(imagePath); + ImageInfo imageInfo = Image.Identify(testFile.Bytes); + }); } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 94dcd2b7b..bc699da88 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -348,6 +348,7 @@ public static class TestImages public const string Issue2638 = "Jpg/issues/Issue2638.jpg"; public const string Issue2758 = "Jpg/issues/issue-2758.jpg"; public const string Issue2857 = "Jpg/issues/issue-2857-subsub-ifds.jpg"; + public const string Issue2948 = "Jpg/issues/issue-2948-sos.jpg"; public static class Fuzz { diff --git a/tests/Images/Input/Jpg/issues/issue-2948-sos.jpg b/tests/Images/Input/Jpg/issues/issue-2948-sos.jpg new file mode 100644 index 000000000..d210e87e5 --- /dev/null +++ b/tests/Images/Input/Jpg/issues/issue-2948-sos.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ad9c3a6babb41c5aa2a46fbfe74ed5482028c73f48531cf144e1e324ca7988b3 +size 103789 From 143c3bb4f2f9a66e130a40f998dd757bc51d18b9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 21 Nov 2025 17:15:53 +1000 Subject: [PATCH 068/112] Cleanup --- .github/workflows/build-and-test.yml | 6 ------ tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs | 6 +----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3e3d6d0e2..41136bfd8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -62,8 +62,6 @@ jobs: needs: WarmLFS strategy: matrix: - isARM: - - ${{ contains(github.event.pull_request.labels.*.name, 'arch:arm32') || contains(github.event.pull_request.labels.*.name, 'arch:arm64') }} options: - os: ubuntu-latest framework: net9.0 @@ -121,10 +119,6 @@ jobs: sdk: 8.0.x runtime: -x64 codecov: false - exclude: - - isARM: false - options: - os: buildjet-4vcpu-ubuntu-2204-arm runs-on: ${{ matrix.options.os }} diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 6dd26cdcb..3fd55eb91 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -432,9 +432,5 @@ public partial class JpegDecoderTests [Theory] [InlineData(TestImages.Jpeg.Issues.Issue2948)] public void Issue2948_No_SOS_Identify_Throws_InvalidImageContentException(string imagePath) - => Assert.Throws(() => - { - TestFile testFile = TestFile.Create(imagePath); - ImageInfo imageInfo = Image.Identify(testFile.Bytes); - }); + => Assert.Throws(() => _ = Image.Identify(TestFile.Create(imagePath).Bytes)); } From fc211a7aa7e4360112290c1a52b3addc445a86ee Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 21 Nov 2025 14:22:16 +0100 Subject: [PATCH 069/112] Update Intrinsic usage --- .../Common/SimdUtilsTests.Shuffle.cs | 10 +++++----- tests/ImageSharp.Tests/Common/SimdUtilsTests.cs | 2 +- .../ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs | 4 ++-- tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs | 13 ++++++------- .../Formats/Jpg/JpegColorConverterTests.cs | 12 ++++-------- .../Formats/Png/PngDecoderFilterTests.cs | 2 +- .../Formats/Png/PngEncoderFilterTests.cs | 2 +- .../Formats/Png/PngEncoderTests.cs | 2 +- .../Formats/WebP/ColorSpaceTransformUtilsTests.cs | 4 ++-- .../Formats/WebP/LosslessUtilsTests.cs | 14 +++++++------- .../Formats/WebP/PredictorEncoderTests.cs | 4 ++-- .../ImageSharp.Tests/Formats/WebP/QuantEncTests.cs | 2 +- .../Formats/WebP/Vp8ResidualTests.cs | 2 +- .../Formats/WebP/WebpCommonUtilsTests.cs | 4 ++-- .../Formats/WebP/YuvConversionTests.cs | 2 +- .../Processors/Convolution/BokehBlurTest.cs | 12 ++++++------ 16 files changed, 43 insertions(+), 48 deletions(-) diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs index 2a7616570..81daac3e0 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.Shuffle.cs @@ -292,7 +292,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -352,7 +352,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -394,7 +394,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -436,7 +436,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -478,7 +478,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } private static void TestShuffleFloat4Channel( diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index eeaf93645..0a9bb063e 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -133,7 +133,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs index e1d4feaa7..368a7b369 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs @@ -267,7 +267,7 @@ public partial class Block8x8FTests : JpegFixture RunTest, srcSeed, qtSeed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } [Fact] @@ -462,7 +462,7 @@ public partial class Block8x8FTests : JpegFixture // 3. DisableAvx2 - call fallback code of float implementation FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs index 7d7b05a28..50eada4c7 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs @@ -152,7 +152,7 @@ public static class DCTTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, seed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } [Theory] @@ -352,15 +352,14 @@ public static class DCTTests Assert.Equal(expectedDest, actualDest, new ApproximateFloatComparer(1f)); } - // 4 paths: - // 1. AllowAll - call avx/fma implementation - // 2. DisableFMA - call avx without fma implementation - // 3. DisableAvx - call Vector4 implementation - // 4. DisableHWIntrinsic - call scalar fallback implementation + // 3 paths: + // 1. AllowAll - call avx implementation + // 2. DisableAvx - call Vector4 implementation + // 3. DisableHWIntrinsic - call scalar fallback implementation FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, seed, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); } } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 5ea9e4d78..0137709d8 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -19,12 +19,8 @@ public class JpegColorConverterTests private const int TestBufferLength = 40; - private const HwIntrinsics IntrinsicsConfig = HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2; - private static readonly ApproximateColorProfileComparer ColorSpaceComparer = new(epsilon: Precision); - private static readonly ColorProfileConverter ColorSpaceConverter = new(); - public static readonly TheoryData Seeds = new() { 1, 2, 3 }; public JpegColorConverterTests(ITestOutputHelper output) @@ -73,7 +69,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -106,7 +102,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -139,7 +135,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -172,7 +168,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs index 99406be2f..6616b0477 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderFilterTests.cs @@ -171,7 +171,7 @@ public class PngDecoderFilterTests public void PaethFilter_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.AllowAll); [Fact] - public void PaethFilter_WithoutSsse3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableSSE42); + public void PaethFilter_WithoutSsse3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void PaethFilter_WithoutHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPaethFilterTest, HwIntrinsics.DisableHWIntrinsic); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs index 736c8b4c0..3a31b395f 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs @@ -51,7 +51,7 @@ public class PngEncoderFilterTests : MeasureFixture FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index ca01655a0..4ebcbc13b 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -618,7 +618,7 @@ public partial class PngEncoderTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.DisableSSE42, + HwIntrinsics.DisableHWIntrinsic, provider); } diff --git a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs index 06249090d..9657859e0 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/ColorSpaceTransformUtilsTests.cs @@ -71,7 +71,7 @@ public class ColorSpaceTransformUtilsTests public void CollectColorBlueTransforms_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.AllowAll); [Fact] - public void CollectColorBlueTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableSSE42); + public void CollectColorBlueTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void CollectColorBlueTransforms_WithoutVector256_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorBlueTransformsTest, HwIntrinsics.DisableAVX2); @@ -80,7 +80,7 @@ public class ColorSpaceTransformUtilsTests public void CollectColorRedTransforms_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.AllowAll); [Fact] - public void CollectColorRedTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableSSE42); + public void CollectColorRedTransforms_WithoutVector128_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void CollectColorRedTransforms_WithoutVector256_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCollectColorRedTransformsTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs index d2429e71f..4dcccb1a3 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/LosslessUtilsTests.cs @@ -304,19 +304,19 @@ public class LosslessUtilsTests public void Predictor11_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor11_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.DisableSSE42); + public void Predictor11_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor11Test, HwIntrinsics.DisableHWIntrinsic); [Fact] public void Predictor12_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor12_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.DisableSSE42); + public void Predictor12_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor12Test, HwIntrinsics.DisableHWIntrinsic); [Fact] public void Predictor13_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.AllowAll); [Fact] - public void Predictor13_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.DisableSSE42); + public void Predictor13_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunPredictor13Test, HwIntrinsics.DisableHWIntrinsic); [Fact] public void SubtractGreen_Works() => RunSubtractGreenTest(); @@ -331,7 +331,7 @@ public class LosslessUtilsTests public void SubtractGreen_Scalar_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableHWIntrinsic); [Fact] - public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + public void SubtractGreen_WithoutAvxOrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSubtractGreenTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); [Fact] public void AddGreenToBlueAndRed_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.AllowAll); @@ -340,13 +340,13 @@ public class LosslessUtilsTests public void AddGreenToBlueAndRed_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2); [Fact] - public void AddGreenToBlueAndRed_WithoutAVX2OrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + public void AddGreenToBlueAndRed_WithoutAVX2OrSSSE3_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunAddGreenToBlueAndRedTest, HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); [Fact] public void TransformColor_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.AllowAll); [Fact] - public void TransformColor_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableSSE42); + public void TransformColor_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void TransformColor_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorTest, HwIntrinsics.DisableAVX2); @@ -355,7 +355,7 @@ public class LosslessUtilsTests public void TransformColorInverse_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.AllowAll); [Fact] - public void TransformColorInverse_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableSSE42); + public void TransformColorInverse_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void TransformColorInverse_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunTransformColorInverseTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs index 4ab1d019b..16990c357 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/PredictorEncoderTests.cs @@ -24,7 +24,7 @@ public class PredictorEncoderTests [Fact] public void ColorSpaceTransform_WithPeakImage_WithoutSSE41_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableSSE42); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithPeakImage_ProducesExpectedData, HwIntrinsics.DisableHWIntrinsic); [Fact] public void ColorSpaceTransform_WithBikeImage_WithHardwareIntrinsics_Works() @@ -32,7 +32,7 @@ public class PredictorEncoderTests [Fact] public void ColorSpaceTransform_WithBikeImage_WithoutSSE41_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableSSE42); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(ColorSpaceTransform_WithBikeImage_ProducesExpectedData, HwIntrinsics.DisableHWIntrinsic); [Fact] public void ColorSpaceTransform_WithBikeImage_WithoutAvx2_Works() diff --git a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs index 54a80c29f..3808ba6d0 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/QuantEncTests.cs @@ -45,7 +45,7 @@ public class QuantEncTests public void QuantizeBlock_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.AllowAll); [Fact] - public void QuantizeBlock_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableSSE42); + public void QuantizeBlock_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void QuantizeBlock_WithoutAVX2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunQuantizeBlockTest, HwIntrinsics.DisableAVX2); diff --git a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs index c00460471..2a0821108 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/Vp8ResidualTests.cs @@ -252,5 +252,5 @@ public class Vp8ResidualTests public void SetCoeffsTest_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.AllowAll); [Fact] - public void SetCoeffsTest_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.DisableSSE42); + public void SetCoeffsTest_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunSetCoeffsTest, HwIntrinsics.DisableHWIntrinsic); } diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs index 13a204bce..3962d4f37 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpCommonUtilsTests.cs @@ -23,7 +23,7 @@ public class WebpCommonUtilsTests [Fact] public void CheckNonOpaque_WithOpaquePixels_WithoutSse2_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithOpaquePixelsTest, HwIntrinsics.DisableSSE42); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithOpaquePixelsTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void CheckNonOpaque_WithOpaquePixels_WithoutAvx2_Works() @@ -35,7 +35,7 @@ public class WebpCommonUtilsTests [Fact] public void CheckNonOpaque_WithNoneOpaquePixels_WithoutSse2_Works() - => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.DisableSSE42); + => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunCheckNoneOpaqueWithNoneOpaquePixelsTest, HwIntrinsics.DisableHWIntrinsic); [Fact] public void CheckNonOpaque_WithNoneOpaquePixels_WithoutAvx2_Works() diff --git a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs index 5e34f1221..482c41b25 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/YuvConversionTests.cs @@ -32,7 +32,7 @@ public class YuvConversionTests public void UpSampleYuvToRgb_WithHardwareIntrinsics_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.AllowAll); [Fact] - public void UpSampleYuvToRgb_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.DisableSSE42); + public void UpSampleYuvToRgb_WithoutSSE2_Works() => FeatureTestRunner.RunWithHwIntrinsicsFeature(RunUpSampleYuvToRgbTest, HwIntrinsics.DisableHWIntrinsic); [Theory] [WithFile(TestImages.Webp.Yuv, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs index bed2cdbd6..3d4c239c9 100644 --- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs @@ -50,7 +50,7 @@ public class BokehBlurTest List components = new(); foreach (Match match in Regex.Matches(Components10x2, @"\[\[(.*?)\]\]", RegexOptions.Singleline)) { - string[] values = match.Groups[1].Value.Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + string[] values = match.Groups[1].Value.Trim().Split([' '], StringSplitOptions.RemoveEmptyEntries); Complex64[] component = values.Select( value => { @@ -114,12 +114,12 @@ public class BokehBlurTest }; public static readonly string[] TestFiles = - { - TestImages.Png.CalliphoraPartial, + [ + TestImages.Png.CalliphoraPartial, TestImages.Png.Bike, TestImages.Png.BikeGrayscale, - TestImages.Png.Cross, - }; + TestImages.Png.Cross + ]; [Theory] [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32)] @@ -148,7 +148,7 @@ public class BokehBlurTest [Theory] [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.AllowAll)] - [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.DisableSSE42)] + [WithFileCollection(nameof(TestFiles), nameof(BokehBlurValues), PixelTypes.Rgba32, HwIntrinsics.DisableHWIntrinsic)] public void BokehBlurFilterProcessor_Bounded(TestImageProvider provider, BokehBlurInfo value, HwIntrinsics intrinsicsFilter) { static void RunTest(string arg1, string arg2) From a4765d1ff9bdc635f1ad3e301f4e42b93447c4ab Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 21 Nov 2025 14:26:56 +0100 Subject: [PATCH 070/112] Use .NET10 for build and not .net9 --- .github/workflows/build-and-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 64a05db83..99ca63fc3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -76,8 +76,8 @@ jobs: runtime: -x64 codecov: false - os: macos-26 - framework: net9.0 - sdk: 9.0.x + framework: net10.0 + sdk: 10.0.x sdk-preview: true runtime: -x64 codecov: false From 284e40e3dbd305d02ee7a8f03289b152ec250e5c Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Fri, 21 Nov 2025 22:36:18 +0100 Subject: [PATCH 071/112] Disable SSE42 --- tests/ImageSharp.Tests/Common/SimdUtilsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 0a9bb063e..eeaf93645 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -133,7 +133,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); } [Theory] From 766175ff06371286a75f132568ddbcaad29a3bf3 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 22 Nov 2025 12:17:21 +1000 Subject: [PATCH 072/112] Fix tests --- tests/ImageSharp.Tests/Common/SimdUtilsTests.cs | 2 +- .../Formats/Jpg/JpegColorConverterTests.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index eeaf93645..e39f9456f 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -133,7 +133,7 @@ public partial class SimdUtilsTests FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, count, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2); } [Theory] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 0137709d8..8d94fb5cf 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -102,7 +102,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -135,7 +135,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -168,7 +168,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { @@ -201,7 +201,7 @@ public class JpegColorConverterTests { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, - HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE42 | HwIntrinsics.DisableHWIntrinsic); + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX512 | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableHWIntrinsic); static void RunTest(string arg) { From ea4ba7a7daab9be4731588e54a0f7ddd178cd391 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 22 Nov 2025 12:29:14 +1000 Subject: [PATCH 073/112] Update TiffDecoderTests.cs --- tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 13e739e4f..d850c67a5 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -785,7 +785,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester // ImageMagick cannot decode this image. image.DebugSave(provider); image.CompareToReferenceOutput( - ImageComparer.TolerantPercentage(0.0018F), // NET 9+ Uses zlib-ng to decompress, which manages to decode 2 extra pixels. + ImageComparer.TolerantPercentage(0.0034F), // NET 10 Uses zlib-ng to decompress, which manages to decode 3 extra pixels. provider, appendPixelTypeToFileName: false); } From e965d3fac69ff87505a292dda60fc1f72b4db701 Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 5 Dec 2025 00:27:18 -0500 Subject: [PATCH 074/112] Apply color conversion when decoding PNG --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 38f964d37..f7eb0de1f 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -7,9 +7,12 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO.Compression; using System.IO.Hashing; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; +using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Compression.Zlib; using SixLabors.ImageSharp.Formats.Png.Chunks; @@ -323,6 +326,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowNoData(); } + if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + ApplyIccProfile(image, iccProfile, CompactSrgbV4Profile.Profile); + } + return image; } catch @@ -2153,4 +2161,58 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void SwapScanlineBuffers() => (this.scanline, this.previousScanline) = (this.previousScanline, this.scanline); + + // FIXME: Maybe this could be a .Mutate(x => x.ApplyIccProfile(destinationProfile)) ? Nothing related to png here + private static void ApplyIccProfile(Image image, IccProfile sourceProfile, IccProfile destinationProfile) + where TPixel : unmanaged, IPixel + { + ColorConversionOptions options = new() + { + SourceIccProfile = sourceProfile, + TargetIccProfile = destinationProfile, + }; + + ColorProfileConverter converter = new(options); + + image.ProcessPixelRows(pixelAccessor => + { + using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelAccessor.Width * 3); + using IMemoryOwner alphaBuffer = image.Configuration.MemoryAllocator.Allocate(pixelAccessor.Width); + Span rgbPacked = rgbBuffer.Memory.Span; + ref float rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); + Span alphaPacked = alphaBuffer.Memory.Span; + ref float alphaPackedRef = ref MemoryMarshal.GetReference(alphaPacked); + + for (int y = 0; y < pixelAccessor.Height; y++) + { + Span pixelsRow = pixelAccessor.GetRowSpan(y); + int rgbIdx = 0; + for (int x = 0; x < pixelsRow.Length; x++, rgbIdx += 3) + { + Vector4 rgba = pixelsRow[x].ToScaledVector4(); + Unsafe.Add(ref rgbPackedRef, rgbIdx) = rgba.X; + Unsafe.Add(ref rgbPackedRef, rgbIdx + 1) = rgba.Y; + Unsafe.Add(ref rgbPackedRef, rgbIdx + 2) = rgba.Z; + Unsafe.Add(ref alphaPackedRef, x) = rgba.W; + } + + Span source = MemoryMarshal.Cast(rgbPacked); + Span destination = MemoryMarshal.Cast(rgbPacked); + converter.Convert(source, destination); + + rgbIdx = 0; + for (int x = 0; x < pixelsRow.Length; x++, rgbIdx += 3) + { + float r = Unsafe.Add(ref rgbPackedRef, rgbIdx); + float g = Unsafe.Add(ref rgbPackedRef, rgbIdx + 1); + float b = Unsafe.Add(ref rgbPackedRef, rgbIdx + 2); + float a = Unsafe.Add(ref alphaPackedRef, x); + + pixelsRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); + } + } + } + ); + } + } From 0582e85e4957ed29f57d721d4037aa8a7b3076f3 Mon Sep 17 00:00:00 2001 From: Socolin Date: Wed, 10 Dec 2025 23:12:33 -0500 Subject: [PATCH 075/112] Fix decoding tiff image with BigEndian + 64 bit / pixel + associated alpha --- .../Formats/Tiff/Utils/TiffUtilities.cs | 7 ++- .../Formats/Tiff/TiffDecoderTests.cs | 13 +++++ .../Formats/Tiff/Utils/TiffUtilitiesTest.cs | 51 +++++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 1 + ...t_WithAssociatedAlpha_Rgba64_Issue3031.png | 3 ++ ...ha_Rgba64_RgbaAssociatedAlpha16bit_lsb.png | 3 ++ ...ha_Rgba64_RgbaAssociatedAlpha16bit_msb.png | 3 ++ ...tedAlpha_Rgba16161616_Rgba64_Issue3031.png | 3 ++ tests/Images/Input/Tiff/Issues/Issue3031.tiff | 3 ++ 9 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffUtilitiesTest.cs create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_Issue3031.png create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_lsb.png create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_msb.png create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_BigEndian_AssociatedAlpha_Rgba16161616_Rgba64_Issue3031.png create mode 100644 tests/Images/Input/Tiff/Issues/Issue3031.tiff diff --git a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs index e30765b1f..b7d412f3c 100644 --- a/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs +++ b/src/ImageSharp/Formats/Tiff/Utils/TiffUtilities.cs @@ -45,7 +45,12 @@ internal static class TiffUtilities return TPixel.FromRgba64(default); } - return TPixel.FromRgba64(new Rgba64((ushort)(r / a), (ushort)(g / a), (ushort)(b / a), a)); + float scale = 65535f / a; + ushort ur = (ushort)Math.Min(r * scale, 65535); + ushort ug = (ushort)Math.Min(g * scale, 65535); + ushort ub = (ushort)Math.Min(b * scale, 65535); + + return TPixel.FromRgba64(new Rgba64(ur, ug, ub, a)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index d850c67a5..5096d93bd 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -365,6 +365,19 @@ public class TiffDecoderTests : TiffDecoderBaseTester image.CompareToReferenceOutput(ImageComparer.TolerantPercentage(0.0001F), provider); } + [Theory] + [WithFile(Issues3031, PixelTypes.Rgba64)] + [WithFile(Rgba16BitAssociatedAlphaBigEndian, PixelTypes.Rgba64)] + [WithFile(Rgba16BitAssociatedAlphaLittleEndian, PixelTypes.Rgba64)] + public void TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(TiffDecoder.Instance); + image.DebugSave(provider); + + image.CompareToReferenceOutput(ImageComparer.Exact, provider); + } + [Theory] [WithFile(Issues2454_A, PixelTypes.Rgba32)] [WithFile(Issues2454_B, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffUtilitiesTest.cs b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffUtilitiesTest.cs new file mode 100644 index 000000000..6483b63c5 --- /dev/null +++ b/tests/ImageSharp.Tests/Formats/Tiff/Utils/TiffUtilitiesTest.cs @@ -0,0 +1,51 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using SixLabors.ImageSharp.Formats.Tiff.Utils; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Tests.Formats.Tiff.Utils; + +[Trait("Format", "Tiff")] +public class TiffUtilitiesTest +{ + [Theory] + [InlineData(0, 0, 0, 0)] + [InlineData(42, 84, 128, 0)] + [InlineData(65535, 65535, 65535, 0)] + public void ColorFromRgba64Premultiplied_WithZeroAlpha_ReturnsDefaultPixel(ushort r, ushort g, ushort b, ushort a) + { + Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a); + + Assert.Equal(default, actual); + } + + [Theory] + [InlineData(65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535)] + [InlineData(32767, 0, 0, 65535, 32767, 0, 0, 65535)] + [InlineData(0, 32767, 0, 65535, 0, 32767, 0, 65535)] + [InlineData(0, 0, 32767, 65535, 0, 0, 32767, 65535)] + public void ColorFromRgba64Premultiplied_WithNoAlpha_ReturnExpectedValues(ushort r, ushort g, ushort b, ushort a, ushort expectedR, ushort expectedG, ushort expectedB, ushort expectedA) + { + Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a); + + Assert.Equal(new Rgba64(expectedR, expectedG, expectedB, expectedA), actual); + } + + [Theory] + [InlineData(32766, 0, 0, 32766, 65535, 0, 0, 32766)] // Red, 50% Alpha + [InlineData(0, 32766, 0, 32766, 0, 65535, 0, 32766)] // Green, 50% Alpha + [InlineData(0, 0, 32766, 32766, 0, 0, 65535, 32766)] // Blue, 50% Alpha + [InlineData(8191, 0, 0, 16383, 32765, 0, 0, 16383)] // Red, 25% Alpha + [InlineData(0, 8191, 0, 16383, 0, 32765, 0, 16383)] // Green, 25% Alpha + [InlineData(0, 0, 8191, 16383, 0, 0, 32765, 16383)] // Blue, 25% Alpha + [InlineData(8191, 0, 0, 0, 0, 0, 0, 0)] // Red, 0% Alpha + [InlineData(0, 8191, 0, 0, 0, 0, 0, 0)] // Green, 0% Alpha + [InlineData(0, 0, 8191, 0, 0, 0, 0, 0)] // Blue, 0% Alpha + public void ColorFromRgba64Premultiplied_WithAlpha_ReturnExpectedValues(ushort r, ushort g, ushort b, ushort a, ushort expectedR, ushort expectedG, ushort expectedB, ushort expectedA) + { + Rgba64 actual = TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a); + + Assert.Equal(new Rgba64(expectedR, expectedG, expectedB, expectedA), actual); + } +} diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index bc699da88..161b1a709 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1142,6 +1142,7 @@ public static class TestImages public const string Issues2435 = "Tiff/Issues/Issue2435.tiff"; public const string Issues2454_A = "Tiff/Issues/Issue2454_A.tif"; public const string Issues2454_B = "Tiff/Issues/Issue2454_B.tif"; + public const string Issues3031 = "Tiff/Issues/Issue3031.tiff"; public const string Issues2587 = "Tiff/Issues/Issue2587.tiff"; public const string Issues2679 = "Tiff/Issues/Issue2679.tiff"; public const string JpegCompressedGray0000539558 = "Tiff/Issues/JpegCompressedGray-0000539558.tiff"; diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_Issue3031.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_Issue3031.png new file mode 100644 index 000000000..d5a017475 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_Issue3031.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c33a2f63836975bdc7631f26634b3fb0ae98bfaff730300877339cb568141cde +size 124 diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_lsb.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_lsb.png new file mode 100644 index 000000000..a3317a6b4 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_lsb.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e50dfa103459d21642df5e1ca760081fbdfe3b7244624d9d87d8a20f45b51bbe +size 117953 diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_msb.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_msb.png new file mode 100644 index 000000000..5b72c3732 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_64Bit_WithAssociatedAlpha_Rgba64_RgbaAssociatedAlpha16bit_msb.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3333503012aa29e23f0d0e52993ad3499514251208fb3318e2bb1560d54650fa +size 117956 diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_BigEndian_AssociatedAlpha_Rgba16161616_Rgba64_Issue3031.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_BigEndian_AssociatedAlpha_Rgba16161616_Rgba64_Issue3031.png new file mode 100644 index 000000000..d5a017475 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/TiffDecoder_CanDecode_BigEndian_AssociatedAlpha_Rgba16161616_Rgba64_Issue3031.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c33a2f63836975bdc7631f26634b3fb0ae98bfaff730300877339cb568141cde +size 124 diff --git a/tests/Images/Input/Tiff/Issues/Issue3031.tiff b/tests/Images/Input/Tiff/Issues/Issue3031.tiff new file mode 100644 index 000000000..bc3ef7d7c --- /dev/null +++ b/tests/Images/Input/Tiff/Issues/Issue3031.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e4d2db56a1b7fdea09ed65eab1d10a02952821f6662ca77caa44b8c51b30310 +size 416 From 3c7a39623b87169c69041c14b7b4469d5bab370b Mon Sep 17 00:00:00 2001 From: Socolin Date: Sun, 14 Dec 2025 17:22:12 -0500 Subject: [PATCH 076/112] Fix PixelColorType.YCbCr wrongly interpreted as grayscale in PngEncoder --- src/ImageSharp/Formats/Png/PngMetadata.cs | 2 +- .../Formats/Png/PngMetadataTests.cs | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Png/PngMetadata.cs b/src/ImageSharp/Formats/Png/PngMetadata.cs index cecdf88c9..1cf4bb6ed 100644 --- a/src/ImageSharp/Formats/Png/PngMetadata.cs +++ b/src/ImageSharp/Formats/Png/PngMetadata.cs @@ -111,7 +111,7 @@ public class PngMetadata : IFormatMetadata color = PngColorType.Rgb; break; default: - if (colorType.HasFlag(PixelColorType.Luminance)) + if (colorType.HasFlag(PixelColorType.Luminance | PixelColorType.Alpha)) { color = PngColorType.GrayscaleWithAlpha; break; diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index 5cbc27611..a0c552a22 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -336,4 +336,29 @@ public class PngMetadataTests Assert.Equal(42, (int)exif.GetValue(ExifTag.ImageNumber).Value); } + + + [Theory] + [InlineData(PixelColorType.Binary, PngColorType.Palette)] + [InlineData(PixelColorType.Indexed, PngColorType.Palette)] + [InlineData(PixelColorType.Luminance, PngColorType.Grayscale)] + [InlineData(PixelColorType.RGB, PngColorType.Rgb)] + [InlineData(PixelColorType.BGR, PngColorType.Rgb)] + [InlineData(PixelColorType.YCbCr, PngColorType.RgbWithAlpha)] + [InlineData(PixelColorType.CMYK, PngColorType.RgbWithAlpha)] + [InlineData(PixelColorType.YCCK, PngColorType.RgbWithAlpha)] + public void FromFormatConnectingMetadata_ConvertColorTypeAsExpected(PixelColorType pixelColorType, PngColorType expectedPngColorType) + { + FormatConnectingMetadata formatConnectingMetadata = new() + { + PixelTypeInfo = new PixelTypeInfo(24) + { + ColorType = pixelColorType, + }, + }; + + PngMetadata actual = PngMetadata.FromFormatConnectingMetadata(formatConnectingMetadata); + + Assert.Equal(expectedPngColorType, actual.ColorType); + } } From 1e48674d380fdcb33ead3fe8b8acfdf5ae82eb8d Mon Sep 17 00:00:00 2001 From: Socolin Date: Mon, 15 Dec 2025 01:33:23 -0500 Subject: [PATCH 077/112] Optimization in Rgba16161616TiffColor, split a code into 2 loops to avoid a condtion for each pixel --- .../Rgba16161616TiffColor{TPixel}.cs | 57 +++++++++++++------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs index 9847f45b5..086aa3b4e 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/Rgba16161616TiffColor{TPixel}.cs @@ -1,5 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. + #nullable disable using System.Buffers; @@ -48,31 +49,53 @@ internal class Rgba16161616TiffColor : TiffBaseColorDecoder using IMemoryOwner vectors = hasAssociatedAlpha ? this.memoryAllocator.Allocate(width) : null; Span vectorsSpan = hasAssociatedAlpha ? vectors.GetSpan() : []; - for (int y = top; y < top + height; y++) - { - Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); - if (this.isBigEndian) + if (this.isBigEndian) + { + if (hasAssociatedAlpha) { - for (int x = 0; x < pixelRow.Length; x++) + for (int y = top; y < top + height; y++) { - ushort r = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); - offset += 2; - ushort g = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); - offset += 2; - ushort b = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); - offset += 2; - ushort a = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); - offset += 2; - - pixelRow[x] = hasAssociatedAlpha - ? TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a) - : TPixel.FromRgba64(new Rgba64(r, g, b, a)); + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); + + for (int x = 0; x < pixelRow.Length; x++) + { + ushort r = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); + ushort g = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 2, 2)); + ushort b = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 4, 2)); + ushort a = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 6, 2)); + offset += 8; + + pixelRow[x] = TiffUtilities.ColorFromRgba64Premultiplied(r, g, b, a); + } } } else { + for (int y = top; y < top + height; y++) + { + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); + + for (int x = 0; x < pixelRow.Length; x++) + { + ushort r = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); + ushort g = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 2, 2)); + ushort b = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 4, 2)); + ushort a = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset + 6, 2)); + offset += 8; + + pixelRow[x] = TPixel.FromRgba64(new Rgba64(r, g, b, a)); + } + } + } + } + else + { + for (int y = top; y < top + height; y++) + { + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); int byteCount = pixelRow.Length * 8; + PixelOperations.Instance.FromRgba64Bytes( this.configuration, data.Slice(offset, byteCount), From c66833c17622c761fb00a1ebcca6c404a4ed9f46 Mon Sep 17 00:00:00 2001 From: Socolin Date: Tue, 16 Dec 2025 02:10:03 -0500 Subject: [PATCH 078/112] Remove retired macos image from test matrix in CI --- .github/workflows/build-and-test.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 99ca63fc3..637373e80 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -69,12 +69,6 @@ jobs: sdk-preview: true runtime: -x64 codecov: false - - os: macos-13 # macos-latest runs on arm64 runners where libgdiplus is unavailable - framework: net10.0 - sdk: 10.0.x - sdk-preview: true - runtime: -x64 - codecov: false - os: macos-26 framework: net10.0 sdk: 10.0.x @@ -99,11 +93,6 @@ jobs: sdk: 8.0.x runtime: -x64 codecov: false - - os: macos-13 # macos-latest runs on arm64 runners where libgdiplus is unavailable - framework: net8.0 - sdk: 8.0.x - runtime: -x64 - codecov: false - os: macos-26 framework: net8.0 sdk: 8.0.x From bd532d66961bc56ac47852ce19dacb33233eaf1c Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 00:07:00 -0500 Subject: [PATCH 079/112] Add tests to check if PngDecoder apply ICC profile --- .../Formats/Png/PngDecoderTests.cs | 14 ++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 7 +++++++ ...ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png | 3 +++ ...IsConvert_ApplyIccProfile_Rgba32_Perceptual.png | 3 +++ ...gIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray.png | 3 +++ .../Png/icc-profiles/Perceptual-cLUT-only.png | 3 +++ tests/Images/Input/Png/icc-profiles/Perceptual.png | 3 +++ tests/Images/Input/Png/icc-profiles/sRGB_Gray.png | 3 +++ 8 files changed, 39 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png create mode 100644 tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png create mode 100644 tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray.png create mode 100644 tests/Images/Input/Png/icc-profiles/Perceptual-cLUT-only.png create mode 100644 tests/Images/Input/Png/icc-profiles/Perceptual.png create mode 100644 tests/Images/Input/Png/icc-profiles/sRGB_Gray.png diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 3589a25a2..98cfd06b6 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -206,6 +206,20 @@ public partial class PngDecoderTests image.CompareToOriginal(provider, ImageComparer.Exact); } + [Theory] + [WithFile(TestImages.Png.Icc.Perceptual, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.Icc.PerceptualcLUTOnly, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.Icc.SRgbGray, PixelTypes.Rgba32)] + public void Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(PngDecoder.Instance, new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert }); + + image.DebugSave(provider); + image.CompareToReferenceOutput(provider); + Assert.Null(image.Metadata.IccProfile); + } + [Theory] [WithFile(TestImages.Png.SubFilter3BytesPerPixel, PixelTypes.Rgba32)] [WithFile(TestImages.Png.SubFilter4BytesPerPixel, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index bc699da88..18ad62372 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -166,6 +166,13 @@ public static class TestImages // Issue 3000: https://github.com/SixLabors/ImageSharp/issues/3000 public const string Issue3000 = "Png/issues/issue_3000.png"; + public static class Icc + { + public const string SRgbGray = "Png/icc-profiles/sRGB_Gray.png"; + public const string Perceptual = "Png/icc-profiles/Perceptual.png"; + public const string PerceptualcLUTOnly = "Png/icc-profiles/Perceptual-cLUT-only.png"; + } + public static class Bad { public const string MissingDataChunk = "Png/xdtn0g01.png"; diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png new file mode 100644 index 000000000..ffc983901 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b72c885278a066e63c013885c42b772275f25a5f0b2290aa38c87f3dbeac984b +size 81432 diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png new file mode 100644 index 000000000..25a97ca48 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:936261278b1a9f5bf9a2bb4f8da09f2a82e1b5c693790e137c5f98fa4d885735 +size 81785 diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray.png new file mode 100644 index 000000000..5a35cf579 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf856e49e4ece7e59eea684f6fa533ba313a36955be4703894f16b100283cb4a +size 2687 diff --git a/tests/Images/Input/Png/icc-profiles/Perceptual-cLUT-only.png b/tests/Images/Input/Png/icc-profiles/Perceptual-cLUT-only.png new file mode 100644 index 000000000..8ac1afde9 --- /dev/null +++ b/tests/Images/Input/Png/icc-profiles/Perceptual-cLUT-only.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c734cacc2c6e761bab088cac80ef09da7b56a545ce71c6cced4cac31e661795 +size 119811 diff --git a/tests/Images/Input/Png/icc-profiles/Perceptual.png b/tests/Images/Input/Png/icc-profiles/Perceptual.png new file mode 100644 index 000000000..cac9bcb1e --- /dev/null +++ b/tests/Images/Input/Png/icc-profiles/Perceptual.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:208a325dedea4453b7accce1ec540452af2e9be0f8c1f636f1d61a463eb3a9ae +size 123151 diff --git a/tests/Images/Input/Png/icc-profiles/sRGB_Gray.png b/tests/Images/Input/Png/icc-profiles/sRGB_Gray.png new file mode 100644 index 000000000..3326936ce --- /dev/null +++ b/tests/Images/Input/Png/icc-profiles/sRGB_Gray.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c64e0f6cc38750c83e6ff0cf1911e210c342900bb2cd6c88d3daed30c854e863 +size 4531 From 15d11515b77c925b884397217d56ae34cd7dd44a Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 00:07:37 -0500 Subject: [PATCH 080/112] Fix concurrency problem with MemoryAllocatorValidator --- tests/ImageSharp.Tests/MemoryAllocatorValidator.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 395dfd455..2afa5fdc9 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -22,7 +22,10 @@ public static class MemoryAllocatorValidator TestMemoryDiagnostics backing = LocalInstance.Value; if (backing != null) { - backing.TotalRemainingAllocated--; + lock (backing) + { + backing.TotalRemainingAllocated--; + } } } @@ -31,8 +34,11 @@ public static class MemoryAllocatorValidator TestMemoryDiagnostics backing = LocalInstance.Value; if (backing != null) { - backing.TotalAllocated++; - backing.TotalRemainingAllocated++; + lock (backing) + { + backing.TotalAllocated++; + backing.TotalRemainingAllocated++; + } } } From f8c8174b575fedf89e1e2924a8d187794137125b Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 00:09:45 -0500 Subject: [PATCH 081/112] Rework ApplyIccProfile to use ProcessPixelRowsAsVector4 --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 54 +++++++------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index f7eb0de1f..2a2b07389 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -26,6 +26,7 @@ using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; namespace SixLabors.ImageSharp.Formats.Png; @@ -328,7 +329,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) { - ApplyIccProfile(image, iccProfile, CompactSrgbV4Profile.Profile); + ApplyRgbaCompatibleIccProfile(image, iccProfile, CompactSrgbV4Profile.Profile); } return image; @@ -2162,8 +2163,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void SwapScanlineBuffers() => (this.scanline, this.previousScanline) = (this.previousScanline, this.scanline); - // FIXME: Maybe this could be a .Mutate(x => x.ApplyIccProfile(destinationProfile)) ? Nothing related to png here - private static void ApplyIccProfile(Image image, IccProfile sourceProfile, IccProfile destinationProfile) + private static void ApplyRgbaCompatibleIccProfile(Image image, IccProfile sourceProfile, IccProfile destinationProfile) where TPixel : unmanaged, IPixel { ColorConversionOptions options = new() @@ -2174,45 +2174,27 @@ internal sealed class PngDecoderCore : ImageDecoderCore ColorProfileConverter converter = new(options); - image.ProcessPixelRows(pixelAccessor => - { - using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelAccessor.Width * 3); - using IMemoryOwner alphaBuffer = image.Configuration.MemoryAllocator.Allocate(pixelAccessor.Width); - Span rgbPacked = rgbBuffer.Memory.Span; - ref float rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); - Span alphaPacked = alphaBuffer.Memory.Span; - ref float alphaPackedRef = ref MemoryMarshal.GetReference(alphaPacked); - - for (int y = 0; y < pixelAccessor.Height; y++) + image.Mutate(o => o.ProcessPixelRowsAsVector4((pixelsRow, _) => { - Span pixelsRow = pixelAccessor.GetRowSpan(y); - int rgbIdx = 0; - for (int x = 0; x < pixelsRow.Length; x++, rgbIdx += 3) + using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelsRow.Length); + Span rgbPacked = rgbBuffer.Memory.Span; + ref Rgb rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); + + for (int x = 0; x < pixelsRow.Length; x++) { - Vector4 rgba = pixelsRow[x].ToScaledVector4(); - Unsafe.Add(ref rgbPackedRef, rgbIdx) = rgba.X; - Unsafe.Add(ref rgbPackedRef, rgbIdx + 1) = rgba.Y; - Unsafe.Add(ref rgbPackedRef, rgbIdx + 2) = rgba.Z; - Unsafe.Add(ref alphaPackedRef, x) = rgba.W; + Unsafe.Add(ref rgbPackedRef, x) = Rgb.FromScaledVector4(pixelsRow[x]); } - Span source = MemoryMarshal.Cast(rgbPacked); - Span destination = MemoryMarshal.Cast(rgbPacked); - converter.Convert(source, destination); + converter.Convert(rgbPacked, rgbPacked); - rgbIdx = 0; - for (int x = 0; x < pixelsRow.Length; x++, rgbIdx += 3) - { - float r = Unsafe.Add(ref rgbPackedRef, rgbIdx); - float g = Unsafe.Add(ref rgbPackedRef, rgbIdx + 1); - float b = Unsafe.Add(ref rgbPackedRef, rgbIdx + 2); - float a = Unsafe.Add(ref alphaPackedRef, x); + Span pixelsRowAsFloats = MemoryMarshal.Cast(pixelsRow); + ref float pixelsRowAsFloatsRef = ref MemoryMarshal.GetReference(pixelsRowAsFloats); - pixelsRow[x] = TPixel.FromScaledVector4(new Vector4(r, g, b, a)); + int cIdx = 0; + for (int x = 0; x < pixelsRow.Length; x++, cIdx += 4) + { + Unsafe.As(ref Unsafe.Add(ref pixelsRowAsFloatsRef, cIdx)) = rgbPacked[x]; } - } - } - ); + })); } - } From 472089abfbe9eaf9771c226471752a3a7b5558fd Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 02:26:03 -0500 Subject: [PATCH 082/112] Use bulk overload to convert the pixel row from Vector4 to Rgb in ApplyRgbaCompatibleIccProfile --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 2a2b07389..5ad268233 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -2178,13 +2178,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore { using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelsRow.Length); Span rgbPacked = rgbBuffer.Memory.Span; - ref Rgb rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); - - for (int x = 0; x < pixelsRow.Length; x++) - { - Unsafe.Add(ref rgbPackedRef, x) = Rgb.FromScaledVector4(pixelsRow[x]); - } + Rgb.FromScaledVector4(pixelsRow, rgbPacked); converter.Convert(rgbPacked, rgbPacked); Span pixelsRowAsFloats = MemoryMarshal.Cast(pixelsRow); From e6d62d019a75b8d14974446ee06697dd02426a6b Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 14:02:47 -0500 Subject: [PATCH 083/112] Make sure pixel values are float between 0 and 1 during processing of ApplyRgbaCompatibleIccProfile --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 5ad268233..9da533077 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -2174,7 +2174,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore ColorProfileConverter converter = new(options); - image.Mutate(o => o.ProcessPixelRowsAsVector4((pixelsRow, _) => + image.Mutate(o => o.ProcessPixelRowsAsVector4( + (pixelsRow, _) => { using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelsRow.Length); Span rgbPacked = rgbBuffer.Memory.Span; @@ -2190,6 +2191,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { Unsafe.As(ref Unsafe.Add(ref pixelsRowAsFloatsRef, cIdx)) = rgbPacked[x]; } - })); + }, + PixelConversionModifiers.Scale)); } } From 7d06e6df3d09d50306cb4e5213e41de2d9771b8f Mon Sep 17 00:00:00 2001 From: Socolin Date: Fri, 19 Dec 2025 14:10:56 -0500 Subject: [PATCH 084/112] Use the same MemoryAllocator as the one of the image when decoding icc profile of png with ApplyRgbaCompatibleIccProfile --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 9da533077..0bea161dc 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -2170,6 +2170,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore { SourceIccProfile = sourceProfile, TargetIccProfile = destinationProfile, + MemoryAllocator = image.Configuration.MemoryAllocator, }; ColorProfileConverter converter = new(options); From 33aa0c84b78d4d525f989ac5fbddaef02676fa7e Mon Sep 17 00:00:00 2001 From: Socolin Date: Sat, 20 Dec 2025 01:01:10 -0500 Subject: [PATCH 085/112] Apply ICC profile when decoding InterlacedRgba PNG --- src/ImageSharp/ColorProfiles/Rgb.cs | 11 ++ src/ImageSharp/Formats/Png/PngDecoderCore.cs | 71 ++++++-- .../Formats/Png/PngScanlineProcessor.cs | 162 +++++++++++++----- .../Formats/Png/PngDecoderTests.cs | 2 + tests/ImageSharp.Tests/TestImages.cs | 2 + ...ile_Rgba32_sRGB_Gray_Interlaced_Rgba32.png | 3 + ...ile_Rgba32_sRGB_Gray_Interlaced_Rgba64.png | 3 + .../sRGB_Gray_Interlaced_Rgba32.png | 3 + .../sRGB_Gray_Interlaced_Rgba64.png | 3 + 9 files changed, 205 insertions(+), 55 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba32.png create mode 100644 tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba64.png create mode 100644 tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba32.png create mode 100644 tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba64.png diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 42e502592..73c761198 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -100,6 +100,17 @@ public readonly struct Rgb : IProfileConnectingSpace public Vector4 ToScaledVector4() => new(this.AsVector3Unsafe(), 1F); + /// + /// Expands the color into a generic ("scaled") representation + /// with values scaled and usually clamped between 0 and 1. + /// The vector components are typically expanded in least to greatest significance order. + /// + /// The alpha component. + /// The . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Vector4 ToScaledVector4(float alpha) + => new(this.AsVector3Unsafe(), 1F); + /// public static void ToScaledVector4(ReadOnlySpan source, Span destination) { diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 0bea161dc..b0a84341f 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -216,6 +216,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore currentFrameControl = this.ReadFrameControlChunk(chunk.Data.GetSpan()); break; case PngChunkType.FrameData: + { if (frameCount >= this.maxFrames) { goto EOF; @@ -233,6 +234,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore this.InitializeFrame(previousFrameControl, currentFrameControl.Value, image, previousFrame, out currentFrame); + if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + metadata.IccProfile = null; + } + this.currentStream.Position += 4; this.ReadScanlines( chunk.Length - 4, @@ -240,6 +246,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore pngMetadata, this.ReadNextFrameDataChunk, currentFrameControl.Value, + iccProfile, cancellationToken); // if current frame dispose is restore to previous, then from future frame's perspective, it never happened @@ -250,7 +257,10 @@ internal sealed class PngDecoderCore : ImageDecoderCore } break; + } + case PngChunkType.Data: + { pngMetadata.AnimateRootFrame = currentFrameControl != null; currentFrameControl ??= new FrameControl((uint)this.header.Width, (uint)this.header.Height); if (image is null) @@ -261,12 +271,18 @@ internal sealed class PngDecoderCore : ImageDecoderCore AssignColorPalette(this.palette, this.paletteAlpha, pngMetadata); } + if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + metadata.IccProfile = null; + } + this.ReadScanlines( chunk.Length, image.Frames.RootFrame, pngMetadata, this.ReadNextDataChunk, currentFrameControl.Value, + iccProfile, cancellationToken); if (pngMetadata.AnimateRootFrame) { @@ -280,6 +296,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore } break; + } + case PngChunkType.Palette: this.palette = chunk.Data.GetSpan().ToArray(); break; @@ -327,9 +345,9 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowNoData(); } - if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfileToApply)) { - ApplyRgbaCompatibleIccProfile(image, iccProfile, CompactSrgbV4Profile.Profile); + ApplyRgbaCompatibleIccProfile(image, iccProfileToApply, CompactSrgbV4Profile.Profile); } return image; @@ -752,6 +770,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The png metadata /// A delegate to get more data from the inner stream for . /// The frame control + /// Optional ICC profile for color conversion. /// The cancellation token. private void ReadScanlines( int chunkLength, @@ -759,6 +778,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngMetadata pngMetadata, Func getData, in FrameControl frameControl, + IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -772,11 +792,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.header.InterlaceMethod is PngInterlaceMode.Adam7) { - this.DecodeInterlacedPixelData(frameControl, dataStream, image, pngMetadata, cancellationToken); + this.DecodeInterlacedPixelData(frameControl, dataStream, image, pngMetadata, iccProfile, cancellationToken); } else { - this.DecodePixelData(frameControl, dataStream, image, pngMetadata, cancellationToken); + this.DecodePixelData(frameControl, dataStream, image, pngMetadata, iccProfile, cancellationToken); } } @@ -788,12 +808,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The compressed pixel data stream. /// The image frame to decode to. /// The png metadata + /// Optional ICC profile for color conversion. /// The CancellationToken private void DecodePixelData( FrameControl frameControl, DeflateStream compressedStream, ImageFrame imageFrame, PngMetadata pngMetadata, + IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -860,7 +882,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore break; } - this.ProcessDefilteredScanline(frameControl, currentRow, scanSpan, imageFrame, pngMetadata, blendRowBuffer); + this.ProcessDefilteredScanline(frameControl, currentRow, scanSpan, imageFrame, pngMetadata, blendRowBuffer, iccProfile); this.SwapScanlineBuffers(); currentRow++; } @@ -878,12 +900,14 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The compressed pixel data stream. /// The current image frame. /// The png metadata. + /// Optional ICC profile for color conversion. /// The cancellation token. private void DecodeInterlacedPixelData( in FrameControl frameControl, DeflateStream compressedStream, ImageFrame imageFrame, PngMetadata pngMetadata, + IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -974,6 +998,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, pngMetadata, blendRowBuffer, + iccProfile, pixelOffset: Adam7.FirstColumn[pass], increment: Adam7.ColumnIncrement[pass]); @@ -1012,13 +1037,15 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The image /// The png metadata. /// A span used to temporarily hold the decoded row pixel data for alpha blending. + /// Optional ICC profile for color conversion. private void ProcessDefilteredScanline( in FrameControl frameControl, int currentRow, ReadOnlySpan scanline, ImageFrame pixels, PngMetadata pngMetadata, - Span blendRowBuffer) + Span blendRowBuffer, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { Span destination = pixels.PixelBuffer.DangerousGetRowSpan(currentRow); @@ -1052,7 +1079,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore in frameControl, scanlineSpan, rowSpan, - pngMetadata.TransparentColor); + pngMetadata.TransparentColor, + iccProfile); break; @@ -1063,7 +1091,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore scanlineSpan, rowSpan, (uint)this.bytesPerPixel, - (uint)this.bytesPerSample); + (uint)this.bytesPerSample, + iccProfile); break; @@ -1072,7 +1101,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore in frameControl, scanlineSpan, rowSpan, - pngMetadata.ColorTable); + pngMetadata.ColorTable, + iccProfile); break; @@ -1085,7 +1115,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, this.bytesPerPixel, this.bytesPerSample, - pngMetadata.TransparentColor); + pngMetadata.TransparentColor, + iccProfile); break; @@ -1097,7 +1128,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore scanlineSpan, rowSpan, this.bytesPerPixel, - this.bytesPerSample); + this.bytesPerSample, + iccProfile); break; } @@ -1124,6 +1156,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The current image row. /// The png metadata. /// A span used to temporarily hold the decoded row pixel data for alpha blending. + /// Optional ICC profile for color conversion. /// The column start index. Always 0 for none interlaced images. /// The column increment. Always 1 for none interlaced images. private void ProcessInterlacedDefilteredScanline( @@ -1132,6 +1165,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore Span destination, PngMetadata pngMetadata, Span blendRowBuffer, + IccProfile? iccProfile, int pixelOffset = 0, int increment = 1) where TPixel : unmanaged, IPixel @@ -1166,7 +1200,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, (uint)pixelOffset, (uint)increment, - pngMetadata.TransparentColor); + pngMetadata.TransparentColor, + iccProfile); break; @@ -1179,7 +1214,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)pixelOffset, (uint)increment, (uint)this.bytesPerPixel, - (uint)this.bytesPerSample); + (uint)this.bytesPerSample, + iccProfile); break; @@ -1190,7 +1226,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, (uint)pixelOffset, (uint)increment, - pngMetadata.ColorTable); + pngMetadata.ColorTable, + iccProfile); break; @@ -1205,7 +1242,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)increment, this.bytesPerPixel, this.bytesPerSample, - pngMetadata.TransparentColor); + pngMetadata.TransparentColor, + iccProfile); break; @@ -1219,7 +1257,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)pixelOffset, (uint)increment, this.bytesPerPixel, - this.bytesPerSample); + this.bytesPerSample, + iccProfile); break; } diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 33ba58f54..ca4eaa58d 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -1,10 +1,15 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Buffers; using System.Buffers.Binary; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.Formats.Png.Chunks; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Png; @@ -20,7 +25,8 @@ internal static class PngScanlineProcessor in FrameControl frameControl, ReadOnlySpan scanlineSpan, Span rowSpan, - Color? transparentColor) + Color? transparentColor, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel => ProcessInterlacedGrayscaleScanline( bitDepth, @@ -29,7 +35,8 @@ internal static class PngScanlineProcessor rowSpan, 0, 1, - transparentColor); + transparentColor, + iccProfile); public static void ProcessInterlacedGrayscaleScanline( int bitDepth, @@ -38,9 +45,11 @@ internal static class PngScanlineProcessor Span rowSpan, uint pixelOffset, uint increment, - Color? transparentColor) + Color? transparentColor, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { + // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -98,7 +107,8 @@ internal static class PngScanlineProcessor ReadOnlySpan scanlineSpan, Span rowSpan, uint bytesPerPixel, - uint bytesPerSample) + uint bytesPerSample, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel => ProcessInterlacedGrayscaleWithAlphaScanline( bitDepth, @@ -108,7 +118,8 @@ internal static class PngScanlineProcessor 0, 1, bytesPerPixel, - bytesPerSample); + bytesPerSample, + iccProfile); public static void ProcessInterlacedGrayscaleWithAlphaScanline( int bitDepth, @@ -118,9 +129,11 @@ internal static class PngScanlineProcessor uint pixelOffset, uint increment, uint bytesPerPixel, - uint bytesPerSample) + uint bytesPerSample, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { + // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -153,7 +166,8 @@ internal static class PngScanlineProcessor in FrameControl frameControl, ReadOnlySpan scanlineSpan, Span rowSpan, - ReadOnlyMemory? palette) + ReadOnlyMemory? palette, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel => ProcessInterlacedPaletteScanline( frameControl, @@ -161,7 +175,8 @@ internal static class PngScanlineProcessor rowSpan, 0, 1, - palette); + palette, + iccProfile); public static void ProcessInterlacedPaletteScanline( in FrameControl frameControl, @@ -169,9 +184,11 @@ internal static class PngScanlineProcessor Span rowSpan, uint pixelOffset, uint increment, - ReadOnlyMemory? palette) + ReadOnlyMemory? palette, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { +// FIXME-icc if (palette is null) { PngThrowHelper.ThrowMissingPalette(); @@ -198,7 +215,8 @@ internal static class PngScanlineProcessor Span rowSpan, int bytesPerPixel, int bytesPerSample, - Color? transparentColor) + Color? transparentColor, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel => ProcessInterlacedRgbScanline( configuration, @@ -210,7 +228,8 @@ internal static class PngScanlineProcessor 1, bytesPerPixel, bytesPerSample, - transparentColor); + transparentColor, + iccProfile); public static void ProcessInterlacedRgbScanline( Configuration configuration, @@ -222,9 +241,11 @@ internal static class PngScanlineProcessor uint increment, int bytesPerPixel, int bytesPerSample, - Color? transparentColor) + Color? transparentColor, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { + // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -302,7 +323,8 @@ internal static class PngScanlineProcessor ReadOnlySpan scanlineSpan, Span rowSpan, int bytesPerPixel, - int bytesPerSample) + int bytesPerSample, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel => ProcessInterlacedRgbaScanline( configuration, @@ -313,7 +335,8 @@ internal static class PngScanlineProcessor 0, 1, bytesPerPixel, - bytesPerSample); + bytesPerSample, + iccProfile); public static void ProcessInterlacedRgbaScanline( Configuration configuration, @@ -324,43 +347,104 @@ internal static class PngScanlineProcessor uint pixelOffset, uint increment, int bytesPerPixel, - int bytesPerSample) + int bytesPerSample, + IccProfile? iccProfile) where TPixel : unmanaged, IPixel { uint offset = pixelOffset + frameControl.XOffset; ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); - if (bitDepth == 16) + if (iccProfile != null) { - int o = 0; - for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) + ColorConversionOptions options = new() + { + SourceIccProfile = iccProfile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = configuration.MemoryAllocator, + }; + + ColorProfileConverter converter = new(options); + using IMemoryOwner rgbBuffer = configuration.MemoryAllocator.Allocate((int)(frameControl.XMax - offset)); + Span rgbPacked = rgbBuffer.Memory.Span; + ref Rgb rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); + using IMemoryOwner alphaBuffer = configuration.MemoryAllocator.Allocate((int)(frameControl.XMax - offset)); + Span alphaPacked = alphaBuffer.Memory.Span; + ref float alphaPackedRef = ref MemoryMarshal.GetReference(alphaPacked); + + if (bitDepth == 16) + { + int o = 0; + for (int i = 0; i < rgbPacked.Length; o += bytesPerPixel, i++) + { + ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); + ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); + ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); + ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); + + Unsafe.Add(ref rgbPackedRef, i) = new Rgb(r / (float)ushort.MaxValue, g / (float)ushort.MaxValue, b / (float)ushort.MaxValue); + Unsafe.Add(ref alphaPackedRef, i) = a / (float)ushort.MaxValue; + } + } + else { - ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); - ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); - ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); - ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); + ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); + int o = 0; + for (int i = 0; i < rgbPacked.Length; o += bytesPerPixel, i++) + { + byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); + byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); + byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); + + Unsafe.Add(ref rgbPackedRef, i) = new Rgb(r / (float)byte.MaxValue, g / (float)byte.MaxValue, b / (float)byte.MaxValue); + Unsafe.Add(ref alphaPackedRef, i) = a / (float)byte.MaxValue; + } + } + + converter.Convert(rgbPacked, rgbPacked); + + int idx = 0; + for (nuint x = offset; x < frameControl.XMax; x += increment, idx++) + { + Rgb rgb = Unsafe.Add(ref rgbPackedRef, idx); + Vector4 rgba = rgb.ToScaledVector4(Unsafe.Add(ref alphaPackedRef, idx)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromScaledVector4(rgba); } - } - else if (pixelOffset == 0 && increment == 1) - { - PixelOperations.Instance.FromRgba32Bytes( - configuration, - scanlineSpan[..(int)(frameControl.Width * bytesPerPixel)], - rowSpan.Slice((int)frameControl.XOffset, (int)frameControl.Width), - (int)frameControl.Width); } else { - ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); - int o = 0; - for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) + if (bitDepth == 16) + { + int o = 0; + for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) + { + ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); + ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); + ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); + ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); + } + } + else if (pixelOffset == 0 && increment == 1) + { + PixelOperations.Instance.FromRgba32Bytes( + configuration, + scanlineSpan[..(int)(frameControl.Width * bytesPerPixel)], + rowSpan.Slice((int)frameControl.XOffset, (int)frameControl.Width), + (int)frameControl.Width); + } + else { - byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); - byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); - byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); - byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); + ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); + int o = 0; + for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) + { + byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); + byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); + byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); + } } } } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index 98cfd06b6..a58101a6b 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -210,6 +210,8 @@ public partial class PngDecoderTests [WithFile(TestImages.Png.Icc.Perceptual, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Icc.PerceptualcLUTOnly, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Icc.SRgbGray, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.Icc.SRgbGrayInterlacedRgba32, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.Icc.SRgbGrayInterlacedRgba64, PixelTypes.Rgba32)] public void Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 18ad62372..25bec1266 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -169,6 +169,8 @@ public static class TestImages public static class Icc { public const string SRgbGray = "Png/icc-profiles/sRGB_Gray.png"; + public const string SRgbGrayInterlacedRgba32 = "Png/icc-profiles/sRGB_Gray_Interlaced_Rgba32.png"; + public const string SRgbGrayInterlacedRgba64 = "Png/icc-profiles/sRGB_Gray_Interlaced_Rgba64.png"; public const string Perceptual = "Png/icc-profiles/Perceptual.png"; public const string PerceptualcLUTOnly = "Png/icc-profiles/Perceptual-cLUT-only.png"; } diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba32.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba32.png new file mode 100644 index 000000000..270555a55 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba32.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:337e84b78fb07359a42e7eee0eed32e6728497c64aa30c6bd5ea8a3a5ec67ebc +size 5151 diff --git a/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba64.png b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba64.png new file mode 100644 index 000000000..dc5f4a559 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/PngDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_sRGB_Gray_Interlaced_Rgba64.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:456ae30184b13aa2dc3d922db433017e076ff969862fe506436ed96c2d9be0a1 +size 6143 diff --git a/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba32.png b/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba32.png new file mode 100644 index 000000000..7afc51cfe --- /dev/null +++ b/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba32.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fc63cea5de188e76503bde2fce3ff84518af5064bb46d506420cd6d7e58285b +size 7237 diff --git a/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba64.png b/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba64.png new file mode 100644 index 000000000..822aca4f5 --- /dev/null +++ b/tests/Images/Input/Png/icc-profiles/sRGB_Gray_Interlaced_Rgba64.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64343871be4ad61451ef968fa9f07c6a11dee65d0f8fd718ae8c4941586aa60c +size 8227 From 2edab61535c53ae9c665b931c78fcf77cc55407c Mon Sep 17 00:00:00 2001 From: John Fredrickson Date: Tue, 23 Dec 2025 13:31:23 -0600 Subject: [PATCH 086/112] Write into stream instead of simply just advancing it. --- src/ImageSharp/Formats/Webp/Chunks/WebpVp8X.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Webp/Chunks/WebpVp8X.cs b/src/ImageSharp/Formats/Webp/Chunks/WebpVp8X.cs index 491f71650..7cec7c1db 100644 --- a/src/ImageSharp/Formats/Webp/Chunks/WebpVp8X.cs +++ b/src/ImageSharp/Formats/Webp/Chunks/WebpVp8X.cs @@ -123,7 +123,10 @@ internal readonly struct WebpVp8X : IEquatable long pos = RiffHelper.BeginWriteChunk(stream, (uint)WebpChunkType.Vp8X); stream.WriteByte(flags); - stream.Position += 3; // Reserved bytes + + Span reserved = stackalloc byte[3]; + stream.Write(reserved); + WebpChunkParsingUtils.WriteUInt24LittleEndian(stream, this.Width - 1); WebpChunkParsingUtils.WriteUInt24LittleEndian(stream, this.Height - 1); From adf677a829590b02a72753e741506b9615c635c5 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 28 Dec 2025 17:25:08 +0100 Subject: [PATCH 087/112] Add test for writing reserved bytes in WebpVp8X --- .../Formats/WebP/WebpVp8XTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/ImageSharp.Tests/Formats/WebP/WebpVp8XTests.cs diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpVp8XTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpVp8XTests.cs new file mode 100644 index 000000000..78be0bf9f --- /dev/null +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpVp8XTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using SixLabors.ImageSharp.Formats.Webp.Chunks; + +namespace SixLabors.ImageSharp.Tests.Formats.WebP; + +[Trait("Format", "Webp")] +public class WebpVp8XTests +{ + [Fact] + public void WebpVp8X_WriteTo_Writes_Reserved_Bytes() + { + // arrange + WebpVp8X header = new(false, false, false, false, false, 10, 40); + MemoryStream ms = new(); + byte[] expected = [86, 80, 56, 88, 10, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 39, 0, 0]; + + // act + header.WriteTo(ms); + + // assert + byte[] actual = ms.ToArray(); + Assert.Equal(expected, actual); + } +} From 82eb56b1180ec1e509219b2e3732841db7d3dff9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 15:26:26 +1000 Subject: [PATCH 088/112] Basic fallback functionality complete --- .../ColorProfileConverterExtensionsIcc.cs | 41 +++++++++++ ...ofileConverterExtensionsPixelCompatible.cs | 72 +++++++++++++++++++ src/ImageSharp/Formats/ImageDecoderCore.cs | 40 +++++++++++ src/ImageSharp/Formats/Png/PngDecoderCore.cs | 53 ++------------ .../MemoryAllocatorValidator.cs | 35 +++++---- 5 files changed, 177 insertions(+), 64 deletions(-) create mode 100644 src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs index 3ddbf93b5..fd99fb446 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsIcc.cs @@ -39,6 +39,24 @@ internal static class ColorProfileConverterExtensionsIcc 0.0033717495F, 0.0034852044F, 0.0028800198F, 0F, 0.0033717495F, 0.0034852044F, 0.0028800198F, 0F]; + /// + /// Converts a color value from one ICC color profile to another using the specified color profile converter. + /// + /// + /// This method performs color conversion using ICC profiles, ensuring accurate color mapping + /// between different color spaces. Both the source and target ICC profiles must be provided in the converter's + /// options. The method supports perceptual adjustments when required by the profiles. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter configured with source and target ICC profiles. + /// The color value to convert, defined in the source color profile. + /// + /// A color value in the target color profile, resulting from the ICC profile-based conversion of the source value. + /// + /// + /// Thrown if either the source or target ICC profile is missing from the converter options. + /// internal static TTo ConvertUsingIccProfile(this ColorProfileConverter converter, in TFrom source) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile @@ -81,6 +99,29 @@ internal static class ColorProfileConverterExtensionsIcc return TTo.FromScaledVector4(targetParams.Converter.Calculate(targetPcs)); } + /// + /// Converts a span of color values from a source color profile to a destination color profile using ICC profiles. + /// + /// + /// This method performs color conversion by transforming the input values through the Profile + /// Connection Space (PCS) as defined by the provided ICC profiles. Perceptual adjustments are applied as required + /// by the profiles. The method does not support absolute colorimetric intent and will not perform such + /// conversions. + /// + /// The type representing the source color profile. Must implement . + /// The type representing the destination color profile. Must implement . + /// The color profile converter that provides conversion options and ICC profiles. + /// + /// A read-only span containing the source color values to convert. The values must conform to the source color + /// profile. + /// + /// + /// A span to receive the converted color values in the destination color profile. Must be at least as large as the + /// source span. + /// + /// + /// Thrown if the source or target ICC profile is missing from the converter options. + /// internal static void ConvertUsingIccProfile(this ColorProfileConverter converter, ReadOnlySpan source, Span destination) where TFrom : struct, IColorProfile where TTo : struct, IColorProfile diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs new file mode 100644 index 000000000..5f3d42afb --- /dev/null +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs @@ -0,0 +1,72 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; + +namespace SixLabors.ImageSharp.ColorProfiles; + +internal static class ColorProfileConverterExtensionsPixelCompatible +{ + /// + /// Converts the pixel data of the specified image from the source color profile to the target color profile using + /// the provided color profile converter. + /// + /// + /// This method modifies the source image in place by converting its pixel data according to the + /// color profiles specified in the converter. The method does not verify whether the profiles are RGB compatible; + /// if they are not, the conversion may produce incorrect results. Ensure that both the source and target ICC + /// profiles are set on the converter before calling this method. + /// + /// The pixel format. + /// The color profile converter configured with source and target ICC profiles. + /// + /// The image whose pixel data will be converted. The conversion is performed in place, modifying the original + /// image. + /// + /// + /// Thrown if the converter's source or target ICC profile is not specified. + /// + public static void Convert(this ColorProfileConverter converter, Image source) + where TPixel : unmanaged, IPixel + { + // These checks actually take place within the converter, but we want to fail fast here. + // Note. we do not check to see whether the profiles themselves are RGB compatible, + // if they are not, then the converter will simply produce incorrect results. + if (converter.Options.SourceIccProfile is null) + { + throw new InvalidOperationException("Source ICC profile is missing."); + } + + if (converter.Options.TargetIccProfile is null) + { + throw new InvalidOperationException("Target ICC profile is missing."); + } + + // Process the rows in parallel chnks, the converter itself is thread safe. + source.Mutate(o => o.ProcessPixelRowsAsVector4( + row => + { + // Gather and convert the pixels in the row to Rgb. + using IMemoryOwner rgbBuffer = converter.Options.MemoryAllocator.Allocate(row.Length); + Span rgbSpan = rgbBuffer.Memory.Span; + Rgb.FromScaledVector4(row, rgbSpan); + + // Perform the actual color conversion. + converter.ConvertUsingIccProfile(rgbSpan, rgbSpan); + + // Copy the converted Rgb pixels back to the row as TPixel. + ref Vector4 rowRef = ref MemoryMarshal.GetReference(row); + for (int i = 0; i < rgbSpan.Length; i++) + { + Vector3 rgb = rgbSpan[i].AsVector3Unsafe(); + Unsafe.As(ref Unsafe.Add(ref rowRef, i)) = rgb; + } + }, + PixelConversionModifiers.Scale)); + } +} diff --git a/src/ImageSharp/Formats/ImageDecoderCore.cs b/src/ImageSharp/Formats/ImageDecoderCore.cs index adf0107da..da50a1abe 100644 --- a/src/ImageSharp/Formats/ImageDecoderCore.cs +++ b/src/ImageSharp/Formats/ImageDecoderCore.cs @@ -1,8 +1,11 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats; @@ -124,4 +127,41 @@ internal abstract class ImageDecoderCore /// protected abstract Image Decode(BufferedReadStream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel; + + /// + /// Converts the ICC color profile of the specified image to the compact sRGB v4 profile if a source profile is + /// available. + /// + /// + /// This method should only be used by decoders that gurantee that the encoded image data is in a color space + /// compatible with sRGB (e.g. standard RGB, Adobe RGB, ProPhoto RGB). + ///
+ /// If the image does not have a valid ICC profile for color conversion, no changes are made. + /// This operation may affect the color appearance of the image to ensure consistency with the sRGB color + /// space. + ///
+ /// The pixel format. + /// The image whose ICC profile will be converted to the compact sRGB v4 profile. + /// + /// if the conversion was performed; otherwise, . + /// + protected bool TryConvertIccProfile(Image image) + where TPixel : unmanaged, IPixel + { + if (!this.Options.TryGetIccProfileForColorConversion(image.Metadata.IccProfile, out IccProfile? profile)) + { + return false; + } + + ColorConversionOptions options = new() + { + SourceIccProfile = profile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = image.Configuration.MemoryAllocator, + }; + + ColorProfileConverter converter = new(options); + converter.Convert(image); + return true; + } } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index b0a84341f..4c9bd6f32 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -7,12 +7,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO.Compression; using System.IO.Hashing; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -using SixLabors.ImageSharp.ColorProfiles; -using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Compression.Zlib; using SixLabors.ImageSharp.Formats.Png.Chunks; @@ -26,7 +23,6 @@ using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; namespace SixLabors.ImageSharp.Formats.Png; @@ -234,9 +230,10 @@ internal sealed class PngDecoderCore : ImageDecoderCore this.InitializeFrame(previousFrameControl, currentFrameControl.Value, image, previousFrame, out currentFrame); - if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + if (!this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) { - metadata.IccProfile = null; + // TODO: Rework this. We need to preserve metadata + // metadata.IccProfile = null; } this.currentStream.Position += 4; @@ -271,9 +268,10 @@ internal sealed class PngDecoderCore : ImageDecoderCore AssignColorPalette(this.palette, this.paletteAlpha, pngMetadata); } - if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + if (!this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) { - metadata.IccProfile = null; + // TODO: Rework this. We need to preserve metadata + // metadata.IccProfile = null; } this.ReadScanlines( @@ -345,11 +343,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngThrowHelper.ThrowNoData(); } - if (this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfileToApply)) - { - ApplyRgbaCompatibleIccProfile(image, iccProfileToApply, CompactSrgbV4Profile.Profile); - } - + _ = this.TryConvertIccProfile(image); return image; } catch @@ -2201,37 +2195,4 @@ internal sealed class PngDecoderCore : ImageDecoderCore private void SwapScanlineBuffers() => (this.scanline, this.previousScanline) = (this.previousScanline, this.scanline); - - private static void ApplyRgbaCompatibleIccProfile(Image image, IccProfile sourceProfile, IccProfile destinationProfile) - where TPixel : unmanaged, IPixel - { - ColorConversionOptions options = new() - { - SourceIccProfile = sourceProfile, - TargetIccProfile = destinationProfile, - MemoryAllocator = image.Configuration.MemoryAllocator, - }; - - ColorProfileConverter converter = new(options); - - image.Mutate(o => o.ProcessPixelRowsAsVector4( - (pixelsRow, _) => - { - using IMemoryOwner rgbBuffer = image.Configuration.MemoryAllocator.Allocate(pixelsRow.Length); - Span rgbPacked = rgbBuffer.Memory.Span; - - Rgb.FromScaledVector4(pixelsRow, rgbPacked); - converter.Convert(rgbPacked, rgbPacked); - - Span pixelsRowAsFloats = MemoryMarshal.Cast(pixelsRow); - ref float pixelsRowAsFloatsRef = ref MemoryMarshal.GetReference(pixelsRowAsFloats); - - int cIdx = 0; - for (int x = 0; x < pixelsRow.Length; x++, cIdx += 4) - { - Unsafe.As(ref Unsafe.Add(ref pixelsRowAsFloatsRef, cIdx)) = rgbPacked[x]; - } - }, - PixelConversionModifiers.Scale)); - } } diff --git a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs index 2afa5fdc9..6c8dd2618 100644 --- a/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs +++ b/tests/ImageSharp.Tests/MemoryAllocatorValidator.cs @@ -20,26 +20,13 @@ public static class MemoryAllocatorValidator private static void MemoryDiagnostics_MemoryReleased() { TestMemoryDiagnostics backing = LocalInstance.Value; - if (backing != null) - { - lock (backing) - { - backing.TotalRemainingAllocated--; - } - } + backing?.OnReleased(); } private static void MemoryDiagnostics_MemoryAllocated() { TestMemoryDiagnostics backing = LocalInstance.Value; - if (backing != null) - { - lock (backing) - { - backing.TotalAllocated++; - backing.TotalRemainingAllocated++; - } - } + backing?.OnAllocated(); } public static TestMemoryDiagnostics MonitorAllocations() @@ -54,11 +41,23 @@ public static class MemoryAllocatorValidator public static void ValidateAllocations(int expectedAllocationCount = 0) => LocalInstance.Value?.Validate(expectedAllocationCount); - public class TestMemoryDiagnostics : IDisposable + public sealed class TestMemoryDiagnostics : IDisposable { - public int TotalAllocated { get; set; } + private int totalAllocated; + private int totalRemainingAllocated; + + public int TotalAllocated => Volatile.Read(ref this.totalAllocated); + + public int TotalRemainingAllocated => Volatile.Read(ref this.totalRemainingAllocated); + + internal void OnAllocated() + { + Interlocked.Increment(ref this.totalAllocated); + Interlocked.Increment(ref this.totalRemainingAllocated); + } - public int TotalRemainingAllocated { get; set; } + internal void OnReleased() + => Interlocked.Decrement(ref this.totalRemainingAllocated); public void Validate(int expectedAllocationCount) { From d9183d54e73e2d1d28548477cc1d731f2b72fca2 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 15:35:50 +1000 Subject: [PATCH 089/112] Add dev note [skip ci] --- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 4c9bd6f32..f0d3f3339 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -1134,6 +1134,8 @@ internal sealed class PngDecoderCore : ImageDecoderCore PixelOperations.Instance.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.SrcOver); blender.Blend(this.configuration, destination, destination, rowSpan, 1F); } + + // TODO: Here is where we would perform ICC color conversion if needed over the 'destination' span. } finally { From bb93350bb562dfb27ef16d21a8eef2186c50d054 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 21:00:17 +1000 Subject: [PATCH 090/112] Remove per-pixel transform --- ...ofileConverterExtensionsPixelCompatible.cs | 4 +- src/ImageSharp/Formats/Png/PngDecoderCore.cs | 65 ++----- .../Formats/Png/PngScanlineProcessor.cs | 162 +++++------------- 3 files changed, 55 insertions(+), 176 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs index 5f3d42afb..2780f04ba 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs @@ -47,7 +47,7 @@ internal static class ColorProfileConverterExtensionsPixelCompatible throw new InvalidOperationException("Target ICC profile is missing."); } - // Process the rows in parallel chnks, the converter itself is thread safe. + // Process the rows in parallel chunks, the converter itself is thread safe. source.Mutate(o => o.ProcessPixelRowsAsVector4( row => { @@ -64,7 +64,7 @@ internal static class ColorProfileConverterExtensionsPixelCompatible for (int i = 0; i < rgbSpan.Length; i++) { Vector3 rgb = rgbSpan[i].AsVector3Unsafe(); - Unsafe.As(ref Unsafe.Add(ref rowRef, i)) = rgb; + Unsafe.As(ref Unsafe.Add(ref rowRef, (uint)i)) = rgb; } }, PixelConversionModifiers.Scale)); diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index f0d3f3339..bff4d30ee 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -230,12 +230,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore this.InitializeFrame(previousFrameControl, currentFrameControl.Value, image, previousFrame, out currentFrame); - if (!this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) - { - // TODO: Rework this. We need to preserve metadata - // metadata.IccProfile = null; - } - this.currentStream.Position += 4; this.ReadScanlines( chunk.Length - 4, @@ -243,7 +237,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore pngMetadata, this.ReadNextFrameDataChunk, currentFrameControl.Value, - iccProfile, cancellationToken); // if current frame dispose is restore to previous, then from future frame's perspective, it never happened @@ -268,19 +261,12 @@ internal sealed class PngDecoderCore : ImageDecoderCore AssignColorPalette(this.palette, this.paletteAlpha, pngMetadata); } - if (!this.Options.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) - { - // TODO: Rework this. We need to preserve metadata - // metadata.IccProfile = null; - } - this.ReadScanlines( chunk.Length, image.Frames.RootFrame, pngMetadata, this.ReadNextDataChunk, currentFrameControl.Value, - iccProfile, cancellationToken); if (pngMetadata.AnimateRootFrame) { @@ -764,7 +750,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The png metadata /// A delegate to get more data from the inner stream for . /// The frame control - /// Optional ICC profile for color conversion. /// The cancellation token. private void ReadScanlines( int chunkLength, @@ -772,7 +757,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore PngMetadata pngMetadata, Func getData, in FrameControl frameControl, - IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -786,11 +770,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore if (this.header.InterlaceMethod is PngInterlaceMode.Adam7) { - this.DecodeInterlacedPixelData(frameControl, dataStream, image, pngMetadata, iccProfile, cancellationToken); + this.DecodeInterlacedPixelData(frameControl, dataStream, image, pngMetadata, cancellationToken); } else { - this.DecodePixelData(frameControl, dataStream, image, pngMetadata, iccProfile, cancellationToken); + this.DecodePixelData(frameControl, dataStream, image, pngMetadata, cancellationToken); } } @@ -802,14 +786,12 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The compressed pixel data stream. /// The image frame to decode to. /// The png metadata - /// Optional ICC profile for color conversion. /// The CancellationToken private void DecodePixelData( FrameControl frameControl, DeflateStream compressedStream, ImageFrame imageFrame, PngMetadata pngMetadata, - IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -876,7 +858,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore break; } - this.ProcessDefilteredScanline(frameControl, currentRow, scanSpan, imageFrame, pngMetadata, blendRowBuffer, iccProfile); + this.ProcessDefilteredScanline(frameControl, currentRow, scanSpan, imageFrame, pngMetadata, blendRowBuffer); this.SwapScanlineBuffers(); currentRow++; } @@ -894,14 +876,12 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The compressed pixel data stream. /// The current image frame. /// The png metadata. - /// Optional ICC profile for color conversion. /// The cancellation token. private void DecodeInterlacedPixelData( in FrameControl frameControl, DeflateStream compressedStream, ImageFrame imageFrame, PngMetadata pngMetadata, - IccProfile? iccProfile, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { @@ -992,7 +972,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, pngMetadata, blendRowBuffer, - iccProfile, pixelOffset: Adam7.FirstColumn[pass], increment: Adam7.ColumnIncrement[pass]); @@ -1031,15 +1010,13 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The image /// The png metadata. /// A span used to temporarily hold the decoded row pixel data for alpha blending. - /// Optional ICC profile for color conversion. private void ProcessDefilteredScanline( in FrameControl frameControl, int currentRow, ReadOnlySpan scanline, ImageFrame pixels, PngMetadata pngMetadata, - Span blendRowBuffer, - IccProfile? iccProfile) + Span blendRowBuffer) where TPixel : unmanaged, IPixel { Span destination = pixels.PixelBuffer.DangerousGetRowSpan(currentRow); @@ -1073,8 +1050,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore in frameControl, scanlineSpan, rowSpan, - pngMetadata.TransparentColor, - iccProfile); + pngMetadata.TransparentColor); break; @@ -1085,8 +1061,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore scanlineSpan, rowSpan, (uint)this.bytesPerPixel, - (uint)this.bytesPerSample, - iccProfile); + (uint)this.bytesPerSample); break; @@ -1095,8 +1070,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore in frameControl, scanlineSpan, rowSpan, - pngMetadata.ColorTable, - iccProfile); + pngMetadata.ColorTable); break; @@ -1109,8 +1083,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, this.bytesPerPixel, this.bytesPerSample, - pngMetadata.TransparentColor, - iccProfile); + pngMetadata.TransparentColor); break; @@ -1122,8 +1095,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore scanlineSpan, rowSpan, this.bytesPerPixel, - this.bytesPerSample, - iccProfile); + this.bytesPerSample); break; } @@ -1134,8 +1106,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore PixelOperations.Instance.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.SrcOver); blender.Blend(this.configuration, destination, destination, rowSpan, 1F); } - - // TODO: Here is where we would perform ICC color conversion if needed over the 'destination' span. } finally { @@ -1152,7 +1122,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// The current image row. /// The png metadata. /// A span used to temporarily hold the decoded row pixel data for alpha blending. - /// Optional ICC profile for color conversion. /// The column start index. Always 0 for none interlaced images. /// The column increment. Always 1 for none interlaced images. private void ProcessInterlacedDefilteredScanline( @@ -1161,7 +1130,6 @@ internal sealed class PngDecoderCore : ImageDecoderCore Span destination, PngMetadata pngMetadata, Span blendRowBuffer, - IccProfile? iccProfile, int pixelOffset = 0, int increment = 1) where TPixel : unmanaged, IPixel @@ -1196,8 +1164,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, (uint)pixelOffset, (uint)increment, - pngMetadata.TransparentColor, - iccProfile); + pngMetadata.TransparentColor); break; @@ -1210,8 +1177,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)pixelOffset, (uint)increment, (uint)this.bytesPerPixel, - (uint)this.bytesPerSample, - iccProfile); + (uint)this.bytesPerSample); break; @@ -1222,8 +1188,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore rowSpan, (uint)pixelOffset, (uint)increment, - pngMetadata.ColorTable, - iccProfile); + pngMetadata.ColorTable); break; @@ -1238,8 +1203,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)increment, this.bytesPerPixel, this.bytesPerSample, - pngMetadata.TransparentColor, - iccProfile); + pngMetadata.TransparentColor); break; @@ -1253,8 +1217,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore (uint)pixelOffset, (uint)increment, this.bytesPerPixel, - this.bytesPerSample, - iccProfile); + this.bytesPerSample); break; } diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index ca4eaa58d..33ba58f54 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -1,15 +1,10 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Buffers; using System.Buffers.Binary; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using SixLabors.ImageSharp.ColorProfiles; -using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.Formats.Png.Chunks; -using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Png; @@ -25,8 +20,7 @@ internal static class PngScanlineProcessor in FrameControl frameControl, ReadOnlySpan scanlineSpan, Span rowSpan, - Color? transparentColor, - IccProfile? iccProfile) + Color? transparentColor) where TPixel : unmanaged, IPixel => ProcessInterlacedGrayscaleScanline( bitDepth, @@ -35,8 +29,7 @@ internal static class PngScanlineProcessor rowSpan, 0, 1, - transparentColor, - iccProfile); + transparentColor); public static void ProcessInterlacedGrayscaleScanline( int bitDepth, @@ -45,11 +38,9 @@ internal static class PngScanlineProcessor Span rowSpan, uint pixelOffset, uint increment, - Color? transparentColor, - IccProfile? iccProfile) + Color? transparentColor) where TPixel : unmanaged, IPixel { - // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -107,8 +98,7 @@ internal static class PngScanlineProcessor ReadOnlySpan scanlineSpan, Span rowSpan, uint bytesPerPixel, - uint bytesPerSample, - IccProfile? iccProfile) + uint bytesPerSample) where TPixel : unmanaged, IPixel => ProcessInterlacedGrayscaleWithAlphaScanline( bitDepth, @@ -118,8 +108,7 @@ internal static class PngScanlineProcessor 0, 1, bytesPerPixel, - bytesPerSample, - iccProfile); + bytesPerSample); public static void ProcessInterlacedGrayscaleWithAlphaScanline( int bitDepth, @@ -129,11 +118,9 @@ internal static class PngScanlineProcessor uint pixelOffset, uint increment, uint bytesPerPixel, - uint bytesPerSample, - IccProfile? iccProfile) + uint bytesPerSample) where TPixel : unmanaged, IPixel { - // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -166,8 +153,7 @@ internal static class PngScanlineProcessor in FrameControl frameControl, ReadOnlySpan scanlineSpan, Span rowSpan, - ReadOnlyMemory? palette, - IccProfile? iccProfile) + ReadOnlyMemory? palette) where TPixel : unmanaged, IPixel => ProcessInterlacedPaletteScanline( frameControl, @@ -175,8 +161,7 @@ internal static class PngScanlineProcessor rowSpan, 0, 1, - palette, - iccProfile); + palette); public static void ProcessInterlacedPaletteScanline( in FrameControl frameControl, @@ -184,11 +169,9 @@ internal static class PngScanlineProcessor Span rowSpan, uint pixelOffset, uint increment, - ReadOnlyMemory? palette, - IccProfile? iccProfile) + ReadOnlyMemory? palette) where TPixel : unmanaged, IPixel { -// FIXME-icc if (palette is null) { PngThrowHelper.ThrowMissingPalette(); @@ -215,8 +198,7 @@ internal static class PngScanlineProcessor Span rowSpan, int bytesPerPixel, int bytesPerSample, - Color? transparentColor, - IccProfile? iccProfile) + Color? transparentColor) where TPixel : unmanaged, IPixel => ProcessInterlacedRgbScanline( configuration, @@ -228,8 +210,7 @@ internal static class PngScanlineProcessor 1, bytesPerPixel, bytesPerSample, - transparentColor, - iccProfile); + transparentColor); public static void ProcessInterlacedRgbScanline( Configuration configuration, @@ -241,11 +222,9 @@ internal static class PngScanlineProcessor uint increment, int bytesPerPixel, int bytesPerSample, - Color? transparentColor, - IccProfile? iccProfile) + Color? transparentColor) where TPixel : unmanaged, IPixel { - // FIXME-icc uint offset = pixelOffset + frameControl.XOffset; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); @@ -323,8 +302,7 @@ internal static class PngScanlineProcessor ReadOnlySpan scanlineSpan, Span rowSpan, int bytesPerPixel, - int bytesPerSample, - IccProfile? iccProfile) + int bytesPerSample) where TPixel : unmanaged, IPixel => ProcessInterlacedRgbaScanline( configuration, @@ -335,8 +313,7 @@ internal static class PngScanlineProcessor 0, 1, bytesPerPixel, - bytesPerSample, - iccProfile); + bytesPerSample); public static void ProcessInterlacedRgbaScanline( Configuration configuration, @@ -347,104 +324,43 @@ internal static class PngScanlineProcessor uint pixelOffset, uint increment, int bytesPerPixel, - int bytesPerSample, - IccProfile? iccProfile) + int bytesPerSample) where TPixel : unmanaged, IPixel { uint offset = pixelOffset + frameControl.XOffset; ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); - if (iccProfile != null) + if (bitDepth == 16) { - ColorConversionOptions options = new() - { - SourceIccProfile = iccProfile, - TargetIccProfile = CompactSrgbV4Profile.Profile, - MemoryAllocator = configuration.MemoryAllocator, - }; - - ColorProfileConverter converter = new(options); - using IMemoryOwner rgbBuffer = configuration.MemoryAllocator.Allocate((int)(frameControl.XMax - offset)); - Span rgbPacked = rgbBuffer.Memory.Span; - ref Rgb rgbPackedRef = ref MemoryMarshal.GetReference(rgbPacked); - using IMemoryOwner alphaBuffer = configuration.MemoryAllocator.Allocate((int)(frameControl.XMax - offset)); - Span alphaPacked = alphaBuffer.Memory.Span; - ref float alphaPackedRef = ref MemoryMarshal.GetReference(alphaPacked); - - if (bitDepth == 16) - { - int o = 0; - for (int i = 0; i < rgbPacked.Length; o += bytesPerPixel, i++) - { - ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); - ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); - ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); - ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); - - Unsafe.Add(ref rgbPackedRef, i) = new Rgb(r / (float)ushort.MaxValue, g / (float)ushort.MaxValue, b / (float)ushort.MaxValue); - Unsafe.Add(ref alphaPackedRef, i) = a / (float)ushort.MaxValue; - } - } - else - { - ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); - int o = 0; - for (int i = 0; i < rgbPacked.Length; o += bytesPerPixel, i++) - { - byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); - byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); - byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); - byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); - - Unsafe.Add(ref rgbPackedRef, i) = new Rgb(r / (float)byte.MaxValue, g / (float)byte.MaxValue, b / (float)byte.MaxValue); - Unsafe.Add(ref alphaPackedRef, i) = a / (float)byte.MaxValue; - } - } - - converter.Convert(rgbPacked, rgbPacked); - - int idx = 0; - for (nuint x = offset; x < frameControl.XMax; x += increment, idx++) + int o = 0; + for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) { - Rgb rgb = Unsafe.Add(ref rgbPackedRef, idx); - Vector4 rgba = rgb.ToScaledVector4(Unsafe.Add(ref alphaPackedRef, idx)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromScaledVector4(rgba); + ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); + ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); + ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); + ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); } } + else if (pixelOffset == 0 && increment == 1) + { + PixelOperations.Instance.FromRgba32Bytes( + configuration, + scanlineSpan[..(int)(frameControl.Width * bytesPerPixel)], + rowSpan.Slice((int)frameControl.XOffset, (int)frameControl.Width), + (int)frameControl.Width); + } else { - if (bitDepth == 16) - { - int o = 0; - for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) - { - ushort r = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o, bytesPerSample)); - ushort g = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + bytesPerSample, bytesPerSample)); - ushort b = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (2 * bytesPerSample), bytesPerSample)); - ushort a = BinaryPrimitives.ReadUInt16BigEndian(scanlineSpan.Slice(o + (3 * bytesPerSample), bytesPerSample)); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba64(new Rgba64(r, g, b, a)); - } - } - else if (pixelOffset == 0 && increment == 1) - { - PixelOperations.Instance.FromRgba32Bytes( - configuration, - scanlineSpan[..(int)(frameControl.Width * bytesPerPixel)], - rowSpan.Slice((int)frameControl.XOffset, (int)frameControl.Width), - (int)frameControl.Width); - } - else + ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); + int o = 0; + for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) { - ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); - int o = 0; - for (nuint x = offset; x < frameControl.XMax; x += increment, o += bytesPerPixel) - { - byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); - byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); - byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); - byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); - Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); - } + byte r = Unsafe.Add(ref scanlineSpanRef, (uint)o); + byte g = Unsafe.Add(ref scanlineSpanRef, (uint)(o + bytesPerSample)); + byte b = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (2 * bytesPerSample))); + byte a = Unsafe.Add(ref scanlineSpanRef, (uint)(o + (3 * bytesPerSample))); + Unsafe.Add(ref rowSpanRef, x) = TPixel.FromRgba32(new Rgba32(r, g, b, a)); } } } From ce7835694f5e6af7c4dc7b2e34e99de471c245b7 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 21:03:28 +1000 Subject: [PATCH 091/112] Update Rgb.cs --- src/ImageSharp/ColorProfiles/Rgb.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 73c761198..42e502592 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -100,17 +100,6 @@ public readonly struct Rgb : IProfileConnectingSpace public Vector4 ToScaledVector4() => new(this.AsVector3Unsafe(), 1F); - /// - /// Expands the color into a generic ("scaled") representation - /// with values scaled and usually clamped between 0 and 1. - /// The vector components are typically expanded in least to greatest significance order. - /// - /// The alpha component. - /// The . - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector4 ToScaledVector4(float alpha) - => new(this.AsVector3Unsafe(), 1F); - /// public static void ToScaledVector4(ReadOnlySpan source, Span destination) { From bca619751783680b416b140ca0b93991f197f166 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 23:18:55 +1000 Subject: [PATCH 092/112] Make UnmanagedMemoryHandle members readonly and improve pool finalization tests --- .../Internals/UnmanagedMemoryHandle.cs | 14 +- ...niformUnmanagedPoolMemoryAllocatorTests.cs | 162 +++++++++--------- 2 files changed, 90 insertions(+), 86 deletions(-) diff --git a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs index 6b31cadf4..632e1bec0 100644 --- a/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs +++ b/src/ImageSharp/Memory/Allocators/Internals/UnmanagedMemoryHandle.cs @@ -39,13 +39,13 @@ internal struct UnmanagedMemoryHandle : IEquatable Interlocked.Increment(ref totalOutstandingHandles); } - public IntPtr Handle => this.handle; + public readonly IntPtr Handle => this.handle; - public bool IsInvalid => this.Handle == IntPtr.Zero; + public readonly bool IsInvalid => this.Handle == IntPtr.Zero; - public bool IsValid => this.Handle != IntPtr.Zero; + public readonly bool IsValid => this.Handle != IntPtr.Zero; - public unsafe void* Pointer => (void*)this.Handle; + public readonly unsafe void* Pointer => (void*)this.Handle; /// /// Gets the total outstanding handle allocations for testing purposes. @@ -121,9 +121,9 @@ internal struct UnmanagedMemoryHandle : IEquatable this.lengthInBytes = 0; } - public bool Equals(UnmanagedMemoryHandle other) => this.handle.Equals(other.handle); + public readonly bool Equals(UnmanagedMemoryHandle other) => this.handle.Equals(other.handle); - public override bool Equals(object? obj) => obj is UnmanagedMemoryHandle other && this.Equals(other); + public override readonly bool Equals(object? obj) => obj is UnmanagedMemoryHandle other && this.Equals(other); - public override int GetHashCode() => this.handle.GetHashCode(); + public override readonly int GetHashCode() => this.handle.GetHashCode(); } diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index 6e7e9fea7..f3cb6a5e5 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Buffers; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Microsoft.DotNet.RemoteExecutor; @@ -273,67 +274,76 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [InlineData(1200)] // Group of two UniformUnmanagedMemoryPool buffers public void AllocateMemoryGroup_Finalization_ReturnsToPool(int length) { - if (TestEnvironment.IsMacOS) - { - // Skip on macOS: https://github.com/SixLabors/ImageSharp/issues/1887 - return; - } - - if (TestEnvironment.OSArchitecture == Architecture.Arm64) - { - // Skip on ARM64: https://github.com/SixLabors/ImageSharp/issues/2342 - return; - } - - if (!TestEnvironment.RunsOnCI) - { - // This may fail in local runs resulting in high memory load. - // Remove the condition for local debugging! - return; - } - - // RunTest(length.ToString()); - RemoteExecutor.Invoke(RunTest, length.ToString()).Dispose(); + RemoteExecutor.Invoke(RunTest, length.ToString(CultureInfo.InvariantCulture)).Dispose(); static void RunTest(string lengthStr) { UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); - int lengthInner = int.Parse(lengthStr); - + int lengthInner = int.Parse(lengthStr, CultureInfo.InvariantCulture); + + // We want to verify that a leaked (not disposed) `MemoryGroup` still returns its + // unmanaged handles into the pool when it is finalized. + // + // We intentionally do NOT validate this by checking the contents of the re-rented memory + // (contents are not guaranteed to be preserved) nor by comparing pointer values + // (the pool may return a different handle while still correctly pooling). + // + // Instead, we validate that after a forced GC+finalization cycle, a subsequent allocation + // of the same size does not cause the number of outstanding unmanaged handles to *increase* + // compared to a known baseline. + + // Establish a baseline: create one allocation and dispose it so the pool is initialized. + // (This ensures subsequent observations are not biased by first-time pool growth.) + allocator.AllocateGroup(lengthInner, 100).Dispose(); + int baselineHandles = UnmanagedMemoryHandle.TotalOutstandingHandles; + + // Leak one allocation and force finalization. AllocateGroupAndForget(allocator, lengthInner); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); - AllocateGroupAndForget(allocator, lengthInner, true); - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - GC.WaitForPendingFinalizers(); - - using MemoryGroup g = allocator.AllocateGroup(lengthInner, 100); - Assert.Equal(42, g.First().Span[0]); + // Allocate again. If the leaked group was finalized correctly and returned to the pool, + // this should not require additional unmanaged allocations (ie, the handle count must not grow). + allocator.AllocateGroup(lengthInner, 100).Dispose(); + + // Note: we use "<=" instead of "==" here. + // + // After we record the baseline, the pool is allowed to legitimately *decrease* + // `UnmanagedMemoryHandle.TotalOutstandingHandles` by trimming retained buffers + // (eg. via the pool's trim timer/GC callbacks/high-pressure logic). + // + // What must not happen is the opposite: the leaked (non-disposed) group should be finalized + // and its handles returned to the pool such that allocating again does NOT require creating + // additional unmanaged handles. Therefore the only invariant we can reliably assert here is + // "no growth" relative to the baseline. + Assert.True(UnmanagedMemoryHandle.TotalOutstandingHandles <= baselineHandles); + GC.KeepAlive(allocator); } } - private static void AllocateGroupAndForget(UniformUnmanagedMemoryPoolMemoryAllocator allocator, int length, bool check = false) + [MethodImpl(MethodImplOptions.NoInlining)] + private static void AllocateGroupAndForget(UniformUnmanagedMemoryPoolMemoryAllocator allocator, int length) { + // Allocate a group and drop the reference without disposing. + // The test relies on the group's finalizer to return the rented memory to the pool. MemoryGroup g = allocator.AllocateGroup(length, 100); - if (check) - { - Assert.Equal(42, g.First().Span[0]); - } - g.First().Span[0] = 42; + // Touch the memory to ensure the buffer is actually materialized/usable. + g[0].Span[0] = 42; if (length < 512) { - // For ArrayPool.Shared, first array will be returned to the TLS storage of the finalizer thread, - // repeat rental to make sure per-core buckets are also utilized. + // For ArrayPool.Shared, the first rented array may be stored in TLS on the finalizer thread. + // Repeat rental to increase the chance that per-core buckets are involved when length + // is small and allocations go through ArrayPool. MemoryGroup g1 = allocator.AllocateGroup(length, 100); - g1.First().Span[0] = 42; + g1[0].Span[0] = 42; + g1 = null; } + + g = null; } [Theory] @@ -341,69 +351,63 @@ public class UniformUnmanagedPoolMemoryAllocatorTests [InlineData(600)] // Group of single UniformUnmanagedMemoryPool buffer public void AllocateSingleMemoryOwner_Finalization_ReturnsToPool(int length) { - if (TestEnvironment.IsMacOS) - { - // Skip on macOS: https://github.com/SixLabors/ImageSharp/issues/1887 - return; - } - - if (TestEnvironment.OSArchitecture == Architecture.Arm64) - { - // Skip on ARM64: https://github.com/SixLabors/ImageSharp/issues/2342 - return; - } - - if (!TestEnvironment.RunsOnCI) - { - // This may fail in local runs resulting in high memory load. - // Remove the condition for local debugging! - return; - } - - // RunTest(length.ToString()); - RemoteExecutor.Invoke(RunTest, length.ToString()).Dispose(); + RemoteExecutor.Invoke(RunTest, length.ToString(CultureInfo.InvariantCulture)).Dispose(); static void RunTest(string lengthStr) { UniformUnmanagedMemoryPoolMemoryAllocator allocator = new(512, 1024, 16 * 1024, 1024); - int lengthInner = int.Parse(lengthStr); - + int lengthInner = int.Parse(lengthStr, CultureInfo.InvariantCulture); + + // This test verifies pooling behavior when an `IMemoryOwner` is leaked (not disposed) + // and must be returned to the pool by finalization. + // + // We do NOT use a sentinel byte value to prove reuse because the contents of pooled buffers + // are not required to be preserved across rentals. + // + // Instead, we assert that after forcing GC+finalization, renting the same size again does not + // increase `UnmanagedMemoryHandle.TotalOutstandingHandles` above a baseline. + + // Establish a baseline: allocate+dispose once so the pool has a chance to materialize/retain buffers. + allocator.Allocate(lengthInner).Dispose(); + int baselineHandles = UnmanagedMemoryHandle.TotalOutstandingHandles; + + // Leak one allocation and force finalization. AllocateSingleAndForget(allocator, lengthInner); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); - AllocateSingleAndForget(allocator, lengthInner, true); - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - GC.WaitForPendingFinalizers(); + // Allocate again. If the leaked owner was finalized correctly and returned to the pool, + // this should not require additional unmanaged allocations (ie, the handle count must not grow). + allocator.Allocate(lengthInner).Dispose(); - using IMemoryOwner g = allocator.Allocate(lengthInner); - Assert.Equal(42, g.GetSpan()[0]); - GC.KeepAlive(allocator); + // Note: we use "<=" rather than "==". The pool may legitimately trim and free retained buffers, + // reducing the handle count between baseline and check. The invariant is "no growth". + Assert.True(UnmanagedMemoryHandle.TotalOutstandingHandles <= baselineHandles); } } [MethodImpl(MethodImplOptions.NoInlining)] - private static void AllocateSingleAndForget(UniformUnmanagedMemoryPoolMemoryAllocator allocator, int length, bool check = false) + private static void AllocateSingleAndForget(UniformUnmanagedMemoryPoolMemoryAllocator allocator, int length) { - IMemoryOwner g = allocator.Allocate(length); - if (check) - { - Assert.Equal(42, g.GetSpan()[0]); - } + // Allocate and intentionally do not dispose. + IMemoryOwner? g = allocator.Allocate(length); + // Touch the memory to ensure the buffer is actually materialized/usable. g.GetSpan()[0] = 42; if (length < 512) { - // For ArrayPool.Shared, first array will be returned to the TLS storage of the finalizer thread, - // repeat rental to make sure per-core buckets are also utilized. + // For ArrayPool.Shared, the first rented array may be stored in TLS on the finalizer thread. + // Repeat rental to increase the chance that per-core buckets are involved when length + // is small and allocations go through ArrayPool. IMemoryOwner g1 = allocator.Allocate(length); g1.GetSpan()[0] = 42; + g1 = null; } + + g = null; } [Fact] From 55818d39d6fd2ff3baf0adf418131adea29c4d73 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 12 Jan 2026 23:31:42 +1000 Subject: [PATCH 093/112] Minor cleanup --- .../Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs index f3cb6a5e5..c1f5b44bf 100644 --- a/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs +++ b/tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedPoolMemoryAllocatorTests.cs @@ -319,7 +319,6 @@ public class UniformUnmanagedPoolMemoryAllocatorTests // additional unmanaged handles. Therefore the only invariant we can reliably assert here is // "no growth" relative to the baseline. Assert.True(UnmanagedMemoryHandle.TotalOutstandingHandles <= baselineHandles); - GC.KeepAlive(allocator); } } @@ -392,7 +391,7 @@ public class UniformUnmanagedPoolMemoryAllocatorTests private static void AllocateSingleAndForget(UniformUnmanagedMemoryPoolMemoryAllocator allocator, int length) { // Allocate and intentionally do not dispose. - IMemoryOwner? g = allocator.Allocate(length); + IMemoryOwner g = allocator.Allocate(length); // Touch the memory to ensure the buffer is actually materialized/usable. g.GetSpan()[0] = 42; From 192c4aba0530e8828c80884e06541541582b85ae Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 13 Jan 2026 14:46:56 +1000 Subject: [PATCH 094/112] Micro optimizations --- .../Transforms/Resize/ResizeWorker.cs | 72 ++++++++++++++----- tests/ImageSharp.Benchmarks/Config.cs | 12 +++- .../ImageSharp.Benchmarks.csproj | 5 +- .../Processing/Resize.cs | 2 +- 4 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index cce27a401..675a17ef4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -114,30 +114,49 @@ internal sealed class ResizeWorker : IDisposable Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan(); int left = this.targetWorkingRect.Left; - int right = this.targetWorkingRect.Right; int width = this.targetWorkingRect.Width; + nuint widthCount = (uint)width; + + // Hoist invariant calculations outside the loop + int targetOriginY = this.targetOrigin.Y; + int currentWindowMax = this.currentWindow.Max; + int currentWindowMin = this.currentWindow.Min; + nuint workerHeight = (uint)this.workerHeight; + nuint workerHeight2 = workerHeight * 2; + + ref Vector4 tempRowBase = ref MemoryMarshal.GetReference(tempColSpan); + for (int y = rowInterval.Min; y < rowInterval.Max; y++) { // Ensure offsets are normalized for cropping and padding. - ResizeKernel kernel = this.verticalKernelMap.GetKernel((uint)(y - this.targetOrigin.Y)); + ResizeKernel kernel = this.verticalKernelMap.GetKernel((uint)(y - targetOriginY)); - while (kernel.StartIndex + kernel.Length > this.currentWindow.Max) + // Check if we need to slide the window before processing this row + int kernelEnd = kernel.StartIndex + kernel.Length; + while (kernelEnd > currentWindowMax) { this.Slide(); + currentWindowMax = this.currentWindow.Max; + currentWindowMin = this.currentWindow.Min; } - ref Vector4 tempRowBase = ref MemoryMarshal.GetReference(tempColSpan); + int top = kernel.StartIndex - currentWindowMin; + ref Vector4 colRef0 = ref transposedFirstPassBufferSpan[top]; - int top = kernel.StartIndex - this.currentWindow.Min; + nuint i = 0; + for (; i + 1 < widthCount; i += 2) + { + ref Vector4 colRef1 = ref Unsafe.Add(ref colRef0, workerHeight); - ref Vector4 fpBase = ref transposedFirstPassBufferSpan[top]; + Unsafe.Add(ref tempRowBase, i) = kernel.ConvolveCore(ref colRef0); + Unsafe.Add(ref tempRowBase, i + 1) = kernel.ConvolveCore(ref colRef1); - for (nuint x = 0; x < (uint)(right - left); x++) - { - ref Vector4 firstPassColumnBase = ref Unsafe.Add(ref fpBase, x * (uint)this.workerHeight); + colRef0 = ref Unsafe.Add(ref colRef0, workerHeight2); + } - // Destination color components - Unsafe.Add(ref tempRowBase, x) = kernel.ConvolveCore(ref firstPassColumnBase); + if (i < widthCount) + { + Unsafe.Add(ref tempRowBase, i) = kernel.ConvolveCore(ref colRef0); } Span targetRowSpan = destination.DangerousGetRowSpan(y).Slice(left, width); @@ -172,6 +191,13 @@ internal sealed class ResizeWorker : IDisposable nuint left = (uint)this.targetWorkingRect.Left; nuint right = (uint)this.targetWorkingRect.Right; nuint targetOriginX = (uint)this.targetOrigin.X; + nuint widthCount = right - left; + nuint workerHeight = (uint)this.workerHeight; + int currentWindowMin = this.currentWindow.Min; + + // Cache the kernel map reference to reduce repeated field indirections. + ResizeKernelMap kernelMap = this.horizontalKernelMap; + for (int y = calculationInterval.Min; y < calculationInterval.Max; y++) { Span sourceRow = this.source.DangerousGetRowSpan(y); @@ -182,17 +208,25 @@ internal sealed class ResizeWorker : IDisposable tempRowSpan, this.conversionModifiers); - // optimization for: - // Span firstPassSpan = transposedFirstPassBufferSpan.Slice(y - this.currentWindow.Min); - ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - this.currentWindow.Min]; + ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - currentWindowMin]; + + // Unroll by 2 to reduce loop overhead and kernel fetch costs. + nuint x = left; + nuint z = 0; - for (nuint x = left, z = 0; x < right; x++, z++) + for (; z + 1 < widthCount; x += 2, z += 2) { - ResizeKernel kernel = this.horizontalKernelMap.GetKernel(x - targetOriginX); + ResizeKernel kernel0 = kernelMap.GetKernel(x - targetOriginX); + ResizeKernel kernel1 = kernelMap.GetKernel((x + 1) - targetOriginX); - // optimization for: - // firstPassSpan[x * this.workerHeight] = kernel.Convolve(tempRowSpan); - Unsafe.Add(ref firstPassBaseRef, z * (uint)this.workerHeight) = kernel.Convolve(tempRowSpan); + Unsafe.Add(ref firstPassBaseRef, z * workerHeight) = kernel0.Convolve(tempRowSpan); + Unsafe.Add(ref firstPassBaseRef, (z + 1) * workerHeight) = kernel1.Convolve(tempRowSpan); + } + + if (z < widthCount) + { + ResizeKernel kernel = kernelMap.GetKernel(x - targetOriginX); + Unsafe.Add(ref firstPassBaseRef, z * workerHeight) = kernel.Convolve(tempRowSpan); } } } diff --git a/tests/ImageSharp.Benchmarks/Config.cs b/tests/ImageSharp.Benchmarks/Config.cs index 190c245c9..c2d7abcc2 100644 --- a/tests/ImageSharp.Benchmarks/Config.cs +++ b/tests/ImageSharp.Benchmarks/Config.cs @@ -10,6 +10,7 @@ using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Environments; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Reports; +using BenchmarkDotNet.Toolchains.InProcess.Emit; namespace SixLabors.ImageSharp.Benchmarks; @@ -42,7 +43,16 @@ public partial class Config : ManualConfig .WithLaunchCount(1) .WithWarmupCount(3) .WithIterationCount(3) - .WithArguments([new MsBuildArgument("/p:DebugType=portable")])); + .WithArguments([new MsBuildArgument("/p:DebugType=portable")])) ; + } + + public class StandardInProcess : Config + { + public StandardInProcess() => this.AddJob( + Job.Default + .WithRuntime(CoreRuntime.Core80) + .WithToolchain(InProcessEmitToolchain.Instance) + .WithArguments([new MsBuildArgument("/p:DebugType=portable")])); } #if OS_WINDOWS diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 2628623b4..fa5fdd816 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -57,8 +57,9 @@ - - + + + diff --git a/tests/ImageSharp.Benchmarks/Processing/Resize.cs b/tests/ImageSharp.Benchmarks/Processing/Resize.cs index 356027221..3cc10afb7 100644 --- a/tests/ImageSharp.Benchmarks/Processing/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Processing/Resize.cs @@ -12,7 +12,7 @@ using SDImage = System.Drawing.Image; namespace SixLabors.ImageSharp.Benchmarks; -[Config(typeof(Config.Standard))] +[Config(typeof(Config.StandardInProcess))] public abstract class Resize where TPixel : unmanaged, IPixel { From 9f1a4befdf49e80b2f545832f1e6a7392d229482 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 13 Jan 2026 19:19:57 +1000 Subject: [PATCH 095/112] Use the span directly --- .../Transforms/Resize/ResizeKernelMap.cs | 6 +++ .../Transforms/Resize/ResizeWorker.cs | 43 +++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs index c1907bb52..bd4a18c2f 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs @@ -102,6 +102,12 @@ internal partial class ResizeKernelMap : IDisposable [MethodImpl(InliningOptions.ShortMethod)] internal ref ResizeKernel GetKernel(nuint destIdx) => ref this.kernels[(int)destIdx]; + /// + /// Returns a read-only span of over the underlying kernel data. + /// + [MethodImpl(InliningOptions.ShortMethod)] + internal ReadOnlySpan GetKernelSpan() => this.kernels; + /// /// Computes the weights to apply at each pixel when resizing. /// diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs index 675a17ef4..0a4d38655 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs @@ -110,28 +110,36 @@ internal sealed class ResizeWorker : IDisposable { Span tempColSpan = this.tempColumnBuffer.GetSpan(); - // When creating transposedFirstPassBuffer, we made sure it's contiguous: + // When creating transposedFirstPassBuffer, we made sure it's contiguous. Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan(); int left = this.targetWorkingRect.Left; int width = this.targetWorkingRect.Width; nuint widthCount = (uint)width; - // Hoist invariant calculations outside the loop + // Normalize destination-space Y to kernel indices using uint arithmetic. + // This relies on the contract that processing addresses are normalized (cropping/padding handled by targetOrigin). int targetOriginY = this.targetOrigin.Y; + + // Hoist invariant calculations outside the loop. int currentWindowMax = this.currentWindow.Max; int currentWindowMin = this.currentWindow.Min; nuint workerHeight = (uint)this.workerHeight; nuint workerHeight2 = workerHeight * 2; + // Ref-walk the kernel table to avoid bounds checks in the tight loop. + ReadOnlySpan vKernels = this.verticalKernelMap.GetKernelSpan(); + ref ResizeKernel vKernelBase = ref MemoryMarshal.GetReference(vKernels); + ref Vector4 tempRowBase = ref MemoryMarshal.GetReference(tempColSpan); for (int y = rowInterval.Min; y < rowInterval.Max; y++) { - // Ensure offsets are normalized for cropping and padding. - ResizeKernel kernel = this.verticalKernelMap.GetKernel((uint)(y - targetOriginY)); + // Normalize destination-space Y to an unsigned kernel index. + uint vIdx = (uint)(y - targetOriginY); + ref ResizeKernel kernel = ref Unsafe.Add(ref vKernelBase, (nint)vIdx); - // Check if we need to slide the window before processing this row + // Slide the working window when the kernel would read beyond the current cached region. int kernelEnd = kernel.StartIndex + kernel.Length; while (kernelEnd > currentWindowMax) { @@ -143,6 +151,7 @@ internal sealed class ResizeWorker : IDisposable int top = kernel.StartIndex - currentWindowMin; ref Vector4 colRef0 = ref transposedFirstPassBufferSpan[top]; + // Unroll by 2 and advance column refs via arithmetic to reduce inner-loop overhead. nuint i = 0; for (; i + 1 < widthCount; i += 2) { @@ -190,13 +199,18 @@ internal sealed class ResizeWorker : IDisposable nuint left = (uint)this.targetWorkingRect.Left; nuint right = (uint)this.targetWorkingRect.Right; - nuint targetOriginX = (uint)this.targetOrigin.X; nuint widthCount = right - left; + + // Normalize destination-space X to kernel indices using uint arithmetic. + // This relies on the contract that processing addresses are normalized (cropping/padding handled by targetOrigin). + nuint targetOriginX = (uint)this.targetOrigin.X; + nuint workerHeight = (uint)this.workerHeight; int currentWindowMin = this.currentWindow.Min; - // Cache the kernel map reference to reduce repeated field indirections. - ResizeKernelMap kernelMap = this.horizontalKernelMap; + // Ref-walk the kernel table to avoid bounds checks in the tight loop. + ReadOnlySpan hKernels = this.horizontalKernelMap.GetKernelSpan(); + ref ResizeKernel hKernelBase = ref MemoryMarshal.GetReference(hKernels); for (int y = calculationInterval.Min; y < calculationInterval.Max; y++) { @@ -210,14 +224,17 @@ internal sealed class ResizeWorker : IDisposable ref Vector4 firstPassBaseRef = ref transposedFirstPassBufferSpan[y - currentWindowMin]; - // Unroll by 2 to reduce loop overhead and kernel fetch costs. + // Unroll by 2 to reduce loop and kernel lookup overhead. nuint x = left; nuint z = 0; for (; z + 1 < widthCount; x += 2, z += 2) { - ResizeKernel kernel0 = kernelMap.GetKernel(x - targetOriginX); - ResizeKernel kernel1 = kernelMap.GetKernel((x + 1) - targetOriginX); + nuint hIdx0 = (uint)(x - targetOriginX); + nuint hIdx1 = (uint)((x + 1) - targetOriginX); + + ref ResizeKernel kernel0 = ref Unsafe.Add(ref hKernelBase, (nint)hIdx0); + ref ResizeKernel kernel1 = ref Unsafe.Add(ref hKernelBase, (nint)hIdx1); Unsafe.Add(ref firstPassBaseRef, z * workerHeight) = kernel0.Convolve(tempRowSpan); Unsafe.Add(ref firstPassBaseRef, (z + 1) * workerHeight) = kernel1.Convolve(tempRowSpan); @@ -225,7 +242,9 @@ internal sealed class ResizeWorker : IDisposable if (z < widthCount) { - ResizeKernel kernel = kernelMap.GetKernel(x - targetOriginX); + nuint hIdx = (uint)(x - targetOriginX); + ref ResizeKernel kernel = ref Unsafe.Add(ref hKernelBase, (nint)hIdx); + Unsafe.Add(ref firstPassBaseRef, z * workerHeight) = kernel.Convolve(tempRowSpan); } } From d041f47726e8bbdf2147f17fb71a8c2a3e115958 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 14 Jan 2026 08:53:32 +1000 Subject: [PATCH 096/112] Update Config.cs --- tests/ImageSharp.Benchmarks/Config.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/Config.cs b/tests/ImageSharp.Benchmarks/Config.cs index c2d7abcc2..9231fc8b4 100644 --- a/tests/ImageSharp.Benchmarks/Config.cs +++ b/tests/ImageSharp.Benchmarks/Config.cs @@ -43,7 +43,7 @@ public partial class Config : ManualConfig .WithLaunchCount(1) .WithWarmupCount(3) .WithIterationCount(3) - .WithArguments([new MsBuildArgument("/p:DebugType=portable")])) ; + .WithArguments([new MsBuildArgument("/p:DebugType=portable")])); } public class StandardInProcess : Config From 74e8321cd551f4a1b23a7a51a4cc891b4bddbf1d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 20 Jan 2026 16:55:35 +1000 Subject: [PATCH 097/112] Update field names and fix assignment bug --- .../Extensions/Drawing/DrawImageExtensions.cs | 128 +++++++++++++----- .../Processors/Drawing/DrawImageProcessor.cs | 18 +-- .../DrawImageProcessor{TPixelBg,TPixelFg}.cs | 31 +++-- 3 files changed, 126 insertions(+), 51 deletions(-) diff --git a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs index a6a02e133..42051ca93 100644 --- a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs @@ -17,15 +17,19 @@ public static class DrawImageExtensions /// The current image processing context. /// The image to draw on the currently processing image. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, float opacity, - int repeatCount) + int foregroundRepeatCount = 0) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); + return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } /// @@ -35,16 +39,20 @@ public static class DrawImageExtensions /// The image to draw on the currently processing image. /// The rectangle structure that specifies the portion of the image to draw. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, Rectangle foregroundRectangle, float opacity, - int repeatCount) + int foregroundRepeatCount = 0) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); + return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } /// @@ -54,14 +62,18 @@ public static class DrawImageExtensions /// The image to draw on the currently processing image. /// The color blending mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, PixelColorBlendingMode colorBlending, float opacity, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, colorBlending, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, colorBlending, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -71,6 +83,10 @@ public static class DrawImageExtensions /// The rectangle structure that specifies the portion of the image to draw. /// The color blending mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -78,8 +94,8 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -89,6 +105,10 @@ public static class DrawImageExtensions /// The color blending mode. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -96,8 +116,8 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -108,6 +128,10 @@ public static class DrawImageExtensions /// The color blending mode. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -116,8 +140,8 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -125,13 +149,17 @@ public static class DrawImageExtensions /// The current image processing context. /// The image to draw on the currently processing image. /// The options, including the blending type and blending amount. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, GraphicsOptions options, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, options, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, options, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -140,14 +168,18 @@ public static class DrawImageExtensions /// The image to draw on the currently processing image. /// The rectangle structure that specifies the portion of the image to draw. /// The options, including the blending type and blending amount. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, Rectangle foregroundRectangle, GraphicsOptions options, - int repeatCount) - => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -156,16 +188,20 @@ public static class DrawImageExtensions /// The image to draw on the currently processing image. /// The location on the currently processing image at which to draw. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, Point backgroundLocation, float opacity, - int repeatCount) + int foregroundRepeatCount = 0) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); + return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } /// @@ -176,6 +212,10 @@ public static class DrawImageExtensions /// The location on the currently processing image at which to draw. /// The rectangle structure that specifies the portion of the image to draw. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -183,10 +223,10 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, float opacity, - int repeatCount) + int foregroundRepeatCount = 0) { GraphicsOptions options = source.GetGraphicsOptions(); - return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, repeatCount); + return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } /// @@ -197,6 +237,10 @@ public static class DrawImageExtensions /// The location on the currently processing image at which to draw. /// The color blending to apply. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -204,8 +248,8 @@ public static class DrawImageExtensions Point backgroundLocation, PixelColorBlendingMode colorBlending, float opacity, - int repeatCount) - => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -216,6 +260,10 @@ public static class DrawImageExtensions /// The rectangle structure that specifies the portion of the image to draw. /// The color blending to apply. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -224,8 +272,8 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int repeatCount) - => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -234,14 +282,18 @@ public static class DrawImageExtensions /// The image to draw on the currently processing image. /// The location on the currently processing image at which to draw. /// The options containing the blend mode and opacity. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image foreground, Point backgroundLocation, GraphicsOptions options, - int repeatCount) - => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -251,6 +303,10 @@ public static class DrawImageExtensions /// The location on the currently processing image at which to draw. /// The rectangle structure that specifies the portion of the image to draw. /// The options containing the blend mode and opacity. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -258,8 +314,8 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, GraphicsOptions options, - int repeatCount) - => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, repeatCount); + int foregroundRepeatCount = 0) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -270,6 +326,10 @@ public static class DrawImageExtensions /// The color blending to apply. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -278,8 +338,8 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int repeatCount) - => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity, repeatCount)); + int foregroundRepeatCount = 0) + => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity, foregroundRepeatCount)); /// /// Draws the given image together with the currently processing image by blending their pixels. @@ -291,6 +351,10 @@ public static class DrawImageExtensions /// The color blending to apply. /// The alpha composition mode. /// The opacity of the image to draw. Must be between 0 and 1. + /// + /// The number of times the foreground frames are allowed to loop while applying this operation across successive frames. + /// A value of 0 means loop indefinitely. + /// /// The . public static IImageProcessingContext DrawImage( this IImageProcessingContext source, @@ -300,8 +364,8 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int repeatCount) => + int foregroundRepeatCount = 0) => source.ApplyProcessor( - new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, repeatCount), + new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount), foregroundRectangle); } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs index 3e17dae51..675d1a311 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor.cs @@ -19,15 +19,15 @@ public class DrawImageProcessor : IImageProcessor /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. - /// The loop count. The number of times to loop the animation. 0 means infinitely. + /// The number of times the foreground frames are allowed to loop. 0 means infinitely. public DrawImageProcessor( Image foreground, Point backgroundLocation, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity, - int repeatCount) - : this(foreground, backgroundLocation, foreground.Bounds, colorBlendingMode, alphaCompositionMode, opacity, repeatCount) + int foregroundRepeatCount) + : this(foreground, backgroundLocation, foreground.Bounds, colorBlendingMode, alphaCompositionMode, opacity, foregroundRepeatCount) { } @@ -40,7 +40,7 @@ public class DrawImageProcessor : IImageProcessor /// The blending mode to use when drawing the image. /// The Alpha blending mode to use when drawing the image. /// The opacity of the image to blend. - /// The loop count. The number of times to loop the animation. 0 means infinitely. + /// The number of times the foreground frames are allowed to loop. 0 means infinitely. public DrawImageProcessor( Image foreground, Point backgroundLocation, @@ -48,7 +48,7 @@ public class DrawImageProcessor : IImageProcessor PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity, - int repeatCount) + int foregroundRepeatCount) { this.ForeGround = foreground; this.BackgroundLocation = backgroundLocation; @@ -56,7 +56,7 @@ public class DrawImageProcessor : IImageProcessor this.ColorBlendingMode = colorBlendingMode; this.AlphaCompositionMode = alphaCompositionMode; this.Opacity = opacity; - this.RepeatCount = repeatCount; + this.ForegroundRepeatCount = foregroundRepeatCount; } /// @@ -90,9 +90,9 @@ public class DrawImageProcessor : IImageProcessor public float Opacity { get; } /// - /// Gets the loop count. The number of times to loop the animation. 0 means infinitely. + /// Gets the number of times the foreground frames are allowed to loop. 0 means infinitely. /// - public int RepeatCount { get; } + public int ForegroundRepeatCount { get; } /// public IImageProcessor CreatePixelSpecificProcessor(Configuration configuration, Image source, Rectangle sourceRectangle) @@ -133,6 +133,6 @@ public class DrawImageProcessor : IImageProcessor this.definition.ColorBlendingMode, this.definition.AlphaCompositionMode, this.definition.Opacity, - this.definition.RepeatCount); + this.definition.ForegroundRepeatCount); } } diff --git a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs index 001888865..7a1ffb85f 100644 --- a/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs +++ b/src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs @@ -17,7 +17,11 @@ internal class DrawImageProcessor : ImageProcessor where TPixelBg : unmanaged, IPixel where TPixelFg : unmanaged, IPixel { - private int currentFrameLoop; + /// + /// Counts how many times has been called for this processor instance. + /// Used to select the current foreground frame. + /// + private int foregroundFrameCounter; /// /// Initializes a new instance of the class. @@ -30,7 +34,10 @@ internal class DrawImageProcessor : ImageProcessor /// The blending mode to use when drawing the image. /// The alpha blending mode to use when drawing the image. /// The opacity of the image to blend. Must be between 0 and 1. - /// The loop count. The number of times to loop the animation. 0 means infinitely. + /// + /// The number of times the foreground frames are allowed to loop while applying this processor across successive frames. + /// A value of 0 means loop indefinitely. + /// public DrawImageProcessor( Configuration configuration, Image foregroundImage, @@ -40,10 +47,10 @@ internal class DrawImageProcessor : ImageProcessor PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity, - int repeatCount) + int foregroundRepeatCount) : base(configuration, backgroundImage, backgroundImage.Bounds) { - Guard.MustBeGreaterThanOrEqualTo(repeatCount, 0, nameof(repeatCount)); + Guard.MustBeGreaterThanOrEqualTo(foregroundRepeatCount, 0, nameof(foregroundRepeatCount)); Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.ForegroundImage = foregroundImage; @@ -51,6 +58,7 @@ internal class DrawImageProcessor : ImageProcessor this.Opacity = opacity; this.Blender = PixelOperations.Instance.GetPixelBlender(colorBlendingMode, alphaCompositionMode); this.BackgroundLocation = backgroundLocation; + this.ForegroundRepeatCount = foregroundRepeatCount; } /// @@ -79,9 +87,10 @@ internal class DrawImageProcessor : ImageProcessor public Point BackgroundLocation { get; } /// - /// Gets the loop count. The number of times to loop the animation. 0 means infinitely. + /// Gets the number of times the foreground frames are allowed to loop while applying this processor across + /// successive frames. A value of 0 means loop indefinitely. /// - public int RepeatCount { get; } + public int ForegroundRepeatCount { get; } /// protected override void OnFrameApply(ImageFrame source) @@ -124,9 +133,9 @@ internal class DrawImageProcessor : ImageProcessor // Sanitize the dimensions so that we don't try and sample outside the image. Rectangle backgroundRectangle = Rectangle.Intersect(new Rectangle(left, top, width, height), this.SourceRectangle); Configuration configuration = this.Configuration; - int currentFrameIndex = this.currentFrameLoop % this.ForegroundImage.Frames.Count; + int currentFrameIndex = this.foregroundFrameCounter % this.ForegroundImage.Frames.Count; - DrawImageProcessor.RowOperation operation = + RowOperation operation = new( configuration, source.PixelBuffer, @@ -141,9 +150,11 @@ internal class DrawImageProcessor : ImageProcessor new Rectangle(0, 0, foregroundRectangle.Width, foregroundRectangle.Height), in operation); - if (this.RepeatCount is 0 || this.currentFrameLoop / this.ForegroundImage.Frames.Count < this.RepeatCount) + // The repeat count only affects how the foreground frame advances across successive background frames. + // When exhausted, the selected foreground frame stops advancing. + if (this.ForegroundRepeatCount is 0 || this.foregroundFrameCounter / this.ForegroundImage.Frames.Count < this.ForegroundRepeatCount) { - this.currentFrameLoop++; + this.foregroundFrameCounter++; } } From bc35ee6b37ee638c5ff491efff59b0625a19ca14 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 22 Jan 2026 15:32:06 +1000 Subject: [PATCH 098/112] Enhance XmpProfile to add XDocument normalization --- .../Metadata/Profiles/XMP/XmpProfile.cs | 118 ++++++++++++++---- .../Formats/Tiff/TiffMetadataTests.cs | 4 +- .../Metadata/ImageFrameMetadataTests.cs | 2 +- .../Metadata/Profiles/XMP/XmpProfileTests.cs | 36 +++++- 4 files changed, 129 insertions(+), 31 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs b/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs index 77ff35df0..de34a1eaa 100644 --- a/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Diagnostics; using System.Text; +using System.Xml; using System.Xml.Linq; namespace SixLabors.ImageSharp.Metadata.Profiles.Xmp; @@ -25,18 +25,17 @@ public sealed class XmpProfile : IDeepCloneable /// Initializes a new instance of the class. /// /// The UTF8 encoded byte array to read the XMP profile from. - public XmpProfile(byte[]? data) => this.Data = data; + public XmpProfile(byte[]? data) => this.Data = NormalizeDataIfNeeded(data); /// - /// Initializes a new instance of the class - /// by making a copy from another XMP profile. + /// Initializes a new instance of the class from an XML document. + /// The document is serialized as UTF-8 without BOM. /// - /// The other XMP profile, from which the clone should be made from. - private XmpProfile(XmpProfile other) + /// The XMP XML document. + public XmpProfile(XDocument document) { - Guard.NotNull(other, nameof(other)); - - this.Data = other.Data; + Guard.NotNull(document, nameof(document)); + this.Data = SerializeDocument(document); } /// @@ -45,30 +44,28 @@ public sealed class XmpProfile : IDeepCloneable internal byte[]? Data { get; private set; } /// - /// Gets the raw XML document containing the XMP profile. + /// Convert the content of this into an . /// /// The - public XDocument? GetDocument() + public XDocument? ToXDocument() { - byte[]? byteArray = this.Data; - if (byteArray is null) + byte[]? data = this.Data; + if (data is null || data.Length == 0) { return null; } - // Strip leading whitespace, as the XmlReader doesn't like them. - int count = byteArray.Length; - for (int i = count - 1; i > 0; i--) + using MemoryStream stream = new(data, writable: false); + + XmlReaderSettings settings = new() { - if (byteArray[i] is 0 or 0x0f) - { - count--; - } - } + DtdProcessing = DtdProcessing.Ignore, + XmlResolver = null, + CloseInput = false + }; - using MemoryStream stream = new(byteArray, 0, count); - using StreamReader reader = new(stream, Encoding.UTF8); - return XDocument.Load(reader); + using XmlReader reader = XmlReader.Create(stream, settings); + return XDocument.Load(reader, LoadOptions.PreserveWhitespace); } /// @@ -84,5 +81,76 @@ public sealed class XmpProfile : IDeepCloneable } /// - public XmpProfile DeepClone() => new(this); + public XmpProfile DeepClone() + { + Guard.NotNull(this.Data); + + byte[] clone = new byte[this.Data.Length]; + this.Data.AsSpan().CopyTo(clone); + return new XmpProfile(clone); + } + + private static byte[] SerializeDocument(XDocument document) + { + using MemoryStream ms = new(); + + XmlWriterSettings writerSettings = new() + { + Encoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), // no BOM + OmitXmlDeclaration = true, // generally safer for XMP consumers + Indent = false, + NewLineHandling = NewLineHandling.None + }; + + using (XmlWriter xw = XmlWriter.Create(ms, writerSettings)) + { + document.Save(xw); + } + + return ms.ToArray(); + } + + private static byte[]? NormalizeDataIfNeeded(byte[]? data) + { + if (data is null || data.Length == 0) + { + return data; + } + + // Allocation-free fast path for the normal case. + bool hasBom = data.Length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF; + bool hasTrailingPad = data[^1] is 0 or 0x0F; + + if (!hasBom && !hasTrailingPad) + { + return data; + } + + int start = hasBom ? 3 : 0; + int end = data.Length; + + if (hasTrailingPad) + { + while (end > start) + { + byte b = data[end - 1]; + if (b is not 0 and not 0x0F) + { + break; + } + + end--; + } + } + + int length = end - start; + if (length <= 0) + { + return []; + } + + byte[] normalized = new byte[length]; + Buffer.BlockCopy(data, start, normalized, 0, length); + return normalized; + } } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index 20b3ec2bb..f92d8ed59 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -157,7 +157,7 @@ public class TiffMetadataTests { Assert.NotNull(rootFrameMetaData.XmpProfile); Assert.NotNull(rootFrameMetaData.ExifProfile); - Assert.Equal(2599, rootFrameMetaData.XmpProfile.Data.Length); + Assert.Equal(2596, rootFrameMetaData.XmpProfile.Data.Length); // padding bytes are trimmed Assert.Equal(25, rootFrameMetaData.ExifProfile.Values.Count); } } @@ -186,7 +186,7 @@ public class TiffMetadataTests Assert.Equal(32, rootFrame.Width); Assert.Equal(32, rootFrame.Height); Assert.NotNull(rootFrame.Metadata.XmpProfile); - Assert.Equal(2599, rootFrame.Metadata.XmpProfile.Data.Length); + Assert.Equal(2596, rootFrame.Metadata.XmpProfile.Data.Length); // padding bytes are trimmed ExifProfile exifProfile = rootFrame.Metadata.ExifProfile; TiffFrameMetadata tiffFrameMetadata = rootFrame.Metadata.GetTiffMetadata(); diff --git a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs index cee37ca56..e50d0b617 100644 --- a/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs +++ b/tests/ImageSharp.Tests/Metadata/ImageFrameMetadataTests.cs @@ -74,7 +74,7 @@ public class ImageFrameMetadataTests Assert.False(metaData.ExifProfile.Equals(clone.ExifProfile)); Assert.True(metaData.ExifProfile.Values.Count == clone.ExifProfile.Values.Count); Assert.False(ReferenceEquals(metaData.XmpProfile, clone.XmpProfile)); - Assert.True(metaData.XmpProfile.Data.Equals(clone.XmpProfile.Data)); + Assert.False(ReferenceEquals(metaData.XmpProfile.Data, clone.XmpProfile.Data)); Assert.False(metaData.GetGifMetadata().Equals(clone.GetGifMetadata())); Assert.False(metaData.IccProfile.Equals(clone.IccProfile)); Assert.False(metaData.IptcProfile.Equals(clone.IptcProfile)); diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index e121d24f9..8e8f89e6f 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -78,6 +78,34 @@ public class XmpProfileTests } } + [Fact] + public void XmlProfile_CtorFromXDocument_Works() + { + // arrange + XDocument document = CreateMinimalXDocument(); + + // act + XmpProfile profile = new(document); + + // assert + XmpProfileContainsExpectedValues(profile); + } + + [Fact] + public void XmpProfile_ToXDocument_ReturnsValidDocument() + { + // arrange + XmpProfile profile = CreateMinimalXmlProfile(); + + // act + XDocument document = profile.ToXDocument(); + + // assert + Assert.NotNull(document); + Assert.Equal("xmpmeta", document.Root.Name.LocalName); + Assert.Equal("adobe:ns:meta/", document.Root.Name.NamespaceName); + } + [Fact] public void XmpProfile_ToFromByteArray_ReturnsClone() { @@ -97,11 +125,11 @@ public class XmpProfileTests { // arrange XmpProfile profile = CreateMinimalXmlProfile(); - byte[] original = profile.ToByteArray(); + byte[] original = profile.Data; // act XmpProfile clone = profile.DeepClone(); - byte[] actual = clone.ToByteArray(); + byte[] actual = clone.Data; // assert Assert.False(ReferenceEquals(original, actual)); @@ -218,7 +246,7 @@ public class XmpProfileTests private static void XmpProfileContainsExpectedValues(XmpProfile xmp) { Assert.NotNull(xmp); - XDocument document = xmp.GetDocument(); + XDocument document = xmp.ToXDocument(); Assert.NotNull(document); Assert.Equal("xmpmeta", document.Root.Name.LocalName); Assert.Equal("adobe:ns:meta/", document.Root.Name.NamespaceName); @@ -232,6 +260,8 @@ public class XmpProfileTests return profile; } + private static XDocument CreateMinimalXDocument() => CreateMinimalXmlProfile().ToXDocument(); + private static Image WriteAndRead(Image image, IImageEncoder encoder) { using (MemoryStream memStream = new()) From 81d533b320816726dd3a56a634e30b3df1aed61b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 22 Jan 2026 16:10:21 +1000 Subject: [PATCH 099/112] Improve behavior and add comments --- .../Metadata/Profiles/XMP/XmpProfile.cs | 32 +++++++++++++++---- .../Metadata/Profiles/XMP/XmpProfileTests.cs | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs b/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs index de34a1eaa..639f09722 100644 --- a/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs +++ b/src/ImageSharp/Metadata/Profiles/XMP/XmpProfile.cs @@ -46,7 +46,7 @@ public sealed class XmpProfile : IDeepCloneable /// /// Convert the content of this into an . /// - /// The + /// The instance, or if no XMP data is present. public XDocument? ToXDocument() { byte[]? data = this.Data; @@ -74,8 +74,14 @@ public sealed class XmpProfile : IDeepCloneable /// The public byte[] ToByteArray() { - Guard.NotNull(this.Data); - byte[] result = new byte[this.Data.Length]; + byte[]? data = this.Data; + + if (data is null) + { + return []; + } + + byte[] result = new byte[data.Length]; this.Data.AsSpan().CopyTo(result); return result; } @@ -83,10 +89,15 @@ public sealed class XmpProfile : IDeepCloneable /// public XmpProfile DeepClone() { - Guard.NotNull(this.Data); + byte[]? data = this.Data; + if (data is null) + { + // Preserve the semantics of an "empty" profile when cloning. + return new XmpProfile(); + } - byte[] clone = new byte[this.Data.Length]; - this.Data.AsSpan().CopyTo(clone); + byte[] clone = new byte[data.Length]; + data.AsSpan().CopyTo(clone); return new XmpProfile(clone); } @@ -118,7 +129,14 @@ public sealed class XmpProfile : IDeepCloneable } // Allocation-free fast path for the normal case. + + // Check for UTF-8 BOM (0xEF,0xBB,0xBF) bool hasBom = data.Length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF; + + // XMP metadata is commonly stored in fixed-size container blocks (e.g. TIFF tag 700). + // Producers often pad unused space so the packet can be updated in-place without + // rewriting the file. In practice this padding is either NUL (0x00) from the container + // or 0x0F used by Adobe XMP writers. Both are invalid XML and must be trimmed. bool hasTrailingPad = data[^1] is 0 or 0x0F; if (!hasBom && !hasTrailingPad) @@ -146,7 +164,7 @@ public sealed class XmpProfile : IDeepCloneable int length = end - start; if (length <= 0) { - return []; + return null; } byte[] normalized = new byte[length]; diff --git a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs index 8e8f89e6f..32d4bc7cd 100644 --- a/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs +++ b/tests/ImageSharp.Tests/Metadata/Profiles/XMP/XmpProfileTests.cs @@ -79,7 +79,7 @@ public class XmpProfileTests } [Fact] - public void XmlProfile_CtorFromXDocument_Works() + public void XmpProfile_CtorFromXDocument_Works() { // arrange XDocument document = CreateMinimalXDocument(); From ff02d0c1f0cf947f70a8c950ac294068b666f211 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 23 Jan 2026 14:30:21 +1000 Subject: [PATCH 100/112] Use IptcProfile in PNG --- src/ImageSharp/Formats/Png/PngConstants.cs | 42 ++++ src/ImageSharp/Formats/Png/PngDecoderCore.cs | 218 +++++++++++++++++- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 159 +++++++++++++ .../Profiles/IPTC/IptcRecordNumber.cs | 4 +- .../Metadata/Profiles/IPTC/IptcValue.cs | 36 ++- .../Formats/Png/PngMetadataTests.cs | 50 +++- tests/ImageSharp.Tests/TestImages.cs | 1 + tests/Images/Input/Png/iptc-profile.png | 3 + 8 files changed, 499 insertions(+), 14 deletions(-) create mode 100644 tests/Images/Input/Png/iptc-profile.png diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 17d13e86d..c5d887985 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -62,6 +62,21 @@ internal static class PngConstants /// public const int MinTextKeywordLength = 1; + /// + /// Specifies the keyword used to identify the Exif raw profile in image metadata. + /// + public const string ExifRawProfileKeyword = "Raw profile type exif"; + + /// + /// Specifies the profile keyword used to identify raw IPTC metadata within image files. + /// + public const string IptcRawProfileKeyword = "Raw profile type iptc"; + + /// + /// The IPTC resource id in Photoshop IRB. 0x0404 (big endian). + /// + public const ushort AdobeIptcResourceId = 0x0404; + /// /// Gets the header bytes identifying a Png. /// @@ -100,4 +115,31 @@ internal static class PngConstants (byte)'m', (byte)'p' ]; + + /// + /// Gets the ASCII bytes for the "Photoshop 3.0" identifier used in some PNG metadata payloads. + /// This value is null-terminated. + /// + public static ReadOnlySpan AdobePhotoshop30 => + [ + (byte)'P', + (byte)'h', + (byte)'o', + (byte)'t', + (byte)'o', + (byte)'s', + (byte)'h', + (byte)'o', + (byte)'p', + (byte)' ', + (byte)'3', + (byte)'.', + (byte)'0', + 0 + ]; + + /// + /// Gets the ASCII bytes for the "8BIM" signature used in Photoshop resources. + /// + public static ReadOnlySpan EightBim => [(byte)'8', (byte)'B', (byte)'I', (byte)'M']; } diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index bff4d30ee..271474a7e 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -21,6 +21,7 @@ using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Cicp; using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.Metadata.Profiles.Xmp; using SixLabors.ImageSharp.PixelFormats; @@ -1440,14 +1441,19 @@ internal sealed class PngDecoderCore : ImageDecoderCore /// object unmodified. private static bool TryReadTextChunkMetadata(ImageMetadata baseMetadata, string chunkName, string chunkText) { - if (chunkName.Equals("Raw profile type exif", StringComparison.OrdinalIgnoreCase) && + if (chunkName.Equals(PngConstants.ExifRawProfileKeyword, StringComparison.OrdinalIgnoreCase) && TryReadLegacyExifTextChunk(baseMetadata, chunkText)) { // Successfully parsed legacy exif data from text return true; } - // TODO: "Raw profile type iptc", potentially others? + if (chunkName.Equals(PngConstants.IptcRawProfileKeyword, StringComparison.OrdinalIgnoreCase) && + TryReadLegacyIptcTextChunk(baseMetadata, chunkText)) + { + // Successfully parsed legacy iptc data from text + return true; + } // No special chunk data identified return false; @@ -1571,6 +1577,214 @@ internal sealed class PngDecoderCore : ImageDecoderCore return true; } + /// + /// Reads iptc data encoded into a text chunk with the name "Raw profile type iptc". + /// This convention is used by ImageMagick/exiftool/exiv2/digiKam and stores a byte-count + /// followed by hex-encoded bytes. + /// + /// The to store the decoded iptc tags into. + /// The contents of the "Raw profile type iptc" text chunk. + private static bool TryReadLegacyIptcTextChunk(ImageMetadata metadata, string data) + { + // Preserve first IPTC found. + if (metadata.IptcProfile != null) + { + return true; + } + + ReadOnlySpan dataSpan = data.AsSpan().TrimStart(); + + // Must start with the "iptc" identifier (case-insensitive). + // Common real-world format (ImageMagick/ExifTool) is: + // "IPTC profile\n \n" + if (dataSpan.Length < 4 || !StringEqualsInsensitive(dataSpan[..4], "iptc".AsSpan())) + { + return false; + } + + // Skip the remainder of the first line ("IPTC profile", etc). + int firstLineEnd = dataSpan.IndexOf('\n'); + if (firstLineEnd < 0) + { + return false; + } + + dataSpan = dataSpan[(firstLineEnd + 1)..].TrimStart(); + + // Next line contains the decimal byte length (often indented). + int dataLengthEnd = dataSpan.IndexOf('\n'); + if (dataLengthEnd < 0) + { + return false; + } + + int dataLength; + try + { + dataLength = ParseInt32(dataSpan[..dataLengthEnd]); + } + catch + { + return false; + } + + if (dataLength <= 0) + { + return false; + } + + // Skip to the hex-encoded data. + dataSpan = dataSpan[(dataLengthEnd + 1)..].Trim(); + + byte[] iptcBlob = new byte[dataLength]; + + try + { + int written = 0; + + for (; written < dataLength;) + { + ReadOnlySpan lineSpan = dataSpan; + + int newlineIndex = dataSpan.IndexOf('\n'); + if (newlineIndex != -1) + { + lineSpan = dataSpan[..newlineIndex]; + } + + // Important: handle CRLF and any incidental whitespace. + lineSpan = lineSpan.Trim(); // removes ' ', '\t', '\r', '\n', etc. + + if (!lineSpan.IsEmpty) + { + written += HexConverter.HexStringToBytes(lineSpan, iptcBlob.AsSpan()[written..]); + } + + if (newlineIndex == -1) + { + break; + } + + dataSpan = dataSpan[(newlineIndex + 1)..]; + } + + if (written != dataLength) + { + return false; + } + } + catch + { + return false; + } + + // Prefer IRB extraction if this is Photoshop-style data (8BIM resource blocks). + byte[] iptcPayload = TryExtractIptcFromPhotoshopIrb(iptcBlob, out byte[] extracted) + ? extracted + : iptcBlob; + + metadata.IptcProfile = new IptcProfile(iptcPayload); + return true; + } + + /// + /// Attempts to extract IPTC metadata from a Photoshop Image Resource Block (IRB) contained within the specified + /// data buffer. + /// + /// This method scans the provided data for a Photoshop IRB block containing IPTC metadata and + /// extracts it if present. The method does not validate the contents of the IPTC data beyond locating the + /// appropriate resource block. + /// A read-only span of bytes containing the Photoshop IRB data to search for embedded IPTC metadata. + /// When this method returns, contains the extracted IPTC metadata as a byte array if found; otherwise, an undefined + /// value. + /// if IPTC metadata is successfully extracted from the IRB data; otherwise, . + private static bool TryExtractIptcFromPhotoshopIrb(ReadOnlySpan data, out byte[] iptcBytes) + { + iptcBytes = default!; + + ReadOnlySpan adobePhotoshop30 = PngConstants.AdobePhotoshop30; + + // Some writers include the "Photoshop 3.0\0" header, some store just IRB blocks. + if (data.Length >= adobePhotoshop30.Length && data[..adobePhotoshop30.Length].SequenceEqual(adobePhotoshop30)) + { + data = data[adobePhotoshop30.Length..]; + } + + ReadOnlySpan eightBim = PngConstants.EightBim; + ushort adobeIptcResourceId = PngConstants.AdobeIptcResourceId; + while (data.Length >= 12) + { + if (!data[..4].SequenceEqual(eightBim)) + { + return false; + } + + data = data[4..]; + + // Resource ID (2 bytes, big endian) + if (data.Length < 2) + { + return false; + } + + ushort resourceId = (ushort)((data[0] << 8) | data[1]); + data = data[2..]; + + // Pascal string name (1-byte length, then bytes), padded to even. + if (data.Length < 1) + { + return false; + } + + int nameLen = data[0]; + int nameFieldLen = 1 + nameLen; + if ((nameFieldLen & 1) != 0) + { + nameFieldLen++; // pad to even + } + + if (data.Length < nameFieldLen + 4) + { + return false; + } + + data = data[nameFieldLen..]; + + // Resource data size (4 bytes, big endian) + int size = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; + data = data[4..]; + + if (size < 0 || data.Length < size) + { + return false; + } + + ReadOnlySpan payload = data[..size]; + + // Data is padded to even. + int advance = size; + if ((advance & 1) != 0) + { + advance++; + } + + if (resourceId == adobeIptcResourceId) + { + iptcBytes = payload.ToArray(); + return true; + } + + if (data.Length < advance) + { + return false; + } + + data = data[advance..]; + } + + return false; + } + /// /// Reads the color profile chunk. The data is stored similar to the zTXt chunk. /// diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 2b01affea..2bb97221c 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -8,6 +8,7 @@ using System.IO.Hashing; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; +using System.Text; using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Compression.Zlib; using SixLabors.ImageSharp.Formats.Png.Chunks; @@ -217,6 +218,7 @@ internal sealed class PngEncoderCore : IDisposable this.WritePhysicalChunk(stream, metadata); this.WriteExifChunk(stream, metadata); this.WriteXmpChunk(stream, metadata); + this.WriteIptcChunk(stream, metadata); this.WriteTextChunks(stream, pngMetadata); if (image.Frames.Count > 1) @@ -889,6 +891,163 @@ internal sealed class PngEncoderCore : IDisposable this.WriteChunk(stream, PngChunkType.InternationalText, payload); } + /// + /// Writes the IPTC metadata from the specified image metadata to the provided stream as a compressed zTXt chunk in + /// PNG format, if IPTC data is present. + /// + /// The containing image data. + /// The image metadata. + private void WriteIptcChunk(Stream stream, ImageMetadata meta) + { + if ((this.chunkFilter & PngChunkFilter.ExcludeTextChunks) == PngChunkFilter.ExcludeTextChunks) + { + return; + } + + if (meta.IptcProfile is null || !meta.IptcProfile.Values.Any()) + { + return; + } + + meta.IptcProfile.UpdateData(); + + byte[]? iptcData = meta.IptcProfile.Data; + if (iptcData?.Length is 0 or null) + { + return; + } + + // For interoperability, wrap raw IPTC (IIM) in a Photoshop IRB (8BIM, resource 0x0404), + // since "Raw profile type iptc" commonly stores IRB payloads. + using IMemoryOwner irb = this.BuildPhotoshopIrbForIptc(iptcData); + + Span irbSpan = irb.GetSpan(); + + // Build "raw profile" textual wrapper: + // "IPTC profile\n\n\n" + string rawProfileText = BuildRawProfileText("IPTC profile", irbSpan); + + byte[] compressedData = this.GetZlibCompressedBytes(PngConstants.Encoding.GetBytes(rawProfileText)); + + // zTXt layout: keyword (latin-1) + 0 + compression-method(0) + compressed-data + const string iptcRawProfileKeyword = PngConstants.IptcRawProfileKeyword; + int payloadLength = iptcRawProfileKeyword.Length + compressedData.Length + 2; + + using IMemoryOwner payload = this.memoryAllocator.Allocate(payloadLength); + Span outputBytes = payload.GetSpan(); + + PngConstants.Encoding.GetBytes(iptcRawProfileKeyword).CopyTo(outputBytes); + int bytesWritten = iptcRawProfileKeyword.Length; + outputBytes[bytesWritten++] = 0; // Null separator + outputBytes[bytesWritten++] = 0; // Compression method: deflate + compressedData.CopyTo(outputBytes[bytesWritten..]); + + this.WriteChunk(stream, PngChunkType.CompressedText, outputBytes); + } + + /// + /// Builds a Photoshop Image Resource Block (IRB) containing the specified IPTC-IIM data. + /// + /// The returned IRB uses resource ID 0x0404 and an empty Pascal string for the name, as required + /// for IPTC-NAA record embedding in Photoshop files. The data is padded to ensure even length, as specified by the + /// IRB format. + /// + /// The IPTC-IIM data to embed in the IRB, provided as a read-only span of bytes. The data is included as-is in the + /// resulting block. + /// + /// + /// A byte array representing the Photoshop IRB with the embedded IPTC-IIM data, formatted according to the + /// Photoshop specification. + /// + private IMemoryOwner BuildPhotoshopIrbForIptc(ReadOnlySpan iptcIim) + { + // IRB block: + // 4 bytes: "8BIM" + // 2 bytes: resource id 0x0404 (big endian) + // 2 bytes: pascal name (len=0) + pad to even => 0x00 0x00 + // 4 bytes: data size (big endian) + // n bytes: IPTC-IIM data + // pad to even + int pad = (iptcIim.Length & 1) != 0 ? 1 : 0; + IMemoryOwner bufferOwner = this.memoryAllocator.Allocate(4 + 2 + 2 + 4 + iptcIim.Length + pad); + Span buffer = bufferOwner.GetSpan(); + + int bytesWritten = 0; + PngConstants.EightBim.CopyTo(buffer); + bytesWritten += 4; + + buffer[bytesWritten++] = 0x04; + buffer[bytesWritten++] = 0x04; + + buffer[bytesWritten++] = 0x00; // Pascal name length + buffer[bytesWritten++] = 0x00; // pad to even + + int size = iptcIim.Length; + buffer[bytesWritten++] = (byte)((size >> 24) & 0xFF); + buffer[bytesWritten++] = (byte)((size >> 16) & 0xFF); + buffer[bytesWritten++] = (byte)((size >> 8) & 0xFF); + buffer[bytesWritten++] = (byte)(size & 0xFF); + + iptcIim.CopyTo(buffer[bytesWritten..]); + + // Final pad byte already zero-initialized if needed + return bufferOwner; + } + + /// + /// Builds a formatted text representation of a binary profile, including a header, the payload length, and the + /// payload as hexadecimal text. + /// + /// + /// The hexadecimal payload is formatted with 64 bytes per line to improve readability. The + /// output consists of the header line, a line with the payload length, and one or more lines of hexadecimal + /// text. + /// + /// The header text to include at the beginning of the profile. This is written as the first line of the output. + /// The binary payload to encode as hexadecimal text. The payload is split into lines of 64 bytes each. + /// + /// A string containing the header, the payload length, and the hexadecimal representation of the payload, each on + /// separate lines. + /// + private static string BuildRawProfileText(string header, ReadOnlySpan payload) + { + // Hex text can be multi-line + // Use 64 bytes per line (128 hex chars) to keep the chunk readable. + const int bytesPerLine = 64; + + int hexChars = payload.Length * 2; + int lineCount = (payload.Length + (bytesPerLine - 1)) / bytesPerLine; + int newlineCount = 2 + lineCount; // header line + length line + hex lines + int capacity = header.Length + 32 + hexChars + newlineCount; + + StringBuilder sb = new(capacity); + sb.Append(header).Append('\n'); + sb.Append(payload.Length).Append('\n'); + + int i = 0; + while (i < payload.Length) + { + int take = Math.Min(bytesPerLine, payload.Length - i); + AppendHex(sb, payload.Slice(i, take)); + sb.Append('\n'); + i += take; + } + + return sb.ToString(); + } + + private static void AppendHex(StringBuilder sb, ReadOnlySpan data) + { + const string hex = "0123456789ABCDEF"; + + for (int i = 0; i < data.Length; i++) + { + byte b = data[i]; + _ = sb.Append(hex[b >> 4]); + _ = sb.Append(hex[b & 0x0F]); + } + } + /// /// Writes the CICP profile chunk /// diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcRecordNumber.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcRecordNumber.cs index 2d5fe6a09..bbbeb83e0 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcRecordNumber.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcRecordNumber.cs @@ -9,12 +9,12 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.IPTC; internal enum IptcRecordNumber : byte { /// - /// A Envelope Record. + /// An Envelope Record. /// Envelope = 0x01, /// - /// A Application Record. + /// An Application Record. /// Application = 0x02 } diff --git a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs index 7735810b3..65daf5936 100644 --- a/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs +++ b/src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs @@ -2,6 +2,7 @@ // Licensed under the Six Labors Split License. using System.Diagnostics; +using System.Globalization; using System.Text; namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; @@ -9,7 +10,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Iptc; /// /// Represents a single value of the IPTC profile. /// -[DebuggerDisplay("{Tag} = {ToString(),nq} ({GetType().Name,nq})")] +[DebuggerDisplay("{Tag} = {DebuggerDisplayValue(),nq} ({GetType().Name,nq})")] public sealed class IptcValue : IDeepCloneable { private byte[] data = []; @@ -213,4 +214,37 @@ public sealed class IptcValue : IDeepCloneable return encoding.GetString(this.data); } + + private string DebuggerDisplayValue() + { + // IPTC RecordVersion (2:00) is a 2-byte binary value, commonly 0x0004. + // Showing it as UTF-8 produces control characters like "\0\u0004". + if (this.Tag == IptcTag.RecordVersion && this.data.Length == 2) + { + int version = (this.data[0] << 8) | this.data[1]; + return version.ToString(CultureInfo.InvariantCulture); + } + + // Prefer readable text if it looks like it, otherwise show hex. + // (Avoid surprising debugger output for binary payloads.) + bool printable = true; + for (int i = 0; i < this.data.Length; i++) + { + byte b = this.data[i]; + + // If any byte is an ASCII control character, treat this value as binary. + if (b is < 0x20 or 0x7F) + { + printable = false; + break; + } + } + + if (printable) + { + return this.Value; + } + + return Convert.ToHexString(this.data); + } } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs index a0c552a22..42048426e 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png.Chunks; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; +using SixLabors.ImageSharp.Metadata.Profiles.Iptc; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; @@ -31,16 +32,16 @@ public class PngMetadataTests ColorType = PngColorType.GrayscaleWithAlpha, InterlaceMethod = PngInterlaceMode.Adam7, Gamma = 2, - TextData = new List { new("name", "value", "foo", "bar") }, + TextData = [new("name", "value", "foo", "bar")], RepeatCount = 123, AnimateRootFrame = false }; - PngMetadata clone = (PngMetadata)meta.DeepClone(); + PngMetadata clone = meta.DeepClone(); - Assert.True(meta.BitDepth == clone.BitDepth); - Assert.True(meta.ColorType == clone.ColorType); - Assert.True(meta.InterlaceMethod == clone.InterlaceMethod); + Assert.Equal(meta.BitDepth, clone.BitDepth); + Assert.Equal(meta.ColorType, clone.ColorType); + Assert.Equal(meta.InterlaceMethod, clone.InterlaceMethod); Assert.True(meta.Gamma.Equals(clone.Gamma)); Assert.False(meta.TextData.Equals(clone.TextData)); Assert.True(meta.TextData.SequenceEqual(clone.TextData)); @@ -53,15 +54,47 @@ public class PngMetadataTests clone.Gamma = 1; clone.RepeatCount = 321; - Assert.False(meta.BitDepth == clone.BitDepth); - Assert.False(meta.ColorType == clone.ColorType); - Assert.False(meta.InterlaceMethod == clone.InterlaceMethod); + Assert.NotEqual(meta.BitDepth, clone.BitDepth); + Assert.NotEqual(meta.ColorType, clone.ColorType); + Assert.NotEqual(meta.InterlaceMethod, clone.InterlaceMethod); Assert.False(meta.Gamma.Equals(clone.Gamma)); Assert.False(meta.TextData.Equals(clone.TextData)); Assert.True(meta.TextData.SequenceEqual(clone.TextData)); Assert.False(meta.RepeatCount == clone.RepeatCount); } + [Theory] + [WithFile(TestImages.Png.IptcMetadata, PixelTypes.Rgba32)] + public void Decoder_CanReadIptcProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(PngDecoder.Instance); + Assert.NotNull(image.Metadata.IptcProfile); + Assert.Equal("test1, test2", image.Metadata.IptcProfile.GetValues(IptcTag.Keywords)[0].Value); + Assert.Equal("\0\u0004", image.Metadata.IptcProfile.GetValues(IptcTag.RecordVersion)[0].Value); + } + + [Theory] + [WithFile(TestImages.Png.IptcMetadata, PixelTypes.Rgba32)] + public void Encoder_CanWriteIptcProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(PngDecoder.Instance); + Assert.NotNull(image.Metadata.IptcProfile); + Assert.Equal("test1, test2", image.Metadata.IptcProfile.GetValues(IptcTag.Keywords)[0].Value); + Assert.Equal("\0\u0004", image.Metadata.IptcProfile.GetValues(IptcTag.RecordVersion)[0].Value); + + using MemoryStream memoryStream = new(); + image.Save(memoryStream, new PngEncoder()); + + memoryStream.Position = 0; + + using Image decoded = PngDecoder.Instance.Decode(DecoderOptions.Default, memoryStream); + Assert.NotNull(decoded.Metadata.IptcProfile); + Assert.Equal("test1, test2", decoded.Metadata.IptcProfile.GetValues(IptcTag.Keywords)[0].Value); + Assert.Equal("\0\u0004", decoded.Metadata.IptcProfile.GetValues(IptcTag.RecordVersion)[0].Value); + } + [Theory] [WithFile(TestImages.Png.PngWithMetadata, PixelTypes.Rgba32)] public void Decoder_CanReadTextData(TestImageProvider provider) @@ -337,7 +370,6 @@ public class PngMetadataTests Assert.Equal(42, (int)exif.GetValue(ExifTag.ImageNumber).Value); } - [Theory] [InlineData(PixelColorType.Binary, PngColorType.Palette)] [InlineData(PixelColorType.Indexed, PngColorType.Palette)] diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index f6cd776e4..6b4a86666 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -62,6 +62,7 @@ public static class TestImages public const string TestPattern31x31HalfTransparent = "Png/testpattern31x31-halftransparent.png"; public const string XmpColorPalette = "Png/xmp-colorpalette.png"; public const string AdamHeadsHlg = "Png/adamHeadsHLG.png"; + public const string IptcMetadata = "Png/iptc-profile.png"; // Animated // https://philip.html5.org/tests/apng/tests.html diff --git a/tests/Images/Input/Png/iptc-profile.png b/tests/Images/Input/Png/iptc-profile.png new file mode 100644 index 000000000..fa4199a0c --- /dev/null +++ b/tests/Images/Input/Png/iptc-profile.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae7f5d11145762b6544b3e289fc6c3bcb13a5f4cd8511b02280da683bec4c96e +size 448011 From 99aadf6b038296dad3fbb24e1eb324b9179bdccc Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 28 Jan 2026 10:10:14 +1000 Subject: [PATCH 101/112] Use overloads not nullable params --- .../Extensions/Drawing/DrawImageExtensions.cs | 296 +++++++++++++++++- 1 file changed, 280 insertions(+), 16 deletions(-) diff --git a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs index 42051ca93..79fe68c20 100644 --- a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs @@ -11,6 +11,19 @@ namespace SixLabors.ImageSharp.Processing; /// public static class DrawImageExtensions { + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + float opacity) + => DrawImage(source, foreground, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -26,12 +39,27 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -49,12 +77,27 @@ public static class DrawImageExtensions Image foreground, Rectangle foregroundRectangle, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The color blending mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -72,9 +115,26 @@ public static class DrawImageExtensions Image foreground, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, colorBlending, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -94,9 +154,26 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The color blending mode. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -116,9 +193,28 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending mode. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -140,9 +236,22 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The options, including the blending type and blending amount. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + GraphicsOptions options) + => DrawImage(source, foreground, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -158,9 +267,24 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, options, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The options, including the blending type and blending amount. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + GraphicsOptions options) + => DrawImage(source, foreground, foregroundRectangle, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -178,9 +302,24 @@ public static class DrawImageExtensions Image foreground, Rectangle foregroundRectangle, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + float opacity) + => DrawImage(source, foreground, backgroundLocation, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -198,12 +337,29 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -223,12 +379,29 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The color blending to apply. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, backgroundLocation, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -248,9 +421,28 @@ public static class DrawImageExtensions Point backgroundLocation, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending to apply. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -272,9 +464,24 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + GraphicsOptions options) + => DrawImage(source, foreground, backgroundLocation, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -292,9 +499,26 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + GraphicsOptions options) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -314,9 +538,28 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The color blending to apply. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, backgroundLocation, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -338,9 +581,30 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity, foregroundRepeatCount)); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending to apply. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -364,7 +628,7 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) => + int foregroundRepeatCount) => source.ApplyProcessor( new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount), foregroundRectangle); From 55d6711c19ef0580a54e8ab7d62028f19923335e Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 28 Jan 2026 11:16:40 +1000 Subject: [PATCH 102/112] Add test --- .../ImageSharp.Tests/Drawing/DrawImageTests.cs | 17 +++++++++++++++++ .../00.png | 3 +++ .../01.png | 3 +++ .../02.png | 3 +++ .../03.png | 3 +++ .../04.png | 3 +++ 6 files changed, 32 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/00.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/01.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/02.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/03.png create mode 100644 tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/04.png diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs index 1d0fdf62d..7f87111e8 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTests.cs @@ -293,4 +293,21 @@ public class DrawImageTests appendPixelTypeToFileName: false, appendSourceFileOrDescription: false); } + + [Theory] + [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] + public void DrawImageAnimatedForegroundRepeatCount(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image background = provider.GetImage(); + using Image foreground = Image.Load(TestFile.Create(TestImages.Gif.Giphy).Bytes); + + Size size = new(foreground.Width / 4, foreground.Height / 4); + foreground.Mutate(x => x.Resize(size.Width, size.Height, KnownResamplers.Bicubic)); + + background.Mutate(x => x.DrawImage(foreground, Point.Empty, 1F, 0)); + + background.DebugSaveMultiFrame(provider); + background.CompareToReferenceOutputMultiFrame(provider, ImageComparer.TolerantPercentage(0.01f)); + } } diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/00.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/00.png new file mode 100644 index 000000000..9e3e48a52 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/00.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:003d5986b66f90e0841c3fdfa8c595563c8e237467b8218c6fd7fa283ba28b1d +size 21154 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/01.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/01.png new file mode 100644 index 000000000..7d8babf99 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/01.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1d148bd561f33c2435226c533dea539e1b21567d8f985a4059d501846e0bf30 +size 21761 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/02.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/02.png new file mode 100644 index 000000000..108ccd1f5 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/02.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38519ad5d1d50548fada577d2bd4a8be7f76d1c3071f07bb98f1227c4bc5d303 +size 20522 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/03.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/03.png new file mode 100644 index 000000000..28c79f8c2 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/03.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e922f83fd719ba961b8720417befa119000f2c8f3956d3ac8df60c79ff56fe59 +size 21291 diff --git a/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/04.png b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/04.png new file mode 100644 index 000000000..401939430 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/Drawing/DrawImageTests/DrawImageAnimatedForegroundRepeatCount_Rgba32_giphy.gif/04.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b7b904032ff6c142632e8c1efffe3d71c28a89d5824d9fe13dbf4ceeddcf5e8 +size 21367 From d9816d12b5b2040ddb5ff8a3ab1f8991770cb2d8 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 28 Jan 2026 16:02:15 +1000 Subject: [PATCH 103/112] Add support for ICC conversion to WEBP --- src/ImageSharp/Formats/Webp/WebpDecoderCore.cs | 1 + .../Formats/Png/PngDecoderTests.cs | 1 + .../Formats/WebP/WebpDecoderTests.cs | 14 ++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 6 ++++++ ...ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png | 3 +++ ...IsConvert_ApplyIccProfile_Rgba32_Perceptual.png | 3 +++ .../Webp/icc-profiles/Perceptual-cLUT-only.webp | 3 +++ .../Images/Input/Webp/icc-profiles/Perceptual.webp | 3 +++ 8 files changed, 34 insertions(+) create mode 100644 tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png create mode 100644 tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png create mode 100644 tests/Images/Input/Webp/icc-profiles/Perceptual-cLUT-only.webp create mode 100644 tests/Images/Input/Webp/icc-profiles/Perceptual.webp diff --git a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs index fd31a7fad..d6a07eeca 100644 --- a/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs +++ b/src/ImageSharp/Formats/Webp/WebpDecoderCore.cs @@ -122,6 +122,7 @@ internal sealed class WebpDecoderCore : ImageDecoderCore, IDisposable this.ParseOptionalChunks(stream, metadata, this.webImageInfo.Features, buffer); } + _ = this.TryConvertIccProfile(image); return image; } } diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index a58101a6b..a57599455 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -5,6 +5,7 @@ using System.Runtime.Intrinsics.X86; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; +using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index c0abed214..6744f401e 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -3,6 +3,7 @@ using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; @@ -608,4 +609,17 @@ public class WebpDecoderTests image.DebugSave(provider); image.CompareToOriginal(provider, ReferenceDecoder); } + + [Theory] + [WithFile(Icc.Perceptual, PixelTypes.Rgba32)] + [WithFile(Icc.PerceptualcLUTOnly, PixelTypes.Rgba32)] + public void Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(WebpDecoder.Instance, new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert }); + + image.DebugSave(provider); + image.CompareToReferenceOutput(provider); + Assert.Null(image.Metadata.IccProfile); + } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 6b4a86666..dc3275999 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -901,6 +901,12 @@ public static class TestImages public const string AlphaBlend2 = "Webp/alpha-blend-2.webp"; public const string AlphaBlend3 = "Webp/alpha-blend-3.webp"; public const string AlphaBlend4 = "Webp/alpha-blend-4.webp"; + + public static class Icc + { + public const string Perceptual = "Webp/icc-profiles/Perceptual.webp"; + public const string PerceptualcLUTOnly = "Webp/icc-profiles/Perceptual-cLUT-only.webp"; + } } public static class Tiff diff --git a/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png b/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png new file mode 100644 index 000000000..4a01423ee --- /dev/null +++ b/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a2cbd483eed31cf7b410ef1ee45ae78e77b36e5b9c31f87764a1dfdb9c4e5c8 +size 79768 diff --git a/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png b/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png new file mode 100644 index 000000000..c46b369ef --- /dev/null +++ b/tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:547f3ddb5bdb3a3cb5c87440b65728be295c2b5f3c10a1b0b44299bb3d80e8d7 +size 79651 diff --git a/tests/Images/Input/Webp/icc-profiles/Perceptual-cLUT-only.webp b/tests/Images/Input/Webp/icc-profiles/Perceptual-cLUT-only.webp new file mode 100644 index 000000000..4787b792a --- /dev/null +++ b/tests/Images/Input/Webp/icc-profiles/Perceptual-cLUT-only.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b7ef9eedd1b2a4b93f11ac52807c071f7d0a24513008c3e69b0d4a0fd9b70db +size 186596 diff --git a/tests/Images/Input/Webp/icc-profiles/Perceptual.webp b/tests/Images/Input/Webp/icc-profiles/Perceptual.webp new file mode 100644 index 000000000..b78504f43 --- /dev/null +++ b/tests/Images/Input/Webp/icc-profiles/Perceptual.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aad13221b103b60c21a19e7ecfbab047404f25269485d26fc5dee4be11188865 +size 189800 From b8d288874c746aaa5dd97ce8590c283b4a0831d9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 28 Jan 2026 17:39:04 +1000 Subject: [PATCH 104/112] Optimize conversion with Avx --- ...ofileConverterExtensionsPixelCompatible.cs | 122 +++++++++++- src/ImageSharp/ColorProfiles/Rgb.cs | 184 +++++++++++++++++- 2 files changed, 299 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs index 2780f04ba..3c6cdba4a 100644 --- a/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs +++ b/src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs @@ -5,6 +5,8 @@ using System.Buffers; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; @@ -60,8 +62,126 @@ internal static class ColorProfileConverterExtensionsPixelCompatible converter.ConvertUsingIccProfile(rgbSpan, rgbSpan); // Copy the converted Rgb pixels back to the row as TPixel. + // Important: Preserve alpha from the existing row Vector4 values. + // We merge RGB from rgbSpan into row, leaving W untouched. + ref float srcRgb = ref Unsafe.As(ref MemoryMarshal.GetReference(rgbSpan)); + ref float dstRow = ref Unsafe.As(ref MemoryMarshal.GetReference(row)); + + int count = rgbSpan.Length; + int i = 0; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Vector512 ReadVector512(ref float f) + { + ref byte b = ref Unsafe.As(ref f); + return Unsafe.ReadUnaligned>(ref b); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void WriteVector512(ref float f, Vector512 v) + { + ref byte b = ref Unsafe.As(ref f); + Unsafe.WriteUnaligned(ref b, v); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static Vector256 ReadVector256(ref float f) + { + ref byte b = ref Unsafe.As(ref f); + return Unsafe.ReadUnaligned>(ref b); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + static void WriteVector256(ref float f, Vector256 v) + { + ref byte b = ref Unsafe.As(ref f); + Unsafe.WriteUnaligned(ref b, v); + } + + if (Avx512F.IsSupported) + { + // 4 pixels per iteration. + // + // Source layout (Rgb float stream, 12 floats): + // [r0 g0 b0 r1 g1 b1 r2 g2 b2 r3 g3 b3] + // + // Destination layout (row Vector4 float stream, 16 floats): + // [r0 g0 b0 a0 r1 g1 b1 a1 r2 g2 b2 a2 r3 g3 b3 a3] + // + // We use an overlapped load (16 floats) from the 3-float stride source. + // The permute selects the RGB we need and inserts placeholders for alpha lanes. + // + // Then we blend RGB lanes into the existing destination, preserving alpha lanes. + Vector512 rgbPerm = Vector512.Create(0, 1, 2, 0, 3, 4, 5, 0, 6, 7, 8, 0, 9, 10, 11, 0); + + // BlendVariable selects from the second operand where the sign bit of the mask lane is set. + // We want to overwrite lanes 0,1,2 then 4,5,6 then 8,9,10 then 12,13,14, and preserve lanes 3,7,11,15 (alpha). + Vector512 rgbSelect = Vector512.Create(-0F, -0F, -0F, 0F, -0F, -0F, -0F, 0F, -0F, -0F, -0F, 0F, -0F, -0F, -0F, 0F); + + int quads = count >> 2; + int simdQuads = quads - 1; // Leave the last quad for the scalar tail to avoid the final overlapped load reading past the end. + + for (int q = 0; q < simdQuads; q++) + { + Vector512 dst = ReadVector512(ref dstRow); + Vector512 src = ReadVector512(ref srcRgb); + + Vector512 rgbx = Avx512F.PermuteVar16x32(src, rgbPerm); + Vector512 merged = Avx512F.BlendVariable(dst, rgbx, rgbSelect); + + WriteVector512(ref dstRow, merged); + + // Advance input by 4 pixels (4 * 3 = 12 floats) + srcRgb = ref Unsafe.Add(ref srcRgb, 12); + + // Advance output by 4 pixels (4 * 4 = 16 floats) + dstRow = ref Unsafe.Add(ref dstRow, 16); + + i += 4; + } + } + else if (Avx2.IsSupported) + { + // 2 pixels per iteration. + // + // Same idea as AVX-512, but on 256-bit vectors. + // We permute packed RGB into rgbx layout and blend into the existing destination, + // preserving alpha lanes. + Vector256 rgbPerm = Vector256.Create(0, 1, 2, 0, 3, 4, 5, 0); + + Vector256 rgbSelect = Vector256.Create(-0F, -0F, -0F, 0F, -0F, -0F, -0F, 0F); + + int pairs = count >> 1; + int simdPairs = pairs - 1; // Leave the last pair for the scalar tail to avoid the final overlapped load reading past the end. + + for (int p = 0; p < simdPairs; p++) + { + Vector256 dst = ReadVector256(ref dstRow); + Vector256 src = ReadVector256(ref srcRgb); + + Vector256 rgbx = Avx2.PermuteVar8x32(src, rgbPerm); + Vector256 merged = Avx.BlendVariable(dst, rgbx, rgbSelect); + + WriteVector256(ref dstRow, merged); + + // Advance input by 2 pixels (2 * 3 = 6 floats) + srcRgb = ref Unsafe.Add(ref srcRgb, 6); + + // Advance output by 2 pixels (2 * 4 = 8 floats) + dstRow = ref Unsafe.Add(ref dstRow, 8); + + i += 2; + } + } + + // Scalar tail. + // Handles: + // - the last skipped SIMD block (quad or pair) + // - any remainder + // + // Preserve alpha by writing Vector3 into the Vector4 storage. ref Vector4 rowRef = ref MemoryMarshal.GetReference(row); - for (int i = 0; i < rgbSpan.Length; i++) + for (; i < count; i++) { Vector3 rgb = rgbSpan[i].AsVector3Unsafe(); Unsafe.As(ref Unsafe.Add(ref rowRef, (uint)i)) = rgb; diff --git a/src/ImageSharp/ColorProfiles/Rgb.cs b/src/ImageSharp/ColorProfiles/Rgb.cs index 42e502592..c95e54192 100644 --- a/src/ImageSharp/ColorProfiles/Rgb.cs +++ b/src/ImageSharp/ColorProfiles/Rgb.cs @@ -4,6 +4,8 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.ColorProfiles.WorkingSpaces; namespace SixLabors.ImageSharp.ColorProfiles; @@ -105,10 +107,87 @@ public readonly struct Rgb : IProfileConnectingSpace { Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination)); - // TODO: Optimize via SIMD - for (int i = 0; i < source.Length; i++) + int length = source.Length; + if (length == 0) { - destination[i] = source[i].ToScaledVector4(); + return; + } + + ref Rgb srcRgb = ref MemoryMarshal.GetReference(source); + ref Vector4 dstV4 = ref MemoryMarshal.GetReference(destination); + + // Float streams: + // src: r0 g0 b0 r1 g1 b1 ... + // dst: r0 g0 b0 a0 r1 g1 b1 a1 ... + ref float src = ref Unsafe.As(ref srcRgb); + ref float dst = ref Unsafe.As(ref dstV4); + + int i = 0; + + if (Avx512F.IsSupported) + { + // 4 pixels per iteration. Using overlapped 16-float loads. + Vector512 perm = Vector512.Create(0, 1, 2, 0, 3, 4, 5, 0, 6, 7, 8, 0, 9, 10, 11, 0); + Vector512 ones = Vector512.Create(1F); + + // BlendVariable selects from 'ones' where the sign-bit of mask lane is set. + // Using -0f sets only the sign bit, producing an efficient "select lane" mask. + Vector512 alphaSelect = Vector512.Create(0F, 0F, 0F, -0F, 0F, 0F, 0F, -0F, 0F, 0F, 0F, -0F, 0F, 0F, 0F, -0F); + + int quads = length >> 2; + + // Leave the last quad (4 pixels) for the scalar tail. + int simdQuads = quads - 1; + + for (int q = 0; q < simdQuads; q++) + { + Vector512 v = ReadVector512(ref src); + Vector512 rgbx = Avx512F.PermuteVar16x32(v, perm); + Vector512 rgba = Avx512F.BlendVariable(rgbx, ones, alphaSelect); + + WriteVector512(ref dst, rgba); + + src = ref Unsafe.Add(ref src, 12); + dst = ref Unsafe.Add(ref dst, 16); + + i += 4; + } + } + else if (Avx2.IsSupported) + { + // 2 pixels per iteration. Using overlapped 8-float loads. + Vector256 perm = Vector256.Create(0, 1, 2, 0, 3, 4, 5, 0); + + Vector256 ones = Vector256.Create(1F); + + // vblendps mask: bit i selects lane i from 'ones' when set. + // We want lanes 3 and 7 -> 0b10001000 = 0x88. + const byte alphaMask = 0x88; + + int pairs = length >> 1; + + // Leave the last pair (2 pixels) for the scalar tail. + int simdPairs = pairs - 1; + + for (int p = 0; p < simdPairs; p++) + { + Vector256 v = ReadVector256(ref src); + Vector256 rgbx = Avx2.PermuteVar8x32(v, perm); + Vector256 rgba = Avx.Blend(rgbx, ones, alphaMask); + + WriteVector256(ref dst, rgba); + + src = ref Unsafe.Add(ref src, 6); + dst = ref Unsafe.Add(ref dst, 8); + + i += 2; + } + } + + // Tail (and non-AVX paths) + for (; i < length; i++) + { + Unsafe.Add(ref dstV4, i) = Unsafe.Add(ref srcRgb, i).ToScaledVector4(); } } @@ -117,10 +196,75 @@ public readonly struct Rgb : IProfileConnectingSpace { Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination)); - // TODO: Optimize via SIMD - for (int i = 0; i < source.Length; i++) + int length = source.Length; + if (length == 0) { - destination[i] = FromScaledVector4(source[i]); + return; + } + + ref Vector4 srcV4 = ref MemoryMarshal.GetReference(source); + ref Rgb dstRgb = ref MemoryMarshal.GetReference(destination); + + // Float streams: + // src: r0 g0 b0 a0 r1 g1 b1 a1 ... + // dst: r0 g0 b0 r1 g1 b1 ... + ref float src = ref Unsafe.As(ref srcV4); + ref float dst = ref Unsafe.As(ref dstRgb); + + int i = 0; + + if (Avx512F.IsSupported) + { + // 4 pixels per iteration. Using overlapped 16-float stores: + Vector512 idx = Vector512.Create(0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 3, 7, 11, 15); + + // Number of 4-pixel groups in the input. + int quads = length >> 2; + + // Leave the last quad (4 pixels) for the scalar tail. + int simdQuads = quads - 1; + + for (int q = 0; q < simdQuads; q++) + { + Vector512 v = ReadVector512(ref src); + Vector512 packed = Avx512F.PermuteVar16x32(v, idx); + + WriteVector512(ref dst, packed); + + src = ref Unsafe.Add(ref src, 16); + dst = ref Unsafe.Add(ref dst, 12); + i += 4; + } + } + else if (Avx2.IsSupported) + { + // 2 pixels per iteration, using overlapped 8-float stores: + Vector256 idx = Vector256.Create(0, 1, 2, 4, 5, 6, 0, 0); + + int pairs = length >> 1; + + // Leave the last pair (2 pixels) for the scalar tail. + int simdPairs = pairs - 1; + + int pairIndex = 0; + for (; pairIndex < simdPairs; pairIndex++) + { + Vector256 v = ReadVector256(ref src); + Vector256 packed = Avx2.PermuteVar8x32(v, idx); + + WriteVector256(ref dst, packed); + + src = ref Unsafe.Add(ref src, 8); + dst = ref Unsafe.Add(ref dst, 6); + i += 2; + } + } + + // Tail (and non-AVX paths) + for (; i < length; i++) + { + Vector4 v = Unsafe.Add(ref srcV4, i); + Unsafe.Add(ref dstRgb, i) = FromScaledVector4(v); } } @@ -288,4 +432,32 @@ public readonly struct Rgb : IProfileConnectingSpace M44 = 1F }; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static Vector512 ReadVector512(ref float src) + { + ref byte b = ref Unsafe.As(ref src); + return Unsafe.ReadUnaligned>(ref b); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static Vector256 ReadVector256(ref float src) + { + ref byte b = ref Unsafe.As(ref src); + return Unsafe.ReadUnaligned>(ref b); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void WriteVector512(ref float dst, Vector512 value) + { + ref byte b = ref Unsafe.As(ref dst); + Unsafe.WriteUnaligned(ref b, value); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void WriteVector256(ref float dst, Vector256 value) + { + ref byte b = ref Unsafe.As(ref dst); + Unsafe.WriteUnaligned(ref b, value); + } } From 08dd24fbee71b6c296392c92f2000a5151d6b948 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 28 Jan 2026 17:58:50 +1000 Subject: [PATCH 105/112] Remove unused namespaces --- tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs | 1 - tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index a57599455..a58101a6b 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -5,7 +5,6 @@ using System.Runtime.Intrinsics.X86; using Microsoft.DotNet.RemoteExecutor; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Png; -using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.TestUtilities; diff --git a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs index 6744f401e..a3e3b81cf 100644 --- a/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs @@ -3,7 +3,6 @@ using System.Runtime.Intrinsics.X86; using SixLabors.ImageSharp.Formats; -using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Exif; From 7f402b8bb8840b1d48efaef6ea67e40b8d94c62b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 29 Jan 2026 21:09:36 +1000 Subject: [PATCH 106/112] Allow conversion for CIE Lab and CMYK --- .../CieLab16PlanarTiffColor{TPixel}.cs | 144 ++++++++++++++++++ .../CieLab16TiffColor{TPixel}.cs | 140 +++++++++++++++++ ...}.cs => CieLab8PlanarTiffColor{TPixel}.cs} | 2 +- ...TPixel}.cs => CieLab8TiffColor{TPixel}.cs} | 10 +- .../CmykTiffColor{TPixel}.cs | 69 +++++++-- .../TiffColorDecoderFactory{TPixel}.cs | 40 +++-- .../YCbCrConverter.cs | 2 +- .../Formats/Tiff/TiffDecoderCore.cs | 18 ++- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 10 +- .../Formats/Tiff/TiffDecoderTests.cs | 15 +- tests/ImageSharp.Tests/TestImages.cs | 6 + ...plyIccProfile_Rgba32_Perceptual_CIELAB.png | 3 + ...ApplyIccProfile_Rgba32_Perceptual_CMYK.png | 3 + .../Tiff/icc-profiles/Perceptual_CIELAB.tiff | 3 + .../Tiff/icc-profiles/Perceptual_CMYK.tiff | 3 + 15 files changed, 432 insertions(+), 36 deletions(-) create mode 100644 src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16PlanarTiffColor{TPixel}.cs create mode 100644 src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16TiffColor{TPixel}.cs rename src/ImageSharp/Formats/Tiff/PhotometricInterpretation/{CieLabPlanarTiffColor{TPixel}.cs => CieLab8PlanarTiffColor{TPixel}.cs} (94%) rename src/ImageSharp/Formats/Tiff/PhotometricInterpretation/{CieLabTiffColor{TPixel}.cs => CieLab8TiffColor{TPixel}.cs} (83%) create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CIELAB.png create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CMYK.png create mode 100644 tests/Images/Input/Tiff/icc-profiles/Perceptual_CIELAB.tiff create mode 100644 tests/Images/Input/Tiff/icc-profiles/Perceptual_CMYK.tiff diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16PlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16PlanarTiffColor{TPixel}.cs new file mode 100644 index 000000000..b422e65ad --- /dev/null +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16PlanarTiffColor{TPixel}.cs @@ -0,0 +1,144 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; +using System.Numerics; +using System.Runtime.InteropServices; +using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; +using SixLabors.ImageSharp.Formats.Tiff.Utils; +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; + +/// +/// Implements decoding pixel data with photometric interpretation of type 'CieLab' with the planar configuration. +/// Each channel is represented with 16 bits. +/// +/// The type of pixel format. +internal class CieLab16PlanarTiffColor : TiffBasePlanarColorDecoder + where TPixel : unmanaged, IPixel +{ + private readonly ColorProfileConverter colorProfileConverter; + private readonly Configuration configuration; + private readonly bool isBigEndian; + + // libtiff encodes 16-bit Lab as: + // L* : unsigned [0, 65535] mapping to [0, 100] + // a*, b* : signed [-32768, 32767], values are 256x the 1976 a*, b* values. + private const float Inv65535 = 1f / 65535f; + private const float Inv256 = 1f / 256f; + + public CieLab16PlanarTiffColor( + Configuration configuration, + DecoderOptions decoderOptions, + ImageFrameMetadata metadata, + MemoryAllocator allocator, + bool isBigEndian) + { + this.isBigEndian = isBigEndian; + this.configuration = configuration; + + if (decoderOptions.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + ColorConversionOptions options = new() + { + SourceIccProfile = iccProfile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + else + { + ColorConversionOptions options = new() + { + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + } + + /// + public override void Decode(IMemoryOwner[] data, Buffer2D pixels, int left, int top, int width, int height) + { + Span lPlane = data[0].GetSpan(); + Span aPlane = data[1].GetSpan(); + Span bPlane = data[2].GetSpan(); + + // Allocate temporary buffers to hold the LAB -> RGB conversion. + // This should be the maximum width of a row. + using IMemoryOwner rgbBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + using IMemoryOwner vectorBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + + Span rgbRow = rgbBuffer.Memory.Span; + Span vectorRow = vectorBuffer.Memory.Span; + + // Reuse the rgbRow span for lab data since both are 3-float structs, avoiding an extra allocation. + Span cieLabRow = MemoryMarshal.Cast(rgbRow); + + int stride = width * 2; + + if (this.isBigEndian) + { + for (int y = 0; y < height; y++) + { + int rowBase = y * stride; + Span pixelRow = pixels.DangerousGetRowSpan(top + y).Slice(left, width); + + for (int x = 0; x < width; x++) + { + int i = rowBase + (x * 2); + + ushort lRaw = TiffUtilities.ConvertToUShortBigEndian(lPlane.Slice(i, 2)); + short aRaw = unchecked((short)TiffUtilities.ConvertToUShortBigEndian(aPlane.Slice(i, 2))); + short bRaw = unchecked((short)TiffUtilities.ConvertToUShortBigEndian(bPlane.Slice(i, 2))); + + float l = lRaw * 100f * Inv65535; + float a = aRaw * Inv256; + float b = bRaw * Inv256; + + cieLabRow[x] = new CieLab(l, a, b); + } + + // Convert CIE Lab -> Rgb -> Vector4 -> TPixel + this.colorProfileConverter.Convert(cieLabRow, rgbRow); + Rgb.ToScaledVector4(rgbRow, vectorRow); + PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorRow, pixelRow, PixelConversionModifiers.Scale); + } + + return; + } + + for (int y = 0; y < height; y++) + { + int rowBase = y * stride; + Span pixelRow = pixels.DangerousGetRowSpan(top + y).Slice(left, width); + + for (int x = 0; x < width; x++) + { + int i = rowBase + (x * 2); + + ushort lRaw = TiffUtilities.ConvertToUShortLittleEndian(lPlane.Slice(i, 2)); + short aRaw = unchecked((short)TiffUtilities.ConvertToUShortLittleEndian(aPlane.Slice(i, 2))); + short bRaw = unchecked((short)TiffUtilities.ConvertToUShortLittleEndian(bPlane.Slice(i, 2))); + + float l = lRaw * 100f * Inv65535; + float a = aRaw * Inv256; + float b = bRaw * Inv256; + + cieLabRow[x] = new CieLab(l, a, b); + } + + // Convert CIE Lab -> Rgb -> Vector4 -> TPixel + this.colorProfileConverter.Convert(cieLabRow, rgbRow); + Rgb.ToScaledVector4(rgbRow, vectorRow); + PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorRow, pixelRow, PixelConversionModifiers.Scale); + } + } +} diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16TiffColor{TPixel}.cs new file mode 100644 index 000000000..4455753bf --- /dev/null +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab16TiffColor{TPixel}.cs @@ -0,0 +1,140 @@ +// Copyright (c) Six Labors. +// Licensed under the Six Labors Split License. + +using System.Buffers; +using System.Numerics; +using System.Runtime.InteropServices; +using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; +using SixLabors.ImageSharp.Formats.Tiff.Utils; +using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; +using SixLabors.ImageSharp.PixelFormats; + +namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; + +/// +/// Implements decoding pixel data with photometric interpretation of type 'CieLab'. +/// Each channel is represented with 16 bits. +/// +/// The type of pixel format. +internal class CieLab16TiffColor : TiffBaseColorDecoder + where TPixel : unmanaged, IPixel +{ + private readonly ColorProfileConverter colorProfileConverter; + private readonly Configuration configuration; + private readonly bool isBigEndian; + + // libtiff encodes 16-bit Lab as: + // L* : unsigned [0, 65535] mapping to [0, 100] + // a*, b* : signed [-32768, 32767], values are 256x the 1976 a*, b* values. + private const float Inv65535 = 1f / 65535f; + private const float Inv256 = 1f / 256f; + + public CieLab16TiffColor( + Configuration configuration, + DecoderOptions decoderOptions, + ImageFrameMetadata metadata, + MemoryAllocator allocator, + bool isBigEndian) + { + this.isBigEndian = isBigEndian; + this.configuration = configuration; + + if (decoderOptions.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + ColorConversionOptions options = new() + { + SourceIccProfile = iccProfile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + else + { + ColorConversionOptions options = new() + { + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + } + + /// + public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) + { + int offset = 0; + + // Allocate temporary buffers to hold the LAB -> RGB conversion. + // This should be the maximum width of a row. + using IMemoryOwner rgbBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + using IMemoryOwner vectorBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + + Span rgbRow = rgbBuffer.Memory.Span; + Span vectorRow = vectorBuffer.Memory.Span; + + // Reuse the rgbRow span for lab data since both are 3-float structs, avoiding an extra allocation. + Span cieLabRow = MemoryMarshal.Cast(rgbRow); + + if (this.isBigEndian) + { + for (int y = top; y < top + height; y++) + { + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); + + for (int x = 0; x < pixelRow.Length; x++) + { + ushort lRaw = TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2)); + offset += 2; + short aRaw = unchecked((short)TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2))); + offset += 2; + short bRaw = unchecked((short)TiffUtilities.ConvertToUShortBigEndian(data.Slice(offset, 2))); + offset += 2; + + float l = lRaw * 100f * Inv65535; + float a = aRaw * Inv256; + float b = bRaw * Inv256; + + cieLabRow[x] = new CieLab(l, a, b); + } + + // Convert CIE Lab -> Rgb -> Vector4 -> TPixel + this.colorProfileConverter.Convert(cieLabRow, rgbRow); + Rgb.ToScaledVector4(rgbRow, vectorRow); + PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorRow, pixelRow, PixelConversionModifiers.Scale); + } + + return; + } + + for (int y = top; y < top + height; y++) + { + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); + + for (int x = 0; x < pixelRow.Length; x++) + { + ushort lRaw = TiffUtilities.ConvertToUShortLittleEndian(data.Slice(offset, 2)); + offset += 2; + short aRaw = unchecked((short)TiffUtilities.ConvertToUShortLittleEndian(data.Slice(offset, 2))); + offset += 2; + short bRaw = unchecked((short)TiffUtilities.ConvertToUShortLittleEndian(data.Slice(offset, 2))); + offset += 2; + + float l = lRaw * 100f * Inv65535; + float a = aRaw * Inv256; + float b = bRaw * Inv256; + + cieLabRow[x] = new CieLab(l, a, b); + } + + // Convert CIE Lab -> Rgb -> Vector4 -> TPixel + this.colorProfileConverter.Convert(cieLabRow, rgbRow); + Rgb.ToScaledVector4(rgbRow, vectorRow); + PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorRow, pixelRow, PixelConversionModifiers.Scale); + } + } +} diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8PlanarTiffColor{TPixel}.cs similarity index 94% rename from src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs rename to src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8PlanarTiffColor{TPixel}.cs index d23d1e290..1252f1d3d 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabPlanarTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8PlanarTiffColor{TPixel}.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; /// Implements decoding pixel data with photometric interpretation of type 'CieLab' with the planar configuration. /// /// The type of pixel format. -internal class CieLabPlanarTiffColor : TiffBasePlanarColorDecoder +internal class CieLab8PlanarTiffColor : TiffBasePlanarColorDecoder where TPixel : unmanaged, IPixel { private static readonly ColorProfileConverter ColorProfileConverter = new(); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8TiffColor{TPixel}.cs similarity index 83% rename from src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs rename to src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8TiffColor{TPixel}.cs index b10d27ccd..ce5bed53c 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLabTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CieLab8TiffColor{TPixel}.cs @@ -10,14 +10,22 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; /// /// Implements decoding pixel data with photometric interpretation of type 'CieLab'. +/// Each channel is represented with 8 bits. /// /// The type of pixel format. -internal class CieLabTiffColor : TiffBaseColorDecoder +internal class CieLab8TiffColor : TiffBaseColorDecoder where TPixel : unmanaged, IPixel { private static readonly ColorProfileConverter ColorProfileConverter = new(); private const float Inv255 = 1f / 255f; + /// + /// Initializes a new instance of the class. + /// + public CieLab8TiffColor() + { + } + /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs index 2e22fcde0..509056267 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/CmykTiffColor{TPixel}.cs @@ -1,10 +1,15 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System.Buffers; using System.Numerics; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.ColorProfiles; +using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.Formats.Tiff.Compression; using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata; +using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; @@ -12,18 +17,48 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; internal class CmykTiffColor : TiffBaseColorDecoder where TPixel : unmanaged, IPixel { - private static readonly ColorProfileConverter ColorProfileConverter = new(); + private readonly ColorProfileConverter colorProfileConverter; + private readonly Configuration configuration; private const float Inv255 = 1f / 255f; private readonly TiffDecoderCompressionType compression; - public CmykTiffColor(TiffDecoderCompressionType compression) => this.compression = compression; + public CmykTiffColor( + TiffDecoderCompressionType compression, + Configuration configuration, + DecoderOptions decoderOptions, + ImageFrameMetadata metadata, + MemoryAllocator allocator) + { + this.compression = compression; + this.configuration = configuration; + + if (decoderOptions.TryGetIccProfileForColorConversion(metadata.IccProfile, out IccProfile? iccProfile)) + { + ColorConversionOptions options = new() + { + SourceIccProfile = iccProfile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + else + { + ColorConversionOptions options = new() + { + MemoryAllocator = allocator + }; + + this.colorProfileConverter = new ColorProfileConverter(options); + } + } /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { int offset = 0; - if (this.compression == TiffDecoderCompressionType.Jpeg) { for (int y = top; y < top + height; y++) @@ -40,17 +75,31 @@ internal class CmykTiffColor : TiffBaseColorDecoder return; } + // Allocate temporary buffers to hold the CMYK -> RGB conversion. + // This should be the maximum width of a row. + using IMemoryOwner rgbBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + using IMemoryOwner vectorBuffer = this.colorProfileConverter.Options.MemoryAllocator.Allocate(width); + + Span rgbRow = rgbBuffer.Memory.Span; + Span vectorRow = vectorBuffer.Memory.Span; + + // Reuse the Vector4 buffer as CMYK storage since both are 4-float structs, avoiding an extra allocation. + Span cmykRow = MemoryMarshal.Cast(vectorRow); + for (int y = top; y < top + height; y++) { Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); - for (int x = 0; x < pixelRow.Length; x++) - { - Cmyk cmyk = new(data[offset] * Inv255, data[offset + 1] * Inv255, data[offset + 2] * Inv255, data[offset + 3] * Inv255); - Rgb rgb = ColorProfileConverter.Convert(in cmyk); - pixelRow[x] = TPixel.FromScaledVector4(new Vector4(rgb.R, rgb.G, rgb.B, 1.0f)); - offset += 4; - } + // Collect CMYK pixels. + // ByteToNormalizedFloat efficiently converts packed 4-byte component data + // to normalized 0-1 floats using SIMD. + SimdUtils.ByteToNormalizedFloat(data.Slice(offset, width * 4), MemoryMarshal.Cast(cmykRow)); + offset += width * 4; + + // Convert CMYK -> RGB -> Vector4 -> TPixel + this.colorProfileConverter.Convert(cmykRow, rgbRow); + Rgb.ToScaledVector4(rgbRow, vectorRow); + PixelOperations.Instance.FromVector4Destructive(this.configuration, vectorRow, pixelRow, PixelConversionModifiers.Scale); } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs index e2eb82e3b..363c16445 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs @@ -3,6 +3,7 @@ using SixLabors.ImageSharp.Formats.Tiff.Compression; using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation; @@ -11,6 +12,8 @@ internal static class TiffColorDecoderFactory where TPixel : unmanaged, IPixel { public static TiffBaseColorDecoder Create( + ImageFrameMetadata metadata, + DecoderOptions options, Configuration configuration, MemoryAllocator memoryAllocator, TiffColorType colorType, @@ -396,13 +399,20 @@ internal static class TiffColorDecoderFactory return new YCbCrTiffColor(memoryAllocator, referenceBlackAndWhite, ycbcrCoefficients, ycbcrSubSampling); case TiffColorType.CieLab: - DebugGuard.IsTrue( - bitsPerSample.Channels == 3 - && bitsPerSample.Channel2 == 8 - && bitsPerSample.Channel1 == 8 - && bitsPerSample.Channel0 == 8, - "bitsPerSample"); - return new CieLabTiffColor(); + + DebugGuard.IsTrue(bitsPerSample.Channels == 3, "bitsPerSample"); + + if (bitsPerSample.Channel0 == 8) + { + return new CieLab8TiffColor(); + } + + return new CieLab16TiffColor( + configuration, + options, + metadata, + memoryAllocator, + byteOrder == ByteOrder.BigEndian); case TiffColorType.Cmyk: DebugGuard.IsTrue( @@ -412,14 +422,19 @@ internal static class TiffColorDecoderFactory && bitsPerSample.Channel1 == 8 && bitsPerSample.Channel0 == 8, "bitsPerSample"); - return new CmykTiffColor(compression); + return new CmykTiffColor(compression, configuration, options, metadata, memoryAllocator); default: throw TiffThrowHelper.InvalidColorType(colorType.ToString()); } } +#pragma warning disable IDE0060 // Remove unused parameter public static TiffBasePlanarColorDecoder CreatePlanar( + ImageFrameMetadata metadata, + DecoderOptions options, + Configuration configuration, + MemoryAllocator allocator, TiffColorType colorType, TiffBitsPerSample bitsPerSample, TiffExtraSampleType? extraSampleType, @@ -443,7 +458,14 @@ internal static class TiffColorDecoderFactory return new YCbCrPlanarTiffColor(referenceBlackAndWhite, ycbcrCoefficients, ycbcrSubSampling); case TiffColorType.CieLabPlanar: - return new CieLabPlanarTiffColor(); + return bitsPerSample.Channel0 == 8 + ? new CieLab8PlanarTiffColor() + : new CieLab16PlanarTiffColor( + configuration, + options, + metadata, + allocator, + byteOrder == ByteOrder.BigEndian); case TiffColorType.Rgb161616Planar: DebugGuard.IsTrue(colorMap == null, "colorMap"); diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs index 744cba35f..9e5e3dba9 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/YCbCrConverter.cs @@ -107,7 +107,7 @@ internal class YCbCrConverter [MethodImpl(MethodImplOptions.AggressiveInlining)] public Rgba32 Convert(float y, float cb, float cr) { - Rgba32 pixel = default(Rgba32); + Rgba32 pixel = default; pixel.R = RoundAndClampTo8Bit((cr * this.cr2R) + y); pixel.G = RoundAndClampTo8Bit((this.y2G * y) + (this.cr2G * cr) + (this.cb2G * cb)); pixel.B = RoundAndClampTo8Bit((cb * this.cb2B) + y); diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 8a4a27946..30fa277fc 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -453,7 +453,7 @@ internal class TiffDecoderCore : ImageDecoderCore } using TiffBaseDecompressor decompressor = this.CreateDecompressor(width, bitsPerPixel, frame.Metadata); - TiffBasePlanarColorDecoder colorDecoder = this.CreatePlanarColorDecoder(); + TiffBasePlanarColorDecoder colorDecoder = this.CreatePlanarColorDecoder(frame.Metadata); for (int i = 0; i < stripsPerPlane; i++) { @@ -518,7 +518,7 @@ internal class TiffDecoderCore : ImageDecoderCore int bitsPerPixel = this.BitsPerPixel; using TiffBaseDecompressor decompressor = this.CreateDecompressor(width, bitsPerPixel, frame.Metadata); - TiffBaseColorDecoder colorDecoder = this.CreateChunkyColorDecoder(); + TiffBaseColorDecoder colorDecoder = this.CreateChunkyColorDecoder(frame.Metadata); Buffer2D pixels = frame.PixelBuffer; // There exists in this world TIFF files with uncompressed strips larger than Int32.MaxValue. @@ -661,7 +661,7 @@ internal class TiffDecoderCore : ImageDecoderCore } using TiffBaseDecompressor decompressor = this.CreateDecompressor(frame.Width, bitsPerPixel, frame.Metadata); - TiffBasePlanarColorDecoder colorDecoder = this.CreatePlanarColorDecoder(); + TiffBasePlanarColorDecoder colorDecoder = this.CreatePlanarColorDecoder(frame.Metadata); int tileIndex = 0; int remainingPixelsInColumn = height; @@ -762,7 +762,7 @@ internal class TiffDecoderCore : ImageDecoderCore Span tileBufferSpan = tileBuffer.GetSpan(); using TiffBaseDecompressor decompressor = this.CreateDecompressor(frame.Width, bitsPerPixel, frame.Metadata, true, tileWidth, tileLength); - TiffBaseColorDecoder colorDecoder = this.CreateChunkyColorDecoder(); + TiffBaseColorDecoder colorDecoder = this.CreateChunkyColorDecoder(frame.Metadata); int tileIndex = 0; for (int tileY = 0; tileY < tilesDown; tileY++) @@ -803,9 +803,11 @@ internal class TiffDecoderCore : ImageDecoderCore } } - private TiffBaseColorDecoder CreateChunkyColorDecoder() + private TiffBaseColorDecoder CreateChunkyColorDecoder(ImageFrameMetadata metadata) where TPixel : unmanaged, IPixel => TiffColorDecoderFactory.Create( + metadata, + this.Options, this.configuration, this.memoryAllocator, this.ColorType, @@ -818,9 +820,13 @@ internal class TiffDecoderCore : ImageDecoderCore this.CompressionType, this.byteOrder); - private TiffBasePlanarColorDecoder CreatePlanarColorDecoder() + private TiffBasePlanarColorDecoder CreatePlanarColorDecoder(ImageFrameMetadata metadata) where TPixel : unmanaged, IPixel => TiffColorDecoderFactory.CreatePlanar( + metadata, + this.Options, + this.configuration, + this.memoryAllocator, this.ColorType, this.BitsPerSample, this.ExtraSamplesType, diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 7519871b7..9445f468c 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -452,13 +452,9 @@ internal static class TiffDecoderOptionsParser TiffThrowHelper.ThrowNotSupported("The number of samples in the TIFF BitsPerSample entry is not supported for CieLab images."); } - ushort bitsPerChannel = options.BitsPerSample.Channel0; - if (bitsPerChannel != 8) - { - TiffThrowHelper.ThrowNotSupported("Only 8 bits per channel is supported for CieLab images."); - } - - options.ColorType = options.PlanarConfiguration == TiffPlanarConfiguration.Chunky ? TiffColorType.CieLab : TiffColorType.CieLabPlanar; + options.ColorType = options.PlanarConfiguration == TiffPlanarConfiguration.Chunky + ? TiffColorType.CieLab + : TiffColorType.CieLabPlanar; break; } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index 5096d93bd..c186d4f01 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -23,7 +23,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester public static readonly string[] MultiframeTestImages = Multiframes; [Theory] - [WithFile(MultiframeDifferentVariants, PixelTypes.Rgba32)] + // [WithFile(MultiframeDifferentVariants, PixelTypes.Rgba32)] [WithFile(Cmyk64BitDeflate, PixelTypes.Rgba32)] public void ThrowsNotSupported(TestImageProvider provider) where TPixel : unmanaged, IPixel => Assert.Throws(() => provider.GetImage(TiffDecoder.Instance)); @@ -352,6 +352,19 @@ public class TiffDecoderTests : TiffDecoderBaseTester image.CompareToReferenceOutput(ImageComparer.Exact, provider); } + [Theory] + [WithFile(Icc.PerceptualCmyk, PixelTypes.Rgba32)] + [WithFile(Icc.PerceptualCieLab, PixelTypes.Rgba32)] + public void Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(TiffDecoder.Instance, new DecoderOptions { ColorProfileHandling = ColorProfileHandling.Convert }); + + image.DebugSave(provider); + image.CompareToReferenceOutput(provider); + Assert.Null(image.Metadata.IccProfile); + } + [Theory] [WithFile(Issues2454_A, PixelTypes.Rgba32)] [WithFile(Issues2454_B, PixelTypes.Rgba32)] diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index dc3275999..ee0766107 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1194,6 +1194,12 @@ public static class TestImages ]; public static readonly string[] Metadata = [SampleMetadata]; + + public static class Icc + { + public const string PerceptualCmyk = "Tiff/icc-profiles/Perceptual_CMYK.tiff"; + public const string PerceptualCieLab = "Tiff/icc-profiles/Perceptual_CIELAB.tiff"; + } } public static class BigTiff diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CIELAB.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CIELAB.png new file mode 100644 index 000000000..3863e7202 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CIELAB.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8dd7d54f362b33c2d2d4b4b3cb3bbece23c14138073403234db7b53012939101 +size 383 diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CMYK.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CMYK.png new file mode 100644 index 000000000..bc97709c1 --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_CMYK.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:370af73b800622a671c0718b2c137ead8401adf20c39b45f153d2c9bb09b40ed +size 385 diff --git a/tests/Images/Input/Tiff/icc-profiles/Perceptual_CIELAB.tiff b/tests/Images/Input/Tiff/icc-profiles/Perceptual_CIELAB.tiff new file mode 100644 index 000000000..ab2aff820 --- /dev/null +++ b/tests/Images/Input/Tiff/icc-profiles/Perceptual_CIELAB.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9494eea65b2c5b6ef033fb89b4fee2ef97d07773ae4b3988da972e1ba152b890 +size 64418 diff --git a/tests/Images/Input/Tiff/icc-profiles/Perceptual_CMYK.tiff b/tests/Images/Input/Tiff/icc-profiles/Perceptual_CMYK.tiff new file mode 100644 index 000000000..7dd685fe3 --- /dev/null +++ b/tests/Images/Input/Tiff/icc-profiles/Perceptual_CMYK.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfb7fe9e93362fa121d97fa05f61242733d79fa9fa06bb7153e1773e827567dd +size 601124 From 9fbe5a4b082a40238a765a5eca513bf967074ca4 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 29 Jan 2026 21:31:22 +1000 Subject: [PATCH 107/112] Removed labeled trigger --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 637373e80..ff3d5c7b0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,7 +11,7 @@ on: branches: - main - release/* - types: [ labeled, opened, synchronize, reopened ] + types: [ opened, synchronize, reopened ] jobs: # Prime a single LFS cache and expose the exact key for the matrix From 7e22a01469a53ea93c8dc2fff1829650700e55c5 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 30 Jan 2026 13:42:19 +1000 Subject: [PATCH 108/112] Add RGB support. --- src/ImageSharp/Formats/DecoderOptions.cs | 8 +-- src/ImageSharp/Formats/ImageDecoder.cs | 16 ++++++ src/ImageSharp/Formats/ImageDecoderCore.cs | 53 +++++++++++++++++++ .../TiffColorDecoderFactory{TPixel}.cs | 1 - .../Formats/Tiff/TiffDecoderCore.cs | 15 +++--- .../Formats/Tiff/TiffDecoderTests.cs | 4 +- tests/ImageSharp.Tests/TestImages.cs | 2 + ...pplyIccProfile_Rgba32_Perceptual_RGB16.png | 3 ++ ...ApplyIccProfile_Rgba32_Perceptual_RGB8.png | 3 ++ .../Tiff/icc-profiles/Perceptual_RGB16.tiff | 3 ++ .../Tiff/icc-profiles/Perceptual_RGB8.tiff | 3 ++ 11 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB16.png create mode 100644 tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB8.png create mode 100644 tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB16.tiff create mode 100644 tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB8.tiff diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index bb6c2a282..d4d80fc12 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -78,12 +78,12 @@ public sealed class DecoderOptions return false; } - if (profile.IsCanonicalSrgbMatrixTrc()) + if (this.ColorProfileHandling == ColorProfileHandling.Preserve) { return false; } - if (this.ColorProfileHandling == ColorProfileHandling.Preserve) + if (profile.IsCanonicalSrgbMatrixTrc()) { return false; } @@ -99,11 +99,11 @@ public sealed class DecoderOptions return false; } - if (this.ColorProfileHandling == ColorProfileHandling.Compact && profile.IsCanonicalSrgbMatrixTrc()) + if (this.ColorProfileHandling == ColorProfileHandling.Convert) { return true; } - return this.ColorProfileHandling == ColorProfileHandling.Convert; + return this.ColorProfileHandling == ColorProfileHandling.Compact && profile.IsCanonicalSrgbMatrixTrc(); } } diff --git a/src/ImageSharp/Formats/ImageDecoder.cs b/src/ImageSharp/Formats/ImageDecoder.cs index c18fc663b..2a5d44a35 100644 --- a/src/ImageSharp/Formats/ImageDecoder.cs +++ b/src/ImageSharp/Formats/ImageDecoder.cs @@ -328,6 +328,14 @@ public abstract class ImageDecoder : IImageDecoder { image.Metadata.IccProfile = null; } + + foreach (ImageFrame frame in image.Frames) + { + if (options.CanRemoveIccProfile(frame.Metadata.IccProfile)) + { + frame.Metadata.IccProfile = null; + } + } } private static void HandleIccProfile(DecoderOptions options, ImageInfo image) @@ -336,5 +344,13 @@ public abstract class ImageDecoder : IImageDecoder { image.Metadata.IccProfile = null; } + + foreach (ImageFrameMetadata frame in image.FrameMetadataCollection) + { + if (options.CanRemoveIccProfile(frame.IccProfile)) + { + frame.IccProfile = null; + } + } } } diff --git a/src/ImageSharp/Formats/ImageDecoderCore.cs b/src/ImageSharp/Formats/ImageDecoderCore.cs index da50a1abe..f6b1a92a0 100644 --- a/src/ImageSharp/Formats/ImageDecoderCore.cs +++ b/src/ImageSharp/Formats/ImageDecoderCore.cs @@ -5,6 +5,7 @@ using SixLabors.ImageSharp.ColorProfiles; using SixLabors.ImageSharp.ColorProfiles.Icc; using SixLabors.ImageSharp.IO; using SixLabors.ImageSharp.Memory; +using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.PixelFormats; @@ -164,4 +165,56 @@ internal abstract class ImageDecoderCore converter.Convert(image); return true; } + + /// + /// Converts the ICC color profile of the specified image frame to the compact sRGB v4 profile if a source profile is + /// available. + /// + /// + /// This method should only be used by decoders that gurantee that the encoded image data is in a color space + /// compatible with sRGB (e.g. standard RGB, Adobe RGB, ProPhoto RGB). + ///
+ /// If the image does not have a valid ICC profile for color conversion, no changes are made. + /// This operation may affect the color appearance of the image to ensure consistency with the sRGB color + /// space. + ///
+ /// The pixel format. + /// The image frame whose ICC profile will be converted to the compact sRGB v4 profile. + /// + /// if the conversion was performed; otherwise, . + /// + protected bool TryConvertIccProfile(ImageFrame frame) + where TPixel : unmanaged, IPixel + { + if (!this.Options.TryGetIccProfileForColorConversion(frame.Metadata.IccProfile, out IccProfile? profile)) + { + return false; + } + + ColorConversionOptions options = new() + { + SourceIccProfile = profile, + TargetIccProfile = CompactSrgbV4Profile.Profile, + MemoryAllocator = frame.Configuration.MemoryAllocator, + }; + + ColorProfileConverter converter = new(options); + + ImageMetadata metadata = new() + { + IccProfile = frame.Metadata.IccProfile + }; + + IMemoryGroup m = frame.PixelBuffer.MemoryGroup; + + // Safe: ToArray only materializes the Memory segment list, not the underlying pixel buffers, + // and Wrap(Memory[]) creates a Consumed MemoryGroup that does not own the buffers (Dispose just + // invalidates the view). This means no pixel data is cloned and disposing the temporary image will + // not dispose or leak the frame's pixel buffer. + MemoryGroup memorySource = MemoryGroup.Wrap(m.ToArray()); + + using Image image = new(frame.Configuration, memorySource, frame.Width, frame.Height, metadata); + converter.Convert(image); + return true; + } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs index 363c16445..270c7f356 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs @@ -429,7 +429,6 @@ internal static class TiffColorDecoderFactory } } -#pragma warning disable IDE0060 // Remove unused parameter public static TiffBasePlanarColorDecoder CreatePlanar( ImageFrameMetadata metadata, DecoderOptions options, diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 30fa277fc..e3a51aa8d 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -52,11 +52,6 @@ internal class TiffDecoderCore : ImageDecoderCore ///
private ByteOrder byteOrder; - /// - /// Indicating whether is BigTiff format. - /// - private bool isBigTiff; - /// /// Initializes a new instance of the class. /// @@ -167,7 +162,6 @@ internal class TiffDecoderCore : ImageDecoderCore IList directories = reader.Read(); this.byteOrder = reader.ByteOrder; - this.isBigTiff = reader.IsBigTiff; Size? size = null; uint frameCount = 0; @@ -273,6 +267,15 @@ internal class TiffDecoderCore : ImageDecoderCore this.DecodeImageWithStrips(tags, frame, width, height, cancellationToken); } + // Only RGB-compatible color types can be converted here because the TPixel-based ICC profile conversion + // expects RGB-like pixel data; other photometric interpretations (YCbCr, CMYK, Lab, etc.) would require + // dedicated transforms. We do this once at the frame level to avoid duplicating conversion logic + // across all color decoders and to keep their decode paths focused on raw pixel unpacking. + if (this.ColorType is >= TiffColorType.PaletteColor and <= TiffColorType.Rgba32323232Planar) + { + _ = this.TryConvertIccProfile(frame); + } + return frame; } diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index c186d4f01..e432a7251 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -23,7 +23,7 @@ public class TiffDecoderTests : TiffDecoderBaseTester public static readonly string[] MultiframeTestImages = Multiframes; [Theory] - // [WithFile(MultiframeDifferentVariants, PixelTypes.Rgba32)] + [WithFile(MultiframeDifferentVariants, PixelTypes.Rgba32)] [WithFile(Cmyk64BitDeflate, PixelTypes.Rgba32)] public void ThrowsNotSupported(TestImageProvider provider) where TPixel : unmanaged, IPixel => Assert.Throws(() => provider.GetImage(TiffDecoder.Instance)); @@ -355,6 +355,8 @@ public class TiffDecoderTests : TiffDecoderBaseTester [Theory] [WithFile(Icc.PerceptualCmyk, PixelTypes.Rgba32)] [WithFile(Icc.PerceptualCieLab, PixelTypes.Rgba32)] + [WithFile(Icc.PerceptualRgb8, PixelTypes.Rgba32)] + [WithFile(Icc.PerceptualRgb16, PixelTypes.Rgba32)] public void Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index ee0766107..764954cae 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1199,6 +1199,8 @@ public static class TestImages { public const string PerceptualCmyk = "Tiff/icc-profiles/Perceptual_CMYK.tiff"; public const string PerceptualCieLab = "Tiff/icc-profiles/Perceptual_CIELAB.tiff"; + public const string PerceptualRgb8 = "Tiff/icc-profiles/Perceptual_RGB8.tiff"; + public const string PerceptualRgb16 = "Tiff/icc-profiles/Perceptual_RGB16.tiff"; } } diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB16.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB16.png new file mode 100644 index 000000000..3fcea773a --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB16.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de9cfa53a82b169c533999908c7ace43aa35a8b456d5f0378b539669c7857d1c +size 386 diff --git a/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB8.png b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB8.png new file mode 100644 index 000000000..3fcea773a --- /dev/null +++ b/tests/Images/External/ReferenceOutput/TiffDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual_RGB8.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de9cfa53a82b169c533999908c7ace43aa35a8b456d5f0378b539669c7857d1c +size 386 diff --git a/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB16.tiff b/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB16.tiff new file mode 100644 index 000000000..369284819 --- /dev/null +++ b/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB16.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b0e89ac971c23c12c9edff6f9e9dd066fe99f36e28e89972343d50562dd7dbd +size 65260 diff --git a/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB8.tiff b/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB8.tiff new file mode 100644 index 000000000..e2c1ff54c --- /dev/null +++ b/tests/Images/Input/Tiff/icc-profiles/Perceptual_RGB8.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18b0e5ee58c9f53bf5414fc8244e98d65aa0bc6c3397e201399baff0cd378b23 +size 35236 From dcc736c2c8765cf545cad05717d7d7021735e815 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 2 Feb 2026 11:20:09 +1000 Subject: [PATCH 109/112] Capture palette from Tiff when available. --- src/ImageSharp/Color/Color.cs | 15 +++ .../Tiff/Constants/TiffExtraSamples.cs | 25 ----- .../PaletteTiffColor{TPixel}.cs | 92 +++++++++++++++++-- .../TiffColorDecoderFactory{TPixel}.cs | 2 +- .../Formats/Tiff/TiffDecoderCore.cs | 14 +++ .../Formats/Tiff/TiffFrameMetadata.cs | 8 ++ .../PaletteTiffColorTests.cs | 6 +- .../Formats/Tiff/TiffMetadataTests.cs | 22 ++++- 8 files changed, 145 insertions(+), 39 deletions(-) delete mode 100644 src/ImageSharp/Formats/Tiff/Constants/TiffExtraSamples.cs diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index bb78dcbbc..59bce5876 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -96,6 +96,21 @@ public readonly partial struct Color : IEquatable [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color FromScaledVector(Vector4 source) => new(source); + /// + /// Bulk converts a span of generic scaled to a span of . + /// + /// The source vector span. + /// The destination color span. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void FromScaledVector(ReadOnlySpan source, Span destination) + { + Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination)); + for (int i = 0; i < destination.Length; i++) + { + destination[i] = FromScaledVector(source[i]); + } + } + /// /// Bulk converts a span of a specified type to a span of . /// diff --git a/src/ImageSharp/Formats/Tiff/Constants/TiffExtraSamples.cs b/src/ImageSharp/Formats/Tiff/Constants/TiffExtraSamples.cs deleted file mode 100644 index 10323304f..000000000 --- a/src/ImageSharp/Formats/Tiff/Constants/TiffExtraSamples.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Six Labors. -// Licensed under the Six Labors Split License. - -namespace SixLabors.ImageSharp.Formats.Tiff.Constants; - -/// -/// Enumeration representing the possible uses of extra components in TIFF format files. -/// -internal enum TiffExtraSamples -{ - /// - /// Unspecified data. - /// - Unspecified = 0, - - /// - /// Associated alpha data (with pre-multiplied color). - /// - AssociatedAlpha = 1, - - /// - /// Unassociated alpha data. - /// - UnassociatedAlpha = 2 -} diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs index 69113cf93..5e113ddbb 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs @@ -16,8 +16,13 @@ internal class PaletteTiffColor : TiffBaseColorDecoder where TPixel : unmanaged, IPixel { private readonly ushort bitsPerSample0; + private readonly ushort bitsPerSample1; + private readonly TiffExtraSampleType? extraSamplesType; - private readonly TPixel[] palette; + private readonly Vector4[] paletteVectors; + private readonly float alphaScale; + private readonly bool hasAlpha; + private Color[]? paletteColors; private const float InvMax = 1f / 65535f; @@ -26,34 +31,100 @@ internal class PaletteTiffColor : TiffBaseColorDecoder ///
/// The number of bits per sample for each pixel. /// The RGB color lookup table to use for decoding the image. - public PaletteTiffColor(TiffBitsPerSample bitsPerSample, ushort[] colorMap) + /// The type of extra samples. + public PaletteTiffColor(TiffBitsPerSample bitsPerSample, ushort[] colorMap, TiffExtraSampleType? extraSamplesType) { this.bitsPerSample0 = bitsPerSample.Channel0; + this.bitsPerSample1 = bitsPerSample.Channel1; + this.extraSamplesType = extraSamplesType; + int colorCount = 1 << this.bitsPerSample0; - this.palette = GeneratePalette(colorMap, colorCount); + + // TIFF PaletteColor uses ColorMap (tag 320 / 0x0140) which is RGB-only (no alpha). + this.paletteVectors = GeneratePaletteVectors(colorMap, colorCount); + + // ExtraSamples (tag 338 / 0x0152) describes extra per-pixel samples stored in the image data stream. + // For PaletteColor, any alpha is per pixel (stored alongside the index), not per palette entry. + this.hasAlpha = + this.bitsPerSample1 > 0 + && this.extraSamplesType.HasValue + && this.extraSamplesType != TiffExtraSampleType.UnspecifiedData; + + if (this.hasAlpha) + { + ulong alphaMax = (1UL << this.bitsPerSample1) - 1; + this.alphaScale = alphaMax > 0 ? 1f / alphaMax : 1f; + } } + public Color[] PaletteColors => this.paletteColors ??= GenerateColorPalette(this.paletteVectors); + /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) { BitReader bitReader = new(data); + if (this.hasAlpha) + { + Color[] colors = this.paletteColors ??= GenerateColorPalette(this.paletteVectors); + + // NOTE: ExtraSamples may report "AssociatedAlphaData". For PaletteColor, the stored color sample is the + // palette index, not per-pixel RGB components, so the premultiplication concept is not representable + // in the encoded stream. We therefore treat the alpha sample as a per-pixel alpha value applied after + // palette expansion. + for (int y = top; y < top + height; y++) + { + Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); + for (int x = 0; x < pixelRow.Length; x++) + { + int index = bitReader.ReadBits(this.bitsPerSample0); + float alpha = bitReader.ReadBits(this.bitsPerSample1) * this.alphaScale; + + // Defensive guard against malformed streams. + if ((uint)index >= (uint)this.paletteVectors.Length) + { + index = 0; + } + + Vector4 color = this.paletteVectors[index]; + color.W = alpha; + + pixelRow[x] = TPixel.FromScaledVector4(color); + + // Best-effort palette update for downstream conversions. + // This is intentionally "last writer wins" with no per-pixel branch. + colors[index] = Color.FromScaledVector(color); + } + + bitReader.NextRow(); + } + + return; + } + for (int y = top; y < top + height; y++) { Span pixelRow = pixels.DangerousGetRowSpan(y).Slice(left, width); for (int x = 0; x < pixelRow.Length; x++) { int index = bitReader.ReadBits(this.bitsPerSample0); - pixelRow[x] = this.palette[index]; + + // Defensive guard against malformed streams. + if ((uint)index >= (uint)this.paletteVectors.Length) + { + index = 0; + } + + pixelRow[x] = TPixel.FromScaledVector4(this.paletteVectors[index]); } bitReader.NextRow(); } } - private static TPixel[] GeneratePalette(ushort[] colorMap, int colorCount) + private static Vector4[] GeneratePaletteVectors(ushort[] colorMap, int colorCount) { - TPixel[] palette = new TPixel[colorCount]; + Vector4[] palette = new Vector4[colorCount]; const int rOffset = 0; int gOffset = colorCount; @@ -64,9 +135,16 @@ internal class PaletteTiffColor : TiffBaseColorDecoder float r = colorMap[rOffset + i] * InvMax; float g = colorMap[gOffset + i] * InvMax; float b = colorMap[bOffset + i] * InvMax; - palette[i] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); + palette[i] = new Vector4(r, g, b, 1f); } return palette; } + + private static Color[] GenerateColorPalette(Vector4[] palette) + { + Color[] colors = new Color[palette.Length]; + Color.FromScaledVector(palette, colors); + return colors; + } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs index 270c7f356..dd36e912c 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/TiffColorDecoderFactory{TPixel}.cs @@ -387,7 +387,7 @@ internal static class TiffColorDecoderFactory case TiffColorType.PaletteColor: DebugGuard.NotNull(colorMap, "colorMap"); - return new PaletteTiffColor(bitsPerSample, colorMap); + return new PaletteTiffColor(bitsPerSample, colorMap, extraSampleType); case TiffColorType.YCbCr: DebugGuard.IsTrue( diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index e3a51aa8d..5705e2a54 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -620,6 +620,13 @@ internal class TiffDecoderCore : ImageDecoderCore colorDecoder.Decode(stripBufferSpan, pixels, 0, top, width, stripHeight); } + + // If the color decoder is the palette decoder we need to capture its palette. + if (colorDecoder is PaletteTiffColor paletteDecoder) + { + TiffFrameMetadata tiffFrameMetadata = frame.Metadata.GetTiffMetadata(); + tiffFrameMetadata.LocalColorTable = paletteDecoder.PaletteColors; + } } /// @@ -804,6 +811,13 @@ internal class TiffDecoderCore : ImageDecoderCore tileIndex++; } } + + // If the color decoder is the palette decoder we need to capture its palette. + if (colorDecoder is PaletteTiffColor paletteDecoder) + { + TiffFrameMetadata tiffFrameMetadata = frame.Metadata.GetTiffMetadata(); + tiffFrameMetadata.LocalColorTable = paletteDecoder.PaletteColors; + } } private TiffBaseColorDecoder CreateChunkyColorDecoder(ImageFrameMetadata metadata) diff --git a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs index d9dfafbcc..09a9e8cf9 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs @@ -33,6 +33,7 @@ public class TiffFrameMetadata : IFormatFrameMetadata this.InkSet = other.InkSet; this.EncodingWidth = other.EncodingWidth; this.EncodingHeight = other.EncodingHeight; + this.LocalColorTable = other.LocalColorTable; } /// @@ -75,6 +76,11 @@ public class TiffFrameMetadata : IFormatFrameMetadata /// public int EncodingHeight { get; set; } + /// + /// Gets or sets the local color table, if any. + /// + public ReadOnlyMemory? LocalColorTable { get; set; } + /// public static TiffFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectingFrameMetadata metadata) { @@ -100,6 +106,8 @@ public class TiffFrameMetadata : IFormatFrameMetadata public void AfterFrameApply(ImageFrame source, ImageFrame destination, Matrix4x4 matrix) where TPixel : unmanaged, IPixel { + this.LocalColorTable = null; + float ratioX = destination.Width / (float)source.Width; float ratioY = destination.Height / (float)source.Height; this.EncodingWidth = Scale(this.EncodingWidth, destination.Width, ratioX); diff --git a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs index a645f2edd..dbfa00950 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/PhotometricInterpretation/PaletteTiffColorTests.cs @@ -89,7 +89,11 @@ public class PaletteTiffColorTests : PhotometricInterpretationTestBase public void Decode_WritesPixelData(byte[] inputData, ushort bitsPerSample, ushort[] colorMap, int left, int top, int width, int height, Rgba32[][] expectedResult) => AssertDecode(expectedResult, pixels => { - new PaletteTiffColor(new TiffBitsPerSample(bitsPerSample, 0, 0), colorMap).Decode(inputData, pixels, left, top, width, height); + new PaletteTiffColor( + new TiffBitsPerSample(bitsPerSample, 0, 0), + colorMap, + TiffExtraSampleType.UnspecifiedData) + .Decode(inputData, pixels, left, top, width, height); }); private static uint[][] GeneratePalette(int count) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs index f92d8ed59..8d75cd9bc 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffMetadataTests.cs @@ -61,16 +61,15 @@ public class TiffMetadataTests clone.PhotometricInterpretation = TiffPhotometricInterpretation.CieLab; clone.Predictor = TiffPredictor.Horizontal; - Assert.False(meta.BitsPerPixel == clone.BitsPerPixel); - Assert.False(meta.Compression == clone.Compression); - Assert.False(meta.PhotometricInterpretation == clone.PhotometricInterpretation); - Assert.False(meta.Predictor == clone.Predictor); + Assert.NotEqual(meta.BitsPerPixel, clone.BitsPerPixel); + Assert.NotEqual(meta.Compression, clone.Compression); + Assert.NotEqual(meta.PhotometricInterpretation, clone.PhotometricInterpretation); + Assert.NotEqual(meta.Predictor, clone.Predictor); } private static void VerifyExpectedTiffFrameMetaDataIsPresent(TiffFrameMetadata frameMetaData) { Assert.NotNull(frameMetaData); - Assert.NotNull(frameMetaData.BitsPerPixel); Assert.Equal(TiffBitsPerPixel.Bit4, frameMetaData.BitsPerPixel); Assert.Equal(TiffCompression.Lzw, frameMetaData.Compression); Assert.Equal(TiffPhotometricInterpretation.PaletteColor, frameMetaData.PhotometricInterpretation); @@ -409,4 +408,17 @@ public class TiffMetadataTests // Adding the IPTC and ICC profiles dynamically increments the number of values in the original EXIF profile by 2 Assert.Equal(exifProfileInput.Values.Count + 2, encodedImageExifProfile.Values.Count); } + + [Theory] + [WithFile(PaletteDeflateMultistrip, PixelTypes.Rgba32)] + [WithFile(PaletteUncompressed, PixelTypes.Rgba32)] + public void TiffDecoder_CanAssign_ColorPalette(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(TiffDecoder.Instance); + ImageFrame frame = image.Frames.RootFrame; + TiffFrameMetadata tiffMeta = frame.Metadata.GetTiffMetadata(); + Assert.Equal(TiffPhotometricInterpretation.PaletteColor, tiffMeta.PhotometricInterpretation); + Assert.NotNull(tiffMeta.LocalColorTable); + } } From a4c1a155e5f3455df0c5e7b623b29f609a311a96 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 2 Feb 2026 12:42:51 +1000 Subject: [PATCH 110/112] Fix reviewed issues --- src/ImageSharp/Color/Color.cs | 6 +-- .../PaletteTiffColor{TPixel}.cs | 46 +++++++++++++++---- .../Formats/Tiff/TiffDecoderOptionsParser.cs | 2 +- .../Formats/Tiff/TiffFrameMetadata.cs | 6 ++- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 59bce5876..dd248d488 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -105,7 +105,7 @@ public readonly partial struct Color : IEquatable public static void FromScaledVector(ReadOnlySpan source, Span destination) { Guard.DestinationShouldNotBeTooShort(source, destination, nameof(destination)); - for (int i = 0; i < destination.Length; i++) + for (int i = 0; i < source.Length; i++) { destination[i] = FromScaledVector(source[i]); } @@ -127,14 +127,14 @@ public readonly partial struct Color : IEquatable PixelTypeInfo info = TPixel.GetPixelTypeInfo(); if (info.ComponentInfo.HasValue && info.ComponentInfo.Value.GetMaximumComponentPrecision() <= (int)PixelComponentBitDepth.Bit32) { - for (int i = 0; i < destination.Length; i++) + for (int i = 0; i < source.Length; i++) { destination[i] = FromScaledVector(source[i].ToScaledVector4()); } } else { - for (int i = 0; i < destination.Length; i++) + for (int i = 0; i < source.Length; i++) { destination[i] = new Color(source[i]); } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs index 5e113ddbb..d1b519bdd 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/PaletteTiffColor{TPixel}.cs @@ -19,7 +19,9 @@ internal class PaletteTiffColor : TiffBaseColorDecoder private readonly ushort bitsPerSample1; private readonly TiffExtraSampleType? extraSamplesType; - private readonly Vector4[] paletteVectors; + private readonly Vector4[] vectorPallete; + private readonly TPixel[] pixelPalette; + private readonly float alphaScale; private readonly bool hasAlpha; private Color[]? paletteColors; @@ -41,7 +43,7 @@ internal class PaletteTiffColor : TiffBaseColorDecoder int colorCount = 1 << this.bitsPerSample0; // TIFF PaletteColor uses ColorMap (tag 320 / 0x0140) which is RGB-only (no alpha). - this.paletteVectors = GeneratePaletteVectors(colorMap, colorCount); + this.vectorPallete = GenerateVectorPalette(colorMap, colorCount); // ExtraSamples (tag 338 / 0x0152) describes extra per-pixel samples stored in the image data stream. // For PaletteColor, any alpha is per pixel (stored alongside the index), not per palette entry. @@ -54,10 +56,16 @@ internal class PaletteTiffColor : TiffBaseColorDecoder { ulong alphaMax = (1UL << this.bitsPerSample1) - 1; this.alphaScale = alphaMax > 0 ? 1f / alphaMax : 1f; + this.pixelPalette = []; + } + else + { + // Pre-generate pixel palette for non-alpha case for performance. + this.pixelPalette = GeneratePixelPalette(colorMap, colorCount); } } - public Color[] PaletteColors => this.paletteColors ??= GenerateColorPalette(this.paletteVectors); + public Color[] PaletteColors => this.paletteColors ??= GenerateColorPalette(this.vectorPallete); /// public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height) @@ -66,7 +74,7 @@ internal class PaletteTiffColor : TiffBaseColorDecoder if (this.hasAlpha) { - Color[] colors = this.paletteColors ??= GenerateColorPalette(this.paletteVectors); + Color[] colors = this.paletteColors ??= GenerateColorPalette(this.vectorPallete); // NOTE: ExtraSamples may report "AssociatedAlphaData". For PaletteColor, the stored color sample is the // palette index, not per-pixel RGB components, so the premultiplication concept is not representable @@ -81,18 +89,19 @@ internal class PaletteTiffColor : TiffBaseColorDecoder float alpha = bitReader.ReadBits(this.bitsPerSample1) * this.alphaScale; // Defensive guard against malformed streams. - if ((uint)index >= (uint)this.paletteVectors.Length) + if ((uint)index >= (uint)this.vectorPallete.Length) { index = 0; } - Vector4 color = this.paletteVectors[index]; + Vector4 color = this.vectorPallete[index]; color.W = alpha; pixelRow[x] = TPixel.FromScaledVector4(color); // Best-effort palette update for downstream conversions. // This is intentionally "last writer wins" with no per-pixel branch. + // Performance is not an issue here since the constructor performs no actual transformations. colors[index] = Color.FromScaledVector(color); } @@ -110,19 +119,19 @@ internal class PaletteTiffColor : TiffBaseColorDecoder int index = bitReader.ReadBits(this.bitsPerSample0); // Defensive guard against malformed streams. - if ((uint)index >= (uint)this.paletteVectors.Length) + if ((uint)index >= (uint)this.pixelPalette.Length) { index = 0; } - pixelRow[x] = TPixel.FromScaledVector4(this.paletteVectors[index]); + pixelRow[x] = this.pixelPalette[index]; } bitReader.NextRow(); } } - private static Vector4[] GeneratePaletteVectors(ushort[] colorMap, int colorCount) + private static Vector4[] GenerateVectorPalette(ushort[] colorMap, int colorCount) { Vector4[] palette = new Vector4[colorCount]; @@ -141,6 +150,25 @@ internal class PaletteTiffColor : TiffBaseColorDecoder return palette; } + private static TPixel[] GeneratePixelPalette(ushort[] colorMap, int colorCount) + { + TPixel[] palette = new TPixel[colorCount]; + + const int rOffset = 0; + int gOffset = colorCount; + int bOffset = colorCount * 2; + + for (int i = 0; i < palette.Length; i++) + { + float r = colorMap[rOffset + i] * InvMax; + float g = colorMap[gOffset + i] * InvMax; + float b = colorMap[bOffset + i] * InvMax; + palette[i] = TPixel.FromScaledVector4(new Vector4(r, g, b, 1f)); + } + + return palette; + } + private static Color[] GenerateColorPalette(Vector4[] palette) { Color[] colors = new Color[palette.Length]; diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs index 9445f468c..983b08c71 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs @@ -407,7 +407,7 @@ internal static class TiffDecoderOptionsParser if (exifProfile.TryGetValue(ExifTag.ColorMap, out IExifValue value)) { options.ColorMap = value.Value; - if (options.BitsPerSample.Channels != 1) + if (options.BitsPerSample.Channels is not 1 and not 2) { TiffThrowHelper.ThrowNotSupported("The number of samples in the TIFF BitsPerSample entry is not supported."); } diff --git a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs index 09a9e8cf9..d4815ebdd 100644 --- a/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs +++ b/src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs @@ -33,7 +33,11 @@ public class TiffFrameMetadata : IFormatFrameMetadata this.InkSet = other.InkSet; this.EncodingWidth = other.EncodingWidth; this.EncodingHeight = other.EncodingHeight; - this.LocalColorTable = other.LocalColorTable; + + if (other.LocalColorTable?.Length > 0) + { + this.LocalColorTable = other.LocalColorTable.Value.ToArray(); + } } /// From c43b6365d057c6e3302778ebd9ee9c21f49452b9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 2 Feb 2026 12:46:03 +1000 Subject: [PATCH 111/112] Ensure palette is always captured. --- .../Formats/Tiff/TiffDecoderCore.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index 5705e2a54..1822cb8d1 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -584,6 +584,15 @@ internal class TiffDecoderCore : ImageDecoderCore } } + { + // If the color decoder is the palette decoder we need to capture its palette. + if (colorDecoder is PaletteTiffColor paletteDecoder) + { + TiffFrameMetadata tiffFrameMetadata = frame.Metadata.GetTiffMetadata(); + tiffFrameMetadata.LocalColorTable = paletteDecoder.PaletteColors; + } + } + return; } @@ -621,11 +630,13 @@ internal class TiffDecoderCore : ImageDecoderCore colorDecoder.Decode(stripBufferSpan, pixels, 0, top, width, stripHeight); } - // If the color decoder is the palette decoder we need to capture its palette. - if (colorDecoder is PaletteTiffColor paletteDecoder) { - TiffFrameMetadata tiffFrameMetadata = frame.Metadata.GetTiffMetadata(); - tiffFrameMetadata.LocalColorTable = paletteDecoder.PaletteColors; + // If the color decoder is the palette decoder we need to capture its palette. + if (colorDecoder is PaletteTiffColor paletteDecoder) + { + TiffFrameMetadata tiffFrameMetadata = frame.Metadata.GetTiffMetadata(); + tiffFrameMetadata.LocalColorTable = paletteDecoder.PaletteColors; + } } } From b83ac7cca6d10bec8799da501b4671eb1d28d103 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 3 Feb 2026 16:13:18 +1000 Subject: [PATCH 112/112] Add Codecov token to workflow for coverage reporting --- .github/workflows/code-coverage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 985b3aefb..bda6b3961 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -85,3 +85,4 @@ jobs: if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors') with: flags: unittests + token: ${{ secrets.CODECOV_TOKEN }}