Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(skia): Add support for WriteableBitmap
- Loading branch information
1 parent
50aef82
commit 8da3a80
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using Windows.Foundation; | ||
using Windows.Storage.Streams; | ||
using Uno.Foundation; | ||
using Windows.UI.Composition; | ||
|
||
namespace Windows.UI.Xaml.Media.Imaging | ||
{ | ||
partial class WriteableBitmap | ||
{ | ||
private SkiaCompositionSurface _surface; | ||
|
||
private protected override bool TryOpenSourceSync(int? targetWidth, int? targetHeight, out ImageData image) | ||
{ | ||
var handle = GCHandle.Alloc(_buffer.Data, GCHandleType.Pinned); | ||
|
||
_surface ??= new SkiaCompositionSurface(); | ||
|
||
_surface.SetPixels(PixelWidth, PixelHeight, _buffer.Data); | ||
|
||
image = new ImageData { | ||
Value = _surface | ||
}; | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters