Browse Source

Throw exception if bits per channel for rgb are not equal

pull/1724/head
Brian Popow 5 years ago
parent
commit
c61ce85fb7
  1. 8
      src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

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

@ -220,11 +220,17 @@ namespace SixLabors.ImageSharp.Formats.Tiff
case TiffPhotometricInterpretation.Rgb: case TiffPhotometricInterpretation.Rgb:
{ {
if (options.BitsPerSample.Channels != 3) TiffBitsPerSample bitsPerSample = options.BitsPerSample;
if (bitsPerSample.Channels != 3)
{ {
TiffThrowHelper.ThrowNotSupported("The number of samples in the TIFF BitsPerSample entry is not supported."); TiffThrowHelper.ThrowNotSupported("The number of samples in the TIFF BitsPerSample entry is not supported.");
} }
if (!(bitsPerSample.Channel0 == bitsPerSample.Channel1 && bitsPerSample.Channel1 == bitsPerSample.Channel2))
{
TiffThrowHelper.ThrowNotSupported("Only BitsPerSample with equal bits per channel are supported.");
}
if (options.PlanarConfiguration == TiffPlanarConfiguration.Chunky) if (options.PlanarConfiguration == TiffPlanarConfiguration.Chunky)
{ {
ushort bitsPerChannel = options.BitsPerSample.Channel0; ushort bitsPerChannel = options.BitsPerSample.Channel0;

Loading…
Cancel
Save