FayWang-MSFT avatar image
0 Votes"
FayWang-MSFT asked FayWang-MSFT commented

[UWP] Using GetThumbnailAsync() sometimes will not preserve a gif transparency on its thumbnail

Source link:

I'm developing an application and there is a page that we need to show a preview list of images from a folder.

I'm using the StorageFile.GetThumbnailAsync method to retrieve the thumbnail, but for some gif files it will not preserve the background transparency.

 var thumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem);
 BitmapImage bitmapImage = new BitmapImage();
 await bitmapImage.SetSourceAsync(thumbnail);

I could not find a pattern for this behavior and it seems to be something related to Windows. On Windows Explorer, some gif files show the background as white and some as black, although they were created using the same lib.

When I open and show the gif file it works fine, only the thumbnail that comes with the black background.

Does anyone have any idea what could be causing that?

I've attached some images below of a sample app that I used to isolate the issue.

alt text
alt text
alt text

Here are the three pictures that can cause the same issue.

pic1.jpg (516.7 KiB)
pic2.jpg (443.5 KiB)
pic3.jpg (447.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Based on the three gif files, it indeed shows the black background in the thumbnail. And I wonder what lib you used to create these gif files? In addition, if possible, you can check the background image layers from the gif to see if there is any difference between them.

0 Votes 0 ·

0 Answers