How to draw string to a bitmap image in WinRT

前端 未结 5 1731
执念已碎
执念已碎 2021-01-19 12:37

How do you draw a string to an image in winRT? In WinForms that could be done using drawstring() method inside the system.drawing name

相关标签:
5条回答
  • 2021-01-19 12:42

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

    0 讨论(0)
  • 2021-01-19 12:56

    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);
    
    0 讨论(0)
  • 2021-01-19 12:59

    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.

    0 讨论(0)
  • 2021-01-19 13:02

    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.

    0 讨论(0)
  • 2021-01-19 13:06

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

    0 讨论(0)
提交回复
热议问题