views:

227

answers:

1

Hi,

I have a set of image resources in a Silverlight client and I'm trying to render text on them. I can load the original BitmapImage into a WriteableBitmap but see no facility for rendering text onto it. Could anyone point me in the right direction?

Thanks,

+3  A: 

You could probably achieve this by using a Grid like this:-

<Grid x:Name="MyGrid">
  <Bitmap Source="urltoimg" />
  <TextBlock Text="Text to Overlay" />
</Grid>

Then in code:-

WriteableBitmap wb = new WritableBitmap(MyGird, null);
AnthonyWJones
This will work. Alternatively, if you don't want to create a Grid to contain both the Image and the TextBlock, you can use WriteableBitmap.Render() to render both elements into the bitmap without adding the TextBlock to the visual tree.
KeithMahoney