diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T4BitCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T4BitCompressor.cs index 0c296cb9d9..d038e9c8bf 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T4BitCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T4BitCompressor.cs @@ -21,16 +21,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors /// /// Initializes a new instance of the class. /// - /// The output. - /// The allocator. - /// The width. + /// The output stream to write the compressed data. + /// The memory allocator. + /// The width of the image. /// The bits per pixel. /// Indicates if the modified huffman RLE should be used. public T4BitCompressor(Stream output, MemoryAllocator allocator, int width, int bitsPerPixel, bool useModifiedHuffman = false) - : base(output, allocator, width, bitsPerPixel) - { - this.useModifiedHuffman = useModifiedHuffman; - } + : base(output, allocator, width, bitsPerPixel) => this.useModifiedHuffman = useModifiedHuffman; /// public override TiffCompression Method => this.useModifiedHuffman ? TiffCompression.Ccitt1D : TiffCompression.CcittGroup3Fax; diff --git a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs index 1741440103..9e03d2764a 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Compressors/T6BitCompressor.cs @@ -15,9 +15,9 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors internal sealed class T6BitCompressor : TiffCcittCompressor { /// - /// Vertical codes from -3 to +3 + /// Vertical codes from -3 to +3. /// - private static readonly (uint Length, uint Code)[] VerticalCodes = new[] + private static readonly (uint Length, uint Code)[] VerticalCodes = { (7u, 3u), (6u, 3u), @@ -30,6 +30,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors private IMemoryOwner referenceLineBuffer; + /// + /// Initializes a new instance of the class. + /// + /// The output stream to write the compressed data. + /// The memory allocator. + /// The width of the image. + /// The bits per pixel. public T6BitCompressor(Stream output, MemoryAllocator allocator, int width, int bitsPerPixel) : base(output, allocator, width, bitsPerPixel) { @@ -39,14 +46,14 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors public override TiffCompression Method => TiffCompression.CcittGroup4Fax; /// - /// Writes a image compressed with CCITT T4 to the output buffer. + /// Writes a image compressed with CCITT T6 to the output buffer. /// /// The pixels as 8-bit gray array. /// The strip height. /// The destination for the compressed data. protected override void CompressStrip(Span pixelsAsGray, int height, Span compressedData) { - // Initial reference line is all white + // Initial reference line is all white. Span referenceLine = this.referenceLineBuffer.GetSpan(); referenceLine.Fill(0xff); @@ -62,7 +69,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors uint b2 = this.FindRunEnd(referenceLine, b1); if (b2 < a1) { - // pass mode + // Pass mode. this.WriteCode(4, 1, compressedData); a0 = b2; } @@ -80,14 +87,14 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors if ((d >= -3) && (d <= 3)) { - // vertical mode + // Vertical mode. (uint length, uint code) = VerticalCodes[d + 3]; this.WriteCode(length, code, compressedData); a0 = a1; } else { - // Horizontal mode + // Horizontal mode. this.WriteCode(3, 1, compressedData); uint a2 = this.FindRunEnd(row, a1); @@ -117,7 +124,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors b1 = this.FindRunEnd(referenceLine, b1, thisPixel); } - // This row is now the reference line + // This row is now the reference line. row.CopyTo(referenceLine); } @@ -169,11 +176,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors } /// - /// Writes a run to the output buffer + /// Writes a run to the output buffer. /// - /// The length of the run + /// The length of the run. /// If true the run is white pixels, - /// if false the run is black pixels + /// if false the run is black pixels. /// The destination to write the run to. private void WriteRun(uint runLength, bool isWhiteRun, Span compressedData) {