dont create a bitmapimage for gifs

This commit is contained in:
bluepilledgreat 2024-10-19 21:36:48 +01:00
parent 23d8bb1aaa
commit 605db3cc0f

View File

@ -523,21 +523,25 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
if (result == null) if (result == null)
throw new Exception("Image Source uri is null"); throw new Exception("Image Source uri is null");
BitmapImage bitmapImage;
try
{
bitmapImage = new BitmapImage(result);
}
catch (Exception ex)
{
throw new Exception($"Image Failed to create BitmapImage: {ex.Message}", ex);
}
bool isAnimated = ParseXmlAttribute<bool>(xmlElement, "IsAnimated", false); bool isAnimated = ParseXmlAttribute<bool>(xmlElement, "IsAnimated", false);
if (!isAnimated) if (!isAnimated)
{
BitmapImage bitmapImage;
try
{
bitmapImage = new BitmapImage(result);
}
catch (Exception ex)
{
throw new Exception($"Image Failed to create BitmapImage: {ex.Message}", ex);
}
image.Source = bitmapImage; image.Source = bitmapImage;
else // we create the bitmapimage to check if the gif is valid }
else
{
XamlAnimatedGif.AnimationBehavior.SetSourceUri(image, result); XamlAnimatedGif.AnimationBehavior.SetSourceUri(image, result);
}
} }
ApplyTransformations_UIElement(image, xmlElement); ApplyTransformations_UIElement(image, xmlElement);