James Jackson-South
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
20 additions and
4 deletions
-
src/ImageSharp/Formats/Png/PngDecoderCore.cs
-
src/ImageSharp/Processing/Processors/Drawing/DrawImageProcessor{TPixelBg,TPixelFg}.cs
-
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Png/issues/Issue_2666.png
|
|
|
@ -1874,8 +1874,13 @@ internal sealed class PngDecoderCore : IImageDecoderInternals |
|
|
|
PngChunkType type = this.ReadChunkType(buffer); |
|
|
|
|
|
|
|
// If we're reading color metadata only we're only interested in the IHDR and tRNS chunks.
|
|
|
|
// We can skip all other chunk data in the stream for better performance.
|
|
|
|
if (this.colorMetadataOnly && type != PngChunkType.Header && type != PngChunkType.Transparency && type != PngChunkType.Palette) |
|
|
|
// We can skip most other chunk data in the stream for better performance.
|
|
|
|
if (this.colorMetadataOnly && |
|
|
|
type != PngChunkType.Header && |
|
|
|
type != PngChunkType.Transparency && |
|
|
|
type != PngChunkType.Palette && |
|
|
|
type != PngChunkType.AnimationControl && |
|
|
|
type != PngChunkType.FrameControl) |
|
|
|
{ |
|
|
|
chunk = new PngChunk(length, type); |
|
|
|
return true; |
|
|
|
|
|
|
|
@ -98,9 +98,10 @@ internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg> |
|
|
|
top = 0; |
|
|
|
} |
|
|
|
|
|
|
|
// clamp the height/width to the availible space left to prevent overflowing
|
|
|
|
// Clamp the height/width to the available space left to prevent overflowing
|
|
|
|
foregroundRectangle.Width = Math.Min(source.Width - left, foregroundRectangle.Width); |
|
|
|
foregroundRectangle.Height = Math.Min(source.Height - top, foregroundRectangle.Height); |
|
|
|
foregroundRectangle = Rectangle.Intersect(foregroundRectangle, this.ForegroundImage.Bounds); |
|
|
|
|
|
|
|
int width = foregroundRectangle.Width; |
|
|
|
int height = foregroundRectangle.Height; |
|
|
|
@ -111,7 +112,6 @@ internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg> |
|
|
|
} |
|
|
|
|
|
|
|
// Sanitize the dimensions so that we don't try and sample outside the image.
|
|
|
|
foregroundRectangle = Rectangle.Intersect(foregroundRectangle, this.ForegroundImage.Bounds); |
|
|
|
Rectangle backgroundRectangle = Rectangle.Intersect(new(left, top, width, height), this.SourceRectangle); |
|
|
|
Configuration configuration = this.Configuration; |
|
|
|
|
|
|
|
|
|
|
|
@ -665,4 +665,11 @@ public partial class PngDecoderTests |
|
|
|
Assert.True(eofHitCounter.EofHitCount <= 3); |
|
|
|
Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Decode_Issue2666() |
|
|
|
{ |
|
|
|
string path = Path.GetFullPath(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Png.Issue2666)); |
|
|
|
using Image image = Image.Load(path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -73,6 +73,7 @@ public static class TestImages |
|
|
|
public const string DisposeBackgroundRegion = "Png/animated/15-dispose-background-region.png"; |
|
|
|
public const string DisposePreviousFirst = "Png/animated/12-dispose-prev-first.png"; |
|
|
|
public const string BlendOverMultiple = "Png/animated/21-blend-over-multiple.png"; |
|
|
|
public const string Issue2666 = "Png/issues/Issue_2666.png"; |
|
|
|
|
|
|
|
// Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
|
|
|
|
public const string Filter0 = "Png/filter0.png"; |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:ed7665cdfd5fad00c5995040350a254b96af6c0c95ab13975f2291e9d3fce0f3 |
|
|
|
size 8244837 |