-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);
Romasz
  • 29,662
  • 13
  • 79
  • 154
Anand Dubey
  • 103
  • 1
  • 1
  • 6
  • I converted a single image in writable bitmap image but don't know how to add text in it. – Anand Dubey Feb 13 '14 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 '14 at 10:26
  • @AnandDubey You can edit the question by clicking edit button which is in end of the your post – Kumar Feb 13 '14 at 10:35

1 Answers1

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.

Community
  • 1
  • 1
Romasz
  • 29,662
  • 13
  • 79
  • 154