mirror of https://github.com/SixLabors/ImageSharp
Browse Source
* PBM decoder robustness improvements and BufferedReadStream observability Backport of #2551 & #2552 * Remove DoesNotReturn attribute --------- Co-authored-by: James Jackson-South <james_south@hotmail.com>pull/2717/head
committed by
GitHub
11 changed files with 256 additions and 62 deletions
@ -0,0 +1,39 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.IO; |
|||
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