开发者

DrawString on WP7

开发者 https://www.devze.com 2023-04-05 21:07 出处:网络
I\'m trying to develop something on WP7 (XAML not XNA) and 开发者_JAVA百科want to be able to draw text onto an image and then save that image with the text on it. Is there a library or function that a

I'm trying to develop something on WP7 (XAML not XNA) and 开发者_JAVA百科want to be able to draw text onto an image and then save that image with the text on it. Is there a library or function that already exists that does this or would I need to implement my own solution to draw every character?


There is no API in WP7 for rendering text to a bitmap image. The WP7 API for manipulating bitmap images is WriteableBitmap, which gives you an array of pixels and nothing more!

There is a good codeplex project WriteableBitmapEx, which adds various drawing extension methods, but not text rendering.

You can however place text above an image, for example ...

<Grid>
  <Image Source="myImage.png"/>
  <TextBlock Text="Overlay text"/>
<Grid>

This will render the text above the image.

You can also use a WriteableBitmap to 'capture' part of the visual tree into a bitmap, see my blog post for examples. The route you take really depends on your requirements.


I found a way of doing this by adding a Textblock onto the WriteableBitmap. This link gives you an example of how it can be achieved.

How can i write string on WriteableBitmap?

0

精彩评论

暂无评论...
验证码 换一张
取 消