Browse Source
Merge pull request #12793 from PMahern/feature/optional-clear-in-rendertargetbitmap-createdrawingcontext
Made clear behavior in RenderTargetBitmap.CreateDrawingContext optional
pull/12851/head
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
1 deletions
-
src/Avalonia.Base/Media/Imaging/RenderTargetBitmap.cs
|
|
|
@ -62,10 +62,24 @@ namespace Avalonia.Media.Imaging |
|
|
|
return factory.CreateRenderTargetBitmap(size, dpi); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a <see cref="DrawingContext"/> for drawing to the <see cref="RenderTargetBitmap"/>.
|
|
|
|
/// Clears the current image data to transparent.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The drawing context.</returns>
|
|
|
|
public DrawingContext CreateDrawingContext() |
|
|
|
=> CreateDrawingContext(true); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a <see cref="DrawingContext"/> for drawing to the <see cref="RenderTargetBitmap"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="clear">If true, clears the current image data to transparent, if false, leaves the image data unchanged.</param>
|
|
|
|
/// <returns>The drawing context.</returns>
|
|
|
|
public DrawingContext CreateDrawingContext(bool clear) |
|
|
|
{ |
|
|
|
var platform = PlatformImpl.Item.CreateDrawingContext(); |
|
|
|
platform.Clear(Colors.Transparent); |
|
|
|
if(clear) |
|
|
|
platform.Clear(Colors.Transparent); |
|
|
|
return new PlatformDrawingContext(platform); |
|
|
|
} |
|
|
|
|
|
|
|
|