-1

I need to merge text with an image in single writable bitmap image through c# in windows phone 8 app. But I don't know how to merge text with image so that i can get a single writable bitmap image. Can any one help me? I tried this code for image but don't know how to add text with image?

Uri uri = new Uri("Images/Unlocked.png", UriKind.Relative);
StreamResourceInfo resourceInfo = Application.GetResourceStream(uri);
BitmapImage img = new BitmapImage();
img.SetSource(resourceInfo.Stream);
WriteableBitmap writeableBitmap = new WriteableBitmap(img);
3
  • I converted a single image in writable bitmap image but don't know how to add text in it. Feb 13, 2014 at 10:17
  • Are there non-writable bitmaps? I'm sorry, but you've provided no code. Please use search engine - writing text to a bitmap has been raised many times on SO in all C# frameworks.
    – Tarec
    Feb 13, 2014 at 10:26
  • @AnandDubey You can edit the question by clicking edit button which is in end of the your post
    – Kumar
    Feb 13, 2014 at 10:35

1 Answer 1

1

There are already couple of good examples: MSDN, StackOverflow.

Following them your code could look like this:

BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(App.GetResourceStream(new Uri("Images/Unlocked.png", UriKind.Relative)).Stream);
TextBlock drawString = new TextBlock();
drawString.Text = "Simple text";
drawString.FontSize = 12;

WriteableBitmap wb = new WriteableBitmap(bitmap);
wb.Render(drawString, null);
wb.Invalidate();

You have already set the image of your WritableBimap, then you have to Render something on it - any UIELement - not only TextBlock.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.