Browse Source

Override PhotometricInterpretation to RGB only in case of YCbCr, for black and white it should stay as it is

pull/2266/head
Brian Popow 4 years ago
parent
commit
f171184c0c
  1. 15
      src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

15
src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

@ -476,17 +476,20 @@ internal static class TiffDecoderOptionsParser
case TiffCompression.OldJpeg: case TiffCompression.OldJpeg:
{ {
options.CompressionType = TiffDecoderCompressionType.OldJpeg;
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
options.PhotometricInterpretation = TiffPhotometricInterpretation.Rgb;
options.ColorType = TiffColorType.Rgb;
if (!options.OldJpegCompressionStartOfImageMarker.HasValue) if (!options.OldJpegCompressionStartOfImageMarker.HasValue)
{ {
TiffThrowHelper.ThrowNotSupported("Missing SOI marker offset for tiff with old jpeg compression"); TiffThrowHelper.ThrowNotSupported("Missing SOI marker offset for tiff with old jpeg compression");
} }
options.CompressionType = TiffDecoderCompressionType.OldJpeg;
if (options.PhotometricInterpretation is TiffPhotometricInterpretation.YCbCr)
{
// Note: Setting PhotometricInterpretation and color type to RGB here, since the jpeg decoder will handle the conversion of the pixel data.
options.PhotometricInterpretation = TiffPhotometricInterpretation.Rgb;
options.ColorType = TiffColorType.Rgb;
}
break; break;
} }

Loading…
Cancel
Save