Browse Source

Fixed switch for color type

pull/1761/head
Dmitry Pentin 5 years ago
parent
commit
81204d3fcb
  1. 14
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

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

@ -131,14 +131,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
this.WriteStartOfScan(componentCount, componentIds); this.WriteStartOfScan(componentCount, componentIds);
// Write the scan compressed data. // Write the scan compressed data.
if (this.colorType == JpegColorType.Luminance)
{
// luminance quantization table only
new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, cancellationToken);
}
else
{
// luminance and chrominance quantization tables.
switch (this.colorType) switch (this.colorType)
{ {
case JpegColorType.YCbCrRatio444: case JpegColorType.YCbCrRatio444:
@ -148,12 +140,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
new HuffmanScanEncoder(6, stream).Encode420(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken); new HuffmanScanEncoder(6, stream).Encode420(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken);
break; break;
case JpegColorType.Luminance: case JpegColorType.Luminance:
new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken); new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, cancellationToken);
break; break;
case JpegColorType.Rgb: case JpegColorType.Rgb:
new HuffmanScanEncoder(3, stream).EncodeRgb(image, ref luminanceQuantTable, cancellationToken); new HuffmanScanEncoder(3, stream).EncodeRgb(image, ref luminanceQuantTable, cancellationToken);
break; break;
} default:
// all other non-supported color types are checked at the start of this method
break;
} }
// Write the End Of Image marker. // Write the End Of Image marker.

Loading…
Cancel
Save