Browse Source

Merge branch 'main' into bp/tiff-jpeg-cmyk

pull/2937/head
James Jackson-South 11 months ago
committed by GitHub
parent
commit
5fdbe7b4b2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      src/ImageSharp/IO/BufferedReadStream.cs
  2. 6
      src/ImageSharp/IO/ChunkedMemoryStream.cs

21
src/ImageSharp/IO/BufferedReadStream.cs

@ -69,7 +69,7 @@ internal sealed class BufferedReadStream : Stream
} }
/// <summary> /// <summary>
/// Gets the number indicating the EOF hits occured while reading from this instance. /// Gets the number indicating the EOF hits occurred while reading from this instance.
/// </summary> /// </summary>
public int EofHitCount { get; private set; } public int EofHitCount { get; private set; }
@ -213,20 +213,13 @@ internal sealed class BufferedReadStream : Stream
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Seek(long offset, SeekOrigin origin) public override long Seek(long offset, SeekOrigin origin)
{ {
switch (origin) this.Position = origin switch
{ {
case SeekOrigin.Begin: SeekOrigin.Begin => offset,
this.Position = offset; SeekOrigin.Current => this.Position + offset,
break; SeekOrigin.End => this.Length + offset,
_ => throw new ArgumentOutOfRangeException(nameof(offset)),
case SeekOrigin.Current: };
this.Position += offset;
break;
case SeekOrigin.End:
this.Position = this.Length - offset;
break;
}
return this.readerPosition; return this.readerPosition;
} }

6
src/ImageSharp/IO/ChunkedMemoryStream.cs

@ -76,9 +76,9 @@ internal sealed class ChunkedMemoryStream : Stream
this.Position = origin switch this.Position = origin switch
{ {
SeekOrigin.Begin => (int)offset, SeekOrigin.Begin => offset,
SeekOrigin.Current => (int)(this.Position + offset), SeekOrigin.Current => this.Position + offset,
SeekOrigin.End => (int)(this.Length + offset), SeekOrigin.End => this.Length + offset,
_ => throw new ArgumentOutOfRangeException(nameof(offset)), _ => throw new ArgumentOutOfRangeException(nameof(offset)),
}; };

Loading…
Cancel
Save