Skip to content

Commit

Permalink
Merge pull request #2553 from cwensley/curtis/wpf-more-rendertargetbi…
Browse files Browse the repository at this point in the history
…tmap

Wpf: Don't store RenderTargetBitmap anywhere
  • Loading branch information
cwensley authored Sep 14, 2023
2 parents 9826d7c + 4a60587 commit a225a41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Eto.Wpf/Drawing/BitmapHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ protected override void Initialize()

public void SetBitmap(swmi.BitmapSource bitmap)
{
if (bitmap is swmi.RenderTargetBitmap)
bitmap = new swmi.WriteableBitmap(bitmap);
Control = bitmap;
SetFrozen();
}
Expand Down
7 changes: 4 additions & 3 deletions src/Eto.Wpf/Drawing/CachedBitmapFrame.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public swmi.BitmapFrame Get(swmi.BitmapSource image, float scale, int width, int
// There's no way to get around it other than just not creating that many and using GC.Collect/WaitForPendingFinalizers.
// we can't do it in Eto as it'd be a serious performance hit.
var target = new swmi.RenderTargetBitmap(scaledwidth, scaledheight, 96 * scale, 96 * scale, swm.PixelFormats.Default);
target.Render(targetVisual);
target.Freeze();
target.RenderWithCollect(targetVisual);

var writable = new swmi.WriteableBitmap(target);

_cachedFrame = swmi.BitmapFrame.Create(target);
_cachedFrame = swmi.BitmapFrame.Create(writable);
_cachedFrame.Freeze();
_scale = scale;
_width = width;
Expand Down

0 comments on commit a225a41

Please sign in to comment.