如何在WinRT中将字符串绘制到位图图像
如何在winRT
为图像绘制字符串? 在WinForms中,可以使用system.drawing
命名空间内的system.drawing
drawstring()
方法完成,但我无法在WinRT API中找到它的等价物。
Direct2D是WinRT中GDI的替代品。 所以你必须使用C ++ / CX和DirectX来绘制文本。
我没有任何关于你的例子,但也许这个链接 (以及包含的链接)可以帮助你。
在Windows 8.1中,他们最终支持将XAML控件渲染为位图。 现在你可以使用了
var renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(uiElement, width, height)); var buffer = await renderTargetBitmap.GetPixelsAsync(); var tmpWbm = new WriteableBitmap(renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight);
您将不得不使用DirectX。 你可以使用SharpDx在C#中完成 。
你不能 – 很遗憾没有这样的API 🙁
谷歌使用Direct2D和DirectWrite for Graphics的Metro CSharp。 这是他们的代码示例之一。 这不是我见过的最简洁的例子,但确实有效。 使用SharpDX做同样的事情将更清洁。