Skip to content

Commit 31fa1ea

Browse files
committed
Review changes
1 parent 37033cd commit 31fa1ea

12 files changed

+66
-14
lines changed

src/ImageSharp/Formats/Tiff/Compression/Decompressors/CcittReferenceScanline.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public CcittReferenceScanline(bool whiteIsZero, int width)
4848
/// <returns>Position of b1.</returns>
4949
public int FindB1(int a0, byte a0Byte)
5050
{
51-
if (this.scanLine.IsEmpty)
51+
if (this.IsEmpty)
5252
{
5353
return this.FindB1ForImaginaryWhiteLine(a0, a0Byte);
5454
}
@@ -63,7 +63,7 @@ public int FindB1(int a0, byte a0Byte)
6363
/// <returns>Position of b1.</returns>
6464
public int FindB2(int b1)
6565
{
66-
if (this.scanLine.IsEmpty)
66+
if (this.IsEmpty)
6767
{
6868
return this.FindB2ForImaginaryWhiteLine();
6969
}

src/ImageSharp/Formats/Tiff/Compression/Decompressors/CcittTwoDimensionalCodeType.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,71 @@
33

44
namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
55
{
6+
/// <summary>
7+
/// Enum for the different two dimensional code words for the ccitt fax compression.
8+
/// </summary>
69
internal enum CcittTwoDimensionalCodeType
710
{
11+
/// <summary>
12+
/// No valid code word was read.
13+
/// </summary>
814
None = 0,
915

16+
/// <summary>
17+
/// Pass mode: This mode is identified when the position of b2 lies to the left of a1.
18+
/// </summary>
1019
Pass = 1,
1120

21+
/// <summary>
22+
/// Indicates horizontal mode.
23+
/// </summary>
1224
Horizontal = 2,
1325

26+
/// <summary>
27+
/// Vertical 0 code word: relative distance between a1 and b1 is 0.
28+
/// </summary>
1429
Vertical0 = 3,
1530

31+
/// <summary>
32+
/// Vertical r1 code word: relative distance between a1 and b1 is 1, a1 is to the right of b1.
33+
/// </summary>
1634
VerticalR1 = 4,
1735

36+
/// <summary>
37+
/// Vertical r2 code word: relative distance between a1 and b1 is 2, a1 is to the right of b1.
38+
/// </summary>
1839
VerticalR2 = 5,
1940

41+
/// <summary>
42+
/// Vertical r3 code word: relative distance between a1 and b1 is 3, a1 is to the right of b1.
43+
/// </summary>
2044
VerticalR3 = 6,
2145

46+
/// <summary>
47+
/// Vertical l1 code word: relative distance between a1 and b1 is 1, a1 is to the left of b1.
48+
/// </summary>
2249
VerticalL1 = 7,
2350

51+
/// <summary>
52+
/// Vertical l2 code word: relative distance between a1 and b1 is 2, a1 is to the left of b1.
53+
/// </summary>
2454
VerticalL2 = 8,
2555

56+
/// <summary>
57+
/// Vertical l3 code word: relative distance between a1 and b1 is 3, a1 is to the left of b1.
58+
/// </summary>
2659
VerticalL3 = 9,
2760

61+
/// <summary>
62+
/// 1d extensions code word, extension code is used to indicate the change from the current mode to another mode, e.g., another coding scheme.
63+
/// Not supported.
64+
/// </summary>
2865
Extensions1D = 10,
2966

67+
/// <summary>
68+
/// 2d extensions code word, extension code is used to indicate the change from the current mode to another mode, e.g., another coding scheme.
69+
/// Not supported.
70+
/// </summary>
3071
Extensions2D = 11,
3172
}
3273
}

src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1818
/// <remarks>
1919
/// Note that the 'OldDeflate' compression type is identical to the 'Deflate' compression type.
2020
/// </remarks>
21-
internal class DeflateTiffCompression : TiffBaseDecompressor
21+
internal sealed class DeflateTiffCompression : TiffBaseDecompressor
2222
{
2323
private readonly bool isBigEndian;
2424

src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1212
/// <summary>
1313
/// Class to handle cases where TIFF image data is compressed using LZW compression.
1414
/// </summary>
15-
internal class LzwTiffCompression : TiffBaseDecompressor
15+
internal sealed class LzwTiffCompression : TiffBaseDecompressor
1616
{
1717
private readonly bool isBigEndian;
1818

src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanBitReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1111
/// Bit reader for data encoded with the modified huffman rle method.
1212
/// See TIFF 6.0 specification, section 10.
1313
/// </summary>
14-
internal class ModifiedHuffmanBitReader : T4BitReader
14+
internal sealed class ModifiedHuffmanBitReader : T4BitReader
1515
{
1616
/// <summary>
1717
/// Initializes a new instance of the <see cref="ModifiedHuffmanBitReader"/> class.

src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanTiffCompression.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1212
/// <summary>
1313
/// Class to handle cases where TIFF image data is compressed using Modified Huffman Compression.
1414
/// </summary>
15-
internal class ModifiedHuffmanTiffCompression : T4TiffCompression
15+
internal sealed class ModifiedHuffmanTiffCompression : TiffBaseDecompressor
1616
{
1717
private readonly byte whiteValue;
1818

@@ -27,13 +27,19 @@ internal class ModifiedHuffmanTiffCompression : T4TiffCompression
2727
/// <param name="bitsPerPixel">The number of bits per pixel.</param>
2828
/// <param name="photometricInterpretation">The photometric interpretation.</param>
2929
public ModifiedHuffmanTiffCompression(MemoryAllocator allocator, TiffFillOrder fillOrder, int width, int bitsPerPixel, TiffPhotometricInterpretation photometricInterpretation)
30-
: base(allocator, fillOrder, width, bitsPerPixel, FaxCompressionOptions.None, photometricInterpretation)
30+
: base(allocator, width, bitsPerPixel)
3131
{
32+
this.FillOrder = fillOrder;
3233
bool isWhiteZero = photometricInterpretation == TiffPhotometricInterpretation.WhiteIsZero;
3334
this.whiteValue = (byte)(isWhiteZero ? 0 : 1);
3435
this.blackValue = (byte)(isWhiteZero ? 1 : 0);
3536
}
3637

38+
/// <summary>
39+
/// Gets the logical order of bits within a byte.
40+
/// </summary>
41+
private TiffFillOrder FillOrder { get; }
42+
3743
/// <inheritdoc/>
3844
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer)
3945
{
@@ -81,5 +87,10 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int
8187
}
8288
}
8389
}
90+
91+
/// <inheritdoc/>
92+
protected override void Dispose(bool disposing)
93+
{
94+
}
8495
}
8596
}

src/ImageSharp/Formats/Tiff/Compression/Decompressors/NoneTiffCompression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1111
/// <summary>
1212
/// Class to handle cases where TIFF image data is not compressed.
1313
/// </summary>
14-
internal class NoneTiffCompression : TiffBaseDecompressor
14+
internal sealed class NoneTiffCompression : TiffBaseDecompressor
1515
{
1616
/// <summary>
1717
/// Initializes a new instance of the <see cref="NoneTiffCompression" /> class.

src/ImageSharp/Formats/Tiff/Compression/Decompressors/PackBitsTiffCompression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1212
/// <summary>
1313
/// Class to handle cases where TIFF image data is compressed using PackBits compression.
1414
/// </summary>
15-
internal class PackBitsTiffCompression : TiffBaseDecompressor
15+
internal sealed class PackBitsTiffCompression : TiffBaseDecompressor
1616
{
1717
private IMemoryOwner<byte> compressedDataMemory;
1818

src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4BitReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ protected void Reset(bool resetRunLength = true)
438438
/// <returns>The value read.</returns>
439439
protected uint ReadValue(int nBits)
440440
{
441-
Guard.MustBeGreaterThan(nBits, 0, nameof(nBits));
441+
DebugGuard.MustBeGreaterThan(nBits, 0, nameof(nBits));
442442

443443
uint v = 0;
444444
int shift = nBits;

src/ImageSharp/Formats/Tiff/Compression/Decompressors/T4TiffCompression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1212
/// <summary>
1313
/// Class to handle cases where TIFF image data is compressed using CCITT T4 compression.
1414
/// </summary>
15-
internal class T4TiffCompression : TiffBaseDecompressor
15+
internal sealed class T4TiffCompression : TiffBaseDecompressor
1616
{
1717
private readonly FaxCompressionOptions faxCompressionOptions;
1818

@@ -51,7 +51,7 @@ public T4TiffCompression(
5151
/// <summary>
5252
/// Gets the logical order of bits within a byte.
5353
/// </summary>
54-
protected TiffFillOrder FillOrder { get; }
54+
private TiffFillOrder FillOrder { get; }
5555

5656
/// <inheritdoc/>
5757
protected override void Decompress(BufferedReadStream stream, int byteCount, int stripHeight, Span<byte> buffer)

0 commit comments

Comments
 (0)