Browse Source

Always use RgbJpegSpectralConverter for decompressed jpeg data

pull/2177/head
Brian Popow 4 years ago
parent
commit
1959bf6531
  1. 5
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/JpegTiffCompression.cs
  2. 5
      src/ImageSharp/Formats/Tiff/Compression/Decompressors/RgbJpegSpectralConverter.cs

5
src/ImageSharp/Formats/Tiff/Compression/Decompressors/JpegTiffCompression.cs

@ -73,8 +73,9 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
case TiffPhotometricInterpretation.YCbCr:
case TiffPhotometricInterpretation.Rgb:
{
using SpectralConverter<Rgb24> spectralConverter = this.photometricInterpretation == TiffPhotometricInterpretation.YCbCr ?
new RgbJpegSpectralConverter<Rgb24>(this.configuration) : new SpectralConverter<Rgb24>(this.configuration);
// The jpeg data should treated as RGB color space. If the PhotometricInterpretation is YCbCr,
// the conversion to RGB will be handled in the next step by the YCbCr color decoder.
using SpectralConverter<Rgb24> spectralConverter = new RgbJpegSpectralConverter<Rgb24>(this.configuration);
var scanDecoder = new HuffmanScanDecoder(stream, spectralConverter, CancellationToken.None);
jpegDecoder.LoadTables(this.jpegTables, scanDecoder);
jpegDecoder.ParseStream(stream, spectralConverter, CancellationToken.None);

5
src/ImageSharp/Formats/Tiff/Compression/Decompressors/RgbJpegSpectralConverter.cs

@ -8,8 +8,9 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
{
/// <summary>
/// Spectral converter for YCbCr TIFF's which use the JPEG compression.
/// The jpeg data should be always treated as RGB color space.
/// Spectral converter for TIFF's which use the JPEG compression.
/// The compressed jpeg data should be always treated as RGB color space.
/// If PhotometricInterpretation indicates the data is YCbCr, the color decoder will handle the conversion.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
internal sealed class RgbJpegSpectralConverter<TPixel> : SpectralConverter<TPixel>

Loading…
Cancel
Save