【问题标题】:WriteableBitmap doesn't render on Linux but works on UWP and WasmWriteableBitmap 不能在 Linux 上渲染,但适用于 UWP 和 Wasm
【发布时间】:2020-09-16 15:57:06
【问题描述】:

我正在尝试使用 WriteableBitmap 对象在 UI 上呈现一个红色框。该应用程序在 UWP 上按预期工作:

在使用 Gtk.Skia 的 Linux 上,没有任何显示(共享相同的代码):

这是 C# 代码:

 public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
        Paint();
    }
    private void Paint()
    {
        WriteableBitmap _wb = new WriteableBitmap(100, 100);

        byte[] imageArray = new byte[_wb.PixelHeight * _wb.PixelWidth * 4];

        for (int i = 0; i < imageArray.Length; i += 4)
        {
            imageArray[i] = 0;
            imageArray[i + 1] = 0;
            imageArray[i + 2] = 255;
            imageArray[i + 3] = 255;
        }

        using (Stream stream = _wb.PixelBuffer.AsStream())
        {
            stream.Write(imageArray, 0, imageArray.Length);

        }
        test.Source = _wb;

    }
}

XAML 代码:

<Page
x:Class="test.Uno.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Image x:Name="test" VerticalAlignment="Top" />
</Grid>

【问题讨论】:

    标签: c# xaml cross-platform uno-platform


    【解决方案1】:

    Skia 尚不支持 WriteableBitmap。这是related issue

    更新 (2020-09-18):WriteableBitmap 可用于 Uno.UI 3.1.0-dev.364 及更高版本中的 Skia GTK/WPF。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-07
      • 2021-04-15
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      相关资源
      最近更新 更多