diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/EncodingConfigs/JpegFrameConfig.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/EncodingConfigs/JpegFrameConfig.cs
index 5a59837e58..0b7b21f90b 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/EncodingConfigs/JpegFrameConfig.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/EncodingConfigs/JpegFrameConfig.cs
@@ -5,7 +5,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
internal class JpegFrameConfig
{
- public JpegFrameConfig(JpegColorSpace colorType, JpegEncodingColor encodingColor, JpegComponentConfig[] components, JpegHuffmanTableConfig[] huffmanTables, JpegQuantizationTableConfig[] quantTables)
+ public JpegFrameConfig(JpegColorSpace colorType, JpegColorType encodingColor, JpegComponentConfig[] components, JpegHuffmanTableConfig[] huffmanTables, JpegQuantizationTableConfig[] quantTables)
{
this.ColorType = colorType;
this.EncodingColor = encodingColor;
@@ -25,7 +25,7 @@ internal class JpegFrameConfig
public JpegColorSpace ColorType { get; }
- public JpegEncodingColor EncodingColor { get; }
+ public JpegColorType EncodingColor { get; }
public JpegComponentConfig[] Components { get; }
diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
index d74494f9e5..ac527ff312 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs
@@ -139,13 +139,13 @@ internal class HuffmanScanEncoder
/// Frame to encode.
/// Converter from color to spectral.
/// The token to request cancellation.
- public void EncodeScanBaselineInterleaved(JpegEncodingColor color, JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken)
+ public void EncodeScanBaselineInterleaved(JpegColorType color, JpegFrame frame, SpectralConverter converter, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel
{
switch (color)
{
- case JpegEncodingColor.YCbCrRatio444:
- case JpegEncodingColor.Rgb:
+ case JpegColorType.YCbCrRatio444:
+ case JpegColorType.Rgb:
this.EncodeThreeComponentBaselineInterleavedScanNoSubsampling(frame, converter, cancellationToken);
break;
default:
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncodingColor.cs b/src/ImageSharp/Formats/Jpeg/JpegColorType.cs
similarity index 98%
rename from src/ImageSharp/Formats/Jpeg/JpegEncodingColor.cs
rename to src/ImageSharp/Formats/Jpeg/JpegColorType.cs
index 779ccf61e1..a8429273fe 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncodingColor.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegColorType.cs
@@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg;
///
/// Provides enumeration of available JPEG color types.
///
-public enum JpegEncodingColor : byte
+public enum JpegColorType : byte
{
///
/// YCbCr (luminance, blue chroma, red chroma) color as defined in the ITU-T T.871 specification.
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
index 906505b76a..6028aab300 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
@@ -603,58 +603,58 @@ internal sealed class JpegDecoderCore : IRawJpegData, IImageDecoderInternals
/// Returns the jpeg color type based on the colorspace and subsampling used.
///
/// Jpeg color type.
- private JpegEncodingColor DeduceJpegColorType()
+ private JpegColorType DeduceJpegColorType()
{
switch (this.ColorSpace)
{
case JpegColorSpace.Grayscale:
- return JpegEncodingColor.Luminance;
+ return JpegColorType.Luminance;
case JpegColorSpace.RGB:
- return JpegEncodingColor.Rgb;
+ return JpegColorType.Rgb;
case JpegColorSpace.YCbCr:
if (this.Frame.Components[0].HorizontalSamplingFactor == 1 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
{
- return JpegEncodingColor.YCbCrRatio444;
+ return JpegColorType.YCbCrRatio444;
}
else if (this.Frame.Components[0].HorizontalSamplingFactor == 2 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
{
- return JpegEncodingColor.YCbCrRatio422;
+ return JpegColorType.YCbCrRatio422;
}
else if (this.Frame.Components[0].HorizontalSamplingFactor == 2 && this.Frame.Components[0].VerticalSamplingFactor == 2 &&
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
{
- return JpegEncodingColor.YCbCrRatio420;
+ return JpegColorType.YCbCrRatio420;
}
else if (this.Frame.Components[0].HorizontalSamplingFactor == 4 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
{
- return JpegEncodingColor.YCbCrRatio411;
+ return JpegColorType.YCbCrRatio411;
}
else if (this.Frame.Components[0].HorizontalSamplingFactor == 4 && this.Frame.Components[0].VerticalSamplingFactor == 2 &&
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
{
- return JpegEncodingColor.YCbCrRatio410;
+ return JpegColorType.YCbCrRatio410;
}
else
{
- return JpegEncodingColor.YCbCrRatio420;
+ return JpegColorType.YCbCrRatio420;
}
case JpegColorSpace.Cmyk:
- return JpegEncodingColor.Cmyk;
+ return JpegColorType.Cmyk;
case JpegColorSpace.Ycck:
- return JpegEncodingColor.Ycck;
+ return JpegColorType.Ycck;
default:
- return JpegEncodingColor.YCbCrRatio420;
+ return JpegColorType.YCbCrRatio420;
}
}
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
index 5ff4b1694d..0daaae112c 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
@@ -45,7 +45,7 @@ public sealed class JpegEncoder : ImageEncoder
///
/// Gets the jpeg color for encoding.
///
- public JpegEncodingColor? ColorType { get; init; }
+ public JpegColorType? ColorType { get; init; }
///
protected override void Encode(Image image, Stream stream, CancellationToken cancellationToken)
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
index 4aed795825..71f852a092 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs
@@ -40,7 +40,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YCbCr 4:4:4
new JpegFrameConfig(
JpegColorSpace.YCbCr,
- JpegEncodingColor.YCbCrRatio444,
+ JpegColorType.YCbCrRatio444,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -53,7 +53,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YCbCr 4:2:2
new JpegFrameConfig(
JpegColorSpace.YCbCr,
- JpegEncodingColor.YCbCrRatio422,
+ JpegColorType.YCbCrRatio422,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -66,7 +66,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YCbCr 4:2:0
new JpegFrameConfig(
JpegColorSpace.YCbCr,
- JpegEncodingColor.YCbCrRatio420,
+ JpegColorType.YCbCrRatio420,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -79,7 +79,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YCbCr 4:1:1
new JpegFrameConfig(
JpegColorSpace.YCbCr,
- JpegEncodingColor.YCbCrRatio411,
+ JpegColorType.YCbCrRatio411,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -92,7 +92,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YCbCr 4:1:0
new JpegFrameConfig(
JpegColorSpace.YCbCr,
- JpegEncodingColor.YCbCrRatio410,
+ JpegColorType.YCbCrRatio410,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -105,7 +105,7 @@ internal sealed unsafe partial class JpegEncoderCore
// Luminance
new JpegFrameConfig(
JpegColorSpace.Grayscale,
- JpegEncodingColor.Luminance,
+ JpegColorType.Luminance,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -123,7 +123,7 @@ internal sealed unsafe partial class JpegEncoderCore
// Rgb
new JpegFrameConfig(
JpegColorSpace.RGB,
- JpegEncodingColor.Rgb,
+ JpegColorType.Rgb,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -146,7 +146,7 @@ internal sealed unsafe partial class JpegEncoderCore
// Cmyk
new JpegFrameConfig(
JpegColorSpace.Cmyk,
- JpegEncodingColor.Cmyk,
+ JpegColorType.Cmyk,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -170,7 +170,7 @@ internal sealed unsafe partial class JpegEncoderCore
// YccK
new JpegFrameConfig(
JpegColorSpace.Ycck,
- JpegEncodingColor.Ycck,
+ JpegColorType.Ycck,
new JpegComponentConfig[]
{
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
index b6fda8bc30..523d6b3ba8 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
@@ -780,7 +780,7 @@ internal sealed unsafe partial class JpegEncoderCore : IImageEncoderInternals
private JpegFrameConfig GetFrameConfig(JpegMetadata metadata)
{
- JpegEncodingColor color = this.encoder.ColorType ?? metadata.ColorType ?? JpegEncodingColor.YCbCrRatio420;
+ JpegColorType color = this.encoder.ColorType ?? metadata.ColorType;
JpegFrameConfig frameConfig = Array.Find(
FrameConfigs,
cfg => cfg.EncodingColor == color);
diff --git a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs
index 86b7883c38..0fadc830e5 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegMetadata.cs
@@ -82,7 +82,7 @@ public class JpegMetadata : IFormatMetadata
///
/// Gets or sets the color type.
///
- public JpegEncodingColor ColorType { get; set; } = JpegEncodingColor.YCbCrRatio420;
+ public JpegColorType ColorType { get; set; } = JpegColorType.YCbCrRatio420;
///
/// Gets or sets a value indicating whether the component encoding mode should be interleaved.
@@ -109,29 +109,29 @@ public class JpegMetadata : IFormatMetadata
///
public static JpegMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata)
{
- JpegEncodingColor color;
+ JpegColorType color;
PixelColorType colorType = metadata.PixelTypeInfo.ColorType ?? PixelColorType.YCbCr;
switch (colorType)
{
case PixelColorType.Luminance:
- color = JpegEncodingColor.Luminance;
+ color = JpegColorType.Luminance;
break;
case PixelColorType.CMYK:
- color = JpegEncodingColor.Cmyk;
+ color = JpegColorType.Cmyk;
break;
case PixelColorType.YCCK:
- color = JpegEncodingColor.Ycck;
+ color = JpegColorType.Ycck;
break;
default:
if (colorType.HasFlag(PixelColorType.RGB) || colorType.HasFlag(PixelColorType.BGR))
{
- color = JpegEncodingColor.Rgb;
+ color = JpegColorType.Rgb;
}
else
{
color = metadata.Quality <= Quantization.DefaultQualityFactor
- ? JpegEncodingColor.YCbCrRatio420
- : JpegEncodingColor.YCbCrRatio444;
+ ? JpegColorType.YCbCrRatio420
+ : JpegColorType.YCbCrRatio444;
}
break;
@@ -153,22 +153,22 @@ public class JpegMetadata : IFormatMetadata
PixelComponentInfo info;
switch (this.ColorType)
{
- case JpegEncodingColor.Luminance:
+ case JpegColorType.Luminance:
bpp = 8;
colorType = PixelColorType.Luminance;
info = PixelComponentInfo.Create(1, bpp, 8);
break;
- case JpegEncodingColor.Cmyk:
+ case JpegColorType.Cmyk:
bpp = 32;
colorType = PixelColorType.CMYK;
info = PixelComponentInfo.Create(4, bpp, 8, 8, 8, 8);
break;
- case JpegEncodingColor.Ycck:
+ case JpegColorType.Ycck:
bpp = 32;
colorType = PixelColorType.YCCK;
info = PixelComponentInfo.Create(4, bpp, 8, 8, 8, 8);
break;
- case JpegEncodingColor.Rgb:
+ case JpegColorType.Rgb:
bpp = 24;
colorType = PixelColorType.RGB;
info = PixelComponentInfo.Create(3, bpp, 8, 8, 8);
diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs
index 9096271fe5..08faa539a8 100644
--- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs
+++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs
@@ -33,7 +33,7 @@ internal class TiffJpegCompressor : TiffBaseCompressor
var image = Image.LoadPixelData(rows, width, height);
image.Save(memoryStream, new JpegEncoder()
{
- ColorType = JpegEncodingColor.Rgb
+ ColorType = JpegColorType.Rgb
});
memoryStream.Position = 0;
memoryStream.WriteTo(this.Output);
diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs
index d762e8e95e..deb3125b30 100644
--- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs
+++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs
@@ -39,7 +39,7 @@ public class EncodeJpegComparison
using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage));
this.imageImageSharp = Image.Load(imageBinaryStream);
- this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegEncodingColor.YCbCrRatio420 };
+ this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 };
this.destinationStream = new MemoryStream();
}
diff --git a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs
index 98eb0b54dc..0692c5a3b5 100644
--- a/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs
+++ b/tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegFeatures.cs
@@ -20,19 +20,19 @@ public class EncodeJpegFeatures
// No metadata
private const string TestImage = TestImages.Jpeg.Baseline.Calliphora;
- public static IEnumerable ColorSpaceValues => new[]
+ public static IEnumerable ColorSpaceValues => new[]
{
- JpegEncodingColor.Luminance,
- JpegEncodingColor.Rgb,
- JpegEncodingColor.YCbCrRatio420,
- JpegEncodingColor.YCbCrRatio444,
+ JpegColorType.Luminance,
+ JpegColorType.Rgb,
+ JpegColorType.YCbCrRatio420,
+ JpegColorType.YCbCrRatio444,
};
[Params(75, 90, 100)]
public int Quality;
[ParamsSource(nameof(ColorSpaceValues), Priority = -100)]
- public JpegEncodingColor TargetColorSpace;
+ public JpegColorType TargetColorSpace;
private Image bmpCore;
private JpegEncoder encoder;
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs
index cbb2befcd4..a2c144a656 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs
@@ -145,14 +145,14 @@ public partial class JpegDecoderTests
}
[Theory]
- [InlineData(TestImages.Jpeg.Baseline.Floorplan, JpegEncodingColor.Luminance)]
- [InlineData(TestImages.Jpeg.Baseline.Jpeg420Small, JpegEncodingColor.YCbCrRatio420)]
- [InlineData(TestImages.Jpeg.Baseline.Jpeg444, JpegEncodingColor.YCbCrRatio444)]
- [InlineData(TestImages.Jpeg.Baseline.JpegRgb, JpegEncodingColor.Rgb)]
- [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegEncodingColor.Cmyk)]
- [InlineData(TestImages.Jpeg.Baseline.Jpeg410, JpegEncodingColor.YCbCrRatio410)]
- [InlineData(TestImages.Jpeg.Baseline.Jpeg411, JpegEncodingColor.YCbCrRatio411)]
- public void Identify_DetectsCorrectColorType(string imagePath, JpegEncodingColor expectedColorType)
+ [InlineData(TestImages.Jpeg.Baseline.Floorplan, JpegColorType.Luminance)]
+ [InlineData(TestImages.Jpeg.Baseline.Jpeg420Small, JpegColorType.YCbCrRatio420)]
+ [InlineData(TestImages.Jpeg.Baseline.Jpeg444, JpegColorType.YCbCrRatio444)]
+ [InlineData(TestImages.Jpeg.Baseline.JpegRgb, JpegColorType.Rgb)]
+ [InlineData(TestImages.Jpeg.Baseline.Cmyk, JpegColorType.Cmyk)]
+ [InlineData(TestImages.Jpeg.Baseline.Jpeg410, JpegColorType.YCbCrRatio410)]
+ [InlineData(TestImages.Jpeg.Baseline.Jpeg411, JpegColorType.YCbCrRatio411)]
+ public void Identify_DetectsCorrectColorType(string imagePath, JpegColorType expectedColorType)
{
TestFile testFile = TestFile.Create(imagePath);
using MemoryStream stream = new(testFile.Bytes, false);
@@ -162,12 +162,12 @@ public partial class JpegDecoderTests
}
[Theory]
- [WithFile(TestImages.Jpeg.Baseline.Floorplan, PixelTypes.Rgb24, JpegEncodingColor.Luminance)]
- [WithFile(TestImages.Jpeg.Baseline.Jpeg420Small, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio420)]
- [WithFile(TestImages.Jpeg.Baseline.Jpeg444, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio444)]
- [WithFile(TestImages.Jpeg.Baseline.JpegRgb, PixelTypes.Rgb24, JpegEncodingColor.Rgb)]
- [WithFile(TestImages.Jpeg.Baseline.Cmyk, PixelTypes.Rgb24, JpegEncodingColor.Cmyk)]
- public void Decode_DetectsCorrectColorType(TestImageProvider provider, JpegEncodingColor expectedColorType)
+ [WithFile(TestImages.Jpeg.Baseline.Floorplan, PixelTypes.Rgb24, JpegColorType.Luminance)]
+ [WithFile(TestImages.Jpeg.Baseline.Jpeg420Small, PixelTypes.Rgb24, JpegColorType.YCbCrRatio420)]
+ [WithFile(TestImages.Jpeg.Baseline.Jpeg444, PixelTypes.Rgb24, JpegColorType.YCbCrRatio444)]
+ [WithFile(TestImages.Jpeg.Baseline.JpegRgb, PixelTypes.Rgb24, JpegColorType.Rgb)]
+ [WithFile(TestImages.Jpeg.Baseline.Cmyk, PixelTypes.Rgb24, JpegColorType.Cmyk)]
+ public void Decode_DetectsCorrectColorType(TestImageProvider provider, JpegColorType expectedColorType)
where TPixel : unmanaged, IPixel
{
using Image image = provider.GetImage(JpegDecoder.Instance);
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs
index f06fbe9635..039215bbc5 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.Metadata.cs
@@ -208,11 +208,11 @@ public partial class JpegEncoderTests
}
[Theory]
- [WithFile(TestImages.Jpeg.Baseline.Floorplan, PixelTypes.Rgb24, JpegEncodingColor.Luminance)]
- [WithFile(TestImages.Jpeg.Baseline.Jpeg444, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio444)]
- [WithFile(TestImages.Jpeg.Baseline.Jpeg420Small, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio420)]
- [WithFile(TestImages.Jpeg.Baseline.JpegRgb, PixelTypes.Rgb24, JpegEncodingColor.Rgb)]
- public void Encode_PreservesColorType(TestImageProvider provider, JpegEncodingColor expectedColorType)
+ [WithFile(TestImages.Jpeg.Baseline.Floorplan, PixelTypes.Rgb24, JpegColorType.Luminance)]
+ [WithFile(TestImages.Jpeg.Baseline.Jpeg444, PixelTypes.Rgb24, JpegColorType.YCbCrRatio444)]
+ [WithFile(TestImages.Jpeg.Baseline.Jpeg420Small, PixelTypes.Rgb24, JpegColorType.YCbCrRatio420)]
+ [WithFile(TestImages.Jpeg.Baseline.JpegRgb, PixelTypes.Rgb24, JpegColorType.Rgb)]
+ public void Encode_PreservesColorType(TestImageProvider provider, JpegColorType expectedColorType)
where TPixel : unmanaged, IPixel
{
// arrange
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
index 5842c8e1a0..1f4b3e4656 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
@@ -21,51 +21,51 @@ public partial class JpegEncoderTests
100,
};
- public static readonly TheoryData NonSubsampledEncodingSetups = new()
+ public static readonly TheoryData NonSubsampledEncodingSetups = new()
{
- { JpegEncodingColor.Rgb, 100, 0.0238f / 100 },
- { JpegEncodingColor.Rgb, 80, 1.3044f / 100 },
- { JpegEncodingColor.Rgb, 40, 2.9879f / 100 },
- { JpegEncodingColor.YCbCrRatio444, 100, 0.0780f / 100 },
- { JpegEncodingColor.YCbCrRatio444, 80, 1.4585f / 100 },
- { JpegEncodingColor.YCbCrRatio444, 40, 3.1413f / 100 },
+ { JpegColorType.Rgb, 100, 0.0238f / 100 },
+ { JpegColorType.Rgb, 80, 1.3044f / 100 },
+ { JpegColorType.Rgb, 40, 2.9879f / 100 },
+ { JpegColorType.YCbCrRatio444, 100, 0.0780f / 100 },
+ { JpegColorType.YCbCrRatio444, 80, 1.4585f / 100 },
+ { JpegColorType.YCbCrRatio444, 40, 3.1413f / 100 },
};
- public static readonly TheoryData SubsampledEncodingSetups = new()
+ public static readonly TheoryData SubsampledEncodingSetups = new()
{
- { JpegEncodingColor.YCbCrRatio422, 100, 0.4895f / 100 },
- { JpegEncodingColor.YCbCrRatio422, 80, 1.6043f / 100 },
- { JpegEncodingColor.YCbCrRatio422, 40, 3.1996f / 100 },
- { JpegEncodingColor.YCbCrRatio420, 100, 0.5790f / 100 },
- { JpegEncodingColor.YCbCrRatio420, 80, 1.6692f / 100 },
- { JpegEncodingColor.YCbCrRatio420, 40, 3.2324f / 100 },
- { JpegEncodingColor.YCbCrRatio411, 100, 0.6868f / 100 },
- { JpegEncodingColor.YCbCrRatio411, 80, 1.7139f / 100 },
- { JpegEncodingColor.YCbCrRatio411, 40, 3.2634f / 100 },
- { JpegEncodingColor.YCbCrRatio410, 100, 0.7357f / 100 },
- { JpegEncodingColor.YCbCrRatio410, 80, 1.7495f / 100 },
- { JpegEncodingColor.YCbCrRatio410, 40, 3.2911f / 100 },
+ { JpegColorType.YCbCrRatio422, 100, 0.4895f / 100 },
+ { JpegColorType.YCbCrRatio422, 80, 1.6043f / 100 },
+ { JpegColorType.YCbCrRatio422, 40, 3.1996f / 100 },
+ { JpegColorType.YCbCrRatio420, 100, 0.5790f / 100 },
+ { JpegColorType.YCbCrRatio420, 80, 1.6692f / 100 },
+ { JpegColorType.YCbCrRatio420, 40, 3.2324f / 100 },
+ { JpegColorType.YCbCrRatio411, 100, 0.6868f / 100 },
+ { JpegColorType.YCbCrRatio411, 80, 1.7139f / 100 },
+ { JpegColorType.YCbCrRatio411, 40, 3.2634f / 100 },
+ { JpegColorType.YCbCrRatio410, 100, 0.7357f / 100 },
+ { JpegColorType.YCbCrRatio410, 80, 1.7495f / 100 },
+ { JpegColorType.YCbCrRatio410, 40, 3.2911f / 100 },
};
- public static readonly TheoryData CmykEncodingSetups = new()
+ public static readonly TheoryData CmykEncodingSetups = new()
{
- { JpegEncodingColor.Cmyk, 100, 0.0159f / 100 },
- { JpegEncodingColor.Cmyk, 80, 0.3922f / 100 },
- { JpegEncodingColor.Cmyk, 40, 0.6488f / 100 },
+ { JpegColorType.Cmyk, 100, 0.0159f / 100 },
+ { JpegColorType.Cmyk, 80, 0.3922f / 100 },
+ { JpegColorType.Cmyk, 40, 0.6488f / 100 },
};
- public static readonly TheoryData YcckEncodingSetups = new()
+ public static readonly TheoryData YcckEncodingSetups = new()
{
- { JpegEncodingColor.Ycck, 100, 0.0356f / 100 },
- { JpegEncodingColor.Ycck, 80, 0.1245f / 100 },
- { JpegEncodingColor.Ycck, 40, 0.2663f / 100 },
+ { JpegColorType.Ycck, 100, 0.0356f / 100 },
+ { JpegColorType.Ycck, 80, 0.1245f / 100 },
+ { JpegColorType.Ycck, 40, 0.2663f / 100 },
};
- public static readonly TheoryData LuminanceEncodingSetups = new()
+ public static readonly TheoryData LuminanceEncodingSetups = new()
{
- { JpegEncodingColor.Luminance, 100, 0.0175f / 100 },
- { JpegEncodingColor.Luminance, 80, 0.6730f / 100 },
- { JpegEncodingColor.Luminance, 40, 0.9943f / 100 },
+ { JpegColorType.Luminance, 100, 0.0175f / 100 },
+ { JpegColorType.Luminance, 80, 0.6730f / 100 },
+ { JpegColorType.Luminance, 40, 0.9943f / 100 },
};
[Theory]
@@ -74,7 +74,7 @@ public partial class JpegEncoderTests
[WithFile(TestImages.Png.BikeGrayscale, nameof(LuminanceEncodingSetups), PixelTypes.L8)]
[WithFile(TestImages.Jpeg.Baseline.Cmyk, nameof(CmykEncodingSetups), PixelTypes.Rgb24)]
[WithFile(TestImages.Jpeg.Baseline.Ycck, nameof(YcckEncodingSetups), PixelTypes.Rgb24)]
- public void EncodeBaseline_Interleaved(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_Interleaved(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, colorType, quality, tolerance);
[Theory]
@@ -83,7 +83,7 @@ public partial class JpegEncoderTests
[WithFile(TestImages.Png.BikeGrayscale, nameof(LuminanceEncodingSetups), PixelTypes.L8)]
[WithFile(TestImages.Jpeg.Baseline.Cmyk, nameof(CmykEncodingSetups), PixelTypes.Rgb24)]
[WithFile(TestImages.Jpeg.Baseline.Ycck, nameof(YcckEncodingSetups), PixelTypes.Rgb24)]
- public void EncodeBaseline_NonInterleavedMode(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_NonInterleavedMode(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel
{
using Image image = provider.GetImage();
@@ -108,7 +108,7 @@ public partial class JpegEncoderTests
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 153, 21, PixelTypes.Rgb24)]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 143, 81, PixelTypes.Rgb24)]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 138, 24, PixelTypes.Rgb24)]
- public void EncodeBaseline_WorksWithDifferentSizes(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_WorksWithDifferentSizes(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, colorType, quality);
[Theory]
@@ -121,7 +121,7 @@ public partial class JpegEncoderTests
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 48, 24, PixelTypes.Rgb24)]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 46, 8, PixelTypes.Rgb24)]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 51, 7, PixelTypes.Rgb24)]
- public void EncodeBaseline_WithSmallImages_WorksWithDifferentSizes(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_WithSmallImages_WorksWithDifferentSizes(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, colorType, quality, ImageComparer.Tolerant(0.12f));
[Theory]
@@ -131,28 +131,28 @@ public partial class JpegEncoderTests
[WithSolidFilledImages(1, 1, 100, 100, 100, 255, PixelTypes.La16, 100)]
[WithSolidFilledImages(1, 1, 100, 100, 100, 255, PixelTypes.La32, 100)]
public void EncodeBaseline_Grayscale(TestImageProvider provider, int quality)
- where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, JpegEncodingColor.Luminance, quality);
+ where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, JpegColorType.Luminance, quality);
[Theory]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 96, 96, PixelTypes.Rgb24 | PixelTypes.Bgr24)]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 48, 48, PixelTypes.Rgb24 | PixelTypes.Bgr24)]
- public void EncodeBaseline_IsNotBoundToSinglePixelType(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_IsNotBoundToSinglePixelType(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, colorType, quality);
[Theory]
[WithTestPatternImages(nameof(NonSubsampledEncodingSetups), 48, 48, PixelTypes.Rgb24 | PixelTypes.Bgr24)]
- public void EncodeBaseline_WithSmallImages_IsNotBoundToSinglePixelType(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ public void EncodeBaseline_WithSmallImages_IsNotBoundToSinglePixelType(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel => TestJpegEncoderCore(provider, colorType, quality, comparer: ImageComparer.Tolerant(0.06f));
[Theory]
- [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio444)]
- [WithTestPatternImages(587, 821, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio444)]
- [WithTestPatternImages(677, 683, PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio420)]
- [WithSolidFilledImages(400, 400, nameof(Color.Red), PixelTypes.Rgb24, JpegEncodingColor.YCbCrRatio420)]
- public void EncodeBaseline_WorksWithDiscontiguousBuffers(TestImageProvider provider, JpegEncodingColor colorType)
+ [WithFile(TestImages.Png.CalliphoraPartial, PixelTypes.Rgb24, JpegColorType.YCbCrRatio444)]
+ [WithTestPatternImages(587, 821, PixelTypes.Rgb24, JpegColorType.YCbCrRatio444)]
+ [WithTestPatternImages(677, 683, PixelTypes.Rgb24, JpegColorType.YCbCrRatio420)]
+ [WithSolidFilledImages(400, 400, nameof(Color.Red), PixelTypes.Rgb24, JpegColorType.YCbCrRatio420)]
+ public void EncodeBaseline_WorksWithDiscontiguousBuffers(TestImageProvider provider, JpegColorType colorType)
where TPixel : unmanaged, IPixel
{
- ImageComparer comparer = colorType == JpegEncodingColor.YCbCrRatio444
+ ImageComparer comparer = colorType == JpegColorType.YCbCrRatio444
? ImageComparer.TolerantPercentage(0.1f)
: ImageComparer.TolerantPercentage(5f);
@@ -161,9 +161,9 @@ public partial class JpegEncoderTests
}
[Theory]
- [InlineData(JpegEncodingColor.YCbCrRatio420)]
- [InlineData(JpegEncodingColor.YCbCrRatio444)]
- public async Task Encode_IsCancellable(JpegEncodingColor colorType)
+ [InlineData(JpegColorType.YCbCrRatio420)]
+ [InlineData(JpegColorType.YCbCrRatio444)]
+ public async Task Encode_IsCancellable(JpegColorType colorType)
{
CancellationTokenSource cts = new();
using PausedStream pausedStream = new(new MemoryStream());
@@ -201,13 +201,13 @@ public partial class JpegEncoderTests
image.Mutate(x => x.Crop(132, 1606));
int[] quality = new int[] { 100, 50 };
- JpegEncodingColor[] colors = new[] { JpegEncodingColor.YCbCrRatio444, JpegEncodingColor.YCbCrRatio420 };
+ JpegColorType[] colors = new[] { JpegColorType.YCbCrRatio444, JpegColorType.YCbCrRatio420 };
for (int i = 0; i < quality.Length; i++)
{
int q = quality[i];
for (int j = 0; j < colors.Length; j++)
{
- JpegEncodingColor c = colors[j];
+ JpegColorType c = colors[j];
image.VerifyEncoder(provider, "jpeg", $"{q}-{c}", new JpegEncoder() { Quality = q, ColorType = c }, GetComparer(q, c));
}
}
@@ -216,7 +216,7 @@ public partial class JpegEncoderTests
///
/// Anton's SUPER-SCIENTIFIC tolerance threshold calculation
///
- private static ImageComparer GetComparer(int quality, JpegEncodingColor? colorType)
+ private static ImageComparer GetComparer(int quality, JpegColorType? colorType)
{
float tolerance = 0.015f; // ~1.5%
@@ -224,10 +224,10 @@ public partial class JpegEncoderTests
{
tolerance *= 4.5f;
}
- else if (quality < 75 || colorType == JpegEncodingColor.YCbCrRatio420)
+ else if (quality < 75 || colorType == JpegColorType.YCbCrRatio420)
{
tolerance *= 2.0f;
- if (colorType == JpegEncodingColor.YCbCrRatio420)
+ if (colorType == JpegColorType.YCbCrRatio420)
{
tolerance *= 2.0f;
}
@@ -236,15 +236,15 @@ public partial class JpegEncoderTests
return ImageComparer.Tolerant(tolerance);
}
- private static void TestJpegEncoderCore(TestImageProvider provider, JpegEncodingColor colorType, int quality)
+ private static void TestJpegEncoderCore(TestImageProvider provider, JpegColorType colorType, int quality)
where TPixel : unmanaged, IPixel
=> TestJpegEncoderCore(provider, colorType, quality, GetComparer(quality, colorType));
- private static void TestJpegEncoderCore(TestImageProvider provider, JpegEncodingColor colorType, int quality, float tolerance)
+ private static void TestJpegEncoderCore(TestImageProvider provider, JpegColorType colorType, int quality, float tolerance)
where TPixel : unmanaged, IPixel
=> TestJpegEncoderCore(provider, colorType, quality, new TolerantImageComparer(tolerance));
- private static void TestJpegEncoderCore(TestImageProvider provider, JpegEncodingColor colorType, int quality, ImageComparer comparer)
+ private static void TestJpegEncoderCore(TestImageProvider provider, JpegColorType colorType, int quality, ImageComparer comparer)
where TPixel : unmanaged, IPixel
{
using Image image = provider.GetImage();
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs
index e07c42f898..19b5265a17 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegMetadataTests.cs
@@ -12,10 +12,10 @@ public class JpegMetadataTests
[Fact]
public void CloneIsDeep()
{
- var meta = new JpegMetadata { ColorType = JpegEncodingColor.Luminance };
+ var meta = new JpegMetadata { ColorType = JpegColorType.Luminance };
var clone = (JpegMetadata)meta.DeepClone();
- clone.ColorType = JpegEncodingColor.YCbCrRatio420;
+ clone.ColorType = JpegColorType.YCbCrRatio420;
Assert.False(meta.ColorType.Equals(clone.ColorType));
}