|
|
|
@ -167,14 +167,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
/// <param name="colorType">The color type.</param>
|
|
|
|
/// <returns>true, if color type is supported.</returns>
|
|
|
|
private static bool IsSupportedColorType(JpegColorType? colorType) |
|
|
|
{ |
|
|
|
if (colorType == JpegColorType.YCbCrRatio444 || colorType == JpegColorType.YCbCrRatio420 || colorType == JpegColorType.Luminance || colorType == JpegColorType.Rgb) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
=> colorType == JpegColorType.YCbCrRatio444 |
|
|
|
|| colorType == JpegColorType.YCbCrRatio420 |
|
|
|
|| colorType == JpegColorType.Luminance |
|
|
|
|| colorType == JpegColorType.Rgb; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the component ids.
|
|
|
|
@ -571,14 +567,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
// This uses a C#'s compiler optimization that refers to the static data segment of the assembly,
|
|
|
|
// and doesn't incur any allocation at all.
|
|
|
|
// "default" to 4:2:0
|
|
|
|
ReadOnlySpan<byte> subsamples = new byte[] |
|
|
|
ReadOnlySpan<byte> subsamples = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x22, |
|
|
|
0x11, |
|
|
|
0x11 |
|
|
|
}; |
|
|
|
|
|
|
|
ReadOnlySpan<byte> chroma = new byte[] |
|
|
|
ReadOnlySpan<byte> chroma = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x00, |
|
|
|
0x01, |
|
|
|
@ -587,7 +583,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
|
|
|
|
if (this.colorType == JpegColorType.Luminance) |
|
|
|
{ |
|
|
|
subsamples = new byte[] |
|
|
|
subsamples = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x11, |
|
|
|
0x00, |
|
|
|
@ -600,7 +596,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
{ |
|
|
|
case JpegColorType.YCbCrRatio444: |
|
|
|
case JpegColorType.Rgb: |
|
|
|
subsamples = new byte[] |
|
|
|
subsamples = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x11, |
|
|
|
0x11, |
|
|
|
@ -609,7 +605,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
|
|
|
|
if (this.colorType == JpegColorType.Rgb) |
|
|
|
{ |
|
|
|
chroma = new byte[] |
|
|
|
chroma = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x00, |
|
|
|
0x00, |
|
|
|
@ -619,7 +615,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
|
|
|
|
break; |
|
|
|
case JpegColorType.YCbCrRatio420: |
|
|
|
subsamples = new byte[] |
|
|
|
subsamples = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x22, |
|
|
|
0x11, |
|
|
|
@ -662,7 +658,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
{ |
|
|
|
// This uses a C#'s compiler optimization that refers to the static data segment of the assembly,
|
|
|
|
// and doesn't incur any allocation at all.
|
|
|
|
ReadOnlySpan<byte> huffmanId = new byte[] |
|
|
|
ReadOnlySpan<byte> huffmanId = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x00, |
|
|
|
0x11, |
|
|
|
@ -672,7 +668,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
// Use the same DC/AC tables for all channels for RGB.
|
|
|
|
if (this.colorType == JpegColorType.Rgb) |
|
|
|
{ |
|
|
|
huffmanId = new byte[] |
|
|
|
huffmanId = stackalloc byte[] |
|
|
|
{ |
|
|
|
0x00, |
|
|
|
0x00, |
|
|
|
|