相关疑难解决方法(0)

如何以编程方式将文本添加到位图图像?WPF

我正在使用Kinect传感器通过将视频输入设置为位图源来显示图像上的视频输入,如下所示.但我的问题是如何将图像添加到图像/位图,例如分数计数器,我在下面添加了一张图片来展示我想要实现的目标.

void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
            {

                if (colorFrame == null) return;
                byte[] colorData = new byte[colorFrame.PixelDataLength];
                colorFrame.CopyPixelDataTo(colorData);

                 KinectVideo.Source = BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96,
                    PixelFormats.Bgr32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel);

            }
        } 
Run Code Online (Sandbox Code Playgroud)

带有叠加文字的Kinect视频Feed

c# wpf drawing bitmap

7
推荐指数
1
解决办法
1万
查看次数

绑定 Xaml 位图图像

我有位图图像变量,我想将它绑定到我的 xaml 窗口。

System.Reflection.Assembly thisExe;
        thisExe = System.Reflection.Assembly.GetExecutingAssembly();
        string[] resources = thisExe.GetManifestResourceNames();
        var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SplashDemo.Resources.Untitled-100000.png");
        Bitmap image = new Bitmap(stream);
Run Code Online (Sandbox Code Playgroud)

这是我的 xaml 代码

<Image Source="{Binding Source}" HorizontalAlignment="Left"  Height="210" Margin="35,10,0,0" VerticalAlignment="Top" Width="335">
    </Image>
Run Code Online (Sandbox Code Playgroud)

你能帮我通过 C# 代码将此位图变量绑定到这个 xaml 图像吗?

c# xaml bind bitmap

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

bitmap ×2

c# ×2

bind ×1

drawing ×1

wpf ×1

xaml ×1