Browse Source

Fix read count.

pull/1574/head
James Jackson-South 6 years ago
parent
commit
0ff69248ec
  1. 2
      src/ImageSharp/IO/ChunkedMemoryStream.cs
  2. 11
      tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs

2
src/ImageSharp/IO/ChunkedMemoryStream.cs

@ -295,7 +295,7 @@ namespace SixLabors.ImageSharp.IO
} }
int readCount = Math.Min(count, chunkSize - this.readOffset); int readCount = Math.Min(count, chunkSize - this.readOffset);
chunkBuffer.Slice(this.readOffset, count).CopyTo(buffer.Slice(offset)); chunkBuffer.Slice(this.readOffset, readCount).CopyTo(buffer.Slice(offset));
offset += readCount; offset += readCount;
count -= readCount; count -= readCount;
this.readOffset += readCount; this.readOffset += readCount;

11
tests/ImageSharp.Tests/IO/ChunkedMemoryStreamTests.cs

@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp.Tests.IO
public static TheoryData<string> GetAllTestImages() public static TheoryData<string> GetAllTestImages()
{ {
IEnumerable<string> allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories) IEnumerable<string> allImageFiles = Directory.EnumerateFiles(TestEnvironment.InputImagesDirectoryFullPath, "*.*", SearchOption.AllDirectories)
.Where(s => !s.ToLower().EndsWith("txt")); .Where(s => !s.EndsWith("txt", StringComparison.OrdinalIgnoreCase));
var result = new TheoryData<string>(); var result = new TheoryData<string>();
foreach (string path in allImageFiles) foreach (string path in allImageFiles)
{ {
@ -314,7 +314,12 @@ namespace SixLabors.ImageSharp.Tests.IO
[MemberData(nameof(GetAllTestImages))] [MemberData(nameof(GetAllTestImages))]
public void DecoderIntegrationTest(string testFileFullPath) public void DecoderIntegrationTest(string testFileFullPath)
{ {
Image<Rgba32> expected = null; if (!TestEnvironment.Is64BitProcess)
{
return;
}
Image<Rgba32> expected;
try try
{ {
expected = Image.Load<Rgba32>(testFileFullPath); expected = Image.Load<Rgba32>(testFileFullPath);
@ -326,7 +331,7 @@ namespace SixLabors.ImageSharp.Tests.IO
} }
using FileStream fs = File.OpenRead(testFileFullPath); using FileStream fs = File.OpenRead(testFileFullPath);
using NonSeekableStream nonSeekableStream = new NonSeekableStream(fs); using var nonSeekableStream = new NonSeekableStream(fs);
var actual = Image.Load<Rgba32>(nonSeekableStream); var actual = Image.Load<Rgba32>(nonSeekableStream);

Loading…
Cancel
Save