Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw string to a bitmap image in WinRT

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.

like image 773
yohannist Avatar asked Feb 19 '23 02:02

yohannist


1 Answers

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);
like image 188
Tommy Ovesen Avatar answered Feb 20 '23 14:02

Tommy Ovesen