[Thumbnail providers] Cover errors and edge cases (#23947)

* [Thumbnail providers] Cover errors and edge cases

* Add TODO comment

* Fix tests
This commit is contained in:
Stefan Markovic
2023-02-07 21:11:31 +01:00
committed by GitHub
parent c180150d54
commit 53f0b00328
16 changed files with 104 additions and 73 deletions

View File

@@ -130,19 +130,10 @@ namespace Microsoft.PowerToys.ThumbnailHandler.Stl
return null;
}
using (var memStream = new MemoryStream())
Bitmap thumbnail = GetThumbnail(this.Stream, cx);
if (thumbnail != null && thumbnail.Size.Width > 0 && thumbnail.Size.Height > 0)
{
this.Stream.CopyTo(memStream);
memStream.Position = 0;
using (Bitmap thumbnail = GetThumbnail(memStream, cx))
{
if (thumbnail != null && thumbnail.Size.Width > 0 && thumbnail.Size.Height > 0)
{
return (Bitmap)thumbnail.Clone();
}
}
return thumbnail;
}
return null;