Save an Image to a File in a Applet?(将图像保存到 Applet 中的文件?)
问题描述
所以这就是事情,我试图为一个网页游戏做一个Applet来产生自定义"头像,这个头像是为一个国家的军队提供的,所以头像的选择取决于形象用户,图片上的边框也代表该用户所属的四边形.
So here is te thing, Im trying to do an Applet for a webgame to produces "custom" avatars, this avatar are for a kind off an army of a country, so the avatar cosnsit on the image of the choice of the user, and a frame on the picture thtat represent the quad that the user belongs too.
所以我的计划是让他们从他们计算机中的一个文件中进行选择,然后他们选择他们所属的小队.在此之后,他们将看到图片的预览,他们可以将其保存到他们的计算机中,以便以后在游戏中使用.
So my plan is to make them choose from a file from their computer, and then they choose the squd that they belong to. After this they will see a preview of the picutre and they can save it to their computer to later use it on the game.
我知道您可以在组件的背景上使用 Graphic 或 Graphic2D 绘制图像,但是当我想将其保存到文件时,我该怎么做?
I know that you can draw image with a Graphic or Graphic2D on the background of a component, but then when I want to save it to a file, How I do that?
推荐答案
使用 Plug-In 2 (PI2 - 1.6.0_10+) 架构 JRE 部署的小程序不需要数字代码签名.在 PI2 JRE 中,嵌入式小程序可以访问通常仅适用于 Java Web Start 应用程序的所有服务.
Digital code signing is not required for an applet deployed using a Plug-In 2 (PI2 - 1.6.0_10+) architecture JRE. In a PI2 JRE, an embedded applet can access all the services normally only available to Java Web Start apps.
此小程序感兴趣的服务是 FileOpenService (FOS),以及PersistenceService (PS).FOS 可用于允许用户导航到文件(或者更确切地说 - 文件内容)对象并从中获取流.一旦用户对裁剪后的图像感到满意,将其保存到 PS 以供以后检索(使用 ImageIO,如前所述).
The services of interest to this applet would be the FileOpenService (FOS), and the PersistenceService (PS). The FOS could be used to allow the user to navigate to a File (or rather - a FileContents) object and obtain streams from it. Once the user is happy with the cropped image, save in to the PS for later retrieval (using ImageIO, as already mentioned).
这篇关于将图像保存到 Applet 中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将图像保存到 Applet 中的文件?


- 如何指定 CORS 的响应标头? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 转换 ldap 日期 2022-01-01