How to draw string to a bitmap image in WinRT

前端 未结 5 1735
执念已碎
执念已碎 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: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);
    

提交回复
热议问题