SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] Corrupted Image when loading from network stream, with 2.88.2.

Open bymin opened this issue 3 years ago • 0 comments

Description

It rendered corrupted image when loading from network stream. It works fine in 2.80.2, not working in the current one 2.88.2. The following code can simply recreate it.

Code // Below is the complete test code in VS2022 on .NET 6

using System.Net; using SkiaSharp;

await DownloadTile("https://tile.openstreetmap.org/1/0/0.png", @"d:\test\test.png");

static async Task DownloadTile(string uri, string path) {

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.UserAgent = "agent";

using var webResponse = await request.GetResponseAsync(); await using var input = webResponse.GetResponseStream();

await using var output = File.Create(path); var bitmap = SKBitmap.Decode(input);

using var skImage = SKImage.FromBitmap(bitmap); var skData = skImage.Encode(SKEncodedImageFormat.Png, 80); skData.SaveTo(output); }

Expected Behavior

The tile https://tile.openstreetmap.org/1/0/0.png is saved to d:\test\test.png

Actual Behavior

The tile generated in d:\test\test.png is corrupted, only part of the image can be seen. V2.80.2 doesn't have this issue.

Basic Information Version with issue: 2.88.2 Last known good version: 2.80.2 IDE: Visual Studio 2022 Platform Target Frameworks: Tested in .NET Framework 4.8 and .NET 6 Target Devices: Windows Console.

Screenshots image

bymin avatar Sep 09 '22 19:09 bymin