How do I add watermark text to a bitmap in WinRT?

ぐ巨炮叔叔 提交于 2019-12-10 13:54:52

问题


I would like to do something like this http://weblogs.asp.net/broux/archive/2011/02/08/silverlight-how-to-watermark-a-writeablebitmapimage-with-a-text.aspx. I am having a tough time getting this to work in WinRT. I am using the WriteableBitmap extensions to "render" some text but I want it to look exactly like it looks in this example. Any suggestions or help?


回答1:


You could render that text to a png asset and blit it on top of the bitmap. Unless the text needs to be dynamic - then you'd need DirectWrite. WinRT XAML Toolkit has an extension method you could use to render text to a WriteableBitmap.




回答2:


This gets the job done visually:

<Grid>
    <Image Source="{Binding MyImage}" />
    <Image Source="{Binding MyWatermark}" />
</Grid>

It's certainly the same effect without all the work. If you are wanting to get it to literally make the watermark part of the original image, offloading to a service is your only current option. Without the Render() method on the WriteableBitmap there is no other option for you. Not even the XAML Toolkit solves this problem. It's a common request.

But depending on your use case, this might just be exactly what you want!

I hope it is. Best of luck.



来源:https://stackoverflow.com/questions/14352717/how-do-i-add-watermark-text-to-a-bitmap-in-winrt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!