From 9e94055bc126e63090e0fb887b664845293f3daa Mon Sep 17 00:00:00 2001 From: Paisley Date: Fri, 8 Sep 2023 11:20:51 -0500 Subject: [PATCH] Added a function to RenderTargetBitmap to create a DrawingContext for editing the current image data and not clearing it. --- api/Avalonia.nupkg.xml | 6 ------ .../Media/Imaging/RenderTargetBitmap.cs | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/api/Avalonia.nupkg.xml b/api/Avalonia.nupkg.xml index 3c1071e1ef..6a7d53544e 100644 --- a/api/Avalonia.nupkg.xml +++ b/api/Avalonia.nupkg.xml @@ -1,12 +1,6 @@  - - CP0002 - M:Avalonia.Media.Imaging.RenderTargetBitmap.CreateDrawingContext - baseline/netstandard2.0/Avalonia.Base.dll - target/netstandard2.0/Avalonia.Base.dll - CP0006 P:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.ImportCompleted diff --git a/src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs b/src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs index 5824a2b994..4adac60c2d 100644 --- a/src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs +++ b/src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs @@ -63,15 +63,24 @@ namespace Avalonia.Media.Imaging } /// - /// Creates a for drawing to the . + /// Creates a for drawing to the . + /// Clears the current image data to transparent. /// - /// Indicates if the image should be cleared. /// The drawing context. - public DrawingContext CreateDrawingContext(bool clear = true) + public DrawingContext CreateDrawingContext() + { + var platform = PlatformImpl.Item.CreateDrawingContext(); + platform.Clear(Colors.Transparent); + return new PlatformDrawingContext(platform); + } + + /// + /// Creates a for editing the already existing image in the . + /// + /// The drawing context. + public DrawingContext CreateEditDrawingContext() { var platform = PlatformImpl.Item.CreateDrawingContext(); - if(clear) - platform.Clear(Colors.Transparent); return new PlatformDrawingContext(platform); }