Browse Source

Fixed switch for color type

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

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

@ -131,29 +131,23 @@ 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) switch (this.colorType)
{ {
// luminance quantization table only case JpegColorType.YCbCrRatio444:
new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, cancellationToken); new HuffmanScanEncoder(3, stream).Encode444(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken);
} break;
else case JpegColorType.YCbCrRatio420:
{ new HuffmanScanEncoder(6, stream).Encode420(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken);
// luminance and chrominance quantization tables. break;
switch (this.colorType) case JpegColorType.Luminance:
{ new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, cancellationToken);
case JpegColorType.YCbCrRatio444: break;
new HuffmanScanEncoder(3, stream).Encode444(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken); case JpegColorType.Rgb:
break; new HuffmanScanEncoder(3, stream).EncodeRgb(image, ref luminanceQuantTable, cancellationToken);
case JpegColorType.YCbCrRatio420: break;
new HuffmanScanEncoder(6, stream).Encode420(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken); default:
break; // all other non-supported color types are checked at the start of this method
case JpegColorType.Luminance: break;
new HuffmanScanEncoder(1, stream).EncodeGrayscale(image, ref luminanceQuantTable, ref chrominanceQuantTable, cancellationToken);
break;
case JpegColorType.Rgb:
new HuffmanScanEncoder(3, stream).EncodeRgb(image, ref luminanceQuantTable, cancellationToken);
break;
}
} }
// Write the End Of Image marker. // Write the End Of Image marker.

Loading…
Cancel
Save