保存图像在一个小程序文件? [英] Save an Image to a File in a Applet?

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

问题描述

所以在这里为TE的事情,我试着去了webgame的做了一个小程序产生的定制的头像,这个头像是一种断一个国家的军队,这样的选择的图像上的头像cosnsit用户,并在thtat重新present用户所属太四图像帧

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.

所以,我的计划是让他们从自己的计算机中的文件进行选择,然后他们选择,他们属于squd。在此之后,他们将看到的承受力的preVIEW,他们可以将其保存到自己的电脑以后使用它的游戏。

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.

我知道,你可以画图像与组件的背景图形或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?

推荐答案

不需要使用部署一个applet数码code签约插件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.

感兴趣此applet的服务将是 FileOpenService ( FOS)和 PersistenceService (PS)。果寡糖可以用于允许用户导航到一个文件(或更确切地说 - 一个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天全站免登陆