How to draw string to a bitmap image in WinRT

▼魔方 西西 提交于 2019-12-04 03:49:08

问题


How do you draw a string to an image in winRT? In WinForms that could be done using drawstring() method inside the system.drawing namespace but i couldn't find its equivalent in WinRT API.


回答1:


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.




回答2:


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);



回答3:


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




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/14005424/how-to-draw-string-to-a-bitmap-image-in-winrt

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