n00b
n00b

Reputation: 6340

DrawString on WP7

I'm trying to develop something on WP7 (XAML not XNA) and 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?

Upvotes: 2

Views: 1307

Answers (2)

n00b
n00b

Reputation: 6340

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?

Upvotes: 0

ColinE
ColinE

Reputation: 70142

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.

Upvotes: 3

Related Questions