【发布时间】: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