diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/WriteableBitmap.wasm.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/WriteableBitmap.wasm.cs index ff63bee54db7483518382a502c868129526df59f..a39127d59d348f2e87521984f985acaed21e7dd0 100644 --- a/src/Uno.UI/UI/Xaml/Media/Imaging/WriteableBitmap.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Media/Imaging/WriteableBitmap.wasm.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using Windows.Foundation; using Windows.Storage.Streams; using Uno.Foundation; +using Uno.UI.Xaml; using Uno.UI.Xaml.Media; namespace Windows.UI.Xaml.Media.Imaging @@ -17,7 +18,7 @@ namespace Windows.UI.Xaml.Media.Imaging try { - var value = WebAssemblyRuntime.InvokeJS("Uno.UI.WindowManager.current.rawPixelsToBase64EncodeImage(" + pinnedData + ", " + PixelWidth + ", " + PixelHeight + ");"); + var value = WindowManagerInterop.RawPixelsToBase64EncodeImage(pinnedData, PixelWidth, PixelHeight); image = ImageData.FromDataUri(value); diff --git a/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs b/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs index c500ba49d298044306aa0749d424cbed40a7303e..ca2c3f6832b6d5d2188ff02fdd24ae26655068d3 100644 --- a/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs +++ b/src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs @@ -1180,6 +1180,14 @@ namespace Uno.UI.Xaml } #endregion + internal static string RawPixelsToBase64EncodeImage(IntPtr data, int width, int height) + => +#if NET7_0_OR_GREATER + NativeMethods.RawPixelsToBase64EncodeImage(data, width, height); +#else + WebAssemblyRuntime.InvokeJS("Uno.UI.WindowManager.current.rawPixelsToBase64EncodeImage(" + data + ", " + width + ", " + height + ");"); +#endif + internal static void SetRootElement(IntPtr htmlId) { #if NET7_0_OR_GREATER @@ -1259,6 +1267,9 @@ namespace Uno.UI.Xaml [JSImport("globalThis.Uno.UI.WindowManager.current.measureViewNativeFast")] internal static partial void MeasureView(IntPtr htmlId, double availableWidth, double availableHeight, bool measureContent, IntPtr pReturn); + [JSImport("globalThis.Uno.UI.WindowManager.current.rawPixelsToBase64EncodeImage")] + internal static partial string RawPixelsToBase64EncodeImage(IntPtr data, int width, int height); + [JSImport("globalThis.Uno.UI.WindowManager.current.releasePointerCapture")] internal static partial void ReleasePointerCapture(IntPtr htmlId, double pointerId);