0
我发现很多Windows Phone 8/8.1的例子,但我似乎无法找到一个用于Window 10 UWP的例子。在图像上保存textBlock
所以我需要的是一个可移动的textBlock在图像上。我似乎不知道如何加载图像,写入一些文本然后保存。
代码我现在有[不起作用]
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(1, 1);
Graphics drawing = Graphics.FromImage(img);
//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);
//free up the dummy image and old graphics object
img.Dispose();
drawing.Dispose();
//create a new image of the right size
img = new Bitmap((int)textSize.Width, (int)textSize.Height);
drawing = Graphics.FromImage(img);
//paint the background
drawing.Clear(backColor);
//create a brush for the text
Brush textBrush = new SolidBrush(textColor);
drawing.DrawString(text, font, textBrush, 0, 0);
drawing.Save();
textBrush.Dispose();
drawing.Dispose();
请标记此答案,如果它对您有用!谢谢! – RicardoPons