Skip to content

Commit c61ce85

Browse files
committed
Throw exception if bits per channel for rgb are not equal
1 parent 0b059b5 commit c61ce85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,17 @@ private static void ParseColorType(this TiffDecoderCore options, ExifProfile exi
220220

221221
case TiffPhotometricInterpretation.Rgb:
222222
{
223-
if (options.BitsPerSample.Channels != 3)
223+
TiffBitsPerSample bitsPerSample = options.BitsPerSample;
224+
if (bitsPerSample.Channels != 3)
224225
{
225226
TiffThrowHelper.ThrowNotSupported("The number of samples in the TIFF BitsPerSample entry is not supported.");
226227
}
227228

229+
if (!(bitsPerSample.Channel0 == bitsPerSample.Channel1 && bitsPerSample.Channel1 == bitsPerSample.Channel2))
230+
{
231+
TiffThrowHelper.ThrowNotSupported("Only BitsPerSample with equal bits per channel are supported.");
232+
}
233+
228234
if (options.PlanarConfiguration == TiffPlanarConfiguration.Chunky)
229235
{
230236
ushort bitsPerChannel = options.BitsPerSample.Channel0;

0 commit comments

Comments
 (0)