views:

41

answers:

2

Is there any way I can embed the images within my exe (as resource?) and use it in generated HTML ?

Here are the requirements:

A. I want to show dynamic HTML content (e.g. using webBrowser control, VS 2008, VB .Net, winForm desktop application)

B. I want to generate the HTML on-the-fly using XML and XSL (file1.xml or file2.xml transformed by my.xsl)

C. The HTML may contain IMG tags (file1.gif and or file2.gif according to the xml+xsl transformation)

and here comes the complicated one:

D. All these files (file1.xml, file2.xml, my.xsl, file1.gif, file2.gif) should be embedded in one exe file.

I guess the XML and XSL can be embedded resources, and I can read them as stream, but what ways do I have to reference the image within the HTML ?

<IMG src="???" />
  • I do not want to use absolute path and external files.
  • If the image files are resources, can I use relative path? Relative to what? (I can use BASE tag, and then what?)
  • Can I use stream as in email messages? If so, where can I find the format I need to use?

http://www.websiteoptimization.com/speed/tweak/inline-images/ are browser dependent.

  • What is the browser used by webBrowser control?
  • IE?
  • what version?

  • Does it matter if I use GIF or JPG or BMP (or any other image format) for the images?

  • Does it matter if I use mshtml library and not the regular webBrowser control? (currently I use http://www.itwriting.com/htmleditor/index.php )

  • Does it matter if I upgrade to VS 2010 ?

Thanks,

Atara

+1  A: 

The browser engine is the same with the IE on your customer's computer, so its version depends on the client's IE version.

By default image/gif, image/jpeg, and image/pjpeg are supported natively. On my computer, image decode filters for image/bmp,image/x-icon, image/png and image/x-wmf are also supported. You probably want to stick to the native formats though. I am not sure those filters are tested for the res protocol in case you change the base url of images in your HTML output.

The Webbrowser classes in Windows Forms, WPF and Silverlight are all wrappers of IE's webbrowser control (MSHTML in IE SDK refers to the DOM implementation and refer the ActiveX hosting MSHTML as the webbrowser control). If you use MSHTML directly then you need to write your own UI, which does not fit your requirement.

All your calls to IE's engine are handled by IE's APIs. Installing Visual Studio 2010 on your developer machine will not change IE API's behavior on your customer's machines.

Sheng Jiang 蒋晟
Can I understand from your detailed answer, that I can use "Inline Images with Data URLs" only if my client have IE 8?
Atara
what do you mean "Inline Images with Data URLs"? If the image is inlined like an SVG then it does not have an external url.
Sheng Jiang 蒋晟
A: 

to avoid customers problem I am going to use boxedApp or a similiar tool.

http://www.boxedapp.com/

Atara