From 54196314af35589371ab7038dfe6dc82a979c52e Mon Sep 17 00:00:00 2001 From: Thomas Levesque Date: Wed, 27 Sep 2017 21:42:03 +0200 Subject: [PATCH 1/2] Fix GDI handle leak (#22) --- .gitignore | 3 ++- WpfAnimatedGif/ImageBehavior.cs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 99abfe1..1344e82 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ NuGetPackages/ # Roslyn cache directories *.ide/ +.vs/ # MSTest test Results [Tt]est[Rr]esult*/ @@ -189,4 +190,4 @@ FakesAssemblies/ # NDepend output NDependOut/ -issues/ \ No newline at end of file +issues/ diff --git a/WpfAnimatedGif/ImageBehavior.cs b/WpfAnimatedGif/ImageBehavior.cs index 6428809..0782b09 100644 --- a/WpfAnimatedGif/ImageBehavior.cs +++ b/WpfAnimatedGif/ImageBehavior.cs @@ -492,9 +492,11 @@ private static BitmapSource ClearArea(BitmapSource frame, FrameMetadata metadata PixelFormats.Pbgra32); bitmap.Render(visual); - if (bitmap.CanFreeze && !bitmap.IsFrozen) - bitmap.Freeze(); - return bitmap; + var result = new WriteableBitmap(bitmap); + + if (result.CanFreeze && !result.IsFrozen) + result.Freeze(); + return result; } private static void TryTwice(Action action) @@ -668,9 +670,11 @@ private static BitmapSource MakeFrame( PixelFormats.Pbgra32); bitmap.Render(visual); - if (bitmap.CanFreeze && !bitmap.IsFrozen) - bitmap.Freeze(); - return bitmap; + var result = new WriteableBitmap(bitmap); + + if (result.CanFreeze && !result.IsFrozen) + result.Freeze(); + return result; } private static RepeatBehavior GetActualRepeatBehavior(Image imageControl, BitmapDecoder decoder, GifFile gifMetadata) From 12408d52d65919ae89a3b91b9604045a799e47c6 Mon Sep 17 00:00:00 2001 From: Thomas Levesque Date: Wed, 27 Sep 2017 21:43:44 +0200 Subject: [PATCH 2/2] Bump version to 1.4.15 --- WpfAnimatedGif.nuspec | 2 +- WpfAnimatedGif/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WpfAnimatedGif.nuspec b/WpfAnimatedGif.nuspec index 99ceb02..eb97199 100644 --- a/WpfAnimatedGif.nuspec +++ b/WpfAnimatedGif.nuspec @@ -3,7 +3,7 @@ WpfAnimatedGif WPF Animated GIF - 1.4.14 + 1.4.15 A simple library to display animated GIF images in WPF A simple library to display animated GIF images in WPF Thomas Levesque diff --git a/WpfAnimatedGif/Properties/AssemblyInfo.cs b/WpfAnimatedGif/Properties/AssemblyInfo.cs index cf7c312..a4b08d2 100644 --- a/WpfAnimatedGif/Properties/AssemblyInfo.cs +++ b/WpfAnimatedGif/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ class VersionInfo /// /// Single place to define version /// - public const string VersionString = "1.4.14"; + public const string VersionString = "1.4.15"; } } \ No newline at end of file