Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PNG loading issues by updating the zlib to one with fixes #2045

Merged
merged 8 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion externals/skia
Submodule skia updated 1 files
+1 −1 DEPS
Binary file added tests/Content/images/osm-liberty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/Content/images/testimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions tests/Tests/SKBitmapTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -705,5 +705,19 @@ public void SetPixelWritesTheColor()

Assert.Equal(expectedPixels, bitmap.Pixels);
}

[SkippableTheory]
[InlineData("osm-liberty.png")]
[InlineData("testimage.png")]
public void CanDecodePotentiallyCorruptPngFiles(string filename)
{
var path = Path.Combine(PathToImages, filename);

var bytes = File.ReadAllBytes(path);
using var data = SKData.CreateCopy(bytes);
using var bitmap = SKBitmap.Decode(data);

Assert.NotNull(bitmap);
}
}
}
14 changes: 14 additions & 0 deletions tests/Tests/SKImageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,5 +942,19 @@ protected override bool OnUseEncodedData(IntPtr data, IntPtr length)
return false;
}
}

[SkippableTheory]
[InlineData("osm-liberty.png", 30, 240, 0xFF725A50)]
[InlineData("testimage.png", 1040, 340, 0xFF0059FF)]
public void CanDecodePotentiallyCorruptPngFiles(string filename, int x, int y, uint color)
{
var path = Path.Combine(PathToImages, filename);

using var image = SKImage.FromEncodedData(path);
using var actualImage = image.ToRasterImage(true);
using var pixmap = actualImage.PeekPixels();

Assert.Equal((SKColor)color, pixmap.GetPixelColor(x, y));
}
}
}