将图像保存到小程序中的文件? [英] Save an Image to a File in a Applet?

查看:25
本文介绍了将图像保存到小程序中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这里是你的事情,我试图为一个网页游戏做一个小程序来产生自定义"头像,这个头像是一个国家军队的一种,所以头像需要选择的形象用户,图片上的一个框也代表用户所属的四边形.

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?

推荐答案

使用插件 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 可用于允许用户导航到 File(或者更确切地说 - FileContents)对象并从中获取流.一旦用户对裁剪后的图像感到满意,就可以将其保存到 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).

这篇关于将图像保存到小程序中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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