avaloniaui / avalonia.gif Goto Github PK
View Code? Open in Web Editor NEWGIF image renderer and player for Avalonia UI Framework
License: MIT License
GIF image renderer and player for Avalonia UI Framework
License: MIT License
Hi,
So I'm trying to load GIF images over URL and File streams and I keep getting InvalidGifStreamException("Not a GIF stream."); exceptions.
Sample code:
var imgStream = File.OpenRead(imageName);
_gifImage.SourceStream = imgStream;
Test GIF
https://github.com/AvaloniaUI/Avalonia.GIF/blob/master/AvaloniaGif.Demo/Images/c-loader.gif
Been Compiling with .NET Core 3.1
Will GIF streams from these sources (and potentially more) be supported?
o(╥﹏╥)o neeed 11.0.0-preview7
If a static image (e.g. png or jpeg) is loaded, a InvalidGifStreamException (Not a GIF stream.) is thrown.
Instead of throwing an exception, it should just display a static image.
Would love to see this published as a nuget package (at least until support is native in Avalonia)
A missing method exception is thrown when using the library. I'm using the RC1 branch:
<gif:GifImage
Width="300"
Height="300"
SourceUri="avares://My App/Assets/Images/Logo.gif" />
This is the error:
System.MissingMethodException: 'Method not found: 'Void Avalonia.Rendering.Composition.CompositionVisual.set_Size(System.Numerics.Vector2)'.'
When using SourceUriRaw, the exception is thrown everytime meanwhile SoureUri only throws the exception when the avalonia resource has been found.
Hello. I'm using your library in my Avalonia project and I stumbled upon an optimization problem. I need to display many gifs from the same file. Displaying around 10-20 gifs is fine, but when i try 50+, my CPU usage rises tremendously. Do you have any advice on how to overcome this problem?
http=>https more secure
I'm working on getting a consistent exception, but it seems like this fails in various ways from hard hanging visual studio when running it under a debugger to segfaults when running it on linux and others. I'll update this if I get more solid exceptions, but in general I believe there is something wrong with the 'changing' of streams. (I'm guessing something in here possibly, but not sure: private static void SourceChanged(AvaloniaPropertyChangedEventArgs e)
I tried adding:
if ((image.gifInstance != null) && (image.gifInstance.Stream != null))
{
image.gifInstance.Stream?.Close();
image.gifInstance.Stream?.Dispose();
}
to see if I could clean up streams I was using..when I'd close the stream on the outside I'd often get exceptions because the stream was in use in the animated gif control. (if there's a way to stop it that may help me).
I also tried just removing the control and then recreating it, but I don't think that was working either...I was simply removing it from the logical tree, so probably leaking controls.
I've been able to repro it with the demo app by simply using the arrow keys and going up and down fairly quickly to force the stream to change. I full screen the app, not sure if that's helpful.. Eventually the app shuts down and visual studio doesn't always catch it.
In my use case I'm making a full screen digital picture display (Dynaframe) that currently shows images and videos. I've had alot of people ask me to play animated gifs as well, so trying to get that in. When it works it's beauitful, I can crossfade the gifs. But on my raspberry pi I get a segfault within about an hour and a half, and on my windows PC I get a crash after 6 hours or so (transitioning images every 10 seconds). The memory usage doesn't climb so I don't think it's a leak, at least not one I'm seeing.
My code looks like the following: (foregroundimage and background image are image controls. gifImage is a xaml control called 'gifImage' in the xaml. ImageString is a path to an animated .gif on a system. It plays through all of the gifs several times over, so I don't believe it's a bad file.
I've reprod this on windows 10 64 bit and a raspberry pi (debian arm 32 bit) running Avalonia 10.12. I've repro'd it in my own code using file streams as well as in the demo code which uses resources.
The xaml:
<gif:GifImage x:Name="gifImage" />
The codebehind:
private void ShowAnimatedGif()
{
try
{
ImageStream = File.OpenRead(ImageString);
ImageStream.Seek(0, SeekOrigin.Begin);
gifImage.SourceStream = ImageStream;
gifImage.Stretch = foregroundImage.Stretch;
gifImage.Opacity = 1;
foregroundImage.Opacity = 0;
backgroundImage.Opacity = 0;
}
catch (Exception exc)
{
Logger.LogComment("Exception Rendering animated GIF: " + exc.ToString());
}
}
I've tried to figure it outmyself but the crash is often in the decoder code and it'll take me quite a bit to ramp up on that and the gif image format. Hoping someone with more experience in this control can repro it and help me get this working.
Huge thanks for your time and for a great control...when it works it's beautiful :)
Missing _bitmapSync property on GifInstance.cs
On Mar 26, #11 was merged which removed the line private readonly object _bitmapSync = new object();
in GifInstance. However, _bitmapSync
is still being referenced in code
Many dynamic images are now in apng format.
I have tried to support but don't know how to overlay and render.
I'm looking to integrate this into my current codebase as I update to Avalonia 11. Is the open PR the right branch to pull or can we please get that integrated so I can test it out? This is a big feature for the users fo Dynaframe :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.