0

I am trying to convert a Bit map image in my windows 8 app (C#), to a string or a regular jpeg.

I am doing thins because I am trying to print the image in some html.

The image is stored in variable itemImage.

When I try to print in in the HTML using the image tag it doesn't show up.

"<img src=" +itemImage + "/>"

When I print in in the html in shows up as Windows.UI.Xaml.Media.Imaging.BitmapImage

How do I show the Image in the html?

Tester
  • 2,887
  • 10
  • 30
  • 60
  • You could convert it to base64 and that can be used in html. [Example conversion](http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base64_string_to_image.aspx). – Silvermind Dec 12 '13 at 16:20

1 Answers1

0

You need to write the image out as a separate file, and then point the <img href=""> tag at that file. Alternatively, set the href to a callback line which calls your program with arguments that cause the program to emit the image data.

OR, you can embed the image data directly in the HTML, but that is a very EVIL hack and you absolutely should not under any circumstances do this. I did not mention this option. :)

Community
  • 1
  • 1
TypeIA
  • 16,916
  • 1
  • 38
  • 52
  • Could you please explain why it is 'EVIL' for this case? I think it is just a nice and simple solution for printing a memory bitmap. Otherwise perhaps even more appropriate for captchas. – Silvermind Dec 12 '13 at 16:24