如何在應用程序中嵌入圖像並在HTML控件中使用它們?

[英]How can I embed images within my application and use them in HTML control?


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

我是否可以將圖像嵌入到exe中(作為資源?)並在生成的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)

A.我想展示動態HTML內容(例如使用webBrowser控件,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)

我想使用XML和XSL(文件1)動態生成HTML。xml或file2。由my.xsl xml轉換)

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

C. HTML可能包含IMG標簽(文件1)。gif或file2。gif根據xml+xsl轉換)

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.

D.所有這些文件(文件1。xml、file2。xml,我。xsl,file1。gif、file2.gif)應該被嵌入到一個exe文件中。

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 ?

我想XML和XSL是可以嵌入資源的,我可以將它們作為流來讀取,但是我要用什么方法來引用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?)
  • 如果圖像文件是資源,我可以使用相對路徑嗎?相對於什么?(我可以用BASE tag,然后呢?)
  • 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.

瀏覽器http://www.websiteoptimization.com/speed/tweak/inline-images/是相關的。

  • What is the browser used by webBrowser control?
  • 什么是瀏覽器使用的webBrowser控件?
  • IE?
  • IE ?
  • what version?

    什么版本?

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

    如果我使用GIF或JPG或BMP(或任何其他圖像格式)的圖像,有關系嗎?

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

    如果我使用mshtml庫而不是常規的webBrowser控件,這有關系嗎?(目前我使用http://www.itwriting.com/htmleditor/index.php)

  • Does it matter if I upgrade to VS 2010 ?

    我升級到VS 2010有關系嗎?

Thanks,

謝謝,

Atara

Atara

4 个解决方案

#1


3  

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

為了避免客戶問題,我將使用boxedApp或者類似的工具。

http://www.boxedapp.com/

http://www.boxedapp.com/

#2


2  

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

瀏覽器引擎和客戶電腦上的IE是一樣的,所以它的版本取決於客戶的IE版本。

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.

默認情況下,本機支持圖像/gif、圖像/jpeg和圖像/pjpeg。在我的計算機上,也支持圖像/bmp、圖像/x圖標、圖像/png和圖像/x-wmf的圖像解碼過濾器。不過,您可能想要堅持使用本機格式。如果您在HTML輸出中更改圖像的基本url,我不確定是否對這些過濾器進行了res協議的測試。

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.

Windows窗體、WPF和Silverlight中的Webbrowser類都是IE的Webbrowser控件的包裝器(IE SDK中的MSHTML表示DOM實現,並將ActiveX托管的MSHTML作為Webbrowser控件)。如果您直接使用MSHTML,那么您需要編寫自己的UI,這並不符合您的需求。

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.

對IE引擎的所有調用都由IE的api處理。在開發者機器上安裝Visual Studio 2010不會改變你客戶機器上IE API的行為。

#3


2  

As for me I would like to use boxedapp too .

至於我,我也想用boxedapp。

#4


2  

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

為了避免客戶問題,我將使用boxedApp或者類似的工具。

http://www.boxedapp.com/

http://www.boxedapp.com/

Thank you. It useful for me)

謝謝你!對我來說有用的)


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/06/10/692552fa6aa08b2466ffcf614a1a2a98.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com