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

2019-06-27 14:41发布

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?

2条回答
疯言疯语
2楼-- · 2019-06-27 15:07

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.

查看更多
爷、活的狠高调
3楼-- · 2019-06-27 15:33

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.

查看更多
登录 后发表回答