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. 11
      src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

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

@ -476,15 +476,18 @@ internal static class TiffDecoderOptionsParser
case TiffCompression.OldJpeg: case TiffCompression.OldJpeg:
{ {
if (!options.OldJpegCompressionStartOfImageMarker.HasValue)
{
TiffThrowHelper.ThrowNotSupported("Missing SOI marker offset for tiff with old jpeg compression");
}
options.CompressionType = TiffDecoderCompressionType.OldJpeg; 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. // 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.PhotometricInterpretation = TiffPhotometricInterpretation.Rgb;
options.ColorType = TiffColorType.Rgb; options.ColorType = TiffColorType.Rgb;
if (!options.OldJpegCompressionStartOfImageMarker.HasValue)
{
TiffThrowHelper.ThrowNotSupported("Missing SOI marker offset for tiff with old jpeg compression");
} }
break; break;

Loading…
Cancel
Save