Is it possible to write text?

Jul 15, 2013 at 3:13 PM
Does it exist simple way to render text on a WriteableBitmap?
Jul 15, 2013 at 5:35 PM
Depends on the platform. For non-WinRT just render a TextBlock using the WB.Render() method. For WinRT since Win 8.1 use the new API for bitmap rendering.
  • rene
Jul 16, 2013 at 6:53 AM
Sorry for ambiquous question. I mean WPF. Silverlight has Render method but WPF doesn't.
Jul 16, 2013 at 8:23 AM
Look into RenderTargetBitmap.
Jul 17, 2013 at 8:53 PM
Edited Jul 17, 2013 at 9:39 PM
I'm trying to draw text in Silverlight. I blit an image and then I want to draw text on top of it
        TextBlock i = new TextBlock();
        i.Text = str;
        i.Foreground = new SolidColorBrush(color);
        wbmp.Render(i, new TranslateTransform() { X = x, Y = y });
But blitted background image is gone and text is drawn on completely black screen.
What do I do wrong? Thanks.

EDIT: Ok got it, have to call Invalidate() before rendering the text.
Oct 12, 2013 at 10:48 PM
I'm seeing this too. My code is on WP8. I am using Resize to resize a WritableBitmap. If I render a textblock onto the WritableBitmap that is returned from resize I get a black rectangle with my text drawn on top. If, however, I use WritableBitmap.SaveJpeg to create a stream backed by MemoryStream and then create a new WritableBitmap from that stream I can render a textblock and the image looks correct. Is there something I need to do to the WritableBitmap that returned from Resize??
Oct 13, 2013 at 3:12 PM
BTW, using blit solves this, but I'm curious why render does not work.
Nov 19, 2013 at 9:07 AM
Any known solutions for WinRT 8?
Nov 19, 2013 at 4:19 PM
For Win 8.1 you want to use the RenderTargetBitmap and render a TextBlock to a bitmap. For Win 8.0 it's not possible in a good way.
Nov 19, 2013 at 4:48 PM
8.0 was my concern. Too bad. Anyway, thanks for the reply. And thank you and the team for all the effort put into this project!