Giter Site home page Giter Site logo

xamlanimatedgif / wpfanimatedgif Goto Github PK

View Code? Open in Web Editor NEW
637.0 27.0 121.0 1.79 MB

A simple library to display animated GIF images in WPF, usable in XAML or in code.

License: Apache License 2.0

C# 99.70% Batchfile 0.30%
hacktoberfest wpf animated gif

wpfanimatedgif's Introduction

WPF Animated GIF

NuGet version AppVeyor build

Nuget package available here: WpfAnimatedGif.

A simple library to display animated GIF images in WPF, usable in XAML or in code.

It's very easy to use: in XAML, instead of setting the Source property, set the AnimatedSource attached property to the image you want:

<Window x:Class="WpfAnimatedGif.Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:gif="http://wpfanimatedgif.codeplex.com"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" />

You can also specify the repeat behavior (the default is 0x, which means it will use the repeat count from the GIF metadata):

        <Image gif:ImageBehavior.RepeatBehavior="3x"
               gif:ImageBehavior.AnimatedSource="Images/animated.gif" />

And of course you can also set the image in code:

var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(fileName);
image.EndInit();
ImageBehavior.SetAnimatedSource(img, image);

See the wiki for more details on usage.

Features

  • Animates GIF images in a normal Image control; no need to use a specific control
  • Takes actual frame duration into account
  • Repeat behavior can be specified; if unspecified, the repeat count from the GIF metadata is used
  • Notification when the animation completes, in case you need to do something after the animation
  • Animation preview in design mode (must be enabled explicitly)
  • Support for controlling the animation manually (pause/resume/seek)

How to build

Run build.cmd.

Note: the library's version number is determined by MinVer based on Git history and tags. A consequence of this is that if you build the project outside a Git repository (e.g. if you just download sources), you'll get a version number of 0.0.0.0. So, in order to build with the correct version number, make sure you're in a Git clone of the project, and that your clone has the tags from the upstream project (git fetch upstream --tags, assuming your remote for the upstream project is named upstream).

wpfanimatedgif's People

Contributors

dhritzkiv avatar dmitriishamrikov avatar ericvf avatar khersonit avatar kikos0 avatar thomaslevesque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wpfanimatedgif's Issues

Pause/Resume on visibility changed

Hi,

As far as I can tell the animation keeps running in the background even when the image is not visible.
Would it be possible to pause and resume the animation when the image visibility changes?

I would be willing to create a PR for this, if you agree with the change.

RepeatBehavior does not exist in current context

I'm trying to understand why RepeatBehavior isn't in the current context. Simple code with WpfanimatedGif referenced in Project, and "using WpfanimatedGif" included also. Code is:
#region Create Loading graphic

    public void workingIndicator()
    {

        var image = new BitmapImage();
        image.BeginInit();
        image.UriSource = new Uri(@Globals.fileName, UriKind.Relative);
        image.EndInit();
        ImageBehavior.SetAnimatedSource(Working, image);
        ImageBehavior.SetRepeatBehavior(Working, new RepeatBehavior(0));
        ImageBehavior.SetRepeatBehavior(Working, RepeatBehavior.forever);

    }

    #endregion Create Loading Graphic

I did rebuild the WpfanimatedGif project to use dotnet4.0 and had to add System.Xaml as a Reference.
fileName is a static Global variable that I use to change the animated Gif based on my Project code.

If I comment out this code, the first animated Gif runs 1 time and stops. Your thoughts would be greatly appreciated. Thanks in advance.

Async way to set animation source

This library is a true lifesaver. But i'm having one issue:
Loading a large GIF (example) freezes the entire UI thread for multiple seconds. I tried setting the image as invisible until the AnimationLoaded event triggers, but that doesn't help either.

The best solution to avoid such problems would probably be to have an async method to set the animated source (SetAnimatedSourceAsync). The method would do all the animation initialization beforehand in an async manner and set the Image Source when the animation loading is completed. With async/await a user would just call and await the method. No hangs and no need to deal with events like AnimationLoaded either.

Content ActualWidth & Height zero

I'm using a control called, ZoomAndPanControl - http://www.codeproject.com/Articles/85603/A-WPF-custom-control-for-zooming-and-panning - I added my branch of his work here at GibHub - https://github.com/ChuckSavage/ZoomAndPanControl

The xaml looks like this
ScrollViewer
ZoomAndPanControl
Grid
Image

When I use the Image's Source, ZoomAndPanControl can use its content.ActualWidth & content.ActualHeight

But when I use gif:ImageBehavoir.AnimatedSource content.ActualWidth & content.ActualHeight (https://github.com/ChuckSavage/ZoomAndPanControl/blob/master/ZoomAndPanControl.cs#L522) are zero. Any idea what could be causing this?

Otherwise, this is a really cool libary - thanks for the hard work

Strong named?

Trying to use this in a VS extension, but that requires the dll to be strong named - is that available?

Binding RepeatBehavior

Hi,
I am trying to bind the RepeatBehavior parameter to a view model property like this:

    <Image Stretch="None" gif:ImageBehavior.RepeatBehavior="Forever">
        <Image.Style>
            <Style TargetType="Image">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=HasInvalid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="False">
                        <Setter Property="gif:ImageBehavior.AnimatedSource" Value="pack://application:,,,/Resources/a.png" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=HasInvalid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="True">
                        <Setter Property="gif:ImageBehavior.AnimatedSource" Value="pack://application:,,,/Resources/b.gif" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=AnimateInvalid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="False">
                        <Setter Property="gif:ImageBehavior.RepeatBehavior" Value="1x" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=AnimateInvalid, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="True">
                        <Setter Property="gif:ImageBehavior.RepeatBehavior" Value="Forever" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Image.Style>
    </Image>

I see the property changing but the animation doesn't stop.
What am I missing?

Cannot find Resource, when uppercase letter in path

Ahoy,
i've found bug where, you get System.IO.IOException resource not found, when your path to gif contains uppercase letter( in both XAML and code).
I've made the directory and gif lowercase as workaround, but i would be fancy, if you change this one thing ;)

Thanks.

Gif not shown in .NET 4.7.2

I tried to use the nuget in a project that targets .NET4.7.2 and the chosen gif is not shown.
When I tried it in 4.5.0 it worked.

Edited GIF causing error.

I implemented the API and it is working fine so far. I edited a gif file online to reverse it/ make it slower the edited gif is somehow not playing.

Original GIF

Edited GIF

When changing the source to the edited gif my window is crashing while loading:
System.Runtime.InteropServices.COMException: "MILERR_WIN32ERROR (Ausnahme von HRESULT: 0x88980003)"

(I could reproduce this problem when editing other gifs)

PS: I also tried the newer XamlAnimatedGif API but the performance was just to bad to use it on WPF+Windows10

Hide then Show again, animation no longer works

I'm setting an Image visible when I launch a background worker and using an animated gif in it and hiding it when the work completes. It works great the first time through, but if I click the "do work" button again when the image is set visible again the animation doesn't work. The only remarkable thing I'm doing in between is re-setting the UriSource of the image.

Is this a bug or am I doing something wrong?

Event OnAnimationStartsOver / StopAtCycleEnd()

Hi there,
what about an "OnAnimationStartsOver" Event for the ImageAnimationController, so that anyone can catch a finished animation to break. Or allow to set the RepeatBehavior to NO_REPEAT, so that then the animation will be stopped after it finished cycling.
Or at simplest: Just let the ImageAnimationController have a method like "StopAtCycleEnd()".

Would be nice to have this, to properly break animation upon the animation end. :)

Filestream error

Hi,
Thanks for sharing your wpf gif library.

I've a problem. When I writing gif file in second time with IO.Filestream , this code below give me an Error because the gif file is launched with another program.

Code :
gifImage.BeginInit();
gifImage.UriSource = new Uri(path);
gifImage.EndInit();
ImageBehavior.SetAnimatedSource(photosGif_finale, gifImage);

What methods should i use to stop this reference for pushing another new gif?
I hope is clear, sorry for my bad english.

Thanks.

v1.5 roadmap question

I need the new feature from v1.5 but this is only beta version.
When is the planned release of the stable version?

Exception from F# WPF

I'm getting this exception

Cannot set unknown member '{http://wpfanimatedgif.codeplex.com}ImageBehavior.AnimatedSource'."}
	System.Exception {System.Xaml.XamlObjectWriterException}

I'm in F# App.fs at startup

[<STAThread>]
[<EntryPoint>]
let main argv =
    try
        if SynchronizationContext.Current = null then
            DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)
            |> SynchronizationContext.SetSynchronizationContext

and the xaml is the standard

xmlns:gif="http://wpfanimatedgif.codeplex.com"
...
<Image gif:ImageBehavior.AnimatedSource="gif\spinner1.gif"  ...

File getting locked

I am using XamlAnimatedGif to play different GIFs, which I am creating through code. I am creating a unique file every time a GIF is to be played and hence the GIF player will play one GIF only once. So, in the process, I created say 10 GIFs, and previewed them as well. And every GIF successfully raised AnimationCompleted event. Post this event is raised, I am trying to delete the file from my hard disk. But there is a lock on the file.
My XAML looks like below, where the binded path property keeps on changing on everytime I create and preview a new GIF:

<Image gif:ImageBehavior.AnimatedSource="{Binding GifImagePath}"
       gif:ImageBehavior.AutoStart="true" 
       gif:ImageBehavior.RepeatBehavior="{Binding RepeatBehavior}"
       gif:ImageBehavior.AnimationCompleted="AnimationCompleted">

Out of memory exception in v1.4.9

I am getting following exception randomly when I create random number of instances (less than 25) of a custom control with WpfAnimatedGif control. Exception stack trace below, highlighted some lines.

at System.Windows.Media.Imaging.BitmapSource.CreateCachedBitmap(BitmapFrame frame, BitmapSourceSafeMILHandle wicSource, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, BitmapPalette palette)
at System.Windows.Media.Imaging.RenderTargetBitmap.CopyCommon(RenderTargetBitmap sourceBitmap)
at System.Windows.Media.Imaging.RenderTargetBitmap.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCoreCommon(Freezable sourceFreezable, Boolean useCurrentValue, Boolean cloneFrozenValues)
at System.Windows.Freezable.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCurrentValue()
at System.Windows.Media.Animation.ObjectKeyFrameCollection.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCurrentValue()
at System.Windows.Media.Animation.ObjectAnimationUsingKeyFrames.CopyCommon(ObjectAnimationUsingKeyFrames sourceAnimation, Boolean isCurrentValueClone)
at System.Windows.Media.Animation.ObjectAnimationUsingKeyFrames.GetCurrentValueAsFrozenCore(Freezable source)
at System.Windows.Freezable.GetCurrentValueAsFrozen()
at System.Windows.Media.Animation.Clock..ctor(Timeline timeline)
at System.Windows.Media.Animation.AnimationTimeline.AllocateClock()
at System.Windows.Media.Animation.Clock.AllocateClock(Timeline timeline, Boolean hasControllableRoot)
at System.Windows.Media.Animation.Clock.BuildClockTreeFromTimeline(Timeline rootTimeline, Boolean hasControllableRoot)
at System.Windows.Media.Animation.AnimationTimeline.CreateClock()
at WpfAnimatedGif.ImageAnimationController..ctor(Image image, ObjectAnimationUsingKeyFrames animation, Boolean autoStart)
at WpfAnimatedGif.ImageBehavior.InitAnimationOrImage(Image imageControl)
at WpfAnimatedGif.ImageBehavior.<>c__DisplayClasse`1.b__b(Object sender, RoutedEventArgs e)

at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()

NullReferenceException Windows XP - v1.4.12

Hi,
I'm getting following exception on Windows XP SP3 with the version 1.4.12:

System.NullReferenceException: Object reference not set to an instance of an object.
at WpfAnimatedGif.ImageBehavior.GetQueryOrDefault[T](BitmapMetadata metadata, String query, T defaultValue)
at WpfAnimatedGif.ImageBehavior.GetFullSize(BitmapDecoder decoder, GifFile gifMetadata)
at WpfAnimatedGif.ImageBehavior.GetAnimation(Image imageControl, BitmapSource source)
at WpfAnimatedGif.ImageBehavior.InitAnimationOrImage(Image imageControl)
at WpfAnimatedGif.ImageBehavior.ImageControlLoaded(Object sender, RoutedEventArgs e)
...

It works well on Windows Vista,7 and 8.1.

Flickering when not at native size

I've got a ~3 second gif in an Image control. When the control is allowed to size automatically (ie I haven't specified width or height), it displays fine at the gif's original dimensions. If I shrink the control by setting width/height, the gif flickers between rendering at it's original size (but clipped by the width/height set, meaning you can only see a bit of it), and rendering scaled to fit the control. The flicker pattern doesn't seem to be consistent (it changes at different times in the gif each loop), though it does spend more time at original size than scaled.

Have you seen this before?

Exception when running in multi-threaded environment

Try to open window with gif image in new thread, first time it works.
Try to open other window with gif image in new thread, fails miserably:

The calling thread cannot access this object because a different thread owns it.

at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Media.Imaging.BitmapDecoder.ToString()
at System.Windows.Media.Imaging.BitmapFrameDecode.ConvertToString(String format, IFormatProvider provider)
at System.Windows.Media.ImageSource.ToString()
at WpfAnimatedGif.AnimationCache.CacheKey.GetUri(ImageSource image)
at WpfAnimatedGif.AnimationCache.CacheKey.ImageEquals(ImageSource x, ImageSource y)
at WpfAnimatedGif.AnimationCache.CacheKey.Equals(CacheKey other)
at WpfAnimatedGif.AnimationCache.CacheKey.Equals(Object obj)
at System.Collections.Generic.ObjectEqualityComparer1.Equals(T x, T y) at System.Collections.Generic.Dictionary2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at WpfAnimatedGif.ImageBehavior.GetAnimation(Image imageControl, BitmapSource source)
at WpfAnimatedGif.ImageBehavior.InitAnimationOrImage(Image imageControl)
at WpfAnimatedGif.ImageBehavior.ImageControlLoaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

System.OutOfMemoryException

I have a virtualized ListBox which should load gifs from hdd and play them. I get only 2 gifs displayed and right away:

An unhandled exception of type 'System.OutOfMemoryException' occurred in PresentationCore.dll
Additional information: Insufficient memory to continue the execution of the program.
<local:cThumbnail3  LongFileName="{Binding FullPath}" />
public class cThumbnail3 : System.Windows.Controls.Grid
{
   public string LongFileName
    {
        get { return (string)GetValue(LongFileNameProperty); }
        set { SetValue(LongFileNameProperty, value); }
    }
    public static readonly DependencyProperty LongFileNameProperty =
        DependencyProperty.Register("LongFileName", typeof(string), typeof(cThumbnail3), new PropertyMetadata(OnLongFileNameChanged));


    static void OnLongFileNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
    {
        cThumbnail3 t = obj as cThumbnail3;
        t.LoadAsGif2();
    }

    public void LoadAsGif2()
    {
        var image = new BitmapImage();
        image.BeginInit();
        image.UriSource = new Uri(LongFileName);
        image.EndInit();

        Image img = new Image();
        ImageBehavior.SetAnimatedSource(img, image);
        this.Children.Clear();
        this.Children.Add(img);
    }
}

Program memory consumption is 1.6 GB right away

MediaElement works for a while but eventually leaks so much memory that it stops playing animations so I looked for alternative.

Removing the GIF from an Image control

Tried setting the animated property to null as I am trying to change the property. Is this possible?

ImageBehavior.SetAnimatedSource(this.imageHolder, null);

Memory/GDI leak

I discovered that this library was causing a GDI leak. When Image controls are loaded and unloaded, for example in tabs or user controls, the number of stored GDI objects slowly crept into the thousands. I tracked the problem down to two issues.

The first one:

If ImageBehavior.SetRepeatBehavior is called after ImageBehavior.SetAnimatedSource, AnimationCache.DecrementReferenceCount in ImageBehavior.cs:318 does not remove the first animation from cache, because the initial animation has repeatbehavior "0x" in the cache key, and the second has, for example, "forever". This first animation will never be removed from the cache.

The second one:

private static Uri GetUri(ImageSource image) in AnimationCache.cs will always return null when the URI source is a file on disk. Changing line 79 to

                if (bmp.BaseUri != null && bmp.UriSource != null && !bmp.UriSource.IsAbsoluteUri)
                    return new Uri(bmp.BaseUri, bmp.UriSource);
                else if (bmp.UriSource != null && bmp.UriSource.IsAbsoluteUri)
                    return bmp.UriSource;

lets the URI matching work as intended (?)

The combination of the source URI never matching, and the duplicate keys were causing the leaks to grow. With these changes i have no more leaks.

Another little quirk i found, was that if a bound Image control is unloaded, and then loaded again with the same url, the "AnimatedSourceChanged" event will never fire. When this happens the gif stops working.

Support for Windows 10

I tried installing through NuGet into a Windows 10 Universal project and it fails.

Wondering if you have tried targeting a Windows 10 Universal build?

Any suggestions?

Thanks,
Gyle

Here is the Package Manager Output:
Attempting to gather dependencies information for package 'XamlAnimatedGif.1.0.0-beta2' with respect to project targeting 'Windows, Version=v8.1'
Attempting to resolve dependencies for package 'XamlAnimatedGif.1.0.0-beta2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'XamlAnimatedGif.1.0.0-beta2'
Resolved actions to install package 'XamlAnimatedGif.1.0.0-beta2'
For adding package 'XamlAnimatedGif 1.0.0-beta2' to project 'CyberDustUniversal' that targets 'win81'.
For adding package 'XamlAnimatedGif 1.0.0-beta2' to project 'CyberDustUniversal' that targets 'win81'.
Package 'XamlAnimatedGif 1.0.0-beta2' already exists in folder 'C:\cyberdust\branches\windows10\CyberDust\packages'
Install failed. Rolling back...
System.InvalidOperationException: Failed to add reference to 'XamlAnimatedGif'. ---> System.Runtime.InteropServices.COMException: Project unavailable.
at EnvDTE.Project.get_Object()
at NuGet.PackageManagement.VisualStudio.EnvDTEProjectUtility.GetReferences(Project project)
at NuGet.PackageManagement.VisualStudio.VSMSBuildNuGetProjectSystem.AddReference(String referencePath)
--- End of inner exception stack trace ---
at NuGet.PackageManagement.NuGetPackageManager.d__ea.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.UIActionEngine.d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.UI.UIActionEngine.d__0.MoveNext()
========== Finished ==========

Needs public key

When I go to compile my solution I get a vague death with the error message of "Could not load file or assembly 'WpfAnimatedGif, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.".  From what I understand, this might be because my projects are signed but WpfAnimatedGif library assembly is not.

Here is more information from the error message.

=== Pre-bind state information ===
LOG: DisplayName = WpfAnimatedGif, PublicKeyToken=null
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: WpfAnimatedGif, PublicKeyToken=null | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file://[redacted]
LOG: Initial PrivatePath = NULL

Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in default load context.
LOG: Using application configuration file: [redacted]
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL
[redacted]/WpfAnimatedGif.DLL.
LOG: Attempting download of new URL
[redacted]/WpfAnimatedGif.DLL.
LOG: Attempting download of new URL
[redacted]/WpfAnimatedGif.EXE.
LOG: Attempting download of new URL
[redacted]/WpfAnimatedGif.EXE.

Setup Error

When i create a setup file. the application work. but not show the window.

GDI Handle leak

There's a GDI handle leak in frames. (It's more obvious if you've got some gif images with hundreds of frames in them as when you hit ~10K frames in your app, it'll crash).

To resolve this:

ImageBehaviour.cs -> MakeFrame

Line 674:
var bitmap = new RenderTargetBitmap(
fullSize.Width, fullSize.Height,
96, 96,
PixelFormats.Pbgra32);
bitmap.Render(visual);

        var result = new WriteableBitmap(bitmap);  

        if (result.CanFreeze && !result.IsFrozen)
            result.Freeze();
        return result;

WriteableBitmaps don't take up a GDI handle. RenderTargetBitmaps do.

Note this only resolves half of the issue though

Inside ImageBehaviour -> GetAnimation

line: 470:
animation.RepeatBehavior = GetActualRepeatBehavior(imageControl, decoder, gifMetadata);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();

Reason for the GC WaitForPendingFinalizers is that the GDI Handle gets disposed in the Finalizer which might not happen before the 10K limit gets breached. (i.e the GC doesn't know about the GDI limit and can let it go over the limit causing an app crash). Sorry it's not in a pull request but my current environment I don't have permissions to install GIT.

System.Runtime.InteropServices.COMException exception thrown

I have used spinner as follows:

<Image x:Name="image" Height="150" Width="150"
       gif:ImageBehavior.AnimatedSource="Images/spinner_purple.gif"
       Visibility="{Binding IsBusy, Converter={dxmvvm:BooleanToVisibilityConverter Inverse=False}}"/>

IsBusy is the public property in ViewModel.

it set it to true when loading some data in background thread as follows:

  private void LoadProjectType()
        {
            var worker = new BackgroundWorker();
            worker.DoWork += (o, ea) =>
            {
                //use the Dispatcher to delegate to update UI thread
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    LookupProjectType = projectTypeDataService.GetAll();
                }));
            };
            worker.RunWorkerCompleted += (o, ea) =>
            {
                IsBusy = false;
            };
            IsBusy = true;
            worker.RunWorkerAsync();
        }

With this implementation, I am sporadically getting below exception and system crashes:


System.Runtime.InteropServices.COMException:
   at System.Windows.Media.Imaging.RenderTargetBitmap.FinalizeCreation (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Imaging.RenderTargetBitmap..ctor (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at WpfAnimatedGif.ImageBehavior.MakeFrame (WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, PublicKeyToken=null)
   at WpfAnimatedGif.ImageBehavior.GetAnimation (WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, PublicKeyToken=null)
   at WpfAnimatedGif.ImageBehavior.InitAnimationOrImage (WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, PublicKeyToken=null)
   at WpfAnimatedGif.ImageBehavior.AnimatedSourceChanged (WpfAnimatedGif, Version=1.4.14.0, Culture=neutral, PublicKeyToken=null)
   at System.Windows.DependencyObject.OnPropertyChanged (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.OnPropertyChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.NotifyPropertyChange (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.UpdateEffectiveValue (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.InvalidateProperty (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.StyleHelper.InvalidateDependents (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.StyleHelper.OnBindingValueInStyleChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpressionBase.ChangeValue (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpression.TransferValue (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpression.ScheduleTransfer (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Data.ClrBindingWorker.NewValueAvailable (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependentList.InvalidateDependents (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.NotifyPropertyChange (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.UpdateEffectiveValue (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.TreeWalkHelper.InvalidateTreeDependentProperty (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.TreeWalkHelper.InvalidateTreeDependentProperties (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.InvalidateTreeDependentProperties (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.OnAncestorChangedInternal (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.TreeWalkHelper.OnAncestorChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkLogicalChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.IterateChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkLogicalChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.IterateChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkLogicalChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.IterateChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkLogicalChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.IterateChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1._VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.VisitNode (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkLogicalChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.IterateChildren (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DescendentsWalker`1.StartWalk (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at MS.Internal.PrePostDescendentsWalker`1.StartWalk (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.TreeWalkHelper.InvalidateOnTreeChange (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.OnVisualParentChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Visual.FireOnVisualParentChanged (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Visual.RemoveVisualChild (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.set_TemplateChild (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.StyleHelper.ClearGeneratedSubTree (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.StyleHelper.DoTemplateInvalidations (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.StyleHelper.UpdateTemplateCache (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.OnTemplateChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.OnPropertyChanged (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.OnPropertyChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.NotifyPropertyChange (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.UpdateEffectiveValue (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.SetValueCommon (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Controls.ContentPresenter.OnContentChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.OnPropertyChanged (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.FrameworkElement.OnPropertyChanged (PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.NotifyPropertyChange (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.UpdateEffectiveValue (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.SetValueCommon (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.DependencyObject.SetValue (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at DevExpress.Xpf.WindowsUI.Internal.ViewPresenter.FinishContentChanging (DevExpress.Xpf.Controls.v17.1, Version=17.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a)
   at DevExpress.Xpf.WindowsUI.Internal.ViewPresenter.OnStoryboardCompleted (DevExpress.Xpf.Controls.v17.1, Version=17.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a)
   at System.Windows.Media.Animation.Clock.FireEvent (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Animation.Clock.RaiseAccumulatedEvents (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Animation.TimeManager.RaiseEnqueuedEvents (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.Animation.TimeManager.Tick (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler (PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen (WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)

New Project Proposal

Hi, do you remember when I asked about a possible project for creating gifs (encoding), a few months ago?

Are you interested? There is no reliable source for gif creating in .Net, the only ones are Bumpkit and Ngif (one uses bad quality and other is full of bugs and slow).

I can actively help you if you need, but I dont have the knowledge to do it alone.

The main idea is this:

  • Should accept images (bmp, png, jpg), BitmapSources or Streams as input.
  • Custom frame sizes, using (x, y, width, heigh), this is allowed by the gif specification.
  • Variable frame rate.
  • Transparency (Replaces the unchanged pixel with a dummy color).
  • Progression report, in %.
  • Number of colors, from 255 to 2 colors (+ 1 transparent/dummy color), very important!.

PS: I also have a method that analizes the list of frames and cuts + paints the unchanged pixels to reduce the file size.

Not sure if this is the right place to ask this, btw.

Setting URI kind to relative disables animation of gifs

hi Thomas,

I have tried several ways to get the animation working using relative URI, but unable to do so. I implement a delegate method registered to Animationloaded, sender receiver is then null and unable to Play().

Setting autostart = true also does not work when relative URI is used. When I switch to absolute URI everything works - the delegate method sender != null so play() works fine and autostart also works.

Can you kindly assist?

System.Windows.Baml2006.TypeConverterMarkupExtension

Received the exception below when trying to create a simple splash screen. Not sure if I am missing something, but I basically copied the markup provided in the intro. Markup and exception are included.


A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '9' and line position '10'.

<Window x:Class="DemoApp.SplashScreen"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:gif="http://wpfanimatedgif.codeplex.com"
        Title="SplashScreen" Height="300" Width="300"
        ResizeMode="NoResize" WindowStyle="None"   
        WindowStartupLocation="CenterScreen" Background="white" BorderThickness="5" BorderBrush="LightGray" Topmost="True">
    <Grid Height="290" VerticalAlignment="Top">
        <Image gif:ImageBehavior.AnimatedSource="Images/loading.gif" />
    </Grid>
</Window>

Memory Leak

Hi,

I have three GIF files that I animate one after another using AnimationCompleted event handler. The files are quite large as they need to run on a full screen mode. My Application usually runs at 40% to 50% of the Physical memory. When I added WpfAnimatedGif it shoots up to 90% to 95% of the Physical memory. I know this has been reported before in Codeplex but I am hoping that you will look into this or give us some work around for this problem. It is a great plugin and it does a lot of things out of the shelf.

Image load event not firing

Seems that WpfAnimatedGif hides Image Load event.

I am dynamically changing image source in an endless loop.
In my project we use WpfAnimatedGif together with Transitionals with DataContext binding and in that case, load event is fired for all not .gif images and is fired only once only for the first .gif image.

I have created a simple wpf app for test purposes. Tried both with DataContext binding and setting source in code behind like this:

var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(fileName);
image.EndInit();
ImageBehavior.SetAnimatedSource(img, image);

And in both cases, load event is fired only once in which Image.Source is null.
Am I missing something? If not, ideas for a possible workaround?
If you are interested in my test app, everything is in MyMainWindow files.

Problem with animated gif in an adorner

I've written a simple adorner for the purpose of displaying an animated 'spinner' gif. The adorner (based on Josh Smith's UIElementAdorner) contains a single child Image control; I set the source using ImageBehavior.SetAnimatedSource(). I create a single instance of the adorner, show it by adding it to the adorned element's adorner layer, and hide it by removing it from the adorned element's adorner layer.

My 'spinner' works great the first time I show it. However when I hide it and show it again, the 'spinner' gif is no longer animated. Any thoughts as to why this might be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.