mirror of https://github.com/SixLabors/ImageSharp
Browse Source
* handle premature EOF in the PBM decoder * BufferedReadStreamExtensions: remove the 'Try' prefix * count EOF hits in BufferedReadStream * use EofHitCounter in pbm tests * Naming convention tweaks --------- Co-authored-by: James Jackson-South <james_south@hotmail.com>pull/2552/head
committed by
GitHub
11 changed files with 253 additions and 49 deletions
@ -0,0 +1,36 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.IO; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.TestUtilities; |
|||
|
|||
internal class EofHitCounter : IDisposable |
|||
{ |
|||
private readonly BufferedReadStream stream; |
|||
|
|||
public EofHitCounter(BufferedReadStream stream, Image image) |
|||
{ |
|||
this.stream = stream; |
|||
this.Image = image; |
|||
} |
|||
|
|||
public int EofHitCount => this.stream.EofHitCount; |
|||
|
|||
public Image Image { get; private set; } |
|||
|
|||
public static EofHitCounter RunDecoder(string testImage) => RunDecoder(TestFile.Create(testImage).Bytes); |
|||
|
|||
public static EofHitCounter RunDecoder(byte[] imageData) |
|||
{ |
|||
BufferedReadStream stream = new(Configuration.Default, new MemoryStream(imageData)); |
|||
Image image = Image.Load(stream); |
|||
return new EofHitCounter(stream, image); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
this.stream.Dispose(); |
|||
this.Image.Dispose(); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
version https://git-lfs.github.com/spec/v1 |
|||
oid sha256:39cf6ca5b2f9d428c0c33e0fc7ab5e92c31e0c8a7d9e0276b9285f51a8ff547c |
|||
size 69 |
|||
Loading…
Reference in new issue