Browse Source
Apply suggestions from code review
Co-authored-by: Günther Foidl <gue@korporal.at>
pull/1747/head
Brian Popow
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
6 additions and
6 deletions
-
src/ImageSharp/Formats/Tiff/Compression/Decompressors/ModifiedHuffmanBitReader.cs
-
src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6BitReader.cs
-
src/ImageSharp/Formats/Tiff/Compression/Decompressors/T6TiffCompression.cs
|
|
|
@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override bool HasMoreData => this.Position < (ulong)this.DataLength - 1 || (this.BitsRead > 0 && this.BitsRead < 7); |
|
|
|
public override bool HasMoreData => this.Position < (ulong)this.DataLength - 1 || ((uint)(this.BitsRead - 1) < (7 - 1)); |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override bool IsEndOfScanLine |
|
|
|
@ -53,8 +53,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors |
|
|
|
{ |
|
|
|
base.StartNewRow(); |
|
|
|
|
|
|
|
int pad = 8 - (this.BitsRead % 8); |
|
|
|
if (pad != 8) |
|
|
|
int remainder = this.BitsRead & 7; // bit-hack for % 8
|
|
|
|
if (remainder != 0) |
|
|
|
{ |
|
|
|
// Skip padding bits, move to next byte.
|
|
|
|
this.Position++; |
|
|
|
|
|
|
|
@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override bool HasMoreData => this.Position < (ulong)this.DataLength - 1 || (this.BitsRead > 0 && this.BitsRead < 7); |
|
|
|
public override bool HasMoreData => this.Position < (ulong)this.DataLength - 1 || ((uint)(this.BitsRead - 1) < (7 - 1)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the two dimensional code.
|
|
|
|
|
|
|
|
@ -84,8 +84,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors |
|
|
|
} |
|
|
|
|
|
|
|
// Write padding bytes, if necessary.
|
|
|
|
uint pad = 8 - (bitsWritten % 8); |
|
|
|
if (pad != 8) |
|
|
|
uint remainder = bitsWritten % 8; |
|
|
|
if (remainder != 0) |
|
|
|
{ |
|
|
|
BitWriterUtils.WriteBits(buffer, (int)bitsWritten, pad, 0); |
|
|
|
bitsWritten += pad; |
|
|
|
|