如何将文字水印添加到UWP中的图像?

问题描述:

我实际上使用Xamarin Forms,并且在我的UWP项目中,我有一个任务将相机拍摄的图像发送到REST服务。图像发送正确,但我想在该图像中添加文字水印,但我真的不知道如何在UWP中实现此功能。该图像作为StorageFile类型从系统中检索。如何将文字水印添加到UWP中的图像?

我试图将该图像文件转换为字节数组并将其转换为位图来处理图像并使用类似绘图或图形库的东西。我可以将图像转换为字节数组,但我甚至无法在UWP项目中使用位图。

我已经在Xamarin Forms论坛中搜索了UWP中的图像处理和文本水印,但是我发现的问题没有得到答复。你有什么想法或线索来实现这一目标吗?

+0

[此视频](https://channel9.msdn.com/Blogs/OneCode/How-to-add-wartermark-text-or-image-to-a-bitmap-in-Windows-Store-app)可能会有所帮助。 –

可以从这样的文件得到的BitmapImage对象:

private static async Task<BitmapImage> ConvertToBitmap(string filename) 
{ 
    StorageFile file = await KnownFolders.DocumentsLibrary.GetFileAsync(filename); 

    return await LoadImage(file); 
} 

private static async Task<BitmapImage> LoadImage(StorageFile file) 
{ 
    BitmapImage bitmapImage = new BitmapImage(); 
    FileRandomAccessStream stream = (FileRandomAccessStream)await file.OpenAsync(FileAccessMode.Read); 

    bitmapImage.SetSource(stream); 

    return bitmapImage; 
} 

对于水印和其他你可以看看Portable AForge.NET Framework图像处理任务。