How to draw string to a bitmap image in WinRT

此生再无相见时 提交于 2019-12-01 19:26:19

Direct2D is a replacement for GDI in WinRT. So you'll have to use C++/CX with DirectX for drawing text.

I don't have any examples for you, but maybe this link (and the links included) can help you on your way.

In Windows 8.1 they finally support rendering of XAML controls to bitmap. Now you can use

var renderTargetBitmap = new RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(uiElement, width, height));
var buffer = await renderTargetBitmap.GetPixelsAsync();
var tmpWbm = new WriteableBitmap(renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight);

You will have to use DirectX. You can do so in C# by using SharpDx.

You can't - there is unfortunately no such API :-(

Google for 'Metro CSharp using Direct2D and DirectWrite for Graphics'. It's one of their code samples. It's not the most concise example I've ever seen, but it does work. Using SharpDX to do the same thing will be cleaner.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!