Skip to content

Commit 3d80dfc

Browse files
Rename to JpegColorType
1 parent fbefb37 commit 3d80dfc

15 files changed

Lines changed: 126 additions & 126 deletions

File tree

src/ImageSharp/Formats/Jpeg/Components/Encoder/EncodingConfigs/JpegFrameConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
55

66
internal class JpegFrameConfig
77
{
8-
public JpegFrameConfig(JpegColorSpace colorType, JpegEncodingColor encodingColor, JpegComponentConfig[] components, JpegHuffmanTableConfig[] huffmanTables, JpegQuantizationTableConfig[] quantTables)
8+
public JpegFrameConfig(JpegColorSpace colorType, JpegColorType encodingColor, JpegComponentConfig[] components, JpegHuffmanTableConfig[] huffmanTables, JpegQuantizationTableConfig[] quantTables)
99
{
1010
this.ColorType = colorType;
1111
this.EncodingColor = encodingColor;
@@ -25,7 +25,7 @@ public JpegFrameConfig(JpegColorSpace colorType, JpegEncodingColor encodingColor
2525

2626
public JpegColorSpace ColorType { get; }
2727

28-
public JpegEncodingColor EncodingColor { get; }
28+
public JpegColorType EncodingColor { get; }
2929

3030
public JpegComponentConfig[] Components { get; }
3131

src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanScanEncoder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ public void BuildHuffmanTable(JpegHuffmanTableConfig tableConfig)
139139
/// <param name="frame">Frame to encode.</param>
140140
/// <param name="converter">Converter from color to spectral.</param>
141141
/// <param name="cancellationToken">The token to request cancellation.</param>
142-
public void EncodeScanBaselineInterleaved<TPixel>(JpegEncodingColor color, JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken)
142+
public void EncodeScanBaselineInterleaved<TPixel>(JpegColorType color, JpegFrame frame, SpectralConverter<TPixel> converter, CancellationToken cancellationToken)
143143
where TPixel : unmanaged, IPixel<TPixel>
144144
{
145145
switch (color)
146146
{
147-
case JpegEncodingColor.YCbCrRatio444:
148-
case JpegEncodingColor.Rgb:
147+
case JpegColorType.YCbCrRatio444:
148+
case JpegColorType.Rgb:
149149
this.EncodeThreeComponentBaselineInterleavedScanNoSubsampling(frame, converter, cancellationToken);
150150
break;
151151
default:

src/ImageSharp/Formats/Jpeg/JpegEncodingColor.cs renamed to src/ImageSharp/Formats/Jpeg/JpegColorType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg;
66
/// <summary>
77
/// Provides enumeration of available JPEG color types.
88
/// </summary>
9-
public enum JpegEncodingColor : byte
9+
public enum JpegColorType : byte
1010
{
1111
/// <summary>
1212
/// YCbCr (luminance, blue chroma, red chroma) color as defined in the ITU-T T.871 specification.

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -603,58 +603,58 @@ internal static JpegColorSpace DeduceJpegColorSpace(byte componentCount)
603603
/// Returns the jpeg color type based on the colorspace and subsampling used.
604604
/// </summary>
605605
/// <returns>Jpeg color type.</returns>
606-
private JpegEncodingColor DeduceJpegColorType()
606+
private JpegColorType DeduceJpegColorType()
607607
{
608608
switch (this.ColorSpace)
609609
{
610610
case JpegColorSpace.Grayscale:
611-
return JpegEncodingColor.Luminance;
611+
return JpegColorType.Luminance;
612612

613613
case JpegColorSpace.RGB:
614-
return JpegEncodingColor.Rgb;
614+
return JpegColorType.Rgb;
615615

616616
case JpegColorSpace.YCbCr:
617617
if (this.Frame.Components[0].HorizontalSamplingFactor == 1 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
618618
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
619619
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
620620
{
621-
return JpegEncodingColor.YCbCrRatio444;
621+
return JpegColorType.YCbCrRatio444;
622622
}
623623
else if (this.Frame.Components[0].HorizontalSamplingFactor == 2 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
624624
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
625625
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
626626
{
627-
return JpegEncodingColor.YCbCrRatio422;
627+
return JpegColorType.YCbCrRatio422;
628628
}
629629
else if (this.Frame.Components[0].HorizontalSamplingFactor == 2 && this.Frame.Components[0].VerticalSamplingFactor == 2 &&
630630
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
631631
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
632632
{
633-
return JpegEncodingColor.YCbCrRatio420;
633+
return JpegColorType.YCbCrRatio420;
634634
}
635635
else if (this.Frame.Components[0].HorizontalSamplingFactor == 4 && this.Frame.Components[0].VerticalSamplingFactor == 1 &&
636636
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
637637
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
638638
{
639-
return JpegEncodingColor.YCbCrRatio411;
639+
return JpegColorType.YCbCrRatio411;
640640
}
641641
else if (this.Frame.Components[0].HorizontalSamplingFactor == 4 && this.Frame.Components[0].VerticalSamplingFactor == 2 &&
642642
this.Frame.Components[1].HorizontalSamplingFactor == 1 && this.Frame.Components[1].VerticalSamplingFactor == 1 &&
643643
this.Frame.Components[2].HorizontalSamplingFactor == 1 && this.Frame.Components[2].VerticalSamplingFactor == 1)
644644
{
645-
return JpegEncodingColor.YCbCrRatio410;
645+
return JpegColorType.YCbCrRatio410;
646646
}
647647
else
648648
{
649-
return JpegEncodingColor.YCbCrRatio420;
649+
return JpegColorType.YCbCrRatio420;
650650
}
651651

652652
case JpegColorSpace.Cmyk:
653-
return JpegEncodingColor.Cmyk;
653+
return JpegColorType.Cmyk;
654654
case JpegColorSpace.Ycck:
655-
return JpegEncodingColor.Ycck;
655+
return JpegColorType.Ycck;
656656
default:
657-
return JpegEncodingColor.YCbCrRatio420;
657+
return JpegColorType.YCbCrRatio420;
658658
}
659659
}
660660

src/ImageSharp/Formats/Jpeg/JpegEncoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public int? Quality
4545
/// <summary>
4646
/// Gets the jpeg color for encoding.
4747
/// </summary>
48-
public JpegEncodingColor? ColorType { get; init; }
48+
public JpegColorType? ColorType { get; init; }
4949

5050
/// <inheritdoc/>
5151
protected override void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken)

src/ImageSharp/Formats/Jpeg/JpegEncoderCore.FrameConfig.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
4040
// YCbCr 4:4:4
4141
new JpegFrameConfig(
4242
JpegColorSpace.YCbCr,
43-
JpegEncodingColor.YCbCrRatio444,
43+
JpegColorType.YCbCrRatio444,
4444
new JpegComponentConfig[]
4545
{
4646
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -53,7 +53,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
5353
// YCbCr 4:2:2
5454
new JpegFrameConfig(
5555
JpegColorSpace.YCbCr,
56-
JpegEncodingColor.YCbCrRatio422,
56+
JpegColorType.YCbCrRatio422,
5757
new JpegComponentConfig[]
5858
{
5959
new JpegComponentConfig(id: 1, hsf: 2, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -66,7 +66,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
6666
// YCbCr 4:2:0
6767
new JpegFrameConfig(
6868
JpegColorSpace.YCbCr,
69-
JpegEncodingColor.YCbCrRatio420,
69+
JpegColorType.YCbCrRatio420,
7070
new JpegComponentConfig[]
7171
{
7272
new JpegComponentConfig(id: 1, hsf: 2, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -79,7 +79,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
7979
// YCbCr 4:1:1
8080
new JpegFrameConfig(
8181
JpegColorSpace.YCbCr,
82-
JpegEncodingColor.YCbCrRatio411,
82+
JpegColorType.YCbCrRatio411,
8383
new JpegComponentConfig[]
8484
{
8585
new JpegComponentConfig(id: 1, hsf: 4, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -92,7 +92,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
9292
// YCbCr 4:1:0
9393
new JpegFrameConfig(
9494
JpegColorSpace.YCbCr,
95-
JpegEncodingColor.YCbCrRatio410,
95+
JpegColorType.YCbCrRatio410,
9696
new JpegComponentConfig[]
9797
{
9898
new JpegComponentConfig(id: 1, hsf: 4, vsf: 2, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -105,7 +105,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
105105
// Luminance
106106
new JpegFrameConfig(
107107
JpegColorSpace.Grayscale,
108-
JpegEncodingColor.Luminance,
108+
JpegColorType.Luminance,
109109
new JpegComponentConfig[]
110110
{
111111
new JpegComponentConfig(id: 0, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -123,7 +123,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
123123
// Rgb
124124
new JpegFrameConfig(
125125
JpegColorSpace.RGB,
126-
JpegEncodingColor.Rgb,
126+
JpegColorType.Rgb,
127127
new JpegComponentConfig[]
128128
{
129129
new JpegComponentConfig(id: 82, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -146,7 +146,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
146146
// Cmyk
147147
new JpegFrameConfig(
148148
JpegColorSpace.Cmyk,
149-
JpegEncodingColor.Cmyk,
149+
JpegColorType.Cmyk,
150150
new JpegComponentConfig[]
151151
{
152152
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),
@@ -170,7 +170,7 @@ private static JpegFrameConfig[] CreateFrameConfigs()
170170
// YccK
171171
new JpegFrameConfig(
172172
JpegColorSpace.Ycck,
173-
JpegEncodingColor.Ycck,
173+
JpegColorType.Ycck,
174174
new JpegComponentConfig[]
175175
{
176176
new JpegComponentConfig(id: 1, hsf: 1, vsf: 1, quantIndex: 0, dcIndex: 0, acIndex: 0),

src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ private void WriteDefineQuantizationTables(JpegQuantizationTableConfig[] configs
780780

781781
private JpegFrameConfig GetFrameConfig(JpegMetadata metadata)
782782
{
783-
JpegEncodingColor color = this.encoder.ColorType ?? metadata.ColorType ?? JpegEncodingColor.YCbCrRatio420;
783+
JpegColorType color = this.encoder.ColorType ?? metadata.ColorType;
784784
JpegFrameConfig frameConfig = Array.Find(
785785
FrameConfigs,
786786
cfg => cfg.EncodingColor == color);

src/ImageSharp/Formats/Jpeg/JpegMetadata.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public int Quality
8282
/// <summary>
8383
/// Gets or sets the color type.
8484
/// </summary>
85-
public JpegEncodingColor ColorType { get; set; } = JpegEncodingColor.YCbCrRatio420;
85+
public JpegColorType ColorType { get; set; } = JpegColorType.YCbCrRatio420;
8686

8787
/// <summary>
8888
/// Gets or sets a value indicating whether the component encoding mode should be interleaved.
@@ -109,29 +109,29 @@ public int Quality
109109
/// <inheritdoc/>
110110
public static JpegMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata)
111111
{
112-
JpegEncodingColor color;
112+
JpegColorType color;
113113
PixelColorType colorType = metadata.PixelTypeInfo.ColorType ?? PixelColorType.YCbCr;
114114
switch (colorType)
115115
{
116116
case PixelColorType.Luminance:
117-
color = JpegEncodingColor.Luminance;
117+
color = JpegColorType.Luminance;
118118
break;
119119
case PixelColorType.CMYK:
120-
color = JpegEncodingColor.Cmyk;
120+
color = JpegColorType.Cmyk;
121121
break;
122122
case PixelColorType.YCCK:
123-
color = JpegEncodingColor.Ycck;
123+
color = JpegColorType.Ycck;
124124
break;
125125
default:
126126
if (colorType.HasFlag(PixelColorType.RGB) || colorType.HasFlag(PixelColorType.BGR))
127127
{
128-
color = JpegEncodingColor.Rgb;
128+
color = JpegColorType.Rgb;
129129
}
130130
else
131131
{
132132
color = metadata.Quality <= Quantization.DefaultQualityFactor
133-
? JpegEncodingColor.YCbCrRatio420
134-
: JpegEncodingColor.YCbCrRatio444;
133+
? JpegColorType.YCbCrRatio420
134+
: JpegColorType.YCbCrRatio444;
135135
}
136136

137137
break;
@@ -153,22 +153,22 @@ public PixelTypeInfo GetPixelTypeInfo()
153153
PixelComponentInfo info;
154154
switch (this.ColorType)
155155
{
156-
case JpegEncodingColor.Luminance:
156+
case JpegColorType.Luminance:
157157
bpp = 8;
158158
colorType = PixelColorType.Luminance;
159159
info = PixelComponentInfo.Create(1, bpp, 8);
160160
break;
161-
case JpegEncodingColor.Cmyk:
161+
case JpegColorType.Cmyk:
162162
bpp = 32;
163163
colorType = PixelColorType.CMYK;
164164
info = PixelComponentInfo.Create(4, bpp, 8, 8, 8, 8);
165165
break;
166-
case JpegEncodingColor.Ycck:
166+
case JpegColorType.Ycck:
167167
bpp = 32;
168168
colorType = PixelColorType.YCCK;
169169
info = PixelComponentInfo.Create(4, bpp, 8, 8, 8, 8);
170170
break;
171-
case JpegEncodingColor.Rgb:
171+
case JpegColorType.Rgb:
172172
bpp = 24;
173173
colorType = PixelColorType.RGB;
174174
info = PixelComponentInfo.Create(3, bpp, 8, 8, 8);

src/ImageSharp/Formats/Tiff/Compression/Compressors/TiffJpegCompressor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override void CompressStrip(Span<byte> rows, int height)
3333
var image = Image.LoadPixelData<Rgb24>(rows, width, height);
3434
image.Save(memoryStream, new JpegEncoder()
3535
{
36-
ColorType = JpegEncodingColor.Rgb
36+
ColorType = JpegColorType.Rgb
3737
});
3838
memoryStream.Position = 0;
3939
memoryStream.WriteTo(this.Output);

tests/ImageSharp.Benchmarks/Codecs/Jpeg/EncodeJpegComparison.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void SetupImageSharp()
3939
using FileStream imageBinaryStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage));
4040

4141
this.imageImageSharp = Image.Load<Rgba32>(imageBinaryStream);
42-
this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegEncodingColor.YCbCrRatio420 };
42+
this.encoderImageSharp = new JpegEncoder { Quality = this.Quality, ColorType = JpegColorType.YCbCrRatio420 };
4343

4444
this.destinationStream = new MemoryStream();
4545
}

0 commit comments

Comments
 (0)