From 9b042a753634dcad4b5dc92cba49583ef54806fa Mon Sep 17 00:00:00 2001 From: Ildar Khayrutdinov Date: Sun, 12 Sep 2021 20:25:01 +0300 Subject: [PATCH] FormatDetector fixes --- .../Formats/Tiff/TiffImageFormatDetector.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs b/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs index 297da2dd8a..5755b306a0 100644 --- a/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs +++ b/src/ImageSharp/Formats/Tiff/TiffImageFormatDetector.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff /// /// Initializes a new instance of the class. /// - /// if set to true [is big tiff]. + /// if set to true is BigTiff. public TiffImageFormatDetector(bool isBigTiff) => this.isBigTiff = isBigTiff; /// @@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff if (header[0] == 0x49 && header[1] == 0x49) { // Little-endian - if (!this.isBigTiff) + if (this.isBigTiff is false) { if (header[2] == 0x2A && header[3] == 0x00) { @@ -48,7 +48,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff } else { - if (header[2] == 0x2B && header[3] == 0x00 && header[4] == 8 && header[5] == 0 && header[6] == 0 && header[7] == 0) + if (header[2] == 0x2B && header[3] == 0x00 + && header[4] == 8 && header[5] == 0 && header[6] == 0 && header[7] == 0) { return true; } @@ -57,12 +58,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff else if (header[0] == 0x4D && header[1] == 0x4D) { // Big-endian - if (header[2] == 0x00 && (header[3] == 0x2A || header[3] == 0x2B)) - { - return true; - } - - if (!this.isBigTiff) + if (this.isBigTiff is false) { if (header[2] == 0 && header[3] == 0x2A) { @@ -71,7 +67,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff } else { - if (header[2] == 0 && header[3] == 0x2A && header[4] == 0 && header[5] == 8 && header[6] == 0 && header[7] == 0) + if (header[2] == 0 && header[3] == 0x2B + && header[4] == 0 && header[5] == 8 && header[6] == 0 && header[7] == 0) { return true; }