0
我擁有爲Win 10手機創建的通用應用程序,它捕捉照片。我想添加郵票(一些文字)到我的照片。可能嗎?這似乎與位圖的工作真的很難在普遍應用在Windows通用應用程序中添加文字到圖片
我擁有爲Win 10手機創建的通用應用程序,它捕捉照片。我想添加郵票(一些文字)到我的照片。可能嗎?這似乎與位圖的工作真的很難在普遍應用在Windows通用應用程序中添加文字到圖片
檢查此鏈接:
How to add wartermark text/image to a bitmap in Windows Store app
或者更好地利用Win2D庫(你可以找到它的NuGet)和摘錄如下:
CanvasDevice device = CanvasDevice.GetSharedDevice();
CanvasRenderTarget offscreen = new CanvasRenderTarget(device, 500, 500, 96);
cbi = await CanvasBitmap.LoadAsync(device, "mydog.jpg");
using (var ds = offscreen.CreateDrawingSession())
{
ds.DrawImage(cbi);
var format = new CanvasTextFormat()
{
FontSize = 24,
HorizontalAlignment = CanvasHorizontalAlignment.Left,
VerticalAlignment = CanvasVerticalAlignment.Top,
WordWrapping = CanvasWordWrapping.Wrap,
FontFamily = "Tahoma"
};
var tl = new CanvasTextLayout(ds, "Some text", format, 200, 50); // width 200 and height 50
ds.DrawTextLayout(tl, 10, 10, Colors.Black);
tl.Dispose();
}
using (var stream = new InMemoryRandomAccessStream())
{
stream.Seek(0);
await offscreen.SaveAsync(stream, CanvasBitmapFileFormat.Png);
BitmapImage image = new BitmapImage();
image.SetSource(stream);
img.Source = image;
}