diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs
index 7ea0f9215..2030ad71b 100644
--- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs
+++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/ProfileResolver.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using System;
+using System.Text;
namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
{
@@ -13,22 +14,22 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
///
/// Describes the EXIF specific markers
///
- public static readonly byte[] JFifMarker = ToAsciiBytes("JFIF\0");
+ public static readonly byte[] JFifMarker = Encoding.UTF8.GetBytes("JFIF\0");
///
/// Describes the EXIF specific markers
///
- public static readonly byte[] IccMarker = ToAsciiBytes("ICC_PROFILE\0");
+ public static readonly byte[] IccMarker = Encoding.UTF8.GetBytes("ICC_PROFILE\0");
///
/// Describes the ICC specific markers
///
- public static readonly byte[] ExifMarker = ToAsciiBytes("Exif\0\0");
+ public static readonly byte[] ExifMarker = Encoding.UTF8.GetBytes("Exif\0\0");
///
/// Describes Adobe specific markers
///
- public static readonly byte[] AdobeMarker = ToAsciiBytes("Adobe");
+ public static readonly byte[] AdobeMarker = Encoding.UTF8.GetBytes("Adobe");
///
/// Returns a value indicating whether the passed bytes are a match to the profile identifer
@@ -41,19 +42,5 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder
return bytesToCheck.Length >= profileIdentifier.Length
&& bytesToCheck.Slice(0, profileIdentifier.Length).SequenceEqual(profileIdentifier);
}
-
- // No Encoding.ASCII nor Linq.Select on NetStandard 1.1
- private static byte[] ToAsciiBytes(string str)
- {
- int length = str.Length;
- byte[] bytes = new byte[length];
- char[] chars = str.ToCharArray();
- for (int i = 0; i < length; i++)
- {
- bytes[i] = (byte)chars[i];
- }
-
- return bytes;
- }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/IJpegDecoderOptions.cs b/src/ImageSharp/Formats/Jpeg/IJpegDecoderOptions.cs
index 880a7f7a3..ef7b377d2 100644
--- a/src/ImageSharp/Formats/Jpeg/IJpegDecoderOptions.cs
+++ b/src/ImageSharp/Formats/Jpeg/IJpegDecoderOptions.cs
@@ -1,11 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SixLabors.ImageSharp.PixelFormats;
-
namespace SixLabors.ImageSharp.Formats.Jpeg
{
///
@@ -18,4 +13,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
///
bool IgnoreMetadata { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs b/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs
index a84652cef..4076b7da8 100644
--- a/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs
+++ b/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs
@@ -1,11 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SixLabors.ImageSharp.PixelFormats;
-
namespace SixLabors.ImageSharp.Formats.Jpeg
{
///
@@ -31,4 +26,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The subsample ratio of the jpg image.
JpegSubsample? Subsample { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs b/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs
index d3f95e40c..1d3be063d 100644
--- a/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs
+++ b/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs
@@ -1,10 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using System.IO;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
diff --git a/src/ImageSharp/Formats/Jpeg/JpegConfigurationModule.cs b/src/ImageSharp/Formats/Jpeg/JpegConfigurationModule.cs
index 23cef5927..c3bf801ac 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegConfigurationModule.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegConfigurationModule.cs
@@ -17,4 +17,4 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
config.ImageFormatsManager.AddImageFormatDetector(new JpegImageFormatDetector());
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs b/src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs
index d888986f3..e25957efc 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegImageFormatDetector.cs
@@ -16,12 +16,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
///
public IImageFormat DetectFormat(ReadOnlySpan header)
{
- if (this.IsSupportedFileFormat(header))
- {
- return ImageFormats.Jpeg;
- }
-
- return null;
+ return this.IsSupportedFileFormat(header) ? ImageFormats.Jpeg : null;
}
private bool IsSupportedFileFormat(ReadOnlySpan header)
@@ -35,36 +30,24 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
///
/// The bytes representing the file header.
/// The
- private bool IsJfif(ReadOnlySpan header)
- {
- // TODO: This should be in constants
- bool isJfif =
- header[6] == 0x4A && // J
- header[7] == 0x46 && // F
- header[8] == 0x49 && // I
- header[9] == 0x46 && // F
- header[10] == 0x00;
-
- return isJfif;
- }
+ private bool IsJfif(ReadOnlySpan header) =>
+ header[6] == 0x4A && // J
+ header[7] == 0x46 && // F
+ header[8] == 0x49 && // I
+ header[9] == 0x46 && // F
+ header[10] == 0x00;
///
/// Returns a value indicating whether the given bytes identify EXIF data.
///
/// The bytes representing the file header.
/// The
- private bool IsExif(ReadOnlySpan header)
- {
- // TODO: This should be in constants
- bool isExif =
- header[6] == 0x45 && // E
- header[7] == 0x78 && // X
- header[8] == 0x69 && // I
- header[9] == 0x66 && // F
- header[10] == 0x00;
-
- return isExif;
- }
+ private bool IsExif(ReadOnlySpan header) =>
+ header[6] == 0x45 && // E
+ header[7] == 0x78 && // X
+ header[8] == 0x69 && // I
+ header[9] == 0x66 && // F
+ header[10] == 0x00;
///
/// Returns a value indicating whether the given bytes identify Jpeg data.
@@ -72,14 +55,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
///
/// The bytes representing the file header.
/// The
- private bool IsJpeg(ReadOnlySpan header)
- {
- // TODO: This should be in constants
- bool isJpg =
- header[0] == 0xFF && // 255
- header[1] == 0xD8; // 216
-
- return isJpg;
- }
+ private bool IsJpeg(ReadOnlySpan header) =>
+ header[0] == 0xFF && // 255
+ header[1] == 0xD8; // 216
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
index e6ee4f16c..7f50a8529 100644
--- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsFrameComponent.cs
@@ -17,7 +17,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
internal class PdfJsFrameComponent : IDisposable, IJpegComponent
{
private readonly MemoryManager memoryManager;
-#pragma warning disable SA1401 // Fields should be private
public PdfJsFrameComponent(MemoryManager memoryManager, PdfJsFrame frame, byte id, int horizontalFactor, int verticalFactor, byte quantizationTableIndex, int index)
{
diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
index 62ae34335..875a86263 100644
--- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTable.cs
@@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
/// The to use for buffer allocations.
/// The code lengths
/// The huffman values
- public PdfJsHuffmanTable(MemoryManager memoryManager, byte[] lengths, byte[] values)
+ public PdfJsHuffmanTable(MemoryManager memoryManager, ReadOnlySpan lengths, ReadOnlySpan values)
{
const int length = 257;
using (IBuffer huffsize = memoryManager.Allocate(length))
@@ -57,10 +57,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
fixed (byte* huffValRef = this.HuffVal.Data)
{
- for (int i = 0; i < values.Length; i++)
- {
- huffValRef[i] = values[i];
- }
+ var huffValSpan = new Span(huffValRef, 256);
+
+ values.CopyTo(huffValSpan);
}
}
@@ -69,7 +68,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
///
/// The code lengths
/// The huffman size span ref
- private static void GenerateSizeTable(byte[] lengths, ref short huffsizeRef)
+ private static void GenerateSizeTable(ReadOnlySpan lengths, ref short huffsizeRef)
{
short index = 0;
for (short l = 1; l <= 16; l++)
@@ -115,7 +114,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
///
/// The code lengths
/// The huffman code span ref
- private void GenerateDecoderTables(byte[] lengths, ref short huffcodeRef)
+ private void GenerateDecoderTables(ReadOnlySpan lengths, ref short huffcodeRef)
{
fixed (short* valOffsetRef = this.ValOffset.Data)
fixed (long* maxcodeRef = this.MaxCode.Data)
@@ -147,7 +146,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
/// The code lengths
/// The huffman value array
/// The huffman code span ref
- private void GenerateLookaheadTables(byte[] lengths, byte[] huffval, ref short huffcodeRef)
+ private void GenerateLookaheadTables(ReadOnlySpan lengths, ReadOnlySpan huffval, ref short huffcodeRef)
{
// TODO: This generation code matches the libJpeg code but the lookahead table is not actually used yet.
// To use it we need to implement fast lookup path in PdfJsScanDecoder.DecodeHuffman
@@ -155,10 +154,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
// will be 8 or fewer bits long and can be handled without looping.
fixed (short* lookaheadRef = this.Lookahead.Data)
{
- for (int i = 0; i < 256; i++)
- {
- lookaheadRef[i] = 2034; // 9 << 8;
- }
+ var lookaheadSpan = new Span(lookaheadRef, 256);
+
+ lookaheadSpan.Fill(2034); // 9 << 8;
int p = 0;
for (int l = 1; l <= 8; l++)
diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
index 0fd6d76b3..3a559bb86 100644
--- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/Components/PdfJsHuffmanTables.cs
@@ -21,10 +21,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components
public ref PdfJsHuffmanTable this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return ref this.tables[index];
- }
+ get => ref this.tables[index];
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
index 336c61699..244d97fba 100644
--- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs
@@ -7,7 +7,6 @@ using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components;
@@ -367,14 +366,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
if (this.ComponentCount == 4)
{
- if (this.adobe.ColorTransform == PdfJsJpegConstants.Markers.Adobe.ColorTransformYcck)
- {
- return JpegColorSpace.Ycck;
- }
- else
- {
- return JpegColorSpace.Cmyk;
- }
+ return this.adobe.ColorTransform == PdfJsJpegConstants.Markers.Adobe.ColorTransformYcck
+ ? JpegColorSpace.Ycck
+ : JpegColorSpace.Cmyk;
}
throw new ImageFormatException($"Unsupported color mode. Max components 4; found {this.ComponentCount}");
@@ -700,8 +694,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
this.BuildHuffmanTable(
huffmanTableSpec >> 4 == 0 ? this.dcHuffmanTables : this.acHuffmanTables,
huffmanTableSpec & 15,
- codeLengths.Array,
- huffmanValues.Array);
+ codeLengths.Span,
+ huffmanValues.Span);
}
}
}
@@ -785,7 +779,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
/// The codelengths
/// The values
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void BuildHuffmanTable(PdfJsHuffmanTables tables, int index, byte[] codeLengths, byte[] values)
+ private void BuildHuffmanTable(PdfJsHuffmanTables tables, int index, ReadOnlySpan codeLengths, ReadOnlySpan values)
{
tables[index] = new PdfJsHuffmanTable(this.configuration.MemoryManager, codeLengths, values);
}
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs
index b98a6fe8e..2ee9498e0 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/AdobeMarkerTests.cs
@@ -1,13 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class AdobeMarkerTests
{
// Taken from actual test image
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs
index e50d84852..4b5cf526b 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.CopyToBufferArea.cs
@@ -1,23 +1,19 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-
-
// Uncomment this to turn unit tests into benchmarks:
//#define BENCHMARKING
-// ReSharper disable InconsistentNaming
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Memory;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using SixLabors.Primitives;
+
+using Xunit;
+using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Memory;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using SixLabors.Primitives;
-
- using Xunit;
- using Xunit.Abstractions;
-
public partial class Block8x8FTests : JpegFixture
{
public class CopyToBufferArea : JpegFixture
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
index 8c12b0050..ac8bed13b 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
@@ -1,24 +1,20 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-
-
// Uncomment this to turn unit tests into benchmarks:
//#define BENCHMARKING
-// ReSharper disable InconsistentNaming
+using System;
+using System.Diagnostics;
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System;
- using System.Diagnostics;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
-
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public partial class Block8x8FTests : JpegFixture
{
#if BENCHMARKING
@@ -65,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
});
Assert.Equal(sum, 64f * 63f * 0.5f);
}
-
+
[Fact]
public void Indexer_ReferenceBenchmarkWithArray()
{
@@ -207,7 +203,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
sw.Stop();
this.Output.WriteLine($"TranposeInto_PinningImpl_Benchmark finished in {sw.ElapsedMilliseconds} ms");
}
-
+
private static float[] Create8x8ColorCropTestData()
{
float[] result = new float[64];
@@ -233,7 +229,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Block8x8F dest = block;
dest.NormalizeColorsInplace();
-
+
float[] array = new float[64];
dest.CopyTo(array);
this.Output.WriteLine("Result:");
@@ -268,7 +264,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
this.CompareBlocks(expected, actual, 0);
}
-
[Theory]
[InlineData(1)]
[InlineData(2)]
@@ -297,7 +292,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(expected, actual);
}
}
-
+
[Fact]
public void RoundInto()
{
@@ -312,7 +307,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
for (int i = 0; i < Block8x8.Size; i++)
{
float expectedFloat = data[i];
- short expectedShort = (short) Math.Round(expectedFloat);
+ short expectedShort = (short)Math.Round(expectedFloat);
short actualShort = dest[i];
Assert.Equal(expectedShort, actualShort);
@@ -349,12 +344,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Block8x8F m = CreateRandomFloatBlock(-500, 500, 42);
Block8x8F actual = original;
-
+
actual.MultiplyInplace(ref m);
for (int i = 0; i < Block8x8F.Size; i++)
{
- Assert.Equal(original[i]*m[i], actual[i]);
+ Assert.Equal(original[i] * m[i], actual[i]);
}
}
@@ -410,7 +405,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
for (int i = 0; i < 64; i++)
{
- Assert.Equal(original[i]*42f, actual[i]);
+ Assert.Equal(original[i] * 42f, actual[i]);
}
}
}
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
index c2fa8c8d4..c7869a6ba 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
@@ -1,12 +1,14 @@
-// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class Block8x8Tests : JpegFixture
{
public Block8x8Tests(ITestOutputHelper output)
@@ -26,11 +28,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(data[i], block[i]);
}
}
-
+
[Fact]
public void Indexer_Set()
{
- var block = default(Block8x8);
+ Block8x8 block = default;
block[17] = 17;
block[42] = 42;
@@ -40,7 +42,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(42, block[42]);
}
-
[Fact]
public unsafe void Indexer_GetScalarAt_SetScalarAt()
{
@@ -117,7 +118,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[Fact]
public void IndexerXY()
{
- var block = default(Block8x8);
+ Block8x8 block = default;
block[8 * 3 + 5] = 42;
short value = block[5, 3];
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs
index 31c95fae6..5bb3ded0b 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/GenericBlock8x8Tests.cs
@@ -1,13 +1,15 @@
-// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System;
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.PixelFormats;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class GenericBlock8x8Tests
{
public static Image CreateTestImage()
@@ -20,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
for (int j = 0; j < 10; j++)
{
- var rgba = new Rgba32((byte)(i+1), (byte)(j+1), (byte)200, (byte)255);
+ var rgba = new Rgba32((byte)(i + 1), (byte)(j + 1), (byte)200, (byte)255);
var color = default(TPixel);
color.PackFromRgba32(rgba);
@@ -107,11 +109,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
span[i] = new Rgb24((byte)i, (byte)(2 * i), (byte)(3 * i));
}
- Rgb24 expected00 = new Rgb24(0, 0, 0);
- Rgb24 expected07 = new Rgb24(7, 14, 21);
- Rgb24 expected11 = new Rgb24(9, 18, 27);
- Rgb24 expected77 = new Rgb24(63, 126, 189);
- Rgb24 expected67 = new Rgb24(62, 124, 186);
+ var expected00 = new Rgb24(0, 0, 0);
+ var expected07 = new Rgb24(7, 14, 21);
+ var expected11 = new Rgb24(9, 18, 27);
+ var expected77 = new Rgb24(63, 126, 189);
+ var expected67 = new Rgb24(62, 124, 186);
Assert.Equal(expected00, block[0, 0]);
Assert.Equal(expected07, block[7, 0]);
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs
index cc06d5701..4e63c97de 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JFifMarkerTests.cs
@@ -1,13 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class JFifMarkerTests
{
// Taken from actual test image
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
index 70a35f182..d2f064175 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
@@ -1,19 +1,20 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
using System;
using System.Numerics;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
+using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters;
using SixLabors.ImageSharp.Memory;
using Xunit;
using Xunit.Abstractions;
-// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
- using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder.ColorConverters;
-
public class JpegColorConverterTests
{
private const float Precision = 0.1f / 255;
@@ -69,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void FromYCbCrSimd_ConvertCore(int size, int seed)
{
JpegColorConverter.ComponentValues values = CreateRandomValues(3, size, seed);
- Vector4[] result = new Vector4[size];
+ var result = new Vector4[size];
JpegColorConverter.FromYCbCrSimd.ConvertCore(values, result);
@@ -134,7 +135,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
int times = 50000;
JpegColorConverter.ComponentValues values = CreateRandomValues(3, count, 1);
- Vector4[] result = new Vector4[count];
+ var result = new Vector4[count];
JpegColorConverter converter = simd ? (JpegColorConverter)new JpegColorConverter.FromYCbCrSimd() : new JpegColorConverter.FromYCbCrBasic();
@@ -159,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var converter = JpegColorConverter.GetConverter(JpegColorSpace.Cmyk);
JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed);
- Vector4[] result = new Vector4[resultBufferLength];
+ var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result);
@@ -192,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
var converter = JpegColorConverter.GetConverter(JpegColorSpace.Grayscale);
JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed);
- Vector4[] result = new Vector4[resultBufferLength];
+ var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result);
@@ -214,7 +215,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
var converter = JpegColorConverter.GetConverter(JpegColorSpace.RGB);
JpegColorConverter.ComponentValues values = CreateRandomValues(3, inputBufferLength, seed);
- Vector4[] result = new Vector4[resultBufferLength];
+ var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result);
@@ -241,7 +242,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var converter = JpegColorConverter.GetConverter(JpegColorSpace.Ycck);
JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed);
- Vector4[] result = new Vector4[resultBufferLength];
+ var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result);
@@ -278,7 +279,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
float maxVal = 255f)
{
var rnd = new Random(seed);
- Buffer2D[] buffers = new Buffer2D[componentCount];
+ var buffers = new Buffer2D[componentCount];
for (int i = 0; i < componentCount; i++)
{
float[] values = new float[inputBufferLength];
@@ -317,7 +318,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
int seed)
{
JpegColorConverter.ComponentValues values = CreateRandomValues(componentCount, inputBufferLength, seed);
- Vector4[] result = new Vector4[resultBufferLength];
+ var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result);
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
index ec3469153..911812ebb 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
@@ -1,26 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System.IO;
+using SixLabors.ImageSharp.Formats.Jpeg;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
+using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
-
-// ReSharper disable InconsistentNaming
+using Xunit;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
- using System.Collections.Generic;
- using System.IO;
-
- using SixLabors.ImageSharp.Formats.Bmp;
- using SixLabors.ImageSharp.Formats.Jpeg;
- using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
- using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
- using SixLabors.Primitives;
-
- using Xunit;
- using Xunit.Abstractions;
-
public class JpegEncoderTests
{
public static readonly TheoryData BitsPerPixel_Quality =
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs
index ec4a42104..ffaccb3f7 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegImagePostProcessorTests.cs
@@ -1,14 +1,17 @@
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
- using Xunit;
- using Xunit.Abstractions;
+using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class JpegImagePostProcessorTests
{
public static string[] BaselineTestJpegs =
@@ -100,8 +103,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.True(report.TotalNormalizedDifference.Value < 0.005f);
}
}
-
-
}
}
}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
index 4eca62cab..49c76dc4e 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
@@ -1,25 +1,22 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-// ReSharper disable InconsistentNaming
-
+using System;
+using System.IO;
+using System.Linq;
+using System.Numerics;
+
+using SixLabors.ImageSharp.Formats;
+using SixLabors.ImageSharp.Formats.Jpeg;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
using SixLabors.ImageSharp.PixelFormats;
+using Xunit;
+using Xunit.Abstractions;
+
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
- using System;
- using System.IO;
- using System.Linq;
- using System.Numerics;
-
- using SixLabors.ImageSharp.Formats;
- using SixLabors.ImageSharp.Formats.Jpeg;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
-
- using Xunit;
- using Xunit.Abstractions;
-
public class JpegProfilingBenchmarks : MeasureFixture
{
public JpegProfilingBenchmarks(ITestOutputHelper output)
@@ -102,14 +99,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
tf => TestImageProvider.File(tf, pixelTypeOverride: PixelTypes.Rgba32).GetImage())
.ToArray();
- using (MemoryStream ms = new MemoryStream())
+ using (var ms = new MemoryStream())
{
this.Measure(executionCount,
() =>
{
foreach (Image img in testImages)
{
- JpegEncoder options = new JpegEncoder { Quality = quality, Subsample = subsample };
+ var options = new JpegEncoder { Quality = quality, Subsample = subsample };
img.Save(ms, options);
ms.Seek(0, SeekOrigin.Begin);
}
@@ -121,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs
index 773d7112b..3d09f4b38 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegToolsTests.cs
@@ -1,12 +1,12 @@
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System.IO;
+using System.IO;
- using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class LibJpegToolsTests
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
index eb8ee90f9..0d563a7b7 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System.Text;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
@@ -6,14 +9,12 @@ using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.Primitives;
+
using Xunit;
using Xunit.Abstractions;
-// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
- using System.Text;
-
public class ParseStreamTests
{
private ITestOutputHelper Output { get; }
@@ -65,19 +66,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(TestImages.Jpeg.Baseline.Cmyk)]
public void PrintComponentData(string imageFile)
{
- StringBuilder bld = new StringBuilder();
+ var sb = new StringBuilder();
using (OrigJpegDecoderCore decoder = JpegFixture.ParseStream(imageFile, true))
{
- bld.AppendLine(imageFile);
- bld.AppendLine($"Size:{decoder.ImageSizeInPixels} MCU:{decoder.ImageSizeInMCU}");
+ sb.AppendLine(imageFile);
+ sb.AppendLine($"Size:{decoder.ImageSizeInPixels} MCU:{decoder.ImageSizeInMCU}");
OrigComponent c0 = decoder.Components[0];
OrigComponent c1 = decoder.Components[1];
- bld.AppendLine($"Luma: SAMP: {c0.SamplingFactors} BLOCKS: {c0.SizeInBlocks}");
- bld.AppendLine($"Chroma: {c1.SamplingFactors} BLOCKS: {c1.SizeInBlocks}");
+ sb.AppendLine($"Luma: SAMP: {c0.SamplingFactors} BLOCKS: {c0.SizeInBlocks}");
+ sb.AppendLine($"Chroma: {c1.SamplingFactors} BLOCKS: {c1.SizeInBlocks}");
}
- this.Output.WriteLine(bld.ToString());
+ this.Output.WriteLine(sb.ToString());
}
public static readonly TheoryData ComponentVerificationData = new TheoryData()
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs
index 1d368d1f5..fa06f91da 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ProfileResolverTests.cs
@@ -1,14 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System.Text;
+using System.Text;
- using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
+using SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class ProfileResolverTests
{
private static readonly byte[] JFifMarker = Encoding.ASCII.GetBytes("JFIF\0");
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs
index 6b9e98d66..b9ae97409 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs
@@ -1,11 +1,11 @@
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public partial class ReferenceImplementationsTests
{
public class AccurateDCT : JpegFixture
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs
index 1fc47726b..11612d3e2 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs
@@ -1,14 +1,15 @@
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using System;
+
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public partial class ReferenceImplementationsTests
{
public class FastFloatingPointDCT : JpegFixture
@@ -79,7 +80,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
this.CompareBlocks(fExpected, fActual, 2);
}
-
[Theory]
[InlineData(42)]
[InlineData(1)]
@@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
float[] floatData = JpegFixture.Create8x8RandomFloatData(-1000, 1000);
- Block8x8F source = default(Block8x8F);
+ Block8x8F source = default;
source.LoadFrom(floatData);
Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformFDCT(ref source);
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs
index f384a76c4..f249aa93b 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs
@@ -1,14 +1,15 @@
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using System;
- using Xunit;
- using Xunit.Abstractions;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public partial class ReferenceImplementationsTests
{
public class StandardIntegerDCT : JpegFixture
@@ -26,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
int[] data = Create8x8RandomIntData(-range, range, seed);
- Block8x8 source = default(Block8x8);
+ Block8x8 source = default;
source.LoadFrom(data);
Block8x8 expected = ReferenceImplementations.AccurateDCT.TransformIDCT(ref source);
@@ -43,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
int[] data = Create8x8RandomIntData(-1000, 1000, seed);
- Block8x8F source = default(Block8x8F);
+ Block8x8F source = default;
source.LoadFrom(data);
Block8x8F expected = ReferenceImplementations.AccurateDCT.TransformFDCT(ref source);
@@ -53,11 +54,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Block8x8 actual8 = ReferenceImplementations.StandardIntegerDCT.Subtract128_TransformFDCT_Upscale8(ref temp);
Block8x8F actual = actual8.AsFloatBlock();
actual /= 8;
-
+
this.CompareBlocks(expected, actual, 1f);
}
-
[Theory]
[InlineData(42, 0)]
[InlineData(1, 0)]
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
index f1ec4af8b..9c134ada9 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
@@ -1,19 +1,19 @@
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- using System;
- using System.IO;
- using System.Linq;
+using System;
+using System.IO;
+using System.Linq;
- using SixLabors.ImageSharp.Formats.Jpeg;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
- using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
+using SixLabors.ImageSharp.Formats.Jpeg;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg
+{
public class SpectralJpegTests
{
public SpectralJpegTests(ITestOutputHelper output)
@@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void PdfJsDecoder_ParseStream_SaveSpectralResult(TestImageProvider provider)
where TPixel : struct, IPixel
{
- PdfJsJpegDecoderCore decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder());
+ var decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder());
byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes;
@@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void OriginalDecoder_ParseStream_SaveSpectralResult(TestImageProvider provider)
where TPixel : struct, IPixel
{
- OrigJpegDecoderCore decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder());
+ var decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder());
byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes;
@@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
return;
}
- PdfJsJpegDecoderCore decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder());
+ var decoder = new PdfJsJpegDecoderCore(Configuration.Default, new JpegDecoder());
byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes;
@@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
return;
}
- OrigJpegDecoderCore decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder());
+ var decoder = new OrigJpegDecoderCore(Configuration.Default, new JpegDecoder());
byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes;
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
index 07268ef21..3e66af50a 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
@@ -1,24 +1,22 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-
-
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Text;
- using SixLabors.ImageSharp.Formats.Jpeg;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using Xunit;
- using Xunit.Abstractions;
+using Xunit;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
+{
public class JpegFixture : MeasureFixture
{
public JpegFixture(ITestOutputHelper output) : base(output)
@@ -70,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
// ReSharper disable once InconsistentNaming
public static int[] Create8x8RandomIntData(int minValue, int maxValue, int seed = 42)
{
- Random rnd = new Random(seed);
+ var rnd = new Random(seed);
int[] result = new int[64];
for (int i = 0; i < 8; i++)
{
@@ -87,7 +85,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public static float[] Create8x8RandomFloatData(float minValue, float maxValue, int seed = 42)
{
- Random rnd = new Random(seed);
+ var rnd = new Random(seed);
float[] result = new float[64];
for (int i = 0; i < 8; i++)
{
@@ -132,12 +130,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
if (count < 0) count = data.Length;
- StringBuilder bld = new StringBuilder();
+ var sb = new StringBuilder();
for (int i = 0; i < count; i++)
{
- bld.Append($"{data[i],3} ");
+ sb.Append($"{data[i],3} ");
}
- this.Output.WriteLine(bld.ToString());
+ this.Output.WriteLine(sb.ToString());
}
protected void Print(string msg)
@@ -154,7 +152,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
internal void CompareBlocks(Span a, Span b, float tolerance)
{
- ApproximateFloatComparer comparer = new ApproximateFloatComparer(tolerance);
+ var comparer = new ApproximateFloatComparer(tolerance);
double totalDifference = 0.0;
bool failed = false;
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs
index a003f749e..45df1d0fc 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.ComponentData.cs
@@ -99,7 +99,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public Image CreateGrayScaleImage()
{
- Image result = new Image(this.WidthInBlocks * 8, this.HeightInBlocks * 8);
+ var result = new Image(this.WidthInBlocks * 8, this.HeightInBlocks * 8);
for (int by = 0; by < this.HeightInBlocks; by++)
{
@@ -119,10 +119,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
for (int x = 0; x < 8; x++)
{
- var val = this.GetBlockValue(block, x, y);
+ float val = this.GetBlockValue(block, x, y);
- Vector4 v = new Vector4(val, val, val, 1);
- Rgba32 color = default(Rgba32);
+ var v = new Vector4(val, val, val, 1);
+ Rgba32 color = default;
color.PackFromVector4(v);
int yy = by * 8 + y;
@@ -143,8 +143,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public bool Equals(ComponentData other)
{
- if (Object.ReferenceEquals(null, other)) return false;
- if (Object.ReferenceEquals(this, other)) return true;
+ if (object.ReferenceEquals(null, other)) return false;
+ if (object.ReferenceEquals(this, other)) return true;
bool ok = this.Index == other.Index && this.HeightInBlocks == other.HeightInBlocks
&& this.WidthInBlocks == other.WidthInBlocks;
//&& this.MinVal == other.MinVal
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
index a353b288a..8ce1f111d 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
@@ -1,16 +1,16 @@
+using System;
+using System.Linq;
+using System.Numerics;
+
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
+using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder;
+using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
+using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
- using System;
- using System.Linq;
- using System.Numerics;
-
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder;
- using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
- using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.Components;
internal static partial class LibJpegTools
{
@@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
return null;
}
- Image result = new Image(c0.WidthInBlocks * 8, c0.HeightInBlocks * 8);
+ var result = new Image(c0.WidthInBlocks * 8, c0.HeightInBlocks * 8);
for (int by = 0; by < c0.HeightInBlocks; by++)
{
@@ -92,8 +92,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float val1 = c0.GetBlockValue(block1, x, y);
float val2 = c0.GetBlockValue(block2, x, y);
- Vector4 v = new Vector4(val0, val1, val2, 1);
- Rgba32 color = default(Rgba32);
+ var v = new Vector4(val0, val1, val2, 1);
+ Rgba32 color = default;
color.PackFromVector4(v);
int yy = by * 8 + y;
@@ -105,8 +105,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public bool Equals(SpectralData other)
{
- if (Object.ReferenceEquals(null, other)) return false;
- if (Object.ReferenceEquals(this, other)) return true;
+ if (object.ReferenceEquals(null, other)) return false;
+ if (object.ReferenceEquals(this, other)) return true;
if (this.ComponentCount != other.ComponentCount)
{
return false;
@@ -123,8 +123,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public override bool Equals(object obj)
{
- if (Object.ReferenceEquals(null, obj)) return false;
- if (Object.ReferenceEquals(this, obj)) return true;
+ if (object.ReferenceEquals(null, obj)) return false;
+ if (object.ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((SpectralData)obj);
}
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs
index 5b9c77f32..9ce027e30 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.cs
@@ -4,10 +4,10 @@ using System.Diagnostics;
using System.IO;
using System.Numerics;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
-
///
/// Utilities to read raw libjpeg data for reference conversion.
///
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs
index 6a1e09a9b..08ef40952 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.AccurateDCT.cs
@@ -1,9 +1,9 @@
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
-{
- using System;
+using System;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
+{
internal static partial class ReferenceImplementations
{
///
@@ -54,7 +54,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
int x, y, u, v;
double tmp, tmp2;
- Block8x8F res = default(Block8x8F);
+ Block8x8F res = default;
for (y=0; y<8; y++) {
for (x=0; x<8; x++) {
@@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
int x, y, u, v;
double tmp, tmp2;
- Block8x8F res = default(Block8x8F);
+ Block8x8F res = default;
for (v = 0; v < 8; v++)
{
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs
index 2e2f12fbc..3742e45bd 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.GT_FloatingPoint_DCT.cs
@@ -1,9 +1,9 @@
// ReSharper disable InconsistentNaming
+using System;
+
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
- using System;
-
internal static partial class ReferenceImplementations
{
///
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
index e18323f84..e3bae95c8 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
@@ -1,14 +1,14 @@
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
-{
- using System;
- using System.Numerics;
- using System.Runtime.CompilerServices;
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using Xunit.Abstractions;
+using Xunit.Abstractions;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
+{
internal static partial class ReferenceImplementations
{
///
@@ -35,7 +35,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float[] temp = new float[64];
iDCT2D_llm(s, d, temp);
- Block8x8F result = default(Block8x8F);
+ Block8x8F result = default;
result.LoadFrom(d);
return result;
}
@@ -48,12 +48,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float[] temp = new float[64];
fDCT2D_llm(s, d, temp);
- Block8x8F result = default(Block8x8F);
+ Block8x8F result = default;
result.LoadFrom(d);
return result;
}
- private static double cos(double x) => Math.Cos(x);
+ private static double Cos(double x) => Math.Cos(x);
private const double M_PI = Math.PI;
@@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
float[] r = new float[8];
for (int i = 0; i < 8; i++)
{
- r[i] = (float)(cos((double)i / 16.0 * M_PI) * M_SQRT2);
+ r[i] = (float)(Cos((double)i / 16.0 * M_PI) * M_SQRT2);
output?.WriteLine($"float r{i} = {r[i]:R}f;");
}
return r;
@@ -214,8 +214,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
/*y[0] = c0 + c1;
y[4] = c0 - c1;*/
- Vector4 w0 = new Vector4(0.541196f);
- Vector4 w1 = new Vector4(1.306563f);
+ var w0 = new Vector4(0.541196f);
+ var w1 = new Vector4(1.306563f);
_mm_store_ps(d, 16, ((w0 * c2) + (w1 * c3)));
@@ -248,7 +248,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
_mm_store_ps(d, 40, (c3 - c1));
//y[5] = c3 - c1; y[3] = c0 - c2;
- Vector4 invsqrt2 = new Vector4(0.707107f);
+ var invsqrt2 = new Vector4(0.707107f);
c0 = ((c0 + c2) * invsqrt2);
c3 = ((c3 + c1) * invsqrt2);
//c0 = (c0 + c2) * invsqrt2;
@@ -279,7 +279,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
fDCT2D8x4_32f(temp.Slice(4), d.Slice(4));
- Vector4 c = new Vector4(0.1250f);
+ var c = new Vector4(0.1250f);
_mm_store_ps(d, 0, (_mm_load_ps(d, 0) * c)); d = d.Slice(4);//0
_mm_store_ps(d, 0, (_mm_load_ps(d, 0) * c)); d = d.Slice(4);//1
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs
index 9afc4b0b3..3d2cbe54f 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.StandardIntegerDCT.cs
@@ -1,10 +1,10 @@
// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
-{
- using System;
+using System;
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
+namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
+{
internal static partial class ReferenceImplementations
{
///
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs
index f1eed08b9..3e3a732e7 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.cs
@@ -1,18 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-
-
// ReSharper disable InconsistentNaming
+using System;
+using System.Runtime.CompilerServices;
+
+using SixLabors.ImageSharp.Formats.Jpeg.Common;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
- using System;
- using System.Runtime.CompilerServices;
-
- using SixLabors.ImageSharp.Formats.Jpeg.Common;
-
///
/// This class contains simplified (unefficient) reference implementations to produce verification data for unit tests
/// Floating point DCT code Ported from https://github.com/norishigefukushima/dct_simd
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
index 988b9e478..e9527e4c3 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
@@ -1,12 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
- using System;
- using System.Numerics;
- using System.Runtime.CompilerServices;
-
///
/// Span Extensions
///
@@ -118,4 +118,4 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
return result;
}
}
-}
+}
\ No newline at end of file