从Image对象浏览器创建映像 [英] Create image in browser from Image object

查看:258
本文介绍了从Image对象浏览器创建映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Java小程序,我有一个图片对象。现在,我要打开该程序在浏览器窗口,并显示从该图片对象在浏览器中的图像。小程序是沙箱,因此图像保存到本地文件系统不是一个选项。

In my Java applet, I have an Image object. Now I want to open a browser window from this program and show the image from this Image object in the browser. The applet is sandboxed, so saving the image to the local file system is not an option.

如何才能显示图像的浏览器?

How can I show the image in the browser?

电流的实施:


  • 小程序中的图像转换为Base64 code,那么

  • 将它传递给传统的ASP那么这个

  • ASP写这篇文章的base64 code服务器和

  • 传递文件的名称和所需的信息,C程序,然后

  • C程序调用Java程序,它是在服务器端,然后这个

  • Java程序读取的base64 code并将其转换成图片

  • 然后ASP读取这个图像,并显示在浏览器

这个过程需要太多的时间来执行。

This process takes too much time to perform.

我只需要显示的小程序创建的映像,其中可如果用户希望保存一个新的弹出。目前,用户正在运行的IE 7,但它可能是我们要求的任何版本。

I just need to show the image created in applet, in a new popup which can be saved if the user wants. Currently the users are running IE 7 but it may be of any version in our requirement.

推荐答案

我从来没有做过,但我希望像这样的工作:

I've never done it, but I expect something like this would work:


  • 恩code中的图像中的applet 基地64 。请注意,J2SE有基地64转换没有内置的类/方法。你要么需要code,或添加了一个API,可以做到这一点。

  • 通过EN codeD数据为JavaScript。

  • 使用JavaScript来写(或更改现有的的src )的 IMG 在页面元素。

  • Encode the image as base 64 in the applet. Note that the J2SE has no inbuilt class/method for base 64 conversion. You'll either need to code it, or add an API that can do it.
  • Pass the encoded data to JavaScript.
  • Use JavaScript to write (or alter the src of an existing) img element in the page.

.. IE浏览器不支持此..

..internet explorer does not support this..

拍摄(复制/粘贴)从2 第二链接的例子,在某些体包裹它&安培; HTML 元素,得到:

Taking (copy/pasting) the example from the 2nd link and wrapping it in some body & html elements, gives:

<html>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">
</body>
</html>

当是在IE中打开我看看。

When that is opened in IE I see..

有关在IE中支持更多详细信息,请参见数据URI方案:缺点,该提到..

For more detail on support in IE, see Data URI scheme: Disadvantages, which mentions..


  • ..

  • 的Internet Explorer至7版(Web流量的约5%为2011年9月),缺乏支持。然而,这可以由服务的浏览器的特定内容来克服。[8]

  • Internet Explorer 8的极限数据URI为32 KB的最大长度。 (Internet Explorer 9中没有此限制)[4] [3]

  • ..

这篇关于从Image对象浏览器创建映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆