Skip to content

Commit

Permalink
Merge pull request #36 from thomaslevesque/fix-gdi-handle-leak
Browse files Browse the repository at this point in the history
Fix GDI handle leak
  • Loading branch information
thomaslevesque authored Sep 27, 2017
2 parents 5e30f4e + 12408d5 commit 822555f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NuGetPackages/

# Roslyn cache directories
*.ide/
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down Expand Up @@ -189,4 +190,4 @@ FakesAssemblies/
# NDepend output
NDependOut/

issues/
issues/
2 changes: 1 addition & 1 deletion WpfAnimatedGif.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>WpfAnimatedGif</id>
<title>WPF Animated GIF</title>
<version>1.4.14</version>
<version>1.4.15</version>
<description>A simple library to display animated GIF images in WPF</description>
<summary>A simple library to display animated GIF images in WPF</summary>
<authors>Thomas Levesque</authors>
Expand Down
16 changes: 10 additions & 6 deletions WpfAnimatedGif/ImageBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion WpfAnimatedGif/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ class VersionInfo
/// <summary>
/// Single place to define version
/// </summary>
public const string VersionString = "1.4.14";
public const string VersionString = "1.4.15";
}
}

0 comments on commit 822555f

Please sign in to comment.