From 5de26525fee985b870375219bd0dcc0352afb73f Mon Sep 17 00:00:00 2001 From: Stefan Nikolei Date: Wed, 25 Jun 2025 18:21:51 +0200 Subject: [PATCH 1/2] 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 74a363eef1..d6bd9e592d 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 b805d63f97..bd17d9a76c 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 6f0e3744f3..583c71379f 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 8c473688f3..a6face960e 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 c20c0d8750..778981fd96 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 ab488591a7..6dc17b9a9c 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 dd8217541a..6f21850818 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 b623149470..fbc2083b39 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 e4dc1945a8..17cb1925df 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 62edfdfdfa..1ac79a9e26 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 796b5506c7..d2121adce2 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 d4050810df..08daf38990 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 1c1127c3be..dc78f28bf1 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 c11679feb1..b83c01064a 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 f5666f7799..502b919177 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 8122d8daa6..eb2d0b2eb3 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 7dca1cf5ea..644cf2df57 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 7b0e096e2a..630017082d 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 7a627b7b84..50b7de68e4 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 fe0088c3ce..4a3a444978 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 8310ca64c8..5da2fdd2e7 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 43f2b0fb25..17d13e86df 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 9643ccef03..3c64128ee1 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 ac7d837985..c4663ac091 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 692e088d1c..cffc96fcdf 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 4e04f9cf17..8e2227cba5 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 114fc12b23..18c0f2e0d3 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 d41749be66..744cba35fd 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 eeb4afebfe..86c6b0c4a6 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 3c2ad60846..f880834119 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 6d3cab1514..c7e1455911 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 027d4f7ee9..f15bf263f2 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 19dc08fc5b..0e3b274914 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 6de3ae7497..875149b1bb 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 ed1ed52abf..ab83e1641c 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 a7c96edb7c..fa68144fbc 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 e4ebe14731..85739a3e20 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 7fe71588c4..9085c09293 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 7ba15a6d61..5cd8812c95 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 818c843ea9..f489899c68 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 a69bcfd006..64c97f7d8a 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 89940d406e..2d6129c4c0 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 d62a64c238..c164045df5 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 6c769a9d17..c6853b40ca 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 5e15e46e97..d4ad22060d 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 d08bf248bb..6dd99fcb02 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 725533ea5f..df6f7bdf83 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 58b759555a..219e785590 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 88281452e0..9e89d24ff4 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 074712d302..084ec388d6 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 5e73e2dd00..6bc0560f02 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 cc44762919..1938ad6302 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 5605d92559..7330cbdf00 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 85c23d1743..306924e62c 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 7c5662e1f2..7735810b3f 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 c4d5a6b95d..ae29223deb 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 0c456eb88e..1dbc666f6f 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 ae4483f2e5..4b3dd7fe73 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 51a739d35e..26cf60034d 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 53c26a57ea..80b0963440 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 fdef1b2bfc..ce54c133b0 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 303272837b..1eca07ec79 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 dd0bc28785..317295144f 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 186f88bb71..4969c3ef7a 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 5d137a615c..0731c7c004 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 75bc5289c9..f8bf19d576 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 3e4f77f9ef..8ba862560b 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 2db2aae195..88787afd4f 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 27511f7beb..072b04fa0d 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 48253bee72..7bb711f3f8 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 324bd4783a..9c8f45f784 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 740b410feb..aee064ccc6 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 3b7e20eb4e..22b25a2bef 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 85fad3f826..a4a71c6731 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 6cf6250cb1..b780b14fb1 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 8126a37fe0..2856abe5c1 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 58b437af0f..ede147dbe9 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 60de0a2042..903a6b0762 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 d55a254530..13300ee804 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 53f9a02781..c2b640a1de 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 f5c42c734b..00db13d4b2 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 829cc64ff6..8dfa987488 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 1a74fe5b2f..3589a25a2d 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 76fd260dd5..fdaa70e031 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 f1dcb357c6..0d666d8c8d 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 0fa7e01e8e..54c8172b86 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 13be77a29b..a645f2edd3 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 2ca9df3d03..5df7c4d62f 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 80a04a7d1e..6935d504ed 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 fa193c1846..7a09bfae7f 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 e31487cd23..20b3ec2bb2 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 6073888fe0..66f3201436 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 09aa94c755..982f0a5d5c 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 73e7044f5b..f4189933fa 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 b4279b0454..23ef8e7b12 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 59691204be..fc7da8cf67 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 dab0716927..c0b14cdd7e 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 7777c61084..8d8bcb57c3 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 4982929c2c..62c67c2e0f 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 1491cd13cf..ca1859e543 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 6a46b26f2d..e86642fea9 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 390170cfef..89256507ed 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 71c9e07fc3..d7f2c7d28e 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 f70623f515..cd1213c230 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 6a196fd16f..490fa3b0b0 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 5762264d21..47ae0daf72 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 a031578221..a064b64723 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 b8dd4be8df..c4b75b5cfa 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 f518b22725..fd9760f48f 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 f62e99a8b8..6e7e9fea73 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 6d35517ac4..cee37ca56e 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 6c499f40c7..c098ace09a 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 cb006ba291..d7d6741baf 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 c8f46d3aa4..0a9b888ed4 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 c64fcab588..2dbe5d343d 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 90cb3a8665..ccf90fe40f 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 d90ccee41d..eb1d3031a4 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 1b3d1bd9ac..43785da6e7 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 703a64333b..f55500f99f 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 7fb93bba54..f00087e1c0 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 36edc10e5d..6f0f06535f 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 5c5fd20e49..c39648d014 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 64dd7a8669..62682e837c 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 9c63d0f7cc..c9d3f69143 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 455aa48ae0..1eec353689 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 04344e1300..be3fc1e500 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 3cc9653347..25acd3aa67 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 ed3be0f677..ab379ad7ca 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 f3d8fd63a8..b7e8597859 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 cf2b7d4dad..3005867ca8 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 d58a5280d1..f2a4b079b5 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 b8b4615b94..2ba757c117 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 984e3bc751..ee21920d4d 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 3e986f0cba..ffa9be6ea7 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 8949049fbc..0b6f5702f3 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 1a4610bf68..00ad71b4ca 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 d6990782b9..0357dda046 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 cc3ea03220..523fd2bdd1 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 30dec4685f..84401e8468 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 e910038efb..e3bc3bba6e 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 02fc23735b..f38bc68d10 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 f91c32df8a..5f14174616 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 6cd99367a9..d0ba39e4c7 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 cedd20f2d7..3799641810 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 6f8244f1c7..be0d077b6a 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 2bd47e4497..c0404d5f12 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 1a72d39b19..6a900a0154 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 2e3679e3af..5219dfdacd 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 0674274246..34625aa1c5 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 81cfea46fd..5f9d70fb23 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 7441bede83..6e097a0bea 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 a83dc3575d..979b0044dc 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 d575489be8..a2c2032672 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 92b74cde17..28bfcfaa8d 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 021f024766..4ea77b41a0 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 592ebb4ebe..7191f3ba74 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 d82d5cd910..349db60f20 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 e9f57a7abe..ec637a7b6b 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 cf472699a7..3392d97ab9 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 cd27eaf0ba..59c092b409 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 a4149f7356..cc4f6f7f3c 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 4b016d5eae..2630acea80 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 1d35a6200a..c6bb38dd83 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 c8e11e69c8..d7352de580 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 c9f13ca2f9..47cf7e6a5d 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 8eed0a1c13..5eb5be0d9a 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 994aa670c7..4a34529dd3 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 fbdfb9d619..2e2416952d 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 34337600eb..82b247d9df 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 4329a6be35..a145e7365e 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 2/2] update shared infra --- shared-infrastructure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-infrastructure b/shared-infrastructure index 132a8232bd..d0f141bad2 160000 --- a/shared-infrastructure +++ b/shared-infrastructure @@ -1 +1 @@ -Subproject commit 132a8232bd61471e9e9df727fb7a112800030327 +Subproject commit d0f141bad2baf7e256aa38ef18129c31cfb857a5